Пример #1
0
 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;
 }
Пример #2
0
 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
         });
     }
 }
Пример #3
0
 public static int GetUserflowValue(string userflowName)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return(-1);
     }
     return(CrittercismAndroid.PluginCallStatic <int>("getTransactionValue", new object[]
     {
         userflowName
     }));
 }
Пример #4
0
 public static void FailUserflow(string userflowName)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return;
     }
     CrittercismAndroid.PluginCallStatic("failTransaction", new object[]
     {
         userflowName
     });
 }
Пример #5
0
 public static void LeaveBreadcrumb(string breadcrumb)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return;
     }
     CrittercismAndroid.PluginCallStatic("leaveBreadcrumb", new object[]
     {
         breadcrumb
     });
 }
Пример #6
0
 public static void SetUsername(string username)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return;
     }
     CrittercismAndroid.PluginCallStatic("setUsername", new object[]
     {
         username
     });
 }
Пример #7
0
 public static void SetOptOut(bool optOutStatus)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return;
     }
     CrittercismAndroid.PluginCallStatic("setOptOutStatus", new object[]
     {
         optOutStatus
     });
 }
Пример #8
0
 public static void SetUserflowValue(string userflowName, int value)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return;
     }
     CrittercismAndroid.PluginCallStatic("setTransactionValue", new object[]
     {
         userflowName,
         value
     });
 }
Пример #9
0
    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
        });
    }
Пример #10
0
    private static void LogUnhandledException(Exception e)
    {
        string fullName = e.GetType().FullName;
        string message  = e.Message;
        string text     = CrittercismAndroid.StackTrace(e);

        CrittercismAndroid.PluginCallStatic((!CrittercismAndroid.logUnhandledExceptionAsCrash) ? "_logHandledException" : "_logCrashException", new object[]
        {
            fullName,
            message,
            text
        });
    }
Пример #11
0
 public static void LogNetworkRequest(string method, string uriString, long latency, long bytesRead, long bytesSent, HttpStatusCode responseCode, WebExceptionStatus exceptionStatus)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return;
     }
     CrittercismAndroid.PluginCallStatic("logNetworkRequest", new object[]
     {
         method,
         uriString,
         latency,
         bytesRead,
         bytesSent,
         (int)responseCode,
         (int)exceptionStatus
     });
 }
Пример #12
0
 public static void SetValue(string key, string value)
 {
     if (!CrittercismAndroid.isInitialized)
     {
         return;
     }
     using (AndroidJavaObject androidJavaObject = new AndroidJavaObject("org.json.JSONObject", new object[0]))
     {
         androidJavaObject.Call <AndroidJavaObject>("put", new object[]
         {
             key,
             value
         });
         CrittercismAndroid.PluginCallStatic("setMetadata", new object[]
         {
             androidJavaObject
         });
     }
 }
Пример #13
0
 public static bool DidCrashOnLastLoad()
 {
     return(CrittercismAndroid.isInitialized && CrittercismAndroid.PluginCallStatic <bool>("didCrashOnLastLoad", new object[0]));
 }
Пример #14
0
 public static bool GetOptOut()
 {
     return(CrittercismAndroid.isInitialized && CrittercismAndroid.PluginCallStatic <bool>("getOptOutStatus", new object[0]));
 }