Skip to content

feat(native): attach bytes #14077

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 2 commits into from
Jul 9, 2025
Merged
Changes from all 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
21 changes: 20 additions & 1 deletion platform-includes/enriching-events/add-attachment/native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,26 @@ sentry_value_t event = sentry_value_new_event();
sentry_capture_event_with_scope(event, scope);
```

<Alert>☝ When using the `crashpad` backend on macOS, the list of attachments that will be added at the time of a hard crash will be frozen at the time of `sentry_init`, and later modifications will not be reflected.</Alert>
Alternately, use `bytes` to initialize an attachment. When doing so, you also need to specify a filename.

```c
char *bytes = ...;
size_t bytes_len = 123;

// Global Scope
sentry_attach_bytes(bytes, bytes_len, "global.bin");

// Local Scope
sentry_scope_t *scope = sentry_local_scope_new();
sentry_scope_attach_bytes(scope, bytes, bytes_len, "local.bin");
sentry_value_t event = sentry_value_new_event();
/* ... */
sentry_capture_event_with_scope(event, scope);
```

<Alert>When using the `crashpad` backend, it writes byte attachments to disk into a flat directory structure. If multiple buffers are attached with the same `filename`, it will internally ensure unique filenames for attachments by appending a unique suffix to the filename. Therefore, attachments may show up with altered names in Sentry.</Alert>

<Alert>When using the `crashpad` backend on macOS, the list of attachments that will be added at the time of a hard crash will be frozen at the time of `sentry_init`, and later modifications will not be reflected.</Alert>

### Removing Scoped Attachments

Expand Down
Loading