Skip to content

Commit 00c0bfd

Browse files
authored
feat(native): attach bytes (#14077)
1 parent ea1face commit 00c0bfd

File tree

1 file changed

+20
-1
lines changed
  • platform-includes/enriching-events/add-attachment

1 file changed

+20
-1
lines changed

platform-includes/enriching-events/add-attachment/native.mdx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,26 @@ sentry_value_t event = sentry_value_new_event();
2424
sentry_capture_event_with_scope(event, scope);
2525
```
2626

27-
<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>
27+
Alternately, use `bytes` to initialize an attachment. When doing so, you also need to specify a filename.
28+
29+
```c
30+
char *bytes = ...;
31+
size_t bytes_len = 123;
32+
33+
// Global Scope
34+
sentry_attach_bytes(bytes, bytes_len, "global.bin");
35+
36+
// Local Scope
37+
sentry_scope_t *scope = sentry_local_scope_new();
38+
sentry_scope_attach_bytes(scope, bytes, bytes_len, "local.bin");
39+
sentry_value_t event = sentry_value_new_event();
40+
/* ... */
41+
sentry_capture_event_with_scope(event, scope);
42+
```
43+
44+
<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>
45+
46+
<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>
2847
2948
### Removing Scoped Attachments
3049

0 commit comments

Comments
 (0)