Skip to content

Commit 0043edf

Browse files
authored
docs: provide example for breadcrumb data property (#951)
1 parent 5596cbb commit 0043edf

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Remove the `CRASHPAD_WER_ENABLED` build flag. The WER module is now built for all supported Windows targets, and registration is conditional on runtime Windows version checks. ([#950](https://github.com/getsentry/sentry-native/pull/950), [crashpad#96](https://github.com/getsentry/crashpad/pull/96))
88

9+
**Docs**:
10+
11+
- Add usage of the breadcrumb `data` property to the example. [#951](https://github.com/getsentry/sentry-native/pull/951)
12+
913
## 0.7.0
1014

1115
**Breaking changes**:

examples/example.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@
99
#include <stdio.h>
1010
#include <stdlib.h>
1111
#include <string.h>
12+
1213
#ifdef NDEBUG
1314
# undef NDEBUG
1415
#endif
16+
1517
#include <assert.h>
1618

1719
#ifdef SENTRY_PLATFORM_WINDOWS
1820
# include <synchapi.h>
1921
# define sleep_s(SECONDS) Sleep((SECONDS)*1000)
2022
#else
23+
2124
# include <signal.h>
2225
# include <unistd.h>
26+
2327
# define sleep_s(SECONDS) sleep(SECONDS)
2428
#endif
2529

@@ -260,6 +264,21 @@ main(int argc, char **argv)
260264
debug_crumb, "category", sentry_value_new_string("example!"));
261265
sentry_value_set_by_key(
262266
debug_crumb, "level", sentry_value_new_string("debug"));
267+
268+
// extend the `http` crumb with (optional) data properties as documented
269+
// here:
270+
// https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/#breadcrumb-types
271+
sentry_value_t http_data = sentry_value_new_object();
272+
sentry_value_set_by_key(http_data, "url",
273+
sentry_value_new_string("https://example.com/api/1.0/users"));
274+
sentry_value_set_by_key(
275+
http_data, "method", sentry_value_new_string("GET"));
276+
sentry_value_set_by_key(
277+
http_data, "status_code", sentry_value_new_int32(200));
278+
sentry_value_set_by_key(
279+
http_data, "reason", sentry_value_new_string("OK"));
280+
sentry_value_set_by_key(debug_crumb, "data", http_data);
281+
263282
sentry_add_breadcrumb(debug_crumb);
264283

265284
sentry_value_t nl_crumb

tests/assertions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ def assert_breadcrumb(envelope):
142142
"message": "debug crumb",
143143
"category": "example!",
144144
"level": "debug",
145+
"data": {
146+
"url": "https://example.com/api/1.0/users",
147+
"method": "GET",
148+
"status_code": 200,
149+
"reason": "OK",
150+
},
145151
}
146152
assert any(matches(b, expected) for b in event["breadcrumbs"])
147153

0 commit comments

Comments
 (0)