using Backtrace.Unity; using Backtrace.Unity.Model; using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Diagnostics; public class TestBacktrace: MonoBehaviour { // Backtrace client instance private BacktraceClient _backtraceClient; void Start() { var serverUrl = "https://submit.backtrace.io/leoncheng/c37b512d36e8a673d1bf37ba13536e4a86632adac3cbf6fe5bf80778e3f2b670/json"; var gameObjectName = "_ErrorManager"; var databasePath = "${Application.persistentDataPath}/sample/backtrace/path"; var attributes = new Dictionary() { { "my-super-cool-attribute-name", "attribute-value" } }; // use game object to initialize Backtrace integration _backtraceClient = GameObject.Find(gameObjectName).GetComponent(); //Read from manager BacktraceClient instance var database = GameObject.Find(gameObjectName).GetComponent(); // or initialize Backtrace integration directly in your source code _backtraceClient = BacktraceClient.Initialize( url: serverUrl, databasePath: databasePath, gameObjectName: gameObjectName, attributes: attributes); } public void OnLogError() { Debug.LogError("Report LogError"); } public void TriggerUnhandledException() { throw new Exception("Unhandled Exception"); } public void TriggerHandledException() { try { // throw an exception here throw new Exception(); } catch (Exception exception) { var report = new BacktraceReport( exception: exception, attributes: new Dictionary() { { "key", "value" } }, attachmentPaths: new List() { @"file_path_1", @"file_path_2" } ); _backtraceClient.Send(report); } } public void TriggerCrash() { //Utils.ForceCrash(ForcedCrashCategory.AccessViolation); } // Update is called once per frame void Update() { } }