Example #1
0
        void SetupMetrica()
        {
            if (string.IsNullOrEmpty(Game.Config.GameConfig.ANALYTICS_APP_KEY))
            {
                return;                                                                    // Отключаем аналитику
            }
            var configuration = new YandexAppMetricaConfig(Game.Config.GameConfig.ANALYTICS_APP_KEY)
            {
                SessionTimeout = (int)SessionTimeoutSec,
                Logs           = Game.Config.GameConfig.ANALYTICS_LOGS,
                HandleFirstActivationAsUpdate = HandleFirstActivationAsUpdate,
                StatisticsSending             = StatisticsSending,
            };

#if !APP_METRICA_TRACK_LOCATION_DISABLED
            configuration.LocationTracking = Game.Config.Current.ANALYTICS_LOCATION_TRACKING;
            if (Game.Config.Current.ANALYTICS_LOCATION_TRACKING)
            {
                Input.location.Start();
            }
#else
            configuration.LocationTracking = false;
#endif

            Instance.ActivateWithConfiguration(configuration);
            ProcessCrashReports();
        }
Example #2
0
 public override void ActivateWithConfiguration(YandexAppMetricaConfig config)
 {
     base.ActivateWithConfiguration(config);
     using (var activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
         var playerActivityContext = activityClass.GetStatic <AndroidJavaObject> ("currentActivity");
         metricaClass.CallStatic("activate", playerActivityContext, config.ToAndroidAppMetricaConfig());
     }
 }
Example #3
0
    public static AndroidJavaObject ToAndroidAppMetricaConfig(this YandexAppMetricaConfig self, AndroidJavaClass metricaClass)
    {
        AndroidJavaObject appMetricaConfig = null;

        using (var configClass = new AndroidJavaClass("com.yandex.metrica.YandexMetricaConfig")) {
            var builder = configClass.CallStatic <AndroidJavaObject> ("newConfigBuilder", self.ApiKey);

            if (self.Location.HasValue)
            {
                var location = self.Location.Value;
                builder.Call <AndroidJavaObject> ("setLocation", location.ToAndroidLocation());
            }
            if (self.AppVersion != null)
            {
                builder.Call <AndroidJavaObject> ("setAppVersion", self.AppVersion);
            }
            if (self.TrackLocationEnabled.HasValue)
            {
                builder.Call <AndroidJavaObject> ("setTrackLocationEnabled", self.TrackLocationEnabled.Value);
            }
            if (self.SessionTimeout.HasValue)
            {
                builder.Call <AndroidJavaObject> ("setSessionTimeout", self.SessionTimeout.Value);
            }
            if (self.ReportCrashesEnabled.HasValue)
            {
                builder.Call <AndroidJavaObject> ("setReportCrashesEnabled", self.ReportCrashesEnabled.Value);
            }
            if (self.LoggingEnabled ?? false)
            {
                builder.Call <AndroidJavaObject> ("setLogEnabled");
            }
            if (self.CollectInstalledApps.HasValue)
            {
                builder.Call <AndroidJavaObject> ("setCollectInstalledApps", self.CollectInstalledApps.Value);
            }
            if (self.HandleFirstActivationAsUpdateEnabled.HasValue)
            {
                builder.Call <AndroidJavaObject> ("handleFirstActivationAsUpdate", self.HandleFirstActivationAsUpdateEnabled.Value);
            }
            if (self.PreloadInfo.HasValue)
            {
                var preloadInfo        = self.PreloadInfo.Value;
                var preloadInfoClass   = new AndroidJavaClass("com.yandex.metrica.PreloadInfo");
                var preloadInfoBuilder = preloadInfoClass.CallStatic <AndroidJavaObject> ("newBuilder", preloadInfo.TrackingId);
                foreach (var kvp in preloadInfo.AdditionalInfo)
                {
                    preloadInfoBuilder.Call <AndroidJavaObject> ("setAdditionalParams", kvp.Key, kvp.Value);
                }
                builder.Call <AndroidJavaObject> ("setPreloadInfo", preloadInfoBuilder.Call <AndroidJavaObject> ("build"));
            }

            // Native crashes are currently not supported
            builder.Call <AndroidJavaObject> ("setReportNativeCrashesEnabled", false);
            appMetricaConfig = builder.Call <AndroidJavaObject> ("build");
        }
        return(appMetricaConfig);
    }
    public static Hashtable ToHashtable(this YandexAppMetricaConfig self)
    {
        var data = new Hashtable {
            { "ApiKey", self.ApiKey },
        };

        if (self.AppVersion != null)
        {
            data ["AppVersion"] = self.AppVersion;
        }
        if (self.Location.HasValue)
        {
            var location = self.Location.Value;
            data ["Location"] = new Hashtable {
                { "Latitude", location.Latitude },
                { "Longitude", location.Longitude },
            };
        }
        if (self.SessionTimeout.HasValue)
        {
            data ["SessionTimeout"] = self.SessionTimeout.Value;
        }
        if (self.CrashReporting.HasValue)
        {
            data ["CrashReporting"] = self.CrashReporting.Value;
        }
        if (self.LocationTracking.HasValue)
        {
            data ["LocationTracking"] = self.LocationTracking.Value;
        }
        if (self.Logs.HasValue)
        {
            data ["Logs"] = self.Logs.Value;
        }
        if (self.HandleFirstActivationAsUpdate.HasValue)
        {
            data ["HandleFirstActivationAsUpdate"] = self.HandleFirstActivationAsUpdate.Value;
        }

        if (self.PreloadInfo.HasValue)
        {
            var preloadInfo = self.PreloadInfo.Value;
            data ["PreloadInfo"] = new Hashtable {
                { "TrackingId", preloadInfo.TrackingId },
                { "AdditionalInfo", new Hashtable(preloadInfo.AdditionalInfo) },
            };
        }
        if (self.StatisticsSending.HasValue)
        {
            data["StatisticsSending"] = self.StatisticsSending.Value;
        }
        if (self.AppForKids.HasValue)
        {
            data["AppForKids"] = self.AppForKids.Value;
        }

        return(data);
    }
Example #5
0
    public void ProcessConfigurationUpdate(YandexAppMetricaConfig config)
    {
        var androidAppMetricaConfig = config.ToAndroidAppMetricaConfig();

        if (androidAppMetricaConfig != null)
        {
            metricaConfigStorage.Call("saveConfig", androidAppMetricaConfig);
        }
    }
Example #6
0
    private void UpdateConfiguration(YandexAppMetricaConfig config)
    {
        _metricaConfig = config;
        ConfigUpdateHandler receiver = OnActivation;

        if (receiver != null)
        {
            receiver(config);
        }
    }
    public void ActivateWithConfiguration(YandexAppMetricaConfig config)
    {
        metricaClass = new AndroidJavaClass("com.yandex.metrica.YandexMetrica");
        using (var configClass = new AndroidJavaClass("com.yandex.metrica.YandexMetricaConfig")) {
            var builder = configClass.CallStatic <AndroidJavaObject>("newConfigBuilder", config.ApiKey);

            if (config.Location != null)
            {
                builder.Call <AndroidJavaObject>("setLocation", config.Location.ToLocation());
            }
            if (config.AppVersion != null)
            {
                builder.Call <AndroidJavaObject>("setAppVersion", config.AppVersion);
            }
            if (config.TrackLocationEnabled.HasValue)
            {
                builder.Call <AndroidJavaObject>("setTrackLocationEnabled", config.TrackLocationEnabled.Value);
            }
            if (config.SessionTimeout.HasValue)
            {
                builder.Call <AndroidJavaObject>("setSessionTimeout", config.SessionTimeout.Value);
            }
            if (config.ReportCrashesEnabled.HasValue)
            {
                builder.Call <AndroidJavaObject>("setReportCrashesEnabled", config.ReportCrashesEnabled.Value);
            }
            if (config.LoggingEnabled ?? false)
            {
                builder.Call <AndroidJavaObject>("setLogEnabled");
            }
            if (config.CollectInstalledApps.HasValue)
            {
                builder.Call <AndroidJavaObject>("setCollectInstalledApps", config.CollectInstalledApps.Value);
            }
            if (config.PreloadInfo != null)
            {
                var preloadInfoClass   = new AndroidJavaClass("com.yandex.metrica.PreloadInfo");
                var preloadInfoBuilder = preloadInfoClass.CallStatic <AndroidJavaObject>("newBuilder", config.PreloadInfo.TrackingId);
                foreach (var kvp in config.PreloadInfo.AdditionalInfo)
                {
                    preloadInfoBuilder.Call <AndroidJavaObject>("setAdditionalParams", kvp.Key, kvp.Value);
                }
                builder.Call <AndroidJavaObject>("setPreloadInfo", preloadInfoBuilder.Call <AndroidJavaObject>("build"));
            }

            // Native crashes are currently not supported
            builder.Call <AndroidJavaObject>("setReportNativeCrashesEnabled", false);

            using (var activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                var playerActivityContext = activityClass.GetStatic <AndroidJavaObject>("currentActivity");
                metricaClass.CallStatic("activate", playerActivityContext, builder.Call <AndroidJavaObject>("build"));
            }
        }
    }
Example #8
0
    public static Hashtable ToHashtable(this YandexAppMetricaConfig self)
    {
        var data = new Hashtable {
            { "ApiKey", self.ApiKey },
        };

        if (self.AppVersion != null)
        {
            data ["AppVersion"] = self.AppVersion;
        }
        if (self.Location.HasValue)
        {
            var location = self.Location.Value;
            data ["Location"] = new Hashtable {
                { "Latitude", location.Latitude },
                { "Longitude", location.Longitude },
            };
        }
        if (self.SessionTimeout.HasValue)
        {
            data ["SessionTimeout"] = self.SessionTimeout.Value;
        }
        if (self.ReportCrashesEnabled.HasValue)
        {
            data ["ReportCrashesEnabled"] = self.ReportCrashesEnabled.Value;
        }
        if (self.TrackLocationEnabled.HasValue)
        {
            data ["TrackLocationEnabled"] = self.TrackLocationEnabled.Value;
        }
        if (self.LoggingEnabled.HasValue)
        {
            data ["LoggingEnabled"] = self.LoggingEnabled.Value;
        }
        if (self.HandleFirstActivationAsUpdateEnabled.HasValue)
        {
            data ["HandleFirstActivationAsUpdateEnabled"] = self.HandleFirstActivationAsUpdateEnabled.Value;
        }

        if (self.PreloadInfo.HasValue)
        {
            var preloadInfo = self.PreloadInfo.Value;
            data ["PreloadInfo"] = new Hashtable {
                { "TrackingId", preloadInfo.TrackingId },
                { "AdditionalInfo", new Hashtable(preloadInfo.AdditionalInfo) },
            };
        }

        return(data);
    }
Example #9
0
    void SetupMetrica()
    {
        var configuration = new YandexAppMetricaConfig(ApiKey)
        {
            SessionTimeout   = (int)SessionTimeoutSec,
            Logs             = Logs,
            LocationTracking = LocationTracking,
            HandleFirstActivationAsUpdate = HandleFirstActivationAsUpdate,
            StatisticsSending             = StatisticsSending,
        };

        configuration.LocationTracking = false;

        Instance.ActivateWithConfiguration(configuration);
        ProcessCrashReports();
    }
Example #10
0
    void SetupMetrica()
    {
                #if UNITY_ANDROID
        APIKey = "c0cb879d-a63e-4eda-a975-e12ec060330e";
                #endif

        var configuration = new YandexAppMetricaConfig(APIKey)
        {
            SessionTimeout = (int)SessionTimeoutSec,
            LoggingEnabled = LoggingEnabled,
            HandleFirstActivationAsUpdateEnabled = HandleFirstActivationAsUpdate,
            TrackLocationEnabled = false
        };

                #if !APP_METRICA_TRACK_LOCATION_DISABLED
        configuration.TrackLocationEnabled = TrackLocation;
        if (TrackLocation)
        {
            Input.location.Start();
        }
                #endif

        CustomEventDelegate.ActionCustomEvent += OnCustomAnalyticsEvent;

        Instance.ActivateWithConfiguration(configuration);

        /*
         * var configuration = new YandexAppMetricaConfig (APIKey) {
         * SessionTimeout = (int)SessionTimeoutSec,
         * LoggingEnabled = LoggingEnabled,
         * HandleFirstActivationAsUpdateEnabled = HandleFirstActivationAsUpdate,
         * };
         *
         #if !APP_METRICA_TRACK_LOCATION_DISABLED
         * configuration.TrackLocationEnabled = TrackLocation;
         * if (TrackLocation) {
         * Input.location.Start ();
         * }
         #else
         * configuration.TrackLocationEnabled = false;
         #endif
         *
         * Instance.ActivateWithConfiguration (configuration);*/
        ProcessCrashReports();
    }
    public void ActivateWithConfiguration(YandexAppMetricaConfig config)
    {
        metricaClass = new AndroidJavaClass("com.yandex.metrica.YandexMetrica");
        using (var configClass = new AndroidJavaClass("com.yandex.metrica.YandexMetricaConfig")) {
            var builder = configClass.CallStatic<AndroidJavaObject>("newConfigBuilder", config.ApiKey);

            if (config.Location != null) {
                builder.Call<AndroidJavaObject>("setLocation", config.Location.ToLocation());
            }
            if (config.AppVersion != null) {
                builder.Call<AndroidJavaObject>("setAppVersion", config.AppVersion);
            }
            if (config.TrackLocationEnabled.HasValue) {
                builder.Call<AndroidJavaObject>("setTrackLocationEnabled", config.TrackLocationEnabled.Value);
            }
            if (config.SessionTimeout.HasValue) {
                builder.Call<AndroidJavaObject>("setSessionTimeout", config.SessionTimeout.Value);
            }
            if (config.ReportCrashesEnabled.HasValue) {
                builder.Call<AndroidJavaObject>("setReportCrashesEnabled", config.ReportCrashesEnabled.Value);
            }
            if (config.LoggingEnabled ?? false) {
                builder.Call<AndroidJavaObject>("setLogEnabled");
            }
            if (config.CollectInstalledApps.HasValue) {
                builder.Call<AndroidJavaObject>("setCollectInstalledApps", config.CollectInstalledApps.Value);
            }
            if (config.PreloadInfo != null) {
                var preloadInfoClass = new AndroidJavaClass("com.yandex.metrica.PreloadInfo");
                var preloadInfoBuilder = preloadInfoClass.CallStatic<AndroidJavaObject>("newBuilder", config.PreloadInfo.TrackingId);
                foreach (var kvp in config.PreloadInfo.AdditionalInfo) {
                    preloadInfoBuilder.Call<AndroidJavaObject>("setAdditionalParams", kvp.Key, kvp.Value);
                }
                builder.Call<AndroidJavaObject>("setPreloadInfo", preloadInfoBuilder.Call<AndroidJavaObject>("build"));
            }

            // Native crashes are currently not supported
            builder.Call<AndroidJavaObject>("setReportNativeCrashesEnabled", false);

            using (var activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                var playerActivityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
                metricaClass.CallStatic("activate", playerActivityContext, builder.Call<AndroidJavaObject>("build"));
            }
        }
    }
Example #12
0
    void SetupMetrica()
    {
        var configuration = new YandexAppMetricaConfig(APIKey)
        {
            SessionTimeout = (int)SessionTimeoutSec,
            LoggingEnabled = LoggingEnabled,
        };

#if !APP_METRICA_TRACK_LOCATION_DISABLED
        configuration.TrackLocationEnabled = TrackLocation;
        if (TrackLocation)
        {
            Input.location.Start();
        }
#endif

        Instance.ActivateWithConfiguration(configuration);
    }
Example #13
0
    private void SetupMetrica()
    {
        YandexAppMetricaConfig yandexAppMetricaConfig = new YandexAppMetricaConfig(ApiKey);

        yandexAppMetricaConfig.SessionTimeout = (int)SessionTimeoutSec;
        yandexAppMetricaConfig.Logs           = Logs;
        yandexAppMetricaConfig.HandleFirstActivationAsUpdate = HandleFirstActivationAsUpdate;
        yandexAppMetricaConfig.StatisticsSending             = StatisticsSending;
        YandexAppMetricaConfig config = yandexAppMetricaConfig;

        config.LocationTracking = LocationTracking;
        if (LocationTracking)
        {
            Input.location.Start();
        }
        Instance.ActivateWithConfiguration(config);
        ProcessCrashReports();
    }
Example #14
0
    void SetupMetrica()
    {
        var configuration = new YandexAppMetricaConfig(APIKey)
        {
            SessionTimeout = (int)SessionTimeoutSec,
            LoggingEnabled = LoggingEnabled,
            HandleFirstActivationAsUpdateEnabled = HandleFirstActivationAsUpdate,
        };

#if !APP_METRICA_TRACK_LOCATION_DISABLED
        configuration.TrackLocationEnabled = TrackLocation;
        if (TrackLocation)
        {
            Input.location.Start();
        }
#else
        configuration.TrackLocationEnabled = false;
#endif

        Instance.ActivateWithConfiguration(configuration);
        ProcessCrashReports();
    }
    private void SetupMetrica()
    {
        YandexAppMetricaConfig configuration = new YandexAppMetricaConfig(ApiKey)
        {
            SessionTimeout = (int)SessionTimeoutSec,
            Logs           = Logs,
            HandleFirstActivationAsUpdate = HandleFirstActivationAsUpdate,
            StatisticsSending             = StatisticsSending
        };

#if !APP_METRICA_TRACK_LOCATION_DISABLED
        configuration.LocationTracking = LocationTracking;
        if (LocationTracking)
        {
            Input.location.Start();
        }
#else
        configuration.LocationTracking = false;
#endif

        Instance.ActivateWithConfiguration(configuration);
    }
Example #16
0
 public override void ActivateWithConfiguration(YandexAppMetricaConfig config)
 {
     base.ActivateWithConfiguration(config);
     ymm_activateWithConfigurationJSON(JsonStringFromDictionary(config.ToHashtable()));
 }
Example #17
0
    void SetupMetrica()
    {
        var configuration = new YandexAppMetricaConfig(APIKey) {
            SessionTimeout = (int)SessionTimeoutSec,
            LoggingEnabled = LoggingEnabled,
        };

        #if !APP_METRICA_TRACK_LOCATION_DISABLED
        configuration.TrackLocationEnabled = TrackLocation;
        if (TrackLocation) {
            Input.location.Start ();
        }
        #endif

        Instance.ActivateWithConfiguration(configuration);
    }
Example #18
0
    public static Hashtable ToHashtable(this YandexAppMetricaConfig self)
    {
        Hashtable data = new Hashtable {
            { "ApiKey", self.ApiKey }
        };

        if (self.AppVersion != null)
        {
            data["AppVersion"] = self.AppVersion;
        }

        if (self.Location.HasValue)
        {
            YandexAppMetricaConfig.Coordinates location = self.Location.Value;
            data["Location"] = new Hashtable {
                { "Latitude", location.Latitude }, { "Longitude", location.Longitude }
            };
        }

        if (self.SessionTimeout.HasValue)
        {
            data["SessionTimeout"] = self.SessionTimeout.Value;
        }

        if (self.CrashReporting.HasValue)
        {
            data["CrashReporting"] = self.CrashReporting.Value;
        }

        if (self.LocationTracking.HasValue)
        {
            data["LocationTracking"] = self.LocationTracking.Value;
        }

        if (self.Logs.HasValue)
        {
            data["Logs"] = self.Logs.Value;
        }

        if (self.HandleFirstActivationAsUpdate.HasValue)
        {
            data["HandleFirstActivationAsUpdate"] = self.HandleFirstActivationAsUpdate.Value;
        }

        if (self.PreloadInfo.HasValue)
        {
            YandexAppMetricaPreloadInfo preloadInfo = self.PreloadInfo.Value;
            data["PreloadInfo"] = new Hashtable
            {
                { "TrackingId", preloadInfo.TrackingId },
                { "AdditionalInfo", new Hashtable(preloadInfo.AdditionalInfo) }
            };
        }

        if (self.StatisticsSending.HasValue)
        {
            data["StatisticsSending"] = self.StatisticsSending.Value;
        }

        if (self.AppForKids.HasValue)
        {
            data["AppForKids"] = self.AppForKids.Value;
        }

        if (self.UserProfileID != null)
        {
            data["UserProfileID"] = self.UserProfileID;
        }

        if (self.RevenueAutoTrackingEnabled.HasValue)
        {
            data["RevenueAutoTrackingEnabled"] = self.RevenueAutoTrackingEnabled.Value;
        }

        return(data);
    }
Example #19
0
 public override void ActivateWithConfiguration(YandexAppMetricaConfig config)
 {
 }
 private void UpdateConfiguration(YandexAppMetricaConfig config)
 {
     _metricaConfig = config;
     this.OnActivation?.Invoke(config);
 }
Example #21
0
 public virtual void ActivateWithConfiguration(YandexAppMetricaConfig config)
 {
     UpdateConfiguration(config);
 }
 public void ActivateWithConfiguration(YandexAppMetricaConfig config)
 {
     ymm_activateWithConfigurationJSON(YMMJSONUtils.JSONEncoder.Encode(config.ToHashtable()));
 }
 public void ActivateWithConfiguration(YandexAppMetricaConfig config)
 {
     ymm_activateWithConfigurationJSON(YMMJSONUtils.JSONEncoder.Encode(config.ToHashtable()));
 }
Example #24
0
    public static AndroidJavaObject ToAndroidAppMetricaConfig(this YandexAppMetricaConfig self)
    {
        AndroidJavaObject androidJavaObject = null;

        using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.yandex.metrica.YandexMetricaConfig"))
        {
            AndroidJavaObject androidJavaObject2 = androidJavaClass.CallStatic <AndroidJavaObject>("newConfigBuilder", new object[1]
            {
                self.ApiKey
            });
            if (self.Location.HasValue)
            {
                YandexAppMetricaConfig.Coordinates value = self.Location.Value;
                androidJavaObject2.Call <AndroidJavaObject>("withLocation", new object[1]
                {
                    value.ToAndroidLocation()
                });
            }
            if (self.AppVersion != null)
            {
                androidJavaObject2.Call <AndroidJavaObject>("withAppVersion", new object[1]
                {
                    self.AppVersion
                });
            }
            if (self.LocationTracking.HasValue)
            {
                androidJavaObject2.Call <AndroidJavaObject>("withLocationTracking", new object[1]
                {
                    self.LocationTracking.Value
                });
            }
            if (self.SessionTimeout.HasValue)
            {
                androidJavaObject2.Call <AndroidJavaObject>("withSessionTimeout", new object[1]
                {
                    self.SessionTimeout.Value
                });
            }
            if (self.CrashReporting.HasValue)
            {
                androidJavaObject2.Call <AndroidJavaObject>("withCrashReporting", new object[1]
                {
                    self.CrashReporting.Value
                });
            }
            bool?logs = self.Logs;
            if (logs.HasValue && logs.Value)
            {
                androidJavaObject2.Call <AndroidJavaObject>("withLogs", new object[0]);
            }
            if (self.InstalledAppCollecting.HasValue)
            {
                androidJavaObject2.Call <AndroidJavaObject>("withInstalledAppCollecting", new object[1]
                {
                    self.InstalledAppCollecting.Value
                });
            }
            if (self.HandleFirstActivationAsUpdate.HasValue)
            {
                androidJavaObject2.Call <AndroidJavaObject>("handleFirstActivationAsUpdate", new object[1]
                {
                    self.HandleFirstActivationAsUpdate.Value
                });
            }
            if (self.PreloadInfo.HasValue)
            {
                YandexAppMetricaPreloadInfo value2             = self.PreloadInfo.Value;
                AndroidJavaClass            androidJavaClass2  = new AndroidJavaClass("com.yandex.metrica.PreloadInfo");
                AndroidJavaObject           androidJavaObject3 = androidJavaClass2.CallStatic <AndroidJavaObject>("newBuilder", new object[1]
                {
                    value2.TrackingId
                });
                foreach (KeyValuePair <string, string> item in value2.AdditionalInfo)
                {
                    androidJavaObject3.Call <AndroidJavaObject>("setAdditionalParams", new object[2]
                    {
                        item.Key,
                        item.Value
                    });
                }
                androidJavaObject2.Call <AndroidJavaObject>("withPreloadInfo", new object[1]
                {
                    androidJavaObject3.Call <AndroidJavaObject>("build", new object[0])
                });
            }
            if (self.StatisticsSending.HasValue)
            {
                androidJavaObject2.Call <AndroidJavaObject>("withStatisticsSending", new object[1]
                {
                    self.StatisticsSending.Value
                });
            }
            androidJavaObject2.Call <AndroidJavaObject>("withNativeCrashReporting", new object[1]
            {
                false
            });
            return(androidJavaObject2.Call <AndroidJavaObject>("build", new object[0]));
        }
    }
 public void ActivateWithConfiguration(YandexAppMetricaConfig config)
 {
 }
Example #26
0
 private void ProcessConfigurationUpdate(YandexAppMetricaConfig config)
 {
     // Yandex AppMetrica Unity Plugin JSON Utils are used here.
     ymp_saveActivationConfigurationJSON(YMMJSONUtils.JSONEncoder.Encode(config.ToHashtable()));
 }
Example #27
0
    public static AndroidJavaObject ToAndroidAppMetricaConfig(this YandexAppMetricaConfig self)
    {
        AndroidJavaObject appMetricaConfig;

        using (AndroidJavaClass configClass = new AndroidJavaClass("com.yandex.metrica.YandexMetricaConfig"))
        {
            AndroidJavaObject builder = configClass.CallStatic <AndroidJavaObject>("newConfigBuilder", self.ApiKey);

            if (self.Location.HasValue)
            {
                YandexAppMetricaConfig.Coordinates location = self.Location.Value;
                builder.Call <AndroidJavaObject>("withLocation", location.ToAndroidLocation());
            }

            if (self.AppVersion != null)
            {
                builder.Call <AndroidJavaObject>("withAppVersion", self.AppVersion);
            }

            if (self.LocationTracking.HasValue)
            {
                builder.Call <AndroidJavaObject>("withLocationTracking", self.LocationTracking.Value);
            }

            if (self.SessionTimeout.HasValue)
            {
                builder.Call <AndroidJavaObject>("withSessionTimeout", self.SessionTimeout.Value);
            }

            if (self.CrashReporting.HasValue)
            {
                builder.Call <AndroidJavaObject>("withCrashReporting", self.CrashReporting.Value);
            }

            if (self.Logs ?? false)
            {
                builder.Call <AndroidJavaObject>("withLogs");
            }

            if (self.HandleFirstActivationAsUpdate.HasValue)
            {
                builder.Call <AndroidJavaObject>("handleFirstActivationAsUpdate",
                                                 self.HandleFirstActivationAsUpdate.Value);
            }

            if (self.PreloadInfo.HasValue)
            {
                YandexAppMetricaPreloadInfo preloadInfo        = self.PreloadInfo.Value;
                AndroidJavaClass            preloadInfoClass   = new AndroidJavaClass("com.yandex.metrica.PreloadInfo");
                AndroidJavaObject           preloadInfoBuilder =
                    preloadInfoClass.CallStatic <AndroidJavaObject>("newBuilder", preloadInfo.TrackingId);
                foreach (KeyValuePair <string, string> kvp in preloadInfo.AdditionalInfo)
                {
                    preloadInfoBuilder.Call <AndroidJavaObject>("setAdditionalParams", kvp.Key, kvp.Value);
                }

                builder.Call <AndroidJavaObject>("withPreloadInfo", preloadInfoBuilder.Call <AndroidJavaObject>("build"));
            }

            if (self.StatisticsSending.HasValue)
            {
                builder.Call <AndroidJavaObject>("withStatisticsSending", self.StatisticsSending.Value);
            }

            if (self.UserProfileID != null)
            {
                builder.Call <AndroidJavaObject>("withUserProfileID", self.UserProfileID);
            }

            if (self.RevenueAutoTrackingEnabled.HasValue)
            {
                builder.Call <AndroidJavaObject>("withRevenueAutoTrackingEnabled",
                                                 self.RevenueAutoTrackingEnabled.Value);
            }

            // Native crashes are currently not supported
            builder.Call <AndroidJavaObject>("withNativeCrashReporting", false);
            // Sessions are monitored by plugin itself
            builder.Call <AndroidJavaObject>("withSessionsAutoTrackingEnabled", false);
            appMetricaConfig = builder.Call <AndroidJavaObject>("build");
        }

        return(appMetricaConfig);
    }