コード例 #1
0
        public static string Serialize(UETEvent evnt)
        {
            if (evnt == null)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            sb.AppendFormat("[evnt.EventDateTime={0}, evnt.GoalValue={1}, evnt.LogServerName={2}, evnt.NavigatedFromURL={3}" +
                            " evnt.PageLoad={4}, evnt.PageTitle={5}, evnt.ReferrerURL={6}, evnt.TimeOnPrevPage={7}, evnt.Version={8}, evnt.Type={9}",
                            new DateTime(evnt.EventDateTime), evnt.GoalValue, evnt.LogServerName, evnt.NavigatedFromURL,
                            evnt.PageLoad, evnt.PageTitle, evnt.ReferrerURL, evnt.TimeOnPrevPage,
                            evnt.Version, evnt.EventType);

            if (evnt.UETMatchingGuid != null)
            {
                sb.AppendFormat(", evnt.UETMatchingGuid={0}", evnt.UETMatchingGuid.ToSystemGuid().ToString());
            }

            if (evnt.customEvent != null)
            {
                var customEvent = evnt.customEvent;
                sb.AppendFormat(", customEvent.Category={0}, customEvent.Action={1}, customEvent.Label={2}, customEvent.Value={3},"
                                , customEvent.EventCategory, customEvent.EventAction, customEvent.EventLabel, customEvent.EventValue);
            }

            sb.Append("]");
            return(sb.ToString());
        }
コード例 #2
0
 private static bool IsCustomGoalEvent(UETEvent evnt)
 {
     // TODO: Curious about the logic. Those fields are emtpy, yet still makes it a customEvent.
     if (evnt != null &&
         evnt.customEvent != null &&
         String.IsNullOrEmpty(evnt.customEvent.EventAction) &&
         String.IsNullOrEmpty(evnt.customEvent.EventCategory) &&
         String.IsNullOrEmpty(evnt.customEvent.EventLabel) &&
         evnt.customEvent.EventValue == null &&
         evnt.GoalValue.HasValue)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #3
0
        /// <summary>
        /// Decides if two events should be grouped as part of the same visit or not
        /// This logic is used in both visitization and escrow
        /// </summary>
        public static bool AreEventGroupsInTheSameVisit(
            UETEvent currentEvent,
            long prevEventDateTime,
            string prevReferrerUrl,
            long sessionTimeoutThreshold)
        {
            var currentNavigatedFromUrl = String.Equals(currentEvent.EventType, VisitizationUtils.EventTypePageLoad, StringComparison.OrdinalIgnoreCase) ? currentEvent.NavigatedFromURL : currentEvent.ReferrerURL;

            // For each two consecutive events, assign the same VisitId to them if:
            // SecondEvent.NavigatedFromURL == FirstEvent.ReferrerURL
            // AND
            // Their time difference is less than SessionTimeoutThresholdInMunites
            var timeDiff = (currentEvent.EventDateTime - prevEventDateTime);

            return(timeDiff >= 0 &&
                   timeDiff <= sessionTimeoutThreshold &&
                   GetHostURL(currentNavigatedFromUrl) == GetHostURL(prevReferrerUrl));
        }
コード例 #4
0
        public string GetData(string line)
        {
            if (string.IsNullOrEmpty(line))
            {
                return(null);
            }
            else
            {
                AppInstallVisitsSchema output = new AppInstallVisitsSchema();
                UETLogView             data   = UETLogView.Deserialize(line);
                output.AppInstallClickId = data.AppInstallClickId;

                var eventDataTime = data.EventDateTime;
                var anid          = data.ANID;
                var muid          = data.MUID;
                var referrerUrl   = data.ReferrerURL;

                var visit = new Visit();
                visit.VisitId = VisitizationUtils.GenerateVisitId(anid, muid, eventDataTime, referrerUrl);

                var uetEvent = new UETEvent();
                uetEvent.EventDateTime    = eventDataTime;
                uetEvent.ANID             = anid == null ? null : new GUID(anid.Value);
                uetEvent.MUID             = muid == null ? null : new GUID(muid.Value);
                uetEvent.ReferrerURL      = referrerUrl;
                uetEvent.PageTitle        = data.PageTitle;
                uetEvent.NavigatedFromURL = data.NavigatedFromURL;
                uetEvent.GoalValue        = data.GoalValue;
                uetEvent.PageLoad         = data.PageLoad;
                uetEvent.Version          = data.Version;
                uetEvent.LogServerName    = data.LogServerName;
                uetEvent.EventType        = data.EventType;

                visit.Events = new List <UETEvent> {
                    uetEvent
                };

                visit.Statistic = new VisitStatistic {
                    VisitStartDateTime = eventDataTime
                };
                output.Visit = visit;
                return(AppInstallVisitsSchema.Serialize(output));
            }
        }
コード例 #5
0
        public IEnumerable <string> GetData(KeyValuePair <string, string> line)
        {
            var uetLogsWithSameUAIPTag = line.Value.Split(new char[] { delimeter }, StringSplitOptions.RemoveEmptyEntries);
            //List<string> output = new List<string>();
            var          eventGroups  = new Dictionary <string, List <UETEvent> >();
            var          firstRow     = true;
            ClientIPData clientIP     = null;
            var          visitization = new VisitizationSchema();

            foreach (var uetLogStr in uetLogsWithSameUAIPTag)
            {
                var uetLog = UETLogView.Deserialize(uetLogStr);
                if (uetLog == null)
                {
                    continue;
                }
                if (firstRow)
                {
                    visitization.UAIPId  = uetLog.UAIPId;
                    visitization.TagId   = uetLog.TagId;
                    visitization.TagName = uetLog.TagName;
                    //visitization.UserAgent = uetLog.UserAgent;  //why UserAgent is needed in the Original VisitizationReducer

                    clientIP = uetLog.ClientIP;
                    firstRow = false;
                }
                var anid            = uetLog.ANID;
                var muid            = uetLog.MUID;
                var isNewMuid       = uetLog.IsNewMUID;
                var analyticsGuid   = uetLog.AnalyticsGuid;
                var uetMatchingGuid = uetLog.UETMatchingGuid;

                var currentUetEvent = new UETEvent();
                currentUetEvent.EventDateTime    = uetLog.EventDateTime;
                currentUetEvent.ANID             = (!anid.HasValue) ? null : new GUID(anid.Value);
                currentUetEvent.MUID             = (!muid.HasValue) ? null : new GUID(muid.Value);
                currentUetEvent.IsNewMUID        = isNewMuid;
                currentUetEvent.ReferrerURL      = uetLog.ReferrerURL;
                currentUetEvent.PageTitle        = uetLog.PageTitle;
                currentUetEvent.customEvent      = uetLog.customEvent;
                currentUetEvent.NavigatedFromURL = uetLog.NavigatedFromURL;
                currentUetEvent.GoalValue        = uetLog.GoalValue;
                currentUetEvent.PageLoad         = uetLog.PageLoad;
                currentUetEvent.Version          = uetLog.Version;
                currentUetEvent.LogServerName    = uetLog.LogServerName;
                currentUetEvent.EventType        = uetLog.EventType;
                currentUetEvent.AnalyticsGuid    = (!analyticsGuid.HasValue) ? null : new GUID(analyticsGuid.Value);
                currentUetEvent.UETMatchingGuid  = (!uetMatchingGuid.HasValue) ? null : new GUID(uetMatchingGuid.Value);

                AddToEventGroups(eventGroups, anid, muid, isNewMuid, currentUetEvent);
            }
            List <UETEvent> newMuidsList;

            if (eventGroups.TryGetValue(GroupKeyNewMuids, out newMuidsList))
            {
                var eventsToBeRemoved = new List <UETEvent>();

                foreach (var uetEvent in newMuidsList)
                {
                    List <UETEvent> events;
                    if (eventGroups.TryGetValue(uetEvent.MUID.ToSystemGuid().ToString(), out events))
                    {
                        eventsToBeRemoved.Add(uetEvent);
                        events.Insert(0, uetEvent);
                    }
                }

                foreach (var ev in eventsToBeRemoved)
                {
                    newMuidsList.Remove(ev);
                }
            }
            foreach (var eventGroup in eventGroups)
            {
                // Build the Visit List from the event groups
                var events = eventGroup.Value;
                if (events.Count > 0)
                {
                    var factObject = BuildVisitEventGroupFromEventsList(sessionTimeoutThreshold, endOfDelta, events, maxEventsPerVisit, maxVisitsPerIPTag);
                    if (factObject.Visits.Count > 0)
                    {
                        factObject.ClientIP = clientIP;

                        var firstEvent = events[0];
                        factObject.ANID      = firstEvent.ANID;
                        factObject.MUID      = firstEvent.MUID;
                        factObject.IsNewMUID = firstEvent.IsNewMUID;

                        visitization.AnalyticsGuid = firstEvent.AnalyticsGuid == null ? (Guid?)null : firstEvent.AnalyticsGuid.ToSystemGuid();

                        FixCustomGoalValues(factObject);
                        visitization.SAEventConversionFactsRow = factObject;
                        yield return(VisitizationSchema.Serialize(visitization));
                        //output.Add(VisitizationSchema.Serialize(visitization));
                    }
                }
            }
            //return output;
        }
コード例 #6
0
        /// <summary>
        /// Add the UETEvent to the dictionary.
        /// </summary>
        private static void AddToEventGroups(Dictionary <string, List <UETEvent> > eventGroups, string key, UETEvent currentUetEvent)
        {
            List <UETEvent> list;

            if (eventGroups.TryGetValue(key, out list))
            {
                list.Add(currentUetEvent);
            }
            else
            {
                eventGroups.Add(key, new List <UETEvent> {
                    currentUetEvent
                });
            }
        }
コード例 #7
0
        private static void AddToEventGroups(Dictionary <string, List <UETEvent> > eventGroups, Guid?anid, Guid?muid, bool?isNewMuid, UETEvent currentUetEvent)
        {
            var groupCandidateKey = "UAIPId";

            // Use ANID prior to MUID
            if (anid.HasValue)
            {
                groupCandidateKey = anid.ToString();
            }
            else if (muid.HasValue)
            {
                groupCandidateKey = (isNewMuid == true) ? GroupKeyNewMuids : muid.ToString();
            }

            AddToEventGroups(eventGroups, groupCandidateKey, currentUetEvent);
        }