Skip to content

Custom context

Custom context lets you attach application-specific information to bug reports. This can be useful for debugging or understanding the environment where the issue occurred.

Setting custom context

To set custom context, use the setCustomContext method on the global Capture object:

js
Capture.setCustomContext({ teamId: "your-data-here" });

When a report is created, the values set at that moment are captured and included. You can view them in the Report panel.

The custom context panel in the Capture UI

Allowed values

The supported value types are: string, number, boolean, null, and undefined.

Replacing context

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

js
Capture.setCustomContext({ teamId: "my-team-id" });
Capture.setCustomContext({ userId: "my-user-id" });
// custom context is now { teamId: "my-team-id", userId: "my-user-id" }

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

js
Capture.setCustomContext({ userId: "my-user-id" }, true);
// custom context is now { userId: "my-user-id" }

Removing context

To remove a previously set key, use unsetCustomContext:

js
Capture.unsetCustomContext("teamId");