Skip to content

Custom context

Custom context lets you attach application-specific data to bug reports. You can use it to capture feature flags, application state, or any other information that helps your team understand the context where an issue occurred.

Note: Use the identify API for user-specific information like name and email. It allows Capture to link multiple reports from the same user and provides better organization in your dashboard.

Setting custom context

Use the setCustomContext method to add custom data:

js
Capture.setCustomContext({
  environment: "production",
  featureFlags: { newDashboard: true, betaFeatures: false },
  appVersion: "2.4.1",
  userRole: "admin",
});

When a bug report is created, the value of the context at that moment are captured and included in the report.

You can call setCustomContext at any time - on page load, when application state changes, or in response to user actions. The most recent values are always used.

Viewing custom context

Custom context appears in the Report panel in the Capture dashboard, making it easy for developers to see the application state when the bug was reported.

Custom context is also included when bug reports are published to integrations like Linear, Jira, or Asana - it appears in the ticket description alongside other bug details.

Allowed values

Custom context supports these value types:

  • string
  • number
  • boolean
  • null
  • undefined

Merging vs replacing context

By default, new values are merged with existing custom context:

js
Capture.setCustomContext({ environment: "production" });
Capture.setCustomContext({ appVersion: "2.4.1" });
// custom context is now { environment: "production", appVersion: "2.4.1" }

To replace the entire context instead of merging, pass true as the second argument:

js
Capture.setCustomContext({ appVersion: "2.4.1" }, true);
// custom context is now { appVersion: "2.4.1" }

Removing context

To remove a specific key from custom context, use unsetCustomContext:

js
Capture.unsetCustomContext("environment");

This is useful when certain context is no longer relevant - for example, clearing feature flag state after a user action.

Next steps

Want to link bug reports to specific users in your application? Learn how to use the identify API to add user context and group reports by user.

Need to route bug reports to different destinations based on context? Check out custom workflows to create custom routing rules.