Configuration options

Discover configuration options to customize your BugSnag integration.

Setting configuration options

Configuration options can be set by creating a configuration object and passing it into BugsnagPerformance.start:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  appVersion: '1.0.0-alpha'
})

Available options

API key

The API key used for performance data sent to BugSnag.

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY'
})

You can find your API key in Project Settings from your BugSnag dashboard.

App version information

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

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  appVersion: '4.10.0'
})

Auto instrumentation

The instrumentation added to your app to capture measurements can be disabled entirely using the following configuration options:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  autoInstrumentAppStarts: false,
  autoInstrumentNetworkRequests: false
})

Code Bundle ID

A user-defined unique identifier for a JavaScript code deployment. There can be multiple deployments for a given appVersion. This is most useful when using a tool like App Center CodePush to update your app.

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  codeBundleId: '1.0-15'
})

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.

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  endpoint: "https://otlp.example.com/v1/traces"
})

Logger

By default, log messages from the BugSnag SDK are prefixed with [bugsnag-performance] and output to the console (if the platform has a useful console object). You can supply your own logger instead, or switch off logging completely by setting logger: null.

If you supply a logger, it must have the following methods: debug, info, warn and error.

// switch off logging
BugsnagPerformance.start({ 
  apiKey: 'YOUR_API_KEY',
  logger: null 
})

// supply a custom logger
var myCustomLogger = {
  debug (message: string) { console.debug(message) },
  info (message: string) { console.info(message) },
  warn (message: string) { console.warn(message) },
  error (message: string) { console.error(message) }
}
BugsnagPerformance.start({ 
  apiKey: 'YOUR_API_KEY',
  logger: myCustomLogger 
})

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 null is returned:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  networkRequestCallback: (requestInfo) => {

    // Don't send network request span
    if (requestInfo.url.includes('no-track.com')) return null

    // Remove user ID
    if (requestInfo.url.matches(/account\/[0-9]+/)) {
      requestInfo.url.replace(/account\/[0-9]+/, 'account/[account-id]')
    }

    return requestInfo
  }
})

The requestInfo object contains a type field that will always be xmlhttprequest as React Native’s fetch implementation is a polyfill for XHR.

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:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  releaseStage: 'testing'
})

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

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  enabledReleaseStages: ['production', 'development', 'testing']
})

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

Sampling probability

By default, the SDK uses BugSnag’s sampling mechanism to spread the span quota in your plan over a month with a constantly adjusted probability that a given user interaction will be recorded. If you are controlling the sampling yourself – such as using an OTel Collector – the sampling probability can be fixed to a value between 0 and 1 to send a fixed proportion.

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  samplingProbability: 1.0
});

When a sampling probability is set explicitly, the captured spans will be counted towards your unmanaged quota. See the Sampling of performance data guide for details.

Service name

A readable identifier for your app to populate the service.name attribute in captured spans.

If you are using a collector, you must configure a service name mapping to match spans from your application to the correct project in BugSnag.

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  serviceName: 'ZippyApp'
});

By default, the service name taken from the bundle identifier of the app, if found, or else is set to ‘unknown_service’.

Trace propagation

Enabling this option sends OpenTelemetry compatible trace context headers on network requests made to your servers.

We only recommend sending this information to servers that are under your control and instrumented by OpenTelemetry. Once configured, you will be able to see full distributed traces in BugSnag.

This is enabled by setting the tracePropagationUrls configuration option to control which URLs should include the header:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  tracePropagationUrls: [/^(http(s)?(:\/\/))?(www\.)?example\.com(\/.*)?$/]
});