Beispiel #1
0
        protected IEnumerator RunTimer()
        {
            while (true)
            {
                yield return(new WaitForSeconds(updateInterval / 4)); //it's better to do 4 small tasks than one big task

                if (_isSuspended == true)
                {
                    continue;
                }

                // device info may have changed
                UpdateDeviceInfo();
                yield return(new WaitForSeconds(updateInterval / 4));

                //check and send any pending crash reports
                if (!manualReports && CrashReporter.fetchReports())
                {
                    CountlyManager.SendReports();
                }
                yield return(new WaitForSeconds(updateInterval / 4));

                // record any pending events
                FlushEvents(0);
                yield return(new WaitForSeconds(updateInterval / 4));

                long duration = TrackSessionLength();
                UpdateSession(duration);
            }
        }
Beispiel #2
0
 public void EmitCrazyEvent()
 {
     CountlyManager.Emit("UTF8こんにちはWorld", 1, 10.25,
                         new Dictionary <string, string>()
     {
         { "demo1", "demo2" },
         { "demo3", "Handles UTF8-テスト JSON\"\nstrings" },
         { "demo4", "1" }
     });
 }
Beispiel #3
0
    public void EmitPurchase()
    {
        double price = 100;

        CountlyManager.Emit("purchase", 1, price,
                            new Dictionary <string, string>()
        {
            { "purchase_id", "product01" },
        });
    }
Beispiel #4
0
    void Start()
    {
        logListener = new SaveLogListener(logStrBuilder);
        CountlyManager.Instance.setLogListener(logListener);

        segmentation = new Dictionary <string, string>();
        profile      = CountlyManager.GetProfile();    //Get link to user profile

        profile.custom.Add("Surname", "Smith");
        profile.custom.Add("Additional info", "Any text here");
        //Here we add custom values to user profile
    }
Beispiel #5
0
    private void OnGUI()
    {
        Rect rect;

        rect = new Rect(10, Screen.height - 20, Screen.width - 20, 150);
        GUILayout.BeginArea(rect);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Emit purchase event"))
        {
            Debug.Log("Emitting purchase event...");

            EmitPurchase();
        }


        if (GUILayout.Button("Emit crazy event"))
        {
            Debug.Log("Emitting crazy event...");

            EmitCrazyEvent();
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        GUILayout.BeginVertical();
        CountlyManager.Instance.userProfile.name     = GUILayout.TextField(CountlyManager.Instance.userProfile.name);
        CountlyManager.Instance.userProfile.username = GUILayout.TextField(CountlyManager.Instance.userProfile.username);
        CountlyManager.Instance.userProfile.byear    = GUILayout.TextField(CountlyManager.Instance.userProfile.byear);
        if (GUILayout.Button("Send Profile"))
        {
            CountlyManager.SendProfile();
        }

        if (GUILayout.Button("Generate crash report"))
        {
            if (!CrashReporter.fetchReports())
            {
                CrashReporter.reports.Add(new CrashReporter.CountlyCrashReport("Test report"));
                CountlyManager.SendReports();
            }
        }
        GUILayout.EndVertical();
    }
 private void Awake()
 {
     CountlyManager.Init("put_your_app_key_here");
 }
Beispiel #7
0
    void OnGUI()
    {
        GUILayout.BeginArea(new Rect(20, 20, Screen.width / 4 - 20, Screen.height - 40));
        if (GUILayout.Button("Sessions"))
        {
            id = 0;
        }
        if (GUILayout.Button("Profile"))
        {
            id = 1;
        }
        if (GUILayout.Button("Events"))
        {
            id = 2;
        }
        if (GUILayout.Button("Reports"))
        {
            id = 3;
        }
        if (GUILayout.Button("Debug log"))
        {
            id = 4;
        }
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(Screen.width / 4, 20, Screen.width * .75f - 20, Screen.height - 40));
        scrollPos = GUILayout.BeginScrollView(scrollPos);
        switch (id)
        {
        case 0:
            GUILayout.Label("Sessions");
            GUILayout.Label("By default, Countly manages sessions automatically. You just have to specify your app host and key.\n If you want to initialize sessions manually, you can call CountlyManager.Init(\"your key\") from any of your classes.");
            break;

        case 1:
            GUILayout.Label("Profile");
            GUILayout.Label("Here's the example of some profile settings.");
            //Display some of profile default values
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name");
            profile.name = GUILayout.TextField(profile.name);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Birth Year");
            profile.byear = GUILayout.TextField(profile.byear);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Gender");
            profile.gender = GUILayout.TextField(profile.gender);
            GUILayout.EndHorizontal();
            GUILayout.Label("Custom values:");
            //Display user defined values
            LayoutKeys(profile.custom);
            GUILayout.Label("These are defined by user.");
            GUILayout.Label("If you leave any of the values blank, they will not be sent.");
            if (GUILayout.Button("Send profile"))
            {
                CountlyManager.SendProfile();                 // use this to send profile to server
            }
            break;

        case 2:
            GUILayout.Label("Events");
            GUILayout.Label("Using Countly event sistem, you can inform server about purchases or any other actions performed by user.");
            GUILayout.BeginHorizontal();
            GUILayout.Label("Key");
            key = GUILayout.TextField(key);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("Count: {0}", count));
            count = (int)GUILayout.HorizontalSlider(count, 1, 5);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("Price: {0}", price));
            price = double.Parse(GUILayout.TextField(price.ToString("0.000")));
            GUILayout.EndHorizontal();
            GUILayout.Label("Segmentation:");
            LayoutKeys(segmentation);
            if (segmentation.Count < 5)
            {
                newKey = GUILayout.TextField(newKey);
                if (newKey != "" && GUILayout.Button(string.Format("Add key: {0}", newKey)))
                {
                    segmentation.Add(newKey, "");
                }
            }
            GUILayout.Label("All the parameters except event key are optional.");
            if (GUILayout.Button("Send event"))
            {
                CountlyManager.Emit(key, count, price, segmentation);                 //Send the event with selected parameters to server
            }

            break;

        case 3:
            GUILayout.Label("Reports");
            GUILayout.Label("Countly will automatically send latest crash report logged by unity on start of each session. \bHowever, you can add more info to reports by generating them yourself. Here's an example report.");
            if (CrashReporter.reports.Count > 0)
            {
                LayoutKeys(CrashReporter.reports[0].parameters);
                GUILayout.Label("Crash reports can also include user-defined keys.");
                LayoutKeys(CrashReporter.reports[0].custom);
                GUILayout.Label("All parameters except _error are optional.");
                if (CrashReporter.reports[0].custom.Count < 5)
                {
                    newKey = GUILayout.TextField(newKey);
                    if (newKey != "" && GUILayout.Button(string.Format("Add key: {0}", newKey)))
                    {
                        CrashReporter.reports[0].custom.Add(newKey, "");
                    }
                }
                if (GUILayout.Button("Send report"))
                {
                    CountlyManager.SendReports();                     //Sends the last available report to the server
                }
            }
            else if (GUILayout.Button("Create report"))
            {
                throw new System.Exception("test report");
            }
            break;

        case 4:
            GUILayout.Label("Debug log");
            txtScrollVector = GUILayout.BeginScrollView(txtScrollVector);
            GUILayout.TextArea(logStrBuilder.ToString());
            GUILayout.EndScrollView();
            break;
        }
        GUILayout.EndScrollView();
        GUILayout.EndArea();
    }