Beispiel #1
0
        private void OnLowMemory()
        {
            if (!InternalConfig.GetInstance().monitoring_enabled)
            {
                return;
            }

            Elephant.Event("Application_low_memory", MonitoringUtils.GetInstance().GetCurrentLevel());
        }
Beispiel #2
0
        private void SendVersionsEvent()
        {
            var versionCheckUtils = VersionCheckUtils.GetInstance();
            var versionData       = new VersionData(Application.version, ElephantVersion.SDK_VERSION,
                                                    SystemInfo.operatingSystem, versionCheckUtils.AdSdkVersion,
                                                    versionCheckUtils.MopubVersion, versionCheckUtils.UnityVersion,
                                                    versionCheckUtils.NetworkVersions);

            var parameters = Params.New()
                             .CustomString(JsonUtility.ToJson(versionData));

            Elephant.Event("elephant_sdk_versions_info", -1, parameters);
        }
Beispiel #3
0
        void ExampleSDKUsage()
        {
            int currentLevel = 1;

            // make sure you send this  at the start of the each level
            Elephant.LevelStarted(currentLevel);

            // basic SDK event
            Elephant.Event("user_clicked_something", currentLevel);


            // SDK event with parameter
            Elephant.Event("custom_reward_event", currentLevel, Params.New().Set("gold", 1000));


            // SDK transaction for currencies (consumable user properties)
            Elephant.Transaction("gem", currentLevel, -10, 90, "skin_unlock");


            // SDK event with some parameters
            Params param2 = Params.New()
                            .Set("gems", 10)
                            .Set("source", "level_reward")
                            .Set("some_double", 3.141592).CustomString("{\"t\": 1}");


            Elephant.Event("custom_reward_event2", currentLevel, param2);


            // send level completed or failed event
            if (LevelPassed())
            {
                Elephant.LevelCompleted(currentLevel);
            }
            else
            {
                Elephant.LevelFailed(currentLevel);
            }


            // use some remote config parameters to change the game remotely ( useful for A\B testing )
            string someString = RemoteConfig.GetInstance().Get("test_string", "default");
            int    someInt    = RemoteConfig.GetInstance().GetInt("test_int", 0);
            long   someLong   = RemoteConfig.GetInstance().GetLong("test_long", 1L);
        }
Beispiel #4
0
        // iOS only!
        // No-op for Android.
        private void ReportLatestCrashLog()
        {
            if (!InternalConfig.GetInstance().monitoring_enabled)
            {
                return;
            }

            var report = CrashReport.lastReport;

            if (report == null)
            {
                return;
            }

            var parameters = Params.New();

            parameters.Set("time", report.time.ToString(CultureInfo.CurrentCulture));
            parameters.Set("text", report.text);
            Elephant.Event("Application_last_crash_log", MonitoringUtils.GetInstance().GetCurrentLevel(), parameters);
        }
Beispiel #5
0
        private IEnumerator InitSDK(bool isOldUser)
        {
            if (Utils.IsFileExists(OLD_ELEPHANT_FILE))
            {
                isOldUser = true;
            }

            string savedConfig = Utils.ReadFromFile(REMOTE_CONFIG_FILE);

            userId = Utils.ReadFromFile(USER_DB_ID) ?? "";

            Log("Remote Config From File --> " + savedConfig);

            var isUsingRemoteConfig = 0;

            openResponse = new OpenResponse();

            if (savedConfig != null)
            {
                RemoteConfig.GetInstance().Init(savedConfig);
                openResponse.remote_config_json = savedConfig;
            }

            openRequestWaiting  = true;
            openRequestSucceded = false;

            float startTime             = Time.time;
            var   realTimeBeforeRequest = DateTime.Now;

            RequestIDFAAndOpen(isOldUser);

            while (openRequestWaiting && (Time.time - startTime) < 5f)
            {
                yield return(null);
            }

            if (openRequestSucceded)
            {
                isUsingRemoteConfig = 1;
            }

            Log(JsonUtility.ToJson(openResponse));

            var parameters = Params.New()
                             .Set("real_duration", (DateTime.Now - realTimeBeforeRequest).TotalMilliseconds)
                             .Set("game_duration", (Time.time - startTime) * 1000)
                             .Set("is_using_remote_config", isUsingRemoteConfig)
                             .CustomString(JsonUtility.ToJson(openResponse));

            Elephant.Event("open_request", -1, parameters);

            RemoteConfig.GetInstance().Init(openResponse.remote_config_json);
            AdConfig.GetInstance().Init(openResponse.ad_config);
            Utils.SaveToFile(REMOTE_CONFIG_FILE, openResponse.remote_config_json);
            Utils.SaveToFile(USER_DB_ID, openResponse.user_id);
            currentSession.user_tag = RemoteConfig.GetInstance().GetTag();

            if (onOpen != null)
            {
                if (openResponse.consent_required)
                {
                    onOpen(true);
                }
                else
                {
                    onOpen(false);
                }
            }
            else
            {
                Debug.LogWarning("ElephantSDK onOpen event is not handled");
            }

            sdkIsReady = true;
            if (onRemoteConfigLoaded != null)
            {
                onRemoteConfigLoaded();
            }
        }