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.s

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

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 page loads, route changes and network requests. These measurements can be disabled using the following configuration options:

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

Ignored URLs for Page Load settling

A page is considered to have loaded when it has “settled”, by which we mean no recent DOM mutations or network requests have been made. If you wish to disregard particular URLs from this calculation, use the settleIgnoreUrls configuration option. The URLs can be either a string or RegExp:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  settleIgnoreUrls: ['https://my.excluded/path', /.*my\.excluded\.domain.*/]
})

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({ 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({ 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.type == 'fetch' && requestInfo.url.matches(/account\/[0-9]+/)) {
      requestInfo.url = requestInfo.url.replace(/account\/[0-9]+/, 'account/[account-id]')
    }

    return requestInfo
  }
})

The type field denotes the type of request, as defined by the PerformanceResourceTiming.initiatorType property.

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.

Routing provider

For finer control of the route names used for Page Load and Route Change spans, a customized implementation of RoutingProvider can be set in configuration:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  routingProvider: new MyCustomRoutingProvider()
})

For more details see Instrumenting page loads & route changes.

Send page attributes

By default, all spans will contain the URL, title and referrer of the page on which it was created. If you do not wish to capture one or more of these fields, they can be disabled using the sendPageAttributes configuration option:

BugsnagPerformance.start({
  apiKey: 'YOUR_API_KEY',
  sendPageAttributes: {
    url: false,
    title: false,
    referrer: false
  }
})