コード例 #1
0
ファイル: Controller.cs プロジェクト: nonumpa/mixpanel-unity
        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
ファイル: Controller.cs プロジェクト: mixpanel/mixpanel-unity
        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);
        }