Пример #1
0
        private void PatchFakeExmData(InitializeTrackerArgs args)
        {
            var fakeDataJson = args.HttpContext.Request.Headers["X-Exm-FakeData"];

            if (string.IsNullOrEmpty(fakeDataJson))
            {
                return;
            }

            var fakeData = JsonConvert.DeserializeObject <ExmFakeData>(fakeDataJson);

            if (!string.IsNullOrEmpty(fakeData.UserAgent))
            {
                args.Session.Interaction.UserAgent = fakeData.UserAgent;
            }

            if (fakeData.RequestTime.HasValue)
            {
                args.Session.Interaction.StartDateTime = fakeData.RequestTime.Value;
                args.Session.Interaction.EndDateTime   = fakeData.RequestTime.Value.AddSeconds(5);
            }

            if (fakeData.GeoData != null)
            {
                args.Session.Interaction.SetGeoData(fakeData.GeoData);
            }
        }
Пример #2
0
        public override void Process(InitializeTrackerArgs args)
        {
            if (Tracker.Current == null || !Tracker.IsActive)
            {
                return;
            }

            try
            {
                var requestInfo = HttpContext.Current.ColossusInfo();
                if (requestInfo == null)
                {
                    if (PatchExmRequestTime(args))
                    {
                        return;
                    }
                }

                if (requestInfo == null)
                {
                    return;
                }

                foreach (var patcher in Patchers)
                {
                    patcher.UpdateSession(args.Session, requestInfo);
                }
            }
            catch (Exception ex)
            {
                //Log but ignore errors to avoid interrupting standard analytics
                Log.Error("xGenerator PatchTracker failed.", ex);
            }
        }
Пример #3
0
        public override void Process(InitializeTrackerArgs args)
        {
            if (Tracker.Current == null || !Tracker.IsActive)
            {
                return;
            }

            var requestInfo = HttpContext.Current.ColossusInfo();

            if (requestInfo == null)
            {
                if (PatchExmRequestTime(args))
                {
                    return;
                }
            }

            if (requestInfo == null)
            {
                return;
            }

            foreach (var patcher in Patchers)
            {
                patcher.UpdateSession(args.Session, requestInfo);
            }
        }
Пример #4
0
        public override void Process(InitializeTrackerArgs args)
        {
            if (Context.Database == null
                || Context.Item == null
                || Context.PageMode.IsPageEditorEditing
                || String.Compare(Context.Database.Name, "core", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return;
            }

            if(Context.Item.Paths.IsContentItem)
                 ProcessOutcomeRules();
        }
Пример #5
0
        public override void Process(InitializeTrackerArgs args)
        {
            if (Tracker.Current == null || !Tracker.IsActive)
            {
                return;
            }

            var requestInfo = HttpContext.Current.ColossusInfo();

            if (requestInfo == null)
            {
                PatchFakeExmData(args);
            }
        }
Пример #6
0
        public override void Process(InitializeTrackerArgs args)
        {
            if (Context.Database == null ||
                Context.Item == null ||
                Context.PageMode.IsPageEditorEditing ||
                String.Compare(Context.Database.Name, "core", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return;
            }

            if (Context.Item.Paths.IsContentItem)
            {
                ProcessOutcomeRules();
            }
        }
Пример #7
0
        private void EnsureSessionContext()
        {
            InitializeTrackerArgs args = new InitializeTrackerArgs();

            if (HttpContext.Current != null)
            {
                args.HttpContext = new HttpContextWrapper(HttpContext.Current);
            }
            EnsureSessionContextPipeline.Run(args);
            if (args.Session == null)
            {
                return;
            }
            Switcher <Session, Session> .Enter(args.Session);
        }
        //public override void Process(StartTrackingArgs args)
        public override void Process(InitializeTrackerArgs args)
        {
            //Assert.IsNotNull((object)Tracker.Current, "Tracker.Current is not initialized");
            //Assert.IsNotNull((object)Tracker.Current.Session, "Tracker.Current.Session is not initialized");
            //if (Tracker.Current.Session.Interaction == null)
            //    return;
            //Tracker.Current.Session.Interaction.UpdateGeoIpData();
            var goldId = new ID("{025AE5A2-A107-4E4E-B26A-E4207C1FAE40}").ToGuid();

            var test = HasCompany();

            if (IfFirstPage() && HasCompany())
            {
                _eventTrackerService.TrackGoal(goldId);
            }
        }
Пример #9
0
        /// <summary>
        /// Processes the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(InitializeTrackerArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (args.IsSessionEnd)
            {
                return;
            }

            HttpContextBase httpContext = args.HttpContext;

            if (httpContext == null)
            {
                args.AbortPipeline();
                return;
            }

            this.CreateAndInitializePage(args.Session.Interaction);
        }
        public override void Process(InitializeTrackerArgs args)
        {
            try
            {
                Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
                HttpContext current = HttpContext.Current;

                if (current == null)
                {
                    args.AbortPipeline();
                }
                else
                {
                    Visitor visitor = Tracker.Visitor;
                    if (visitor.Settings.IsNew)
                    {
                        this.CreateVisitor(args, visitor);
                    }

                    VisitorDataSet.VisitsRow visit = null;
                    if (!visitor.Settings.IsFirstRequest)
                    {
                        visit = visitor.GetCurrentVisit();
                    }
                    if (visit == null)
                    {
                        visit = this.CreateVisit(current, visitor);
                    }

                    var startDateTime = QueryStringHelper.SessionStartDateTime;

                    if (startDateTime != DateTime.MinValue)
                        visit.StartDateTime = startDateTime;

                    this.CreatePage(current, visit);
                }
            }
            catch (Exception exp)
            {
                Sitecore.Diagnostics.Log.Error("Traffic generator initialize pipeline: " + exp.InnerException, this);
            }
        }
Пример #11
0
        private bool PatchExmRequestTime(InitializeTrackerArgs args)
        {
            var exmRequestTime = args.HttpContext.Request.Headers["X-Exm-RequestTime"];

            if (string.IsNullOrEmpty(exmRequestTime))
            {
                return(false);
            }

            DateTime requestTime;

            if (!DateTime.TryParse(exmRequestTime, out requestTime))
            {
                return(false);
            }

            args.Session.Interaction.StartDateTime = requestTime;
            args.Session.Interaction.EndDateTime   = requestTime.AddSeconds(5);
            return(true);
        }
Пример #12
0
        public override void Process(InitializeTrackerArgs args)
        {
            if (Tracker.Current == null || !Tracker.IsActive)
            {
                return;
            }

            try
            {
                var requestInfo = HttpContext.Current.ColossusInfo();
                if (requestInfo == null)
                {
                    PatchFakeExmData(args);
                }
            }
            catch (Exception ex)
            {
                //Log but ignore errors to avoid interrupting standard analytics
                Log.Error("EXM PatchTracker failed.", ex);
            }
        }
        /// <summary>
        /// Processes the specified HttpRequest pipeline arguments.
        /// </summary>
        /// <param name="args">The HttpRequest arguments.</param>
        public override void Process(InitializeTrackerArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            // Ignore requests if itemresolver should not be applied (see method for details).
            if (this.IgnoreRequest(args))
            {
                return;
            }

            var httpContext = args.HttpContext;

            if (httpContext == null)
            {
                args.AbortPipeline();
                return;
            }


            this.CreateAndInitializePage(httpContext, args.Session.Interaction);
        }
        public override void Process(InitializeTrackerArgs args)
        {
            string contactIdentifier = Sitecore.Web.WebUtil.GetQueryString(ContactKey);

            if (!IsValidEmail(contactIdentifier))
            {
                return;
            }

            Sitecore.Analytics.Tracker.Initialize();
            Sitecore.Analytics.Tracker.StartTracking();

            Sitecore.Analytics.Tracker.Current.Session.IdentifyAs("website", contactIdentifier);

            var contact = GetContactByIdentifier(contactIdentifier);

            if (contact == null || !contact.Id.HasValue)
            {
                return;
            }

            Sitecore.Analytics.Tracking.Contact target;
            try
            {
                target = this.ContactManager.LoadContact(contact.Id.Value, !args.Session.IsReadOnly);
                if (target == null)
                {
                    Sitecore.Diagnostics.Log.Warn("Could not load contact from xDB param. ", this);
                }

                args.ContactId       = contact.Id;
                args.Session.Contact = target;
            }
            catch (XdbUnavailableException ex)
            {
                Sitecore.Diagnostics.Log.Error(ex.Message + ex.StackTrace, this);
                Sitecore.Diagnostics.Log.Debug(string.Format("[Analytics]: The contact '{0}' could not be loaded from the database. Treating the contact as temporary.", (object)contact.Id));
            }
        }
        public override void Process(InitializeTrackerArgs args)
        {
            if (HttpContext.Current == null)
            {
                args.AbortPipeline();
                return;
            }

            //no need to restart visit if visit is new
            if (Tracker.Visitor.Settings.IsNew || Tracker.Visitor.Settings.IsFirstRequest || Tracker.CurrentVisit.VisitPageCount < 1)
            {
                return;
            }

            //look for campaign id in query string
            Guid campaign;
            var  campaignStr = WebUtil.GetQueryString(Settings.GetSetting("Analytics.CampaignQueryStringKey")).Trim();

            if (string.IsNullOrEmpty(campaignStr) || !Guid.TryParse(campaignStr, out campaign))
            {
                return;
            }

            //don't restart if the campaign isn't changing
            if (!Tracker.CurrentVisit.IsCampaignIdNull() && Tracker.CurrentVisit.CampaignId == campaign)
            {
                return;
            }

            var current = HttpContext.Current;
            var cookie  = current.Response.Cookies["SC_ANALYTICS_SESSION_COOKIE"];

            if (cookie == null)
            {
                cookie = new HttpCookie("SC_ANALYTICS_SESSION_COOKIE");
                current.Response.Cookies.Add(cookie);
            }
            cookie.Value = "";
        }
Пример #16
0
        public override void Process(InitializeTrackerArgs args)
        {
            if (args.Session.Contact != null)
            {
                return;
            }

            if (args.IsNewContact)
            {
                return;
            }

            string contactIDvalue = Sitecore.Web.WebUtil.GetQueryString(ContactKey);
            Guid   contactID;

            if (!Guid.TryParse(contactIDvalue, out contactID))
            {
                return;
            }

            Sitecore.Diagnostics.Log.Warn("Switching to contact ID. " + contactIDvalue, this);

            //Sitecore.Analytics.Tracking.Contact target;
            try
            {
                //target = this.ContactManager.LoadContact(contactID, !args.Session.IsReadOnly);

                Sitecore.Diagnostics.Log.Warn("Could not load contact from xDB param. ", this);

                args.ContactId = contactID;
                //args.Session.Contact = target;
            }
            catch (XdbUnavailableException ex)
            {
                Sitecore.Diagnostics.Log.Error(ex.Message + ex.StackTrace, this);
                Sitecore.Diagnostics.Log.Debug(string.Format("[Analytics]: The contact '{0}' could not be loaded from the database. Treating the contact as temporary.", (object)contactID));
            }
        }
 private void CreateVisitor(InitializeTrackerArgs args, Visitor visitor)
 {
     visitor.ExternalUser = string.Empty;
     visitor.VisitCount = 0;
     visitor.SetVisitorClassification(0, 0, true);
     visitor.IntegrationId = Guid.Empty;
     visitor.IntegrationLabel = string.Empty;
 }
 /// <summary>
 /// Indicates whether the request should be ignored.
 /// </summary>
 /// <param name="args">The pipeline arguments.</param>
 /// <returns></returns>
 private bool IgnoreRequest(InitializeTrackerArgs args)
 {
     return(Context.Site == null || Context.Item == null || Context.Database == null ||
            (Configuration.IgnoreSites.Count != 0 && Configuration.IgnoreSites.Contains(Context.Site.Name.ToLower())) ||
            args.IsSessionEnd);
 }