Ejemplo n.º 1
0
        public void LogPerformance(string category, TimeSpan performanceCounter, Dictionary <string, string> values = null)
        {
            if (Enabled)
            {
                if (values == null)
                {
                    values = new Dictionary <string, string> ();
                }

                var properties = new Segment.Model.Properties {
                    { Constants.Tracking.Category, category },
                    { "Duration", ((long)performanceCounter.TotalMilliseconds).ToString() }
                };

                foreach (var value in values)
                {
                    properties.Add(value.Key, value.Value);
                }

                Analytics.Client.Track(
                    _userIdentifier,
                    Constants.Tracking.Performance,
                    properties);
            }
        }
Ejemplo n.º 2
0
        public void LogViewHidden(string name)
        {
            if (Enabled)
            {
                var properties = new Segment.Model.Properties {
                    {
                        Constants.Tracking.UserInterfaceEvent,
                        Constants.Tracking.ViewHidden
                    }
                };

                Analytics.Client.Screen(_userIdentifier, name, properties);
            }
        }
        public void LogPerformance(string category, TimeSpan performanceCounter, Dictionary<string, string> values = null)
        {
            if (Enabled) {
                if (values == null)
                    values = new Dictionary<string, string> ();

                var properties = new Segment.Model.Properties {
                    { Constants.Tracking.Category, category },
                    { "Duration", ((long)performanceCounter.TotalMilliseconds).ToString () }
                };

                foreach (var value in values) {
                    properties.Add (value.Key, value.Value);
                }

                Analytics.Client.Track(
                    _userIdentifier,
                    Constants.Tracking.Performance,
                    properties);
            }
        }
Ejemplo n.º 4
0
        private void SendAnalyticsInfo(string username, string eventName, Dictionary <string, object> contextInfo)
        {
            string writeKey = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SegmentWriteKey"] ?? "W21J7U7JO9IXajS1w292q1atMOGklmPi");

            if (Segment.Analytics.Client == null)
            {
                Segment.Analytics.Initialize(writeKey, new Segment.Config().SetAsync(false));
            }

            //Segment.Analytics.Client.Track(ruleType, ruleName);

            //Segment.Analytics
            var req = System.Web.HttpContext.Current.Request;

            var options    = new Segment.Model.Options();
            var properties = new Segment.Model.Properties();

            Uri    referrer  = req.UrlReferrer;
            string userAgent = req.UserAgent;


            string ip = Durados.Web.Mvc.Logging.Logger.GetUserIP();

            const string utm_content  = "utm_content";
            const string utm_campaign = "utm_campaign";
            const string utm_medium   = "utm_medium";
            const string utm_source   = "utm_source";
            const string utm_term     = "utm_term";

            var campaign = new Segment.Model.Dict();


            if (referrer != null)
            {
                var query = referrer.ParseQueryString();
                if (query[utm_content] != null)
                {
                    campaign.Add("content", query[utm_content]);
                }
                if (query[utm_campaign] != null)
                {
                    campaign.Add("name", query[utm_campaign]);
                }
                if (query[utm_medium] != null)
                {
                    campaign.Add("medium", query[utm_medium]);
                }
                if (query[utm_source] != null)
                {
                    campaign.Add("source", query[utm_source]);
                }
                if (query[utm_term] != null)
                {
                    campaign.Add("keyword", query[utm_term]);
                }

                properties.Add("query", referrer.Query);
                properties.Add("path", referrer.PathAndQuery);
                properties.Add("host", referrer.Host);
                properties.Add("url", referrer.ToString());
            }
            foreach (string key in contextInfo.Keys)
            {
                properties.Add(key, contextInfo[key]);
            }
            /* ++ any custom props (eg. title) */

            var context = new Segment.Model.Context();

            context.Add("campaign", campaign);
            context.Add("userAgent", userAgent);
            context.Add("ip", Durados.Web.Mvc.Logging.Logger.UserIPAddress);


            options.SetContext(context);

            Segment.Analytics.Client.Track(username, eventName, properties, options);
        }
        public void LogViewDisplayed(string name)
        {
            if (Enabled) {
                var properties = new Segment.Model.Properties {
                    {
                        Constants.Tracking.UserInterfaceEvent,
                        Constants.Tracking.ViewDisplayed
                    }
                };

                Analytics.Client.Screen (_userIdentifier, name, properties);
            }
        }