Commit 7ac3378
authored
Add deeplinkIntegration for automatic deep link breadcrumbs (#5983)
* feat(core): add deeplinkIntegration for automatic deep link breadcrumbs
Introduces a new `deeplinkIntegration` that automatically captures breadcrumbs
whenever the app is opened or foregrounded via a deep link.
- Intercepts cold-start links via `Linking.getInitialURL()`
- Intercepts warm-open links via `Linking.addEventListener('url', ...)`
- Breadcrumbs use `category: 'deeplink'` and `type: 'navigation'`
- Respects `sendDefaultPii`: when false, query strings are stripped and
numeric / UUID / long-hex path segments are replaced with `<id>`
- Compatible with both Expo Router and plain React Navigation deep linking
(uses the standard RN `Linking` API, no framework-specific dependencies)
- Gracefully skips setup when Linking is unavailable (e.g. web)
Closes #5424
* docs: add changelog entry for deeplinkIntegration
* fix(core): Address review feedback in deeplinkIntegration
- Strip URL fragments (#) in addition to query strings when sendDefaultPii
is off, preventing PII leaks via fragment identifiers
- Store the Linking event listener subscription and remove it on client
close to prevent resource leaks and duplicate breadcrumbs on hot reload
- Cache getBreadcrumbUrl result to avoid redundant getClient lookups and
regex sanitization
- Extract RNLinking and LinkingSubscription interfaces for cleaner types
- Add tests for fragment stripping, combined query+fragment stripping,
and subscription cleanup on client close
* refactor(core): Reuse existing sanitizeUrl from tracing/utils in deeplinkIntegration
Replace the duplicated stripQueryAndFragment/sanitizeUrl logic with the
existing exported sanitizeUrl from tracing/utils.ts, which already strips
query strings and fragments. The deeplink-specific ID replacement regex
is kept in a new sanitizeDeepLinkUrl wrapper.
* fix(core): Fix hostname corruption and repeated setup leak in deeplinkIntegration
- Split URL into authority and path before applying ID-replacement regex
so hostnames that resemble hex strings (e.g. myapp://deadbeef/...) are
not incorrectly replaced with <id>
- Move subscription to the factory closure and remove it on repeated
setup calls to prevent duplicate listeners when Sentry.init() is
called more than once
- Add tests for hostname preservation and repeated setup cleanup
* style: Fix lint issues in deeplinkIntegration
* style: Move interfaces to top and attach JSDoc to tryGetLinking
* fix(core): Rename Linking variable to avoid duplicate declaration in compiled output
The local variable 'Linking' from tryGetLinking() collided with the
destructured 'Linking' from require('react-native') in the compiled JS,
causing a 'Duplicate declaration' build error. Renamed to 'linking'.
* fix(core): Fix Linking duplicate declaration and revert unrelated replay-stubs.jar
- Rename destructured Linking to rnLinking inside tryGetLinking to avoid
Babel/Metro duplicate declaration errors in compiled output
- Fix getInitialURL call chain formatting per lint
- Revert unrelated replay-stubs.jar binary change
* fix(core): Use direct property access for Linking to avoid Babel duplicate declaration
Replace destructured import with direct property access on require result
as suggested by @antonis to fix the persisting Babel/Metro build error.1 parent 04207c4 commit 7ac3378
File tree
4 files changed
+448
-0
lines changed- packages/core
- src/js/integrations
- test/integrations
4 files changed
+448
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| 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 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 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 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
0 commit comments