Exemple #1
0
    /// <summary>
    /// Log a breadcrumb.  Breadcrumbs are used for tracking local events.  Breadcrumbs
    /// will be attached to handled exceptions and crashes, which will allow diagnosing
    /// which events lead up to a crash.
    /// </summary>
    /// <param name="breadcrumb">The breadcrumb text to append to the breadcrumb trail</param>
    /// <example>LeaveBreadcrumb("Game started");</example>
    public static void LeaveBreadcrumb(string breadcrumb)
    {
#if UNITY_IOS
        CrittercismIOS.LeaveBreadcrumb(breadcrumb);
#elif UNITY_ANDROID
        CrittercismAndroid.LeaveBreadcrumb(breadcrumb);
#endif
    }
Exemple #2
0
    void OnGUI()
    {
        if (Screen.height == 0 || Screen.width == 0)
        {
            return;
        }

        int screenButtonHeight = Screen.height / 8;

        if (GUI.Button(new Rect(0, 0, Screen.width, screenButtonHeight), "Null Reference"))
        {
            string crash = null;
            crash = crash.ToLower();
        }

        if (GUI.Button(new Rect(0, screenButtonHeight, Screen.width, screenButtonHeight), "Divide By Zero"))
        {
            int i = 0;
            i = 2 / i;
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 2, Screen.width, screenButtonHeight), "Index Out Of Range"))
        {
            string[] arr = new string[1];
            arr[2] = "Crash";
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 3, Screen.width, screenButtonHeight), "Custom Exception"))
        {
            throw new System.Exception("Custom Exception");
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 4, Screen.width, screenButtonHeight), "Coroutine Custom Exception"))
        {
            StartCoroutine(MonoCorutineCrash());
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 5, Screen.width, screenButtonHeight), "Coroutine Null Exception"))
        {
            StartCoroutine(MonoCorutineNullCrash());
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 7, Screen.width, screenButtonHeight), "Test Messages"))
        {
            Debug.Log("Breadcrumb Test");
            CrittercismAndroid.LeaveBreadcrumb("BreadCrumb");

            Debug.Log("Age Test");
            CrittercismAndroid.SetValue("26", "Age");

            Debug.Log("Email Test");
            CrittercismAndroid.SetValue("*****@*****.**", "Email");

            Debug.Log("User Test");
            CrittercismAndroid.SetUsername("Username");
        }
    }
    void OnGUI()
    {
        if (Screen.height == 0 || Screen.width == 0)
        {
            return;
        }

        int screenButtonHeight = Screen.height / 8;

        if (GUI.Button(new Rect(0, 0, Screen.width, screenButtonHeight), "Null Reference"))
        {
            CrittercismAndroid.LeaveBreadcrumb("Null Reference incoming?!");
            string crash = null;
            crash = crash.ToLower();
        }

        if (GUI.Button(new Rect(0, screenButtonHeight, Screen.width, screenButtonHeight), "Divide By Zero"))
        {
            CrittercismAndroid.LeaveBreadcrumb("Lets divide by zero!");
            int i = 0;
            i = 2 / i;
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 2, Screen.width, screenButtonHeight), "Index Out Of Range"))
        {
            string[] arr = new string[1];
            arr[2] = "Crash";
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 3, Screen.width, screenButtonHeight), "Custom Exception"))
        {
            throw new System.Exception("Custom Exception");
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 4, Screen.width, screenButtonHeight), "Coroutine Custom Exception"))
        {
            StartCoroutine(MonoCorutineCrash());
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 5, Screen.width, screenButtonHeight), "Coroutine Null Exception"))
        {
            StartCoroutine(MonoCorutineNullCrash());
        }

        if (GUI.Button(new Rect(0, screenButtonHeight * 7, Screen.width, screenButtonHeight), "Test Messages"))
        {
            Debug.Log("User Test");
            CrittercismAndroid.SetUsername("RandomUser" + Random.Range(0, 10000).ToString());

            Debug.Log("Breadcrumb Test");
            CrittercismAndroid.LeaveBreadcrumb("BreadCrumb");

            Debug.Log("Metadata Test");
            CrittercismAndroid.SetMetadata(new string[] { "Age", "Email", "Extra" }, new string[] { Random.Range(10, 90).ToString(), string.Format("email{0}@test.com", Random.Range(0, 200)), "Data" });
        }
    }
    public void OnGUI()
    {
        GUIStyle customStyle = new GUIStyle(GUI.skin.button);

        customStyle.fontSize = 30;
        const int numberOfButtons    = 13;
        int       screenButtonHeight = Screen.height / numberOfButtons;

        if (GUI.Button(new Rect(0, 0, Screen.width, screenButtonHeight), "Set Username", customStyle))
        {
            CrittercismAndroid.SetUsername("MommaCritter");
        }
        if (GUI.Button(new Rect(0, screenButtonHeight, Screen.width, screenButtonHeight), "Set Metadata", customStyle))
        {
            CrittercismAndroid.SetMetadata(new string[] {
                "Game Level",
                "Status"
            }, new string[] {
                "5",
                "Crashes a lot"
            });
        }
        if (GUI.Button(new Rect(0, 2 * screenButtonHeight, Screen.width, screenButtonHeight), "Leave Breadcrumb", customStyle))
        {
            CrittercismAndroid.LeaveBreadcrumb("BreadCrumb");
        }
        if (GUI.Button(new Rect(0, 3 * screenButtonHeight, Screen.width, screenButtonHeight), "Log Network Request", customStyle))
        {
            System.Random random    = new System.Random();
            string[]      methods   = new string[] { "GET", "POST", "HEAD", "PUT" };
            string        method    = methods[random.Next(0, methods.Length)];
            string        uriString = uriStrings[random.Next(0, uriStrings.Length)];
            if (random.Next(0, 2) == 1)
            {
                uriString = uriString + "?doYouLoveCrittercism=YES";
            }
            // latency in milliseconds
            long latency      = (long)Math.Floor(4000.0 * random.NextDouble());
            long bytesRead    = random.Next(0, 10000);
            long bytesSent    = random.Next(0, 10000);
            int  responseCode = 200;
            if (random.Next(0, 5) == 0)
            {
                // Some common response other than 200 == OK .
                int[] responseCodes = new int[] { 301, 308, 400, 401, 402, 403, 404, 405, 408, 500, 502, 503 };
                responseCode = responseCodes[random.Next(0, responseCodes.Length)];
            }
            Console.WriteLine("LogNetworkRequest: \"" + uriString + "\"");
            CrittercismAndroid.LogNetworkRequest(
                method,
                uriString,
                latency,
                bytesRead,
                bytesSent,
                (HttpStatusCode)responseCode,
                WebExceptionStatus.Success);
        }
        if (GUI.Button(new Rect(0, 4 * screenButtonHeight, Screen.width, screenButtonHeight), "C# Crash", customStyle))
        {
            crashInnerException();
        }
        if (GUI.Button(new Rect(0, 5 * screenButtonHeight, Screen.width, screenButtonHeight), "C# Handled Exception", customStyle))
        {
            try {
                crashInnerException();
            } catch (System.Exception e) {
                CrittercismAndroid.LogHandledException(e);
            }
        }
        if (GUI.Button(new Rect(0, 6 * screenButtonHeight, Screen.width, screenButtonHeight), "C# Null Pointer Exception", customStyle))
        {
            try {
                causeNullPointerException();
            } catch (Exception e) {
                CrittercismAndroid.LogHandledException(e);
            }
        }
        if (GUI.Button(new Rect(0, 7 * screenButtonHeight, Screen.width, screenButtonHeight), "Begin Transaction", customStyle))
        {
            CrittercismAndroid.BeginTransaction("UnityAndroid");
        }
        if (GUI.Button(new Rect(0, 8 * screenButtonHeight, Screen.width, screenButtonHeight), "End Transaction", customStyle))
        {
            CrittercismAndroid.EndTransaction("UnityAndroid");
        }
        if (GUI.Button(new Rect(0, 9 * screenButtonHeight, Screen.width, screenButtonHeight), "Fail Transaction", customStyle))
        {
            CrittercismAndroid.FailTransaction("UnityAndroid");
        }
        if (GUI.Button(new Rect(0, 10 * screenButtonHeight, Screen.width, screenButtonHeight), "Cancel Transaction", customStyle))
        {
            CrittercismAndroid.CancelTransaction("UnityAndroid");
        }
        if (GUI.Button(new Rect(0, 11 * screenButtonHeight, Screen.width, screenButtonHeight), "Set Transaction Value", customStyle))
        {
            CrittercismAndroid.SetTransactionValue("UnityAndroid", 500);
        }
        if (GUI.Button(new Rect(0, 12 * screenButtonHeight, Screen.width, screenButtonHeight), "Get Transaction Value", customStyle))
        {
            int value = CrittercismAndroid.GetTransactionValue("UnityAndroid");
            Debug.Log("TransactionValue is: " + value);
        }
    }
Exemple #5
0
 public static void LeaveBreadcrumb(string breadcrumb)
 {
     CrittercismAndroid.LeaveBreadcrumb(breadcrumb);
 }