Skip to content

feat(native): update before_send docs #13984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/platforms/native/common/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Note also that breadcrumbs can be filtered, as discussed in [our Breadcrumbs doc

#### Event Hints

The <PlatformIdentifier name="before-send" /> callback is passed both the `event` and a second argument, `hint`, that holds one or more hints.
The <PlatformIdentifier name="before-send" /> callback is passed the `event`, a second argument `hint` and lastly custom `user_data`.

Typically, a `hint` holds the original exception so that additional data can be extracted or grouping is affected. In this example, the fingerprint is forced to a common value if an exception of a certain type has been caught:

Expand Down
6 changes: 3 additions & 3 deletions platform-includes/configuration/before-send-hint/native.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Alert>

The Native SDK does not pass exception information into the hint, but instead allows to set a custom hint in SDK options. To detect the exception type, inspect the event instead.
The Native SDK does not pass exception information into the hint, but instead allows to set custom `user_data` in the `before_send` SDK option. To detect the exception type, inspect the event instead.

</Alert>

```c
#include <string.h>
#include <sentry.h>

sentry_value_t before_send(sentry_value_t event, void *hint) {
sentry_value_t before_send(sentry_value_t event, void *hint, void *user_data) {
/* sentry_value_t functions handle NULL automatically */
sentry_value_t exceptions = sentry_value_get_by_key(event, "exception");
sentry_value_t values = sentry_value_get_by_key(exceptions, "values");
Expand All @@ -17,7 +17,7 @@ sentry_value_t before_send(sentry_value_t event, void *hint) {
const char *type_str = sentry_value_as_string(type);

/* use the data passed during initialization */
const char *custom_error = (const char *)hint;
const char *custom_error = (const char *)user_data;

if (type_str && strcmp(type_str, custom_error) == 0) {
sentry_value_t fingerprint = sentry_value_new_list();
Expand Down