예제 #1
0
 /// <summary>
 /// Use for persisted user session mode can guarantee uniqueness by machine+user
 /// </summary>
 /// <param name="domain"></param>
 /// <param name="trackingCode"></param>
 /// <param name="randomNumber">Random number that was generated on first launch</param>
 /// <param name="recentVisitCount">Recent visit count, must be incremented before passing in</param>
 /// <param name="firstVisitTimeStamp">Timestamp for first session</param>
 public AnalyticsClient(string domain, string trackingCode, int randomNumber, int recentVisitCount, DateTime?firstVisitTimestamp)
 {
     _sessionVariables     = new VariableBucket();
     Timestamp             = ConvertToUnixTimestamp(DateTime.Now).ToString();
     Domain                = domain;
     RandomNumber          = randomNumber.ToString();
     TrackingCode          = trackingCode;
     FirstSessionTimestamp = firstVisitTimestamp.HasValue ?
                             ConvertToUnixTimestamp(firstVisitTimestamp.Value).ToString() : Timestamp;
     VisitCount = recentVisitCount;
 }
예제 #2
0
 /// <summary>
 /// Use for persisted user session mode can guarantee uniqueness by machine+user
 /// </summary>
 /// <param name="domain"></param>
 /// <param name="trackingCode"></param>
 /// <param name="randomNumber">Random number that was generated on first launch</param>
 /// <param name="recentVisitCount">Recent visit count, must be incremented before passing in</param>
 /// <param name="firstVisitTimeStamp">Timestamp for first session</param>
 public AnalyticsClient(string domain, string trackingCode, int randomNumber, int recentVisitCount, DateTime? firstVisitTimestamp)
 {
     _sessionVariables = new VariableBucket();
     Timestamp = ConvertToUnixTimestamp(DateTime.Now).ToString();
     Domain = domain;
     RandomNumber = randomNumber.ToString();
     TrackingCode = trackingCode;
     FirstSessionTimestamp = firstVisitTimestamp.HasValue ?
         ConvertToUnixTimestamp(firstVisitTimestamp.Value).ToString() : Timestamp;
     VisitCount = recentVisitCount;
 }
예제 #3
0
        public void SubmitPageView(string page, string title, VariableBucket pageVariables)
        {
            var client = CreateBrowser(page, title);

            var variables = _sessionVariables.MergeWith(pageVariables);

            if (variables.Any())
            {
                client.QueryString["utme"] = variables.ToUtme();
            }

            ThreadPool.QueueUserWorkItem(state =>
            {
                client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative));
            });
        }
예제 #4
0
        public VariableBucket MergeWith(VariableBucket other)
        {
            var variables = new KeyValuePair <string, string>?[5];

            _variables.CopyTo(variables, 0);

            for (int i = 0; i < 5; i++)
            {
                if (other._variables[i] != null)
                {
                    variables[i] = other._variables[i];
                }
            }

            return(new VariableBucket(variables));
        }
예제 #5
0
        public VariableBucket MergeWith(VariableBucket other)
        {
            var variables = new KeyValuePair<string, string>?[5];

            _variables.CopyTo(variables, 0);

            for (int i = 0; i < 5; i++)
            {
                if (other._variables[i] != null)
                {
                    variables[i] = other._variables[i];
                }
            }

            return new VariableBucket(variables);
        }
예제 #6
0
        public void SubmitEvent(string page, string title, string category, string action, string label, string value, VariableBucket pageVariables)
        {
            var client = CreateBrowser(page, title);

            client.QueryString["utmt"] = "event";
            client.QueryString["utme"] = FormatUtme(category, action, label, value);

            var variables = _sessionVariables.MergeWith(pageVariables);

            if (variables.Any())
            {
                client.QueryString["utme"] += variables.ToUtme();
            }

            ThreadPool.QueueUserWorkItem(state =>
            {
                client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative));
            });
        }
예제 #7
0
        public void SubmitPageView(string page, string title, VariableBucket pageVariables)
        {
            var client = CreateBrowser(page, title);

            var variables = _sessionVariables.MergeWith(pageVariables);

            if (variables.Any())
                client.QueryString["utme"] = variables.ToUtme();

            ThreadPool.QueueUserWorkItem(state =>
            {
                client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative));
            });
        }
예제 #8
0
        public void SubmitEvent(string page, string title, string category, string action, string label, string value, VariableBucket pageVariables)
        {
            var client = CreateBrowser(page, title);

            client.QueryString["utmt"] = "event";
            client.QueryString["utme"] = FormatUtme(category, action, label, value);

            var variables = _sessionVariables.MergeWith(pageVariables);

            if (variables.Any())
                client.QueryString["utme"] += variables.ToUtme();

            ThreadPool.QueueUserWorkItem(state =>
            {
                client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative));
            });
        }