示例#1
0
        internal static void DoTrack(string eventName, Value properties)
        {
            if (!MixpanelStorage.IsTracking)
            {
                return;
            }
            if (properties == null)
            {
                properties = Mixpanel.ObjectPool.Get();
            }
            properties.Merge(GetEventsDefaultProperties());
            // 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(MixpanelStorage.OnceProperties);
            MixpanelStorage.ResetOnceProperties();
            properties.Merge(MixpanelStorage.SuperProperties);
            Value startTime;

            if (MixpanelStorage.TimedEvents.TryGetValue(eventName, out startTime))
            {
                properties["$duration"] = Util.CurrentTime() - (double)startTime;
                MixpanelStorage.TimedEvents.Remove(eventName);
            }
            properties["token"]       = MixpanelSettings.Instance.Token;
            properties["distinct_id"] = MixpanelStorage.DistinctId;
            properties["time"]        = Util.CurrentTime();
            Value data = Mixpanel.ObjectPool.Get();

            data["event"]        = eventName;
            data["properties"]   = properties;
            data["$mp_metadata"] = Metadata.GetEventMetadata();

            Worker.EnqueueEventOp(data);
        }
示例#2
0
        internal static void DoTrack(string eventName, Value properties)
        {
            if (!MixpanelStorage.IsTracking)
            {
                return;
            }
            if (properties == null)
            {
                properties = new Value();
            }
            properties.Merge(GetEventsDefaultProperties());
            // 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(MixpanelStorage.OnceProperties);
            MixpanelStorage.ResetOnceProperties();
            properties.Merge(MixpanelStorage.SuperProperties);
            Value startTime;

            if (MixpanelStorage.TimedEvents.TryGetValue(eventName, out startTime))
            {
                properties["$duration"] = Util.CurrentTime() - (double)startTime;
                MixpanelStorage.TimedEvents.Remove(eventName);
            }
            properties["token"]       = MixpanelSettings.Instance.Token;
            properties["distinct_id"] = MixpanelStorage.DistinctId;
            properties["time"]        = Util.CurrentTime();

            Value data = new Value();

            data["event"]        = eventName;
            data["properties"]   = properties;
            data["$mp_metadata"] = Metadata.GetEventMetadata();

            if (Debug.isDebugBuild && !eventName.StartsWith("$"))
            {
                MixpanelStorage.HasTracked = true;
            }

            MixpanelStorage.EnqueueTrackingData(data, MixpanelStorage.FlushType.EVENTS);
        }