Manage Custom Context

Custom contexts allow you to attach arbitrary data (strings, lists, dictionaries) to an event. You cannot search these, but they are viewable on the issue page:

Custom contexts as viewed on the Additional Data section of an event

To configure additional context:

Copied
#include <sentry.h>

sentry_value_t extra_value = sentry_value_new_string("Mighty Fighter");
sentry_set_extra("character.name", screen);

When sending context, be aware of maximum payload size, especially if you want to send the whole application state as extra data. Sentry does not recommend this approach since application state can be very large and easily exceed the 200kB maximum that Sentry has on individual event payloads. When this happens, you’ll receive an HTTP Error 413 Payload Too Large message as the server response or (when you set keepalive: true as a fetch parameter), the request will stay pending forever (for example, in Google Chrome).

Sentry will try its best to accommodate the data you send, but Sentry will trim large context payloads or truncate the payloads entirely.

For more details, see the full documentation on SDK data handling.

Extra Data, Additional Data

If you come across any usages of "extra" (setExtra in code) or "Additional Data" (in the UI), just mentally substitute it for context. Extra is deprecated in favor of context.

You can edit this page on GitHub.
Package:
github:getsentry/sentry-native
Version:
0.4.2
Repository:
https://github.com/getsentry/sentry-native