示例#1
0
        void Awake()
        {
            DontDestroyOnLoad(this);

            #if UNITY_EDITOR
            tracking_enabled = trackInEditor;
            #endif

            #if DISABLE_MIXPANEL
            tracking_enabled = false;
            Debug.LogWarning("Your Unity version does not support native plaugins. Disabling Mixpanel.");
            #endif

            if (tracking_enabled && mp_interface == null)
            {
                mp_interface = new mixpanel.detail.Mixpanel(
                    #if DEBUG || UNITY_EDITOR
                    token: debugToken,
                    #else
                    token: token,
                    #endif
                    distinct_id: mixpanel.platform.MixpanelUnityPlatform.get_distinct_id(),
                    storage_directory: mixpanel.platform.MixpanelUnityPlatform.get_storage_directory(),
                    enable_log_queue: true
                    );
                mp_interface.set_minimum_log_level(minLogLevel);
                mp_interface.set_maximum_queue_size((uint)(maxQueueSizeInMB * 1024 * 1024));

                // these are properties that are difficult to obtain only via native code, so we set the as super properties
                Register("$screen_width", Screen.width);
                Register("$screen_height", Screen.height);
                Register("$screen_dpi", Screen.dpi);

                #if UNITY_ANDROID && !UNITY_EDITOR
                Register("$app_build_number", platform.MixpanelUnityPlatform.get_android_version_code());
                Register("$app_version_string", platform.MixpanelUnityPlatform.get_android_version_name());

                people.Set("$android_app_version_string", platform.MixpanelUnityPlatform.get_android_version_name());
                people.Set("$android_app_build_number", platform.MixpanelUnityPlatform.get_android_version_code());
                #endif

                #if UNITY_IOS
                if (useIosIfa && !detail.IOSIdentifiers.MIXPANEL_USE_IOS_IFA_ENABLED)
                {
                    Debug.LogError("Mixpanel: If you want to use the automatic $ios_ifa property, you have to define the MIXPANEL_USE_IOS_IFA script symbol in the player settings." +
                                   "Only enable this, if your app shows advertising, otherwise your app might get rejected or pulled from the store by apple. If your app is " +
                                   "not showing ads disable useIosIfa, remove MIXPANEL_USE_IOS_IFA and delete Plugins/iOS/iOSIdentifiers.mm.");
                }
                if (!useIosIfa && detail.IOSIdentifiers.MIXPANEL_USE_IOS_IFA_ENABLED)
                {
                    Debug.LogError("Mixpanel: You have requested to not use $ios_ifa, but still have the MIXPANEL_USE_IOS_IFA scripting symbol defined. If your app is not showing ads remove MIXPANEL_USE_IOS_IFA and delete Plugins/iOS/iOSIdentifiers.mm");
                }

                #if MIXPANEL_USE_IOS_IFA && !UNITY_EDITOR
                if (useIosIfa) // running on device, enabled via settings and scripting symbol is defined - we can use it.
                {
                    var idfa = detail.IOSIdentifiers.mixpanel_ios_get_idfa();
                    Register("$ios_ifa", idfa);
                    people.Set("$ios_ifa", idfa);
                }
                #endif
                #endif

                if (flushInterval < 0)
                {
                    Debug.LogError("batchSendInterval must be greater or equal zo zero");
                    flushInterval = 0;
                }

                mp_interface.set_flush_interval((uint)flushInterval);

                TrackIntegrationEvent();
            }
        }
示例#2
0
 public People(mixpanel.detail.Mixpanel mixpanel, bool tracking_enabled)
 {
     this.mixpanel         = mixpanel;
     this.tracking_enabled = tracking_enabled;
 }