Configuration options

Discover configuration options to customize your BugSnag integration.

Setting configuration options

Setting configuration in the Unity Editor

Most configuration options can be configured through the Unity Editor, in the BugSnag Configuration window:

Import Package

The “Start Automatically” option is enabled by default and will start sending performance data just before the first scene is loaded, provided your API key has also been set.

If you are using the BugSnag Error Monitoring SDK, the API key and other common configuration options can either be shared or set separately.

Setting configuration in code

To set configuration options in code, first ensure the “Start Automatically” project setting is disabled in the BugSnag Performance Configuration window. Then create a PerformanceConfiguration object, initialized from the Unity Editor, which can then be overridden in code:

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.ReleaseStage = "Production";
BugsnagPerformance.Start(config);

If you do not wish to use the Unity Editor configuration at all, simply create a PerformanceConfiguration object using the object constructor, passing in your API key.

BugsnagPerformance.Start must be called from the main thread – e.g. from the Start lifecycle function of a MonoBehaviour.

Available options

 API key

The API key used for performance data sent to BugSnag.

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.ApiKey = "YOUR-API-KEY";
BugsnagPerformance.Start(config);

 App version information

Setting your app’s version information in configuration allows you to see performance data for a specific release.

BugSnag captures this automatically from your Unity player settings, but it can be overridden in configuration if required:

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.AppVersion = "5.3.55";
config.BundleVersion = "5.3.55.2";
config.VersionCode = 55;
BugsnagPerformance.Start(config);

Auto instrumentation

By default we will measure the time it takes to start your game within the Unity framework: that is from the moment the SubSystemRegistration event is triggered until the AfterSceneLoad event is triggered.

This measurement can be disabled entirely using the following configuration option:

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.AutoInstrumentAppStart = AutoInstrumentAppStartSetting.OFF;
BugsnagPerformance.Start(config);

You can control the point it is ended directly by setting the configuration to .START_ONLY and calling BugsnagPerformance.ReportAppStarted() yourself.

Endpoint

By default we will send trace and span data to otlp.bugsnag.com/v1/traces.

If you are using BugSnag On-premise you’ll need to set this to your Trace Server endpoint.

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.Endpoint = "https://otlp.example.com/v1/traces";
BugsnagPerformance.Start(config);

Network request callback

You can control which network requests are captured and sanitize the URL string sent to your BugSnag dashboard using the NetworkRequestCallback configuration option. The network request span will be transmitted to BugSnag using the url in the returned object, or will not be sent at all if the url is set to null:

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.NetworkRequestCallback = requestInfo => {

    // Don't send network request span
    if (requestInfo.Url.Contains("no-track.com"))
    {
        return null;
    } 

    // Remove user ID
    if (Regex.IsMatch(requestInfo.Url, @"account\/[0-9]+"))
    {
        requestInfo.Url = Regex.Replace(requestInfo.Url, @"account\/[0-9]+", "account/[account-id]");
    }

    return requestInfo;

};

Release stages

Setting a release stage in your configuration allows you to filter performance data by different stages of the application release process (development, production, etc) in the BugSnag dashboard. The release stage is automatically set to “production”, unless the app is built with debug enabled in which case it will be set to “development”.

If you wish to override this, you can do so by setting the ReleaseStage configuration option:

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.ReleaseStage = "testing";
BugsnagPerformance.Start(config);

You can also limit which builds send performance data by setting the EnabledReleaseStages configuration option:

var config = BugsnagPerformanceSettingsObject.LoadConfiguration();
config.EnabledReleaseStages = new [] { "production", "development", "testing" };
BugsnagPerformance.Start(config);

By default, performance data will be sent for all stages.