Commit fb2c71d
Emit screen views as a well-formed app://<bundle id>/<screen> URL (#71)
* Emit screen views as a well-formed app://<bundle id>/<screen> URL
page_url was app://<screen>, which is not a valid URL: the screen name lands
in the authority slot and there is no path at all. Every URL parser therefore
returns an empty path, which is why the ingestion pipeline had to reconstruct
both origin and page_path by hand instead of using the URL functions it
already applies to web events.
Now app://com.acme.wallet/Home — bundle id as the authority, screen as the
path, mirroring https://host/path. domainWithoutWWW() yields the bundle id and
path() yields the screen, with no mobile-specific handling.
The bundle id is also the right authority for the same reason a hostname is:
stable and globally unique. A display name is neither — renaming an app would
split its history, and two apps sharing a name would merge.
Falls back to an empty authority (app:///Home) when no bundle id is available,
which still parses to a correct path; the pipeline resolves origin from
context there. Leading slashes in the screen name are stripped so a
router-style name does not produce a doubled separator.
getDeviceInfo() is now memoised. Screen events need the bundle id and
generateContext needs the same values for every event, so without it each
screen view would cost two native bridge round-trips; with it, zero after the
first event.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Use the configured bundle id for the screen URL, not just the detected one
generateContext lets options.app.bundleId override whatever the native
modules report, but the screen URL read getDeviceInfo() directly — so an
explicitly configured bundle id was ignored and every screen URL silently
fell back to the authority-less form.
Caught by running the example app: it configures
app.bundleId = "com.formo.analytics.demo" and got "app:///Wallet". On React
Native Web that is the only way to get a bundle id at all, since neither
react-native-device-info nor expo-application resolves one there.
Extracted resolveAppBundleId() so the URL and context.app_bundle_id cannot
disagree, and added tests for both precedence orders.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 1d205b0 commit fb2c71d
3 files changed
Lines changed: 183 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
246 | | - | |
| 248 | + | |
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 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 | + | |
12 | 52 | | |
13 | 53 | | |
14 | 54 | | |
15 | | - | |
| 55 | + | |
16 | 56 | | |
17 | 57 | | |
18 | | - | |
| 58 | + | |
19 | 59 | | |
20 | 60 | | |
21 | 61 | | |
22 | | - | |
| 62 | + | |
23 | 63 | | |
24 | 64 | | |
25 | | - | |
| 65 | + | |
26 | 66 | | |
27 | 67 | | |
28 | | - | |
29 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
30 | 72 | | |
31 | | - | |
32 | | - | |
| 73 | + | |
| 74 | + | |
33 | 75 | | |
34 | 76 | | |
35 | 77 | | |
| |||
39 | 81 | | |
40 | 82 | | |
41 | 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 | + | |
42 | 128 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
131 | 163 | | |
132 | 164 | | |
133 | 165 | | |
| |||
165 | 197 | | |
166 | 198 | | |
167 | 199 | | |
| 200 | + | |
| 201 | + | |
168 | 202 | | |
169 | 203 | | |
170 | 204 | | |
| |||
288 | 322 | | |
289 | 323 | | |
290 | 324 | | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
| 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 | + | |
304 | 351 | | |
305 | 352 | | |
306 | 353 | | |
| |||
509 | 556 | | |
510 | 557 | | |
511 | 558 | | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
517 | 577 | | |
518 | 578 | | |
519 | 579 | | |
520 | | - | |
| 580 | + | |
521 | 581 | | |
522 | 582 | | |
523 | 583 | | |
| |||
0 commit comments