Example #1
0
        internal static void DoTrack(string eventName, Value properties)
        {
            if (!IsTracking)
            {
                return;
            }
            if (AutoTrackProperties == null)
            {
                AutoTrackProperties = CollectAutoTrackProperties();
            }
            properties.Merge(AutoTrackProperties);
            // These auto properties can change in runtime so we don't bake them into AutoProperties
            properties["$screen_width"]  = Screen.width;
            properties["$screen_height"] = Screen.height;
            properties.Merge(OnceProperties);
            OnceProperties = new Value();
            properties.Merge(SuperProperties);
            if (TimedEvents.TryGetValue(eventName, out Value startTime))
            {
                properties["$duration"] = CurrentTime() - (double)startTime;
                TimedEvents.Remove(eventName);
            }
            properties["token"]       = MixpanelSettings.Instance.Token;
            properties["distinct_id"] = DistinctId;
            properties["time"]        = CurrentTime();
            Value data = new Value {
                { "event", eventName }, { "properties", properties }
            };

            Enqueue(MixpanelTrackUrl, data);
        }
Example #2
0
        private static void DoTrack(string eventName, Value properties)
        {
            if (!IsTracking)
            {
                return;
            }
            if (properties == null)
            {
                properties = ObjectPool.Get();
            }
            if (_autoTrackProperties == null)
            {
                _autoTrackProperties = CollectAutoTrackProperties();
            }
            properties.Merge(_autoTrackProperties);
            // These auto properties can change in runtime so we don't bake them into AutoProperties
            properties["$screen_width"]  = Screen.width;
            properties["$screen_height"] = Screen.height;
            properties.Merge(OnceProperties);
            ResetOnceProperties();
            properties.Merge(SuperProperties);
            if (TimedEvents.TryGetValue(eventName, out Value startTime))
            {
                properties["$duration"] = CurrentTime() - (double)startTime;
                TimedEvents.Remove(eventName);
            }
            properties["token"]       = MixpanelSettings.Instance.Token;
            properties["distinct_id"] = DistinctId;
            properties["time"]        = CurrentTime();
            Value data = ObjectPool.Get();

            data["event"]      = eventName;
            data["properties"] = properties;
            MixpanelManager.EnqueueTrack(data);
        }
Example #3
0
 /// <summary>
 /// Clears the event timer for a single event.
 /// </summary>
 /// <param name="eventName">the name of event to clear event timer</param>
 public static void ClearTimedEvent(string eventName) => TimedEvents.Remove(eventName);