public static void Init(string appID, CrittercismConfig config) { if (CrittercismAndroid.isInitialized) { Debug.Log("CrittercismAndroid is already initialized."); return; } Debug.Log("Initializing Crittercism with app id " + appID); CrittercismAndroid.mCrittercismsPlugin = new AndroidJavaClass(CrittercismAndroid.CRITTERCISM_CLASS); if (CrittercismAndroid.mCrittercismsPlugin == null) { Debug.Log("CrittercismAndroid failed to initialize. Unable to find class " + CrittercismAndroid.CRITTERCISM_CLASS); return; } using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject @static = androidJavaClass.GetStatic <AndroidJavaObject>("currentActivity")) { CrittercismAndroid.PluginCallStatic("initialize", new object[] { @static, appID, config.GetAndroidConfig() }); } } if (CrittercismAndroid.< > f__mg$cache0 == null) { CrittercismAndroid.< > f__mg$cache0 = new Application.LogCallback(CrittercismAndroid.OnLogMessageReceived); } Application.logMessageReceived += CrittercismAndroid.< > f__mg$cache0; CrittercismAndroid.isInitialized = true; }
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 }
private static void OnLogMessageReceived(string name, string stack, LogType type) { if (type != LogType.Exception) { return; } if (!CrittercismAndroid.isInitialized) { return; } if (CrittercismAndroid.logUnhandledExceptionAsCrash) { CrittercismAndroid.PluginCallStatic("_logCrashException", new object[] { name, name, stack }); } else { stack = new Regex("\r\n").Replace(stack, "\n\tat"); CrittercismAndroid.PluginCallStatic("_logHandledException", new object[] { name, name, stack }); } }
/// <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> /// 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 }
/// <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> /// 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 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> /// 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 }
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" }); } }
/// <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 }
/// <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 }
public static void SetValue(string key, string value) { CrittercismAndroid.SetMetadata(new string[] { key }, new string[] { value }); }
private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs args) { if (!CrittercismAndroid.isInitialized || args == null || args.ExceptionObject == null) { return; } Exception e = args.ExceptionObject as Exception; CrittercismAndroid.LogUnhandledException(e); }
public static int GetUserflowValue(string userflowName) { if (!CrittercismAndroid.isInitialized) { return(-1); } return(CrittercismAndroid.PluginCallStatic <int>("getTransactionValue", new object[] { userflowName })); }
public static void FailUserflow(string userflowName) { if (!CrittercismAndroid.isInitialized) { return; } CrittercismAndroid.PluginCallStatic("failTransaction", new object[] { userflowName }); }
public static void SetOptOut(bool optOutStatus) { if (!CrittercismAndroid.isInitialized) { return; } CrittercismAndroid.PluginCallStatic("setOptOutStatus", new object[] { optOutStatus }); }
public static void LeaveBreadcrumb(string breadcrumb) { if (!CrittercismAndroid.isInitialized) { return; } CrittercismAndroid.PluginCallStatic("leaveBreadcrumb", new object[] { breadcrumb }); }
public static void SetUsername(string username) { if (!CrittercismAndroid.isInitialized) { return; } CrittercismAndroid.PluginCallStatic("setUsername", new object[] { username }); }
private const string CustomVersionName = ""; /*Your Custom Version Name Here*/ void Awake() { #if UNITY_2_6 || UNITY_2_6_1 || UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 #else CrittercismAndroid.Init(CrittercismAppID, bDelaySendingAppLoad, bShouldCollectLogcat, CustomVersionName); #endif #if UNITY_3_3 || UNITY_3_4 || UNITY_3_4_1 || UNITY_3_4_2 #else Destroy(this); #endif }
private const string CrittercismAppID = ""; /*Your App ID Here*/ void Awake() { #if UNITY_2_6 || UNITY_2_6_1 || UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 #else CrittercismAndroid.Init(CrittercismAppID); #endif #if UNITY_3_3 || UNITY_3_4 || UNITY_3_4_1 || UNITY_3_4_2 #else Destroy(this); #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 }
public static void SetUserflowValue(string userflowName, int value) { if (!CrittercismAndroid.isInitialized) { return; } CrittercismAndroid.PluginCallStatic("setTransactionValue", new object[] { userflowName, value }); }
public static void LogHandledException(Exception e) { string fullName = e.GetType().FullName; string message = e.Message; string text = CrittercismAndroid.StackTrace(e); CrittercismAndroid.PluginCallStatic("_logHandledException", new object[] { fullName, message, text }); }