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

By default we will measure your app’s start time (within the JavaScript engine) and the network requests it makes. These measurements can be disabled 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.