示例#1
0
        /// <summary>
        /// Asyncronously tracks an event to the ThisData API
        /// </summary>
        /// <param name="verb">The action taken by the user. eg. log-in</param>
        /// <param name="userId">A unique identifier for the user. If omitted LogonUserIdentity.Name will be used</param>
        /// <param name="name">The full name of the user</param>
        /// <param name="email">The users email address for sending notifications</param>
        /// <param name="mobile">The users mobile phone number for sending SMS notifications</param>
        /// <param name="source">Used to indicate the source of the event and override company or app name in audit log and notifications</param>
        /// <param name="logo_url">Used to override logo used in email notifications</param>
        /// <param name="sessionId">If you use a database to track sessions, you can send us the session ID</param>
        /// <param name="cookieExpected">Send true when using our optional Javascript tracking library, and we'll know to expect a cookie</param> 
        /// <param name="deviceId">A unique device identifier. Typically used for tracking mobile devices.</param> 
        public void TrackAsync(string verb, string userId = "", string name = "", string email = "", string mobile = "", string source = "",
            string logoUrl = "", string sessionId = "", bool cookieExpected = false, string deviceId = "")
        {
            Event message = BuildAuditMessage(verb, userId, name, email, mobile, source, logoUrl, sessionId, cookieExpected, deviceId);

            ThreadPool.QueueUserWorkItem(c =>
            {
                try
                {
                    _currentAuditMessage = message;
                    _transport.Post(Defaults.EventsEndpoint, _currentAuditMessage);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(string.Format("Error sending async audit message {0}", ex.Message));
                }
            });
        }
示例#2
0
        /// <summary>
        /// Formats a message to send to the ThisData API
        /// </summary>
        /// <param name="request">HttpRequest object for the incoming request</param>
        /// <param name="verb">The action taken by the user. eg. log-in</param>
        /// <param name="userId">A unique identifier for the user. If omitted LogonUserIdentity.Name will be used</param>
        /// <param name="name">The full name of the user</param>
        /// <param name="email">The users email address for sending notifications</param>
        /// <param name="mobile">The users mobile phone number for sending SMS notifications</param>
        /// <param name="source">Used to indicate the source of the event and override company or app name in audit log and notifications</param>
        /// <param name="logoUrl">Used to override logo used in email notifications</param>
        /// <param name="sessionId">If you use a database to track sessions, you can send us the session ID</param>
        /// <param name="cookieExpected">Send true when using our optional Javascript tracking library, and we'll know to expect a cookie</param>  
        /// <param name="deviceId">A unique device identifier. Typically used for tracking mobile devices.</param> 
        public static Event Build(HttpRequest request, string verb, string userId = "", string name = "", string email = "", string mobile = "",
            string source = "", string logoUrl = "", string sessionId = "", bool cookieExpected = false, string deviceId = "")
        {
            Event message = new Event();

            message.Verb = verb;
            message.Session.Id = sessionId;
            message.Session.CookieExpected = cookieExpected;
            message.User.Id = String.IsNullOrEmpty(userId) ? "anonymous" : userId;
            message.User.Name = name;
            message.User.Email = email;
            message.User.Mobile = mobile;
            message.Device.Id = deviceId;

            try
            {
                message.UserAgent = request.UserAgent;
                message.IPAddress = GetIpAddress(request);
                message.Session.CookieId = GetCookieId(request);

                // Source options are only supported if source name is provided
                if (!String.IsNullOrEmpty(source))
                {
                    message.Source = new SourceOptions()
                    {
                        Name = source,
                        LogoUrl = logoUrl
                    };
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine("Failed to get basic request info: {0}", e.Message);
            }

            return message;
        }
示例#3
0
 /// <summary>
 /// Tracks an event to the ThisData API
 /// </summary>
 /// <param name="message">Valid ThisData event</param>
 public void Track(Event message)
 {
     _transport.Post(Defaults.EventsEndpoint, _currentAuditMessage);
 }
示例#4
0
 /// <summary>
 /// Tracks an event to the ThisData API
 /// </summary>
 /// <param name="verb">The action taken by the user. eg. log-in</param>
 /// <param name="userId">A unique identifier for the user. If omitted LogonUserIdentity.Name will be used</param>
 /// <param name="name">The full name of the user</param>
 /// <param name="email">The users email address for sending notifications</param>
 /// <param name="mobile">The users mobile phone number for sending SMS notifications</param>
 /// <param name="source">Used to indicate the source of the event and override company or app name in audit log and notifications</param>
 /// <param name="logoUrl">Used to override logo used in email notifications</param>
 /// <param name="sessionId">If you use a database to track sessions, you can send us the session ID</param>
 /// <param name="cookieExpected">Send true when using our optional Javascript tracking library, and we'll know to expect a cookie</param>
 /// <param name="deviceId">A unique device identifier. Typically used for tracking mobile devices.</param>
 public void Track(string verb, string userId = "", string name = "", string email = "", string mobile = "", string source = "",
     string logoUrl = "", string sessionId = "", bool cookieExpected = false, string deviceId = "")
 {
     _currentAuditMessage = BuildAuditMessage(verb, userId, name, email, mobile, source, logoUrl, sessionId, cookieExpected, deviceId);
     _transport.Post(Defaults.EventsEndpoint, _currentAuditMessage);
 }
示例#5
0
 /// <summary>
 /// Get a risk score for user based on current context
 /// </summary>
 /// <param name="message">Current event context for the user</param>
 /// <returns></returns>
 public VerifyResult Verify(Event message)
 {
     _currentAuditMessage = message;
     _currentAuditMessage.Verb = Verbs.VERIFY;
     return _transport.Post<VerifyResult>(Defaults.VerifyEndpoint, _currentAuditMessage);
 }
示例#6
0
 /// <summary>
 /// Get a risk score for user based on current context
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="name"></param>
 /// <param name="email"></param>
 /// <param name="mobile"></param>
 /// <param name="source"></param>
 /// <param name="logoUrl"></param>
 /// <param name="sessionId"></param>
 /// <param name="cookieExpected"></param>
 /// <returns></returns>
 public VerifyResult Verify(string userId = "", string name = "", string email = "", string mobile = "", string source = "", 
     string sessionId = "", bool cookieExpected = false)
 {
     _currentAuditMessage = BuildAuditMessage(Verbs.VERIFY, userId, name, email, mobile, source, "", sessionId, cookieExpected);
     return Verify(_currentAuditMessage);
 }