Backtrace allows you to configure error reporting for your Unity games by using the backtrace-unity library.

The backtrace-unity library can be downloaded from here.


  • Unity environment 2017 +

  • .NET 2.0/3.5/4.5/Standard 2.0 scripting runtime version

  • Mono or IL2CPP scripting backend

Setup and Installation

  1. Download the backtrace-unity zip file. Unzip it and keep the folder in a known location. It can be downloaded from

  2. Open your Unity project

  3. Use the Unity Package Manager to install backtrace-unity (Window -> Package Manager -> Add Package From Disk). The Unity editor will refresh and the Backtrace Plugin should become available in the editor.

Integrating into your Project

  1. Under the Assets Menu, there is now a Backtrace -> Configuration option. Choose that option to have a Backtrace Configuration is generated in the Assets folder.

  2. Next, select an object from the Scene Hierarchy to associate the Backtrace reporting client to. In the example below, we use the _Manager object., Using the Inspector panel, click the Add Component button and search for the Backtrace Client object.

  3. Within the Backtrace Client panel, there is a Backtrace Configuration field. Drag and drop the Backtrace Configuration from the Assets folder to that field. More fields will appear for you to fill in to configure the Backtrace Client and Offline Database options.

Watch this 1 minute silent video to see the Integration and Configuration in action. The first 20 seconds of the video shows the above Integrating steps, and the second part shows details of the below Client and Database Settings.

Note: Please review details for the Server Address and Token fields below.

Backtrace Client and Offline Database Settings

The following is a reference guide to the Backtrace Client fields:

  1. Server Address: This field is required to submit exceptions from your Unity project to your Backtrace instance. The Server Address to use for your instance is provided in the Web Console under Project Settings -> Integration Guides -> Unity.
    NOTE: If Backtrace is hosting your instance, the Server Address will probably be based on, and it will include your project name and submission token embedded in URL. Alternatively, you may see the Integration Guides provides a Server Address to . If this is the case, a separate Token field will also be provided.

  2. Token: If your Server Address is, then you do NOT need to enter a separate token here. If your Project Settings -> Integration Guides -> Unity page in the web console has a separate line for token, then copy that value here.

  3. Reports per minute: Limits the number of reports the client will send per minutes. If set to 0, there is no limit. If set to a higher value and the value is reached, the client will not send any reports until the next minute. Further, the BacktraceClient.Send/BacktraceClient.SendAsync method will return false.

  4. Capture unhandled exceptions: Toggle this on or off to set the library to handle unhandled exceptions that are not captured by try-catch blocks.

  5. Enable Database: When this setting is toggled, the backtrace-unity plugin will configure an offline database that will store reports if they can't be submitted do to being offline or not finding a network. When toggled on, there are a number of Database settings to configure.

  6. Backtrace Database path: This is the path to directory where the Backtrace database will store reports on your game. NOTE: Backtrace database will remove all existing files on database start

  7. Create database directory toggle: If toggled, the library will create the offline database directory if the provided path doesn't exists,

  8. Auto Send Mode: When toggled on, the database will send automatically reports to Backtrace server based on the Retry Settings below. When toggled off, the developer will need to use the Flush method to attempt to send and clear. Recommend that this is toggled on.

  9. Maximum number of records: This is one of two limits you can impose for controlling the growth of the offline store. This setting is the maximum number of stored reports in database. If value is equal to zero, then limit not exists, When the limit is reached, the database will remove the oldest entries.

  10. Maximum database size: This is the second limit you can impose for controlling the growth of the offline store. This setting is the maximum database size in MB. If value is equal to zero, then size is unlimited, When the limit is reached, the database will remove the oldest entries.

  11. Retry interval: If the database is unable to send its record, this setting specifies how many seconds the library should wait between retries.

  12. Maximum retries: If the database is unable to send its record, this setting specifies the maximum number of retries before the system gives up.

  13. Retry order: This specifies in which order records are sent to the Backtrace server.

Using in your C# code

You can further configure your game to submit crashes by making further changes in the C# code for your game. Include the following using statements to be able to use the library

using Backtrace.Unity;
using Backtrace.Unity.Model;

Configuring specific try-catch blocks

If you setup Backtrace client and Backtrace database configuration you can retrieve database and client instances by using GameObject. When you retrieve client instance you can start sending reports from try/catch block in your game! The BacktraceClient.Send method will send an error report to the Backtrace endpoint specified.

//Read from manager BacktraceClient instance
var backtraceClient = GameObject.Find("_Manager").GetComponent<BacktraceClient>();

 //Read from manager BacktraceClient instance
var database = GameObject.Find("_Manager").GetComponent<BacktraceDatabase>();

    //throw exception here
catch(Exception exception){
    var report = new BacktraceReport(exception);

BacktraceReport Options

The BacktraceReport class represents a single error report. You can  submit custom attributes using the attributes parameter, or attach files by supplying an array of file paths in the attachmentPaths parameter.

  //throw exception here
catch (Exception exception)
    var report = new BacktraceReport(
        exception: exception,
        attributes: new Dictionary<string, object>() { { "key", "value" } },
        attachmentPaths: new List<string>() { @"file_path_1", @"file_path_2" }


  • If you setup BacktraceClient with BacktraceDatabase and your application is offline or you pass invalid credentials to Backtrace server, reports will be stored in database directory path.

Attaching custom event handlers

Backtrace Client allows you to attach your custom event handlers. For example, you can trigger actions before the Send method:

 //Add your own handler to client API

backtraceClient.BeforeSend =
    (Model.BacktraceData model) =>
        var data = model;
        //do something with data for example:        
        data.Attributes.Add("eventAtrtibute", "EventAttributeValue");
        if(data.Classifier == null || !data.Classifier.Any())
            data.Attachments.Add("path to attachment");

        return data;

Backtrace Client currently supports the following events:

  • BeforeSend

  • OnClientReportLimitReached

  • OnServerResponse

  • OnServerError

Reporting unhandled application exceptions

BacktraceClient supports reporting of unhandled application exceptions not captured by your try-catch blocks. To enable reporting of unhandled exceptions even if you don't set this option in Backtrace configuration window use code below:


Flush database

When your application starts, database can send stored offline reports. If you want to do make it manually you can use Flush method that allows you to send report to server and then remove it from hard drive. If Send method fails, database will no longer store data.


Clearing database

You can clear all data from database without sending it to server by using Clear method. BacktraceDatabase will remove all files and won't send it to server.


Advanced Topics

For more information on advanced features and architecture related details, please see the Readme on github - 

Investigating an Error in Backtrace

Once errors are being reported to your Backtrace instance, you should see them in your Triage and Web Debugger view. See below for a screenshot of the Triage view with some Unity exceptions reported.

The developer who is debugging the error may find it useful to view more details of Exception. They choose the 'View Latest Trace' action to see more details in the Backtrace Web Debugger. Below we can see a list of all attributes submitted with a report. (Note the yield signs are just an indicator that this value is not indexed in Backtrace). We can also see the call stack and details of the selected frame.

Below we see more details above the Environment Variables from the Web Debugger to further assist with investigation.

Did this answer your question?