public static void LogNetworkRequest(string method, string uriString, long latencyInMilliseconds, int bytesRead, int bytesSent, HttpStatusCode responseCode, WebExceptionStatus exceptionStatus) { #if UNITY_IOS CrittercismIOS.LogNetworkRequest(method, uriString, (double)latencyInMilliseconds / 1000.0, bytesRead, bytesSent, responseCode, exceptionStatus); #elif UNITY_ANDROID CrittercismAndroid.LogNetworkRequest(method, uriString, latencyInMilliseconds, bytesRead, bytesSent, responseCode, exceptionStatus); #endif }
/// <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 }
/// <summary> /// Set the Username of the current user. /// </summary> /// <param name="username">The user name to set</param> public static void SetUsername(string username) { #if UNITY_IOS CrittercismIOS.SetUsername(username); #elif UNITY_ANDROID CrittercismAndroid.SetUsername(username); #endif }
/// <summary> /// Changes whether the user is opted in or out of reporting data to Crittercism. /// </summary> /// <param name="isOptedOut">True to opt out of sending data to Crittercism</param> public static void SetOptOut(bool isOptedOut) { #if UNITY_IOS CrittercismIOS.SetOptOut(isOptedOut); #elif UNITY_ANDROID CrittercismAndroid.SetOptOut(isOptedOut); #endif }
/// <summary> /// Log an exception that has been handled in code. /// This exception will be reported to the Crittercism portal. /// </summary> /// <param name="e">A caught exception that should be reported to Crittercism.</param> public static void LogHandledException(Exception e) { #if UNITY_IOS CrittercismIOS.LogHandledException(e); #elif UNITY_ANDROID CrittercismAndroid.LogHandledException(e); #endif }
/// <summary> /// Report uncaught C# Exception's as crashes (red blips) iff value is true . /// </summary> public static void SetLogUnhandledExceptionAsCrash(bool value) { #if UNITY_IOS CrittercismIOS.SetLogUnhandledExceptionAsCrash(value); #elif UNITY_ANDROID CrittercismAndroid.SetLogUnhandledExceptionAsCrash(value); #endif }
/// <summary> /// Set the currency cents value of a userflow. /// </summary> public static void SetUserflowValue(string name, int value) { #if UNITY_IOS CrittercismIOS.SetUserflowValue(name, value); #elif UNITY_ANDROID CrittercismAndroid.SetUserflowValue(name, value); #endif }
/// <summary> /// End an already begun userflow as a failure. /// </summary> public static void FailUserflow(string name) { #if UNITY_IOS CrittercismIOS.FailUserflow(name); #elif UNITY_ANDROID CrittercismAndroid.FailUserflow(name); #endif }
void Awake() { #if UNITY_IOS CrittercismIOS.Init(CrittercismiOSAppID); #elif UNITY_ANDROID CrittercismAndroid.Init(CrittercismAndroidAppID); #endif }
/// <summary> /// Tell Crittercism to associate the given value/key pair with the current /// device UUID. /// <param name="val">The metadata value to set</param> /// <param name="key">The key to associate with the given metadata<c/param> /// <example>SetValue("5", "Game Level")</example> /// </summary> public static void SetValue(string key, string value) { #if UNITY_IOS CrittercismIOS.SetValue(value, key); #elif UNITY_ANDROID CrittercismAndroid.SetMetadata(new string[] { key }, new string[] { value }); #endif }
void OnGUI() { 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("BreadcrumbTest"); CrittercismIOS.LeaveBreadcrumb("BreadCrumb"); Debug.Log("AgeTest"); CrittercismIOS.SetAge(26); Debug.Log("EMailTest"); CrittercismIOS.SetEmail("*****@*****.**"); Debug.Log("UserTest"); CrittercismIOS.SetUsername("Username"); Debug.Log("ValueTest"); CrittercismIOS.SetValue("A Value", "A Key"); Debug.Log("EventTest"); // CrittercismIOS.LogEvent("EventTest", null); } }
/// <summary> /// Check if the user has opted out of Crittercism. If a user is opted out, then no data will be /// sent to Crittercism. /// </summary> /// <returns>True if the user has opted out of Crittercism</returns> public static bool GetOptOut() { #if UNITY_IOS return(CrittercismIOS.GetOptOut()); #elif UNITY_ANDROID return(CrittercismAndroid.GetOptOut()); #else return(true); #endif }
/// <summary> /// Reporting uncaught C# Exception's as crashes (red blips)? /// </summary> public static bool GetLogUnhandledExceptionAsCrash() { #if UNITY_IOS return(CrittercismIOS.GetLogUnhandledExceptionAsCrash()); #elif UNITY_ANDROID return(CrittercismAndroid.GetLogUnhandledExceptionAsCrash()); #else return(false); #endif }
/// <summary> /// Get the currency cents value of a userflow. /// </summary> public static int GetUserflowValue(string name) { #if UNITY_IOS return(CrittercismIOS.GetUserflowValue(name)); #elif UNITY_ANDROID return(CrittercismAndroid.GetUserflowValue(name)); #else return(-1); #endif }
/// <summary> /// Did the application crash on the previous load? /// </summary> public static bool DidCrashOnLastLoad() { #if UNITY_IOS return(CrittercismIOS.DidCrashOnLastLoad()); #elif UNITY_ANDROID return(CrittercismAndroid.DidCrashOnLastLoad()); #else return(false); #endif }
// 유틸 : 크래시 래포트 설정 void SetCrittercism() { #if UNITY_ANDROID UnityEngine.Debug.LogFormat("Crittercism.DidCrashOnLastLoad = {0}", CrittercismAndroid.DidCrashOnLastLoad()); CrittercismAndroid.Init("20fb64bf760d44589b6aefeb6bcb220700555300"); CrittercismAndroid.SetLogUnhandledExceptionAsCrash(true); #elif UNITY_IPHONE || UNITY_IOS UnityEngine.Debug.LogFormat("Crittercism.DidCrashOnLastLoad = {0}", CrittercismIOS.DidCrashOnLastLoad()); CrittercismIOS.Init("7d02af2372694b93b84d75a999dd7dd400555300"); CrittercismIOS.SetLogUnhandledExceptionAsCrash(true); #endif }
/// <summary> /// Tell Crittercism to associate the given value/key pair with the current /// device UUID. /// <param name="val">The metadata value to set</param> /// <param name="key">The key to associate with the given metadata<c/param> /// <example>SetValue("5", "Game Level")</example> /// </summary> public static void SetMetadata(string[] keys, string[] values) { #if UNITY_IOS int length = keys.Length; for (int i = 0; i < length; i++) { string key = keys [i]; string value = values [i]; CrittercismIOS.SetValue(value, key); } #elif UNITY_ANDROID CrittercismAndroid.SetMetadata(keys, values); #endif }
// 유틸 : 크래시 래포트 설정 void SetCrittercism() { #if UNITY_EDITOR UnityEngine.Debug.LogFormat("AOS Crittercism : {0}", m_strAppKeyForAOS); UnityEngine.Debug.LogFormat("IOS Crittercism : {0}", m_strAppKeyForIOS); #elif UNITY_ANDROID UnityEngine.Debug.LogFormat("Crittercism.DidCrashOnLastLoad = {0}", CrittercismAndroid.DidCrashOnLastLoad()); CrittercismAndroid.Init(m_strAppKeyForAOS); CrittercismAndroid.SetLogUnhandledExceptionAsCrash(true); #elif UNITY_IPHONE || UNITY_IOS UnityEngine.Debug.LogFormat("Crittercism.DidCrashOnLastLoad = {0}", CrittercismIOS.DidCrashOnLastLoad()); CrittercismIOS.Init(m_strAppKeyForIOS); CrittercismIOS.SetLogUnhandledExceptionAsCrash(true); #endif }
void OnGUI() { GUIStyle customStyle = new GUIStyle(GUI.skin.button); customStyle.fontSize = 30; int screenButtonHeight = Screen.height / 8; if (GUI.Button(new Rect(0, 0, Screen.width, screenButtonHeight), "Leave breadcrumb", customStyle)) { CrittercismIOS.LeaveBreadcrumb("BreadCrumb"); } if (GUI.Button(new Rect(0, screenButtonHeight, Screen.width, screenButtonHeight), "Set User Metadata", customStyle)) { CrittercismIOS.SetUsername("Username"); CrittercismIOS.SetValue("5", "Game Level"); CrittercismIOS.SetValue("Crashes a lot", "Status"); } if (GUI.Button(new Rect(0, screenButtonHeight * 2, Screen.width, screenButtonHeight), "C# Crash", customStyle)) { causeDivideByZeroException(); } if (GUI.Button(new Rect(0, screenButtonHeight * 3, Screen.width, screenButtonHeight), "C# Handled Exception", customStyle)) { try { causeDivideByZeroException(); } catch (System.Exception e) { CrittercismIOS.LogHandledException(e); } } if (GUI.Button(new Rect(0, screenButtonHeight * 4, Screen.width, screenButtonHeight), "C# Null Pointer Exception", customStyle)) { try { causeNullPointerException(); } catch (System.Exception e) { CrittercismIOS.LogHandledException(e); } } }
void OnGUI() { GUIStyle customStyle = new GUIStyle(GUI.skin.button); customStyle.fontSize = 30; const int numberOfButtons = 11; int screenButtonHeight = Screen.height / numberOfButtons; if (GUI.Button(new Rect(0, 0, Screen.width, screenButtonHeight), "Leave Breadcrumb", customStyle)) { CrittercismIOS.LeaveBreadcrumb("BreadCrumb"); } if (GUI.Button(new Rect(0, screenButtonHeight, Screen.width, screenButtonHeight), "Set Username", customStyle)) { CrittercismIOS.SetUsername("MommaCritter"); } if (GUI.Button(new Rect(0, screenButtonHeight * 2, Screen.width, screenButtonHeight), "Set Metadata", customStyle)) { CrittercismIOS.SetValue("Game Level", "Status"); CrittercismIOS.SetValue("5", "Crashes a lot"); } if (GUI.Button(new Rect(0, screenButtonHeight * 3, Screen.width, screenButtonHeight), "C# Crash", customStyle)) { crashInnerException(); } if (GUI.Button(new Rect(0, screenButtonHeight * 4, Screen.width, screenButtonHeight), "C# Handled Exception", customStyle)) { try { crashInnerException(); } catch (Exception e) { CrittercismIOS.LogHandledException(e); } } if (GUI.Button(new Rect(0, screenButtonHeight * 5, Screen.width, screenButtonHeight), "C# Null Pointer Exception", customStyle)) { try { causeNullPointerException(); } catch (Exception e) { CrittercismIOS.LogHandledException(e); } } if (GUI.Button(new Rect(0, screenButtonHeight * 6, Screen.width, screenButtonHeight), "Begin Transaction", customStyle)) { CrittercismIOS.BeginTransaction("UnityIOS"); } if (GUI.Button(new Rect(0, screenButtonHeight * 7, Screen.width, screenButtonHeight), "End Transaction", customStyle)) { CrittercismIOS.EndTransaction("UnityIOS"); } if (GUI.Button(new Rect(0, screenButtonHeight * 8, Screen.width, screenButtonHeight), "Fail Transaction", customStyle)) { CrittercismIOS.FailTransaction("UnityIOS"); } if (GUI.Button(new Rect(0, screenButtonHeight * 9, Screen.width, screenButtonHeight), "Set Transaction Value", customStyle)) { CrittercismIOS.SetTransactionValue("UnityIOS", 500); } if (GUI.Button(new Rect(0, screenButtonHeight * 10, Screen.width, screenButtonHeight), "Get Transaction Value", customStyle)) { int value = CrittercismIOS.GetTransactionValue("UnityIOS"); Debug.Log("TransactionValue is: " + value); } }
void Awake() { CrittercismIOS.Init(CrittercismAppID); Destroy(this); }
public static void FailTransaction(string name) { CrittercismIOS.FailUserflow(name); }
public static void EndTransaction(string name) { CrittercismIOS.EndUserflow(name); }
public static void CancelTransaction(string name) { CrittercismIOS.CancelUserflow(name); }
public static void BeginTransaction(string name, int value) { CrittercismIOS.BeginUserflow(name, value); }
public static int GetTransactionValue(string name) { return(CrittercismIOS.GetUserflowValue(name)); }
public static void SetTransactionValue(string name, int value) { CrittercismIOS.SetUserflowValue(name, value); }
private CrittercismTestGUI() { Debug.Log("DidCrashOnLastLoad: " + CrittercismIOS.DidCrashOnLastLoad()); CrittercismIOS.SetLogUnhandledExceptionAsCrash(true); }
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)) { CrittercismIOS.SetUsername("MommaCritter"); } if (GUI.Button(new Rect(0, screenButtonHeight, Screen.width, screenButtonHeight), "Set Metadata", customStyle)) { CrittercismIOS.SetValue("Game Level", "Status"); CrittercismIOS.SetValue("5", "Crashes a lot"); } if (GUI.Button(new Rect(0, 2 * screenButtonHeight, Screen.width, screenButtonHeight), "Leave Breadcrumb", customStyle)) { CrittercismIOS.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 int latency = (int)Math.Floor(4000.0 * random.NextDouble()); int bytesRead = random.Next(0, 10000); int 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 + "\""); CrittercismIOS.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 (Exception e) { CrittercismIOS.LogHandledException(e); } } if (GUI.Button(new Rect(0, 6 * screenButtonHeight, Screen.width, screenButtonHeight), "C# Null Pointer Exception", customStyle)) { try { causeNullPointerException(); } catch (Exception e) { CrittercismIOS.LogHandledException(e); } } if (GUI.Button(new Rect(0, 7 * screenButtonHeight, Screen.width, screenButtonHeight), "Begin Transaction", customStyle)) { CrittercismIOS.BeginTransaction("UnityIOS"); } if (GUI.Button(new Rect(0, 8 * screenButtonHeight, Screen.width, screenButtonHeight), "End Transaction", customStyle)) { CrittercismIOS.EndTransaction("UnityIOS"); } if (GUI.Button(new Rect(0, 9 * screenButtonHeight, Screen.width, screenButtonHeight), "Fail Transaction", customStyle)) { CrittercismIOS.FailTransaction("UnityIOS"); } if (GUI.Button(new Rect(0, 10 * screenButtonHeight, Screen.width, screenButtonHeight), "Cancel Transaction", customStyle)) { CrittercismIOS.CancelTransaction("UnityIOS"); } if (GUI.Button(new Rect(0, 11 * screenButtonHeight, Screen.width, screenButtonHeight), "Set Transaction Value", customStyle)) { CrittercismIOS.SetTransactionValue("UnityIOS", 500); } if (GUI.Button(new Rect(0, 12 * screenButtonHeight, Screen.width, screenButtonHeight), "Get Transaction Value", customStyle)) { int value = CrittercismIOS.GetTransactionValue("UnityIOS"); Debug.Log("TransactionValue is: " + value); } }