Commit d35ffa7
authored
feat: add manual rust error tracking (#129)
* feat: add manual rust error tracking
* test: align error tracking payload assertions
* fix: address error tracking review comments
* feat: add anonymous error capture helper
* docs: use version placeholder in README quickstart
* refactor: remove public exception_from_error helper
Callers build payloads with ExceptionCapture::from_error directly;
capture_error/capture_error_anon keep applying client-level Error
Tracking options internally.
* refactor: make Exception payload-only and apply client options at capture
Exceptions are now plain events: Exception holds only exception-specific
data (items, fingerprint, level) and converts into an Event via
into_event/into_event_anon, so distinct ID, props, groups, flags, and
timestamps use the standard Event API instead of duplicated builders.
Raw frames are captured unclassified at construction and client-level
ErrorTrackingOptions (stacktrace opt-out, in-app classification, frame
and source limits) are applied at capture time in the v0/v1 prep paths,
so free-standing constructors always honor the capturing client's
configuration.
* refactor: unify error capture under capture_exception
Replace capture_error/capture_error_anon and the personless
capture_exception(Exception) with capture_exception(&error, distinct_id)
and capture_exception_anon(&error) across the async, blocking, and global
APIs, matching the capture_exception entry point of other PostHog SDKs.
Built Exception payloads now go through Exception::into_event + capture.
* refactor: adopt options-based capture_exception API
capture_exception(&error) now captures personlessly, and
capture_exception_with(&error, CaptureExceptionOptions) carries the
optional context: distinct_id, custom properties, groups, fingerprint,
and severity level. capture_exception_anon is removed, and the
Exception payload type with its into_event conversions is no longer
exported - python/node expose no payload tier either, keeping the
public surface to two methods plus one options struct.
* refactor: finalize exception events eagerly in build_exception_event
Exception construction is now reachable only through client methods that
hold the client's ErrorTrackingOptions, so client policy (stack walk gating,
in-app classification, frame and source-chain limits, reserved $exception_*
properties) is applied when the event is built instead of at capture time.
Disabling capture_stacktrace now skips the stack walk entirely rather than
discarding the captured frames at send.
This removes the pending-exception staging field from Event and reverts
prepare_event/build_events to main's exception-agnostic shapes.
* refactor: make frame and source-chain limits internal constants
max_frames and max_error_sources leave ErrorTrackingOptions: no other SDK
exposes them, nobody asked for tunability, and the configurable source cap
silently clamped to the build-time bound anyway. The caps remain as
MAX_FRAMES/MAX_ERROR_SOURCES; re-adding knobs later is non-breaking.
* feat: emit one frame per inlined function
resolve_frame yields a symbol per logical layer when the compiler inlined
functions into a physical frame; the previous first-symbol-only guard kept
the innermost layer and silently dropped the inline ancestry, which exists
in no other frame. Emit each layer as its own frame (innermost first,
matching current-first capture order), like the Go runtime does for our Go
SDK. MAX_FRAMES now counts logical frames.
* refactor: mark exception internals pub(crate)
The error_tracking module is private, so these were never reachable, but
the bare pub kept reading as public API in review diffs. Make the
crate-internal surface explicit; the public ET API stays exactly
capture_exception/_with, CaptureExceptionOptions, and ErrorTrackingOptions.
* docs: document the error tracking public surface
/// docs with examples on capture_exception/_with, CaptureExceptionOptions,
and every ErrorTrackingOptions field (derive_builder copies field docs onto
the generated setters), including the capture-site-vs-origin stacktrace
caveat and crate-prefix in-app patterns. README gains the configuration
example and a captured-properties table.
* test: split error tracking integration tests by capture transport
test_error_tracking.rs asserts the V0 wire shape, so it is gated out under
capture-v1; test_error_tracking_v1.rs adds V1-envelope twins (single-attempt
clients against an empty-results 2xx, asserting one well-formed request).
Fixes the error-tracking + capture-v1 combo failing with 404s against
v0-shaped mocks.
* fix: clean up lints surfaced by feature-combo clippy
before_send on the flag-event hosts is only read by the v0 ship path, so
scope a dead_code allow under capture-v1 (the v1 flag path does not apply
before_send hooks today). Restructure the blocking capture cfg splits as
tail blocks so needless_return doesn't fire under capture-v1.
* ci: run error tracking feature combinations
The matrix never enabled error-tracking, so every ET test compiled to
nothing in CI; cover it alone and combined with capture-v1, on both
clients.
* build: drop the backtrace version pin
The pin guarded the declared 1.78 MSRV, but every toolchain it could help
(1.78-1.84) is already locked out by edition-2024 transitive manifests
(idna_adapter via reqwest->url, present on main's lockfile too), so it
protects nothing reachable while exporting =0.3.74 resolution conflicts to
any consumer tree wanting backtrace ^0.3.75. Verified against 0.3.76 across
all feature combos. Whether to restore the 1.78 floor or bump rust-version
is left as a separate decision.
* feat: enable error tracking by default
Every other PostHog SDK ships error tracking in the box; with the backtrace
pin gone there is no resolution cost to carry it as a default feature, and
capture_exception works out of the box. Opt out with default-features =
false. The CI matrix collapses accordingly: the default and capture-v1 steps
now cover error tracking on the async client, keeping explicit steps only
for the blocking client.1 parent f9504c9 commit d35ffa7
15 files changed
Lines changed: 2024 additions & 7 deletions
File tree
- .github/workflows
- .sampo/changesets
- examples
- src
- client
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
49 | 109 | | |
50 | 110 | | |
51 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
59 | 73 | | |
60 | 74 | | |
61 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
| |||
304 | 311 | | |
305 | 312 | | |
306 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
307 | 396 | | |
308 | 397 | | |
309 | 398 | | |
| |||
0 commit comments