@dasasian/firebase-structured-logger 1.2.0 → 1.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +173 -33
  2. package/dist/client/breadcrumbs.d.ts +39 -6
  3. package/dist/client/breadcrumbs.d.ts.map +1 -1
  4. package/dist/client/breadcrumbs.js +98 -10
  5. package/dist/client/breadcrumbs.js.map +1 -1
  6. package/dist/client/logger.d.ts.map +1 -1
  7. package/dist/client/logger.js +4 -7
  8. package/dist/client/logger.js.map +1 -1
  9. package/dist/client/navigation/adapterShared.d.ts +18 -0
  10. package/dist/client/navigation/adapterShared.d.ts.map +1 -0
  11. package/dist/client/navigation/adapterShared.js +49 -0
  12. package/dist/client/navigation/adapterShared.js.map +1 -0
  13. package/dist/client/navigation/react-router.d.ts +30 -0
  14. package/dist/client/navigation/react-router.d.ts.map +1 -0
  15. package/dist/client/navigation/react-router.js +57 -0
  16. package/dist/client/navigation/react-router.js.map +1 -0
  17. package/dist/client/navigation/vue-router.d.ts +28 -0
  18. package/dist/client/navigation/vue-router.d.ts.map +1 -0
  19. package/dist/client/navigation/vue-router.js +47 -0
  20. package/dist/client/navigation/vue-router.js.map +1 -0
  21. package/dist/client/navigation.d.ts +29 -4
  22. package/dist/client/navigation.d.ts.map +1 -1
  23. package/dist/client/navigation.js +60 -4
  24. package/dist/client/navigation.js.map +1 -1
  25. package/dist/client/views.d.ts +3 -0
  26. package/dist/client/views.d.ts.map +1 -0
  27. package/dist/client/views.js +30 -0
  28. package/dist/client/views.js.map +1 -0
  29. package/dist/shared/types.d.ts +16 -9
  30. package/dist/shared/types.d.ts.map +1 -1
  31. package/package.json +30 -3
  32. package/skills/logs/SKILL.md +21 -13
  33. package/skills/query-logs/SKILL.md +1 -1
package/README.md CHANGED
@@ -513,7 +513,7 @@ logger.error(err, { orderId })
513
513
  |---|---|---|
514
514
  | `appId`, `releaseId` | client | your `initLogger` config |
515
515
  | `screen` | client | tracked as the user moves |
516
- | `route`, `path`, `routeSource` | client | with `enableNavigation()` — the route pattern, the real path, and where the pattern came from |
516
+ | `route`, `path` | client | with navigation on — the route pattern and the real path (`routeSource` too, deprecated) |
517
517
  | `userId` | client | `setUser`, held for the session |
518
518
  | `platform` | client | user agent — `ios` / `android` / `macos` / `web` |
519
519
  | `browser` | client | user agent |
@@ -578,9 +578,10 @@ export const logger = initLogger<MyAppLabels>({ /* … */ })
578
578
 
579
579
  logger.setUser(uid, { organizationId }) // on sign in — rides every log until cleared
580
580
  logger.clearUser() // on sign out
581
- logger.setScreen('checkout') // on navigation
582
581
  ```
583
582
 
583
+ The screen comes from navigation — see "Navigation, automatically".
584
+
584
585
  **Backend** — scoped to the request:
585
586
 
586
587
  ```ts
@@ -604,10 +605,9 @@ from [setup](#logging-from-your-cloud-functions) is the same thing without that.
604
605
  ```ts
605
606
  import { bc } from '@dasasian/firebase-structured-logger/client'
606
607
 
607
- bc.nav('Checkout') // also sets labels.screen
608
608
  bc.action('apply_discount', { code: 'SAVE10' })
609
609
  bc.state('total_recalculated', { total: 42.00 })
610
- bc.error('ValidationError', { field: 'price' })
610
+ bc.handledError('draft_save_failed', { attempt: 1 }) // an error you handled and did not log
611
611
  ```
612
612
 
613
613
  A stack trace tells you where the code broke. It cannot tell you what the person did to
@@ -615,66 +615,188 @@ get there, which is usually the part you need to reproduce it. Breadcrumbs are t
615
615
  a rolling record of the last steps, attached automatically to every error and every piece
616
616
  of feedback, with no correlation work on your side.
617
617
 
618
- Drop a `bc.action` before anything that can fail and a `bc.nav` on every screen change, and
619
- `total is wrong` arrives as `navigate_Checkout · apply_discount · total_recalculated ·
620
- tap_place_order`.
618
+ Turn on navigation, drop a `bc.action` before anything that can fail, and `total is wrong`
619
+ arrives as `Checkout · apply_discount · total_recalculated · tap_place_order`.
621
620
 
622
621
  The trail is capped at **50 entries** and **5 minutes** — old enough to cover the steps that
623
622
  led here, short enough that it stays the current attempt rather than the whole session, and
624
623
  bounded so a long-lived tab cannot grow it without limit. It lives in memory only, so it
625
624
  never touches storage and never leaves the device except attached to a log you send.
626
625
 
627
- Breadcrumbs are session-global by design: one user, one path. `bc.nav()` also sets the
628
- current screen, so `labels.screen` stays correct without a second call.
626
+ Breadcrumbs are session-global by design: one user, one path.
627
+
628
+ **Errors and breadcrumbs.** An error you log is already in the logs, in time order with
629
+ everything else the user did — it needs no breadcrumb too. `bc.handledError` is for the
630
+ other kind: an error your code handled and chose not to log, like a save that failed and
631
+ then worked on retry. It costs nothing unless something else goes wrong, and then the
632
+ trail shows it as a clue. (`bc.error`, its old name, warns once and is removed in 2.0.)
629
633
 
630
634
  > Record the step, not the data. Breadcrumb `data` is written to your logs verbatim — keep
631
635
  > PII, tokens and card numbers out of it, the same as you would for any label.
632
636
 
633
637
  ### Navigation, automatically
634
638
 
639
+ Where the user is has one way in for each kind of place:
640
+
641
+ | What changed | Record it with | Gives |
642
+ |---|---|---|
643
+ | a page, and the URL changed | `enableNavigation()`, or a router adapter — automatic | one `nav` breadcrumb; `screen`, `route` and `path` labels |
644
+ | a page, but the URL did not | `navigatedTo('Checkout')` | the same breadcrumb and labels |
645
+ | something inside or on top of a page | `enableViews()` and markup, `data-fsl-view` | a `view` label |
646
+
635
647
  ```ts
636
- import { enableNavigation } from '@dasasian/firebase-structured-logger/client/navigation'
648
+ import { enableNavigation, navigatedTo, defaultLabelsFor } from '@dasasian/firebase-structured-logger/client/navigation'
637
649
 
638
650
  enableNavigation()
639
-
640
- // or name routes the way your router does
641
- enableNavigation({
642
- routeFor: (path) => router.match(path)?.name, // undefined falls back to the id rule
643
- })
644
651
  ```
645
652
 
646
653
  Its own entry point, so an app that never imports it ships none of it, whatever its
647
654
  bundler — and the import says plainly that it wraps `history.pushState` and
648
655
  `replaceState`, the only way to notice a single-page app changing route. Call it once,
649
- before or after `initLogger`. It records the current page at once and every route change
650
- after it, back and forward included, as a `nav` breadcrumb, and every entry carries three
651
- labels:
656
+ before or after `initLogger`. It records the current page at once and every page change
657
+ after it, back and forward included, and every entry carries:
652
658
 
653
659
  | Label | Example | Means |
654
660
  |---|---|---|
655
661
  | `route` | `/orders/:id/items` | the pattern — for grouping and counting |
656
662
  | `path` | `/orders/1042/items` | the real path — for "what went wrong for order 1042?" |
657
- | `routeSource` | `router` or `pattern` | whether `route` came from your `routeFor`, or from the id rule |
663
+ | `screen` | `OrderItems`, or the route when there is no name | the page's name |
664
+ | `routeSource` | `pattern` | **deprecated, removed in 2.0** — set only by the default labels |
665
+
666
+ **The default — the id rule.** A path segment that is all digits, a UUID, a long hex
667
+ string or a ULID becomes `:id`; anything else is kept as written, so a slug like
668
+ `/blog/my-post` stays as it is. `screen` is the route.
658
669
 
659
- `screen` keeps its meaning — the name you give with `bc.nav` or `setScreen` — and falls
660
- back to `route` when you never set one, so an app that does nothing still gets a useful
661
- screen.
670
+ **Your own labels — `labelsFor`.** One function: it gets the real path and returns the
671
+ labels for it. Whatever it returns is used exactly as returned, and a field it leaves out
672
+ is not logged.
662
673
 
663
- **The id rule**, when there is no `routeFor` or it returns `undefined`: a path segment that
664
- is all digits, a UUID, a long hex string or a ULID becomes `:id`. Anything else is kept as
665
- written, so a slug like `/blog/my-post` stays as it is — no rule tells a slug from a page
666
- name reliably, which is what `routeFor` is for.
674
+ ```ts
675
+ enableNavigation({
676
+ labelsFor: (path) => ({ ...defaultLabelsFor(path), screen: path.startsWith('/admin') ? 'Admin' : undefined }),
677
+ })
678
+ ```
679
+
680
+ It must be synchronous — it runs inside your router's own `pushState` — and if it throws,
681
+ that page gets `defaultLabelsFor(path)` and the console says so once.
682
+
683
+ **With React Router or Vue Router — an adapter.** Your router already knows each page's
684
+ pattern and name, so the adapter asks it instead of guessing from the path. It listens to
685
+ the router's own events and does not wrap `history`; `labelsFor` does not apply to it.
686
+
687
+ ```ts
688
+ // Vue Router 4
689
+ import { enableVueRouterNavigation } from '@dasasian/firebase-structured-logger/client/navigation/vue-router'
690
+ enableVueRouterNavigation(router)
691
+
692
+ // React Router 6.4+ or 7, data router (createBrowserRouter and friends)
693
+ import { enableReactRouterNavigation } from '@dasasian/firebase-structured-logger/client/navigation/react-router'
694
+ enableReactRouterNavigation(router)
695
+ ```
696
+
697
+ | Label | Vue Router | React Router |
698
+ |---|---|---|
699
+ | `route` | the full pattern of the deepest match, `/orders/:id/items` | the same, joined from each match's `path`, without the `basename` |
700
+ | `screen` | the `name` of the deepest matched route that has one | `handle.screen` of the deepest match that has one |
701
+ | `path` | `to.path` — never the query or hash | `location.pathname` |
702
+
703
+ No name anywhere in the match → `screen` is the route. Vue names that are symbols are
704
+ skipped. One page change is one breadcrumb: a React Router redirect records only the page
705
+ it ends on, and a Vue navigation that was blocked or cancelled records nothing.
706
+
707
+ One option, `adjust`, takes the router's labels and returns the ones to log — for
708
+ cleaning personal data out of a path:
709
+
710
+ ```ts
711
+ enableVueRouterNavigation(router, {
712
+ adjust: (labels) => ({ ...labels, path: labels.path?.replace(/[^/]+@[^/]+/g, ':email') }),
713
+ })
714
+ ```
715
+
716
+ Each adapter returns a function that stops it. Calling an adapter again stops the first
717
+ one. If you call both an adapter and `enableNavigation()`, the adapter wins and the
718
+ console says so once. Neither router is a dependency of this package: the adapter only
719
+ reads the router you pass in.
720
+
721
+ **Without URL routing** — screens that switch without the address changing — call
722
+ `navigatedTo(screen, { route?, path? })` on each change. It records the same breadcrumb and
723
+ labels as automatic navigation.
724
+
725
+ **One breadcrumb per page change**, structured so it reads without parsing:
726
+
727
+ ```
728
+ { type: "nav", name: "OrderItems", data: { route: "/orders/:id/items", path: "/orders/1042/items" } }
729
+ ```
730
+
731
+ `name` is the screen, else the route, else the path; `data.path` is absent when your
732
+ `labelsFor` leaves `path` out.
667
733
 
668
734
  **What never leaves the browser:** the query string, always — it is where tokens and
669
735
  emails usually ride. The fragment too, unless it is a route: `#/orders/1042` is read as the
670
- path, `#section-3` or `#access_token=…` is dropped. If your paths themselves can hold
671
- personal data (`/users/jane@example.com`), clean them or switch `path` off:
736
+ path, `#section-3` or `#access_token=…` is dropped. `labelsFor` receives the path already
737
+ stripped. If your paths themselves can hold personal data, clean them there:
672
738
 
673
739
  ```ts
674
- enableNavigation({ cleanPath: (path) => path.replace(/[^/]+@[^/]+/g, ':email') })
675
- enableNavigation({ path: false })
740
+ enableNavigation({
741
+ labelsFor: (path) => {
742
+ const labels = defaultLabelsFor(path)
743
+ return { ...labels, path: labels.path?.replace(/[^/]+@[^/]+/g, ':email') }
744
+ },
745
+ })
676
746
  ```
677
747
 
748
+ **With navigation on, `bc.nav` and `setScreen` are ignored** — they would record the same
749
+ page change twice — and the console says so once.
750
+
751
+ **Deprecated in 1.3, removed in 2.0:** `routeFor`, `cleanPath` and `path: false` (each
752
+ warns once; use `labelsFor`), the `routeSource` label, and `bc.nav` / `setScreen` (use
753
+ `enableNavigation`, or `navigatedTo` without URL routing).
754
+
755
+ ### Views: what was on screen
756
+
757
+ A page is navigation. A tab, a checkout step or a dialog inside it is a view. Mark the
758
+ ones that matter in your markup, and turn views on once at startup:
759
+
760
+ ```ts
761
+ import { enableViews } from '@dasasian/firebase-structured-logger/client/views'
762
+
763
+ enableViews()
764
+ ```
765
+
766
+ ```html
767
+ <section data-fsl-view="payment">…</section>
768
+ <div class="modal" data-fsl-view="Attachment">…</div>
769
+ ```
770
+
771
+ An entry written while both are visible carries `view: "payment › Attachment"`. With
772
+ nothing marked visible, there is no `view` label.
773
+
774
+ - **Read when the entry is written.** The logger finds the visible marks at that moment,
775
+ in page order, and joins their names with ` › `. There are no open or close calls to
776
+ make and nothing to keep in sync: a closed dialog is simply not visible any more.
777
+ - **Visible means what the browser says:** `checkVisibility()`, counting
778
+ `display: none`, `visibility: hidden` and `opacity: 0` on the mark or any parent.
779
+ Browsers without it (Safari before 17.4) count only `display: none`.
780
+ - **Page order.** A modal rendered at the end of `<body>` (a React portal, a Vue
781
+ `<Teleport>`) comes after the page, so it reads `payment › Attachment`. If an order
782
+ reads wrong, move the mark.
783
+ - **A label, never a breadcrumb.** A view is where the user is, not a step they took.
784
+ The click that opened the dialog is `bc.action`.
785
+ - **What was on screen when the entry was written,** not when the trouble started. An
786
+ error that surfaces after a request finishes carries whatever is open then.
787
+ - **Not part of the repeat count.** The same error in two dialogs on one screen is
788
+ counted as one error. Repeat summaries carry no `view`.
789
+ - **Names are fixed words, never values.** `data-fsl-view="order"`, not
790
+ `"order-1042"`. The logger never reads the page's text, so a fixed name never carries
791
+ personal data. Mark places, not items: a mark on every row of a list gives
792
+ `row › row › row …`.
793
+ - **Browser entries only.** Entries your Cloud Functions write never carry `view`; follow
794
+ the trace id to the browser entry. Browser entries sent through your log function keep
795
+ it.
796
+ - **Not inside shadow DOM** — marks inside a web component's shadow root are not found.
797
+
798
+ Calling `enableViews()` again does nothing more.
799
+
678
800
  ## Timing: when something is too slow
679
801
 
680
802
  Some failures never throw. A loading screen waits on eight pieces, one of them takes 30
@@ -1021,7 +1143,7 @@ logger.debug(message, labels?, context?, attachments?) // suppressed in producti
1021
1143
 
1022
1144
  logger.setUser(uid, extraLabels?)
1023
1145
  logger.clearUser()
1024
- logger.setScreen(screen)
1146
+ logger.setScreen(screen) // deprecated in 1.3 — use navigation
1025
1147
  logger.addBreadcrumb(type, name, data?)
1026
1148
 
1027
1149
  ```
@@ -1029,8 +1151,16 @@ logger.addBreadcrumb(type, name, data?)
1029
1151
  Optional helpers are separate entry points, so an app ships only what it imports:
1030
1152
 
1031
1153
  ```ts
1032
- import { enableNavigation } from '@dasasian/firebase-structured-logger/client/navigation'
1033
- enableNavigation({ routeFor?, cleanPath?, path? }) // see "Navigation, automatically"
1154
+ import { enableNavigation, navigatedTo, defaultLabelsFor } from '@dasasian/firebase-structured-logger/client/navigation'
1155
+ enableNavigation({ labelsFor?: (path) => ({ route?, screen?, path? }) }) // see "Navigation, automatically"
1156
+ navigatedTo(screen, { route?, path? }) // a page change with no URL change
1157
+
1158
+ import { enableVueRouterNavigation } from '@dasasian/firebase-structured-logger/client/navigation/vue-router'
1159
+ import { enableReactRouterNavigation } from '@dasasian/firebase-structured-logger/client/navigation/react-router'
1160
+ const stop = enableVueRouterNavigation(router, { adjust?: (labels) => labels }) // the same for React Router
1161
+
1162
+ import { enableViews } from '@dasasian/firebase-structured-logger/client/views'
1163
+ enableViews() // see "Views: what was on screen"
1034
1164
 
1035
1165
  import { trace, startTrace, configureTraces } from '@dasasian/firebase-structured-logger/client/timing'
1036
1166
  configureTraces({ name: { warnAfterMs?, steps?: { step: ms } } }) // see "Timing"
@@ -1053,6 +1183,16 @@ and are removed in 2.0:
1053
1183
  | `triggerTestLog()` | `sendTestLog()` |
1054
1184
  | `fsl upload-sourcemaps --functions=<dir>` | `--backend=<dir>` (it is not only for Cloud Functions) |
1055
1185
 
1186
+ **Deprecated in 1.3.** Still working in 1.x, each with a one-time console warning where
1187
+ code can warn; removed in 2.0:
1188
+
1189
+ | Old | New |
1190
+ |---|---|
1191
+ | `enableNavigation({ routeFor })`, `({ cleanPath })`, `({ path: false })` | `enableNavigation({ labelsFor })` |
1192
+ | label `routeSource` | none — `labelsFor`'s answer is final |
1193
+ | `bc.nav(screen)`, `logger.setScreen(screen)` | `enableNavigation()`, or `navigatedTo(screen)` without URL routing |
1194
+ | `bc.error(type, data?)` | `bc.handledError(type, data?)` — only for errors you handled and did not log |
1195
+
1056
1196
  `Logger` is exported as a **type only** — the client logger is a session singleton, so
1057
1197
  annotate with `Logger<MyAppLabels>` and construct with `initLogger()`. A second instance
1058
1198
  would silently share breadcrumbs, screen and the rate-limit budget while looking independent.
@@ -13,25 +13,58 @@ import type { BreadcrumbEntry, NavigationLabels } from '../shared/types';
13
13
  * would have reproduced the bug.
14
14
  */
15
15
  export declare const MAX_BREADCRUMBS = 50;
16
+ /**
17
+ * Set by `enableNavigation()` and `navigatedTo()` (`client/navigation.ts`), never by
18
+ * the core itself — the setter a helper hands data through, mirroring `setCurrentRoute`.
19
+ * Once true, the legacy `bc.nav`/`setScreen` path is ignored: one page change must give
20
+ * exactly one `nav` breadcrumb, never two for the same event.
21
+ */
22
+ export declare function setNavigationEnabled(enabled: boolean): void;
23
+ /** Called by a router adapter's own registration/`stop()` — never by the core itself. */
24
+ export declare function setAdapterActive(active: boolean): void;
25
+ export declare function isAdapterActive(): boolean;
26
+ /** Called once, by `enableNavigation()`, the first time it wraps `history`. */
27
+ export declare function noteHistoryWrapperWired(): void;
28
+ /** @deprecated Use `enableNavigation()`, or `navigatedTo()` without URL routing. */
16
29
  export declare function setCurrentScreen(screen: string): void;
17
30
  export declare function getCurrentScreen(): string | undefined;
18
31
  /**
19
- * Called by `enableNavigation()` (`client/navigation.ts`) on the current page and on
20
- * every route change after it — never by the core itself. Mirrors `setCurrentScreen`:
21
- * the one-way setter a helper hands data through, rather than the core reaching out to
22
- * the helper. Adds a `nav` breadcrumb named after the real path, or the route pattern
23
- * when `path` was omitted (`enableNavigation({ path: false })`).
32
+ * Called by `enableNavigation()` and `navigatedTo()` (`client/navigation.ts`) on every
33
+ * page change — never by the core itself. Mirrors `setNavigationEnabled`: the one-way
34
+ * setter a helper hands data through, rather than the core reaching out to the helper.
35
+ * Adds one `nav` breadcrumb named after `labels.screen`, else `labels.route`, else
36
+ * `labels.path`; `labels` itself is stored exactly as given, so a field left out of it
37
+ * stays absent from the entry labels built from `getCurrentRoute()`.
24
38
  */
25
39
  export declare function setCurrentRoute(labels: NavigationLabels): void;
26
- /** The current page's navigation labels, or `undefined` when `enableNavigation()` was never called. */
40
+ /** The current page's navigation labels, or `undefined` when navigation was never turned on. */
27
41
  export declare function getCurrentRoute(): NavigationLabels | undefined;
42
+ /** Set by `enableViews()`, never by the core itself. A later call replaces the reader. */
43
+ export declare function setViewReader(reader: () => string | undefined): void;
44
+ /** What was on screen right now, or `undefined` when `enableViews()` was never called. */
45
+ export declare function getActiveView(): string | undefined;
46
+ /**
47
+ * The screen to label an entry with right now — navigation's, when it has one,
48
+ * else the legacy `setScreen`/`bc.nav` value. Written once so the label and the
49
+ * repeat signature can never read two different answers to the same question.
50
+ */
51
+ export declare function getActiveScreen(): string | undefined;
28
52
  export declare function addBreadcrumb(type: BreadcrumbEntry['type'], name: string, data?: Record<string, unknown>): void;
29
53
  export declare function getLastBreadcrumbs(count: number): BreadcrumbEntry[];
30
54
  export declare function clearBreadcrumbs(): void;
55
+ /**
56
+ * One way in for each kind of breadcrumb (CLAUDE.md, "Where the user is"). `nav` and
57
+ * `error` are deprecated — `enableNavigation()`/`navigatedTo()` and `handledError`
58
+ * replace them — and each still works, warning once.
59
+ */
31
60
  export declare const bc: {
32
61
  action: (name: string, data?: Record<string, unknown>) => void;
33
62
  state: (name: string, data?: Record<string, unknown>) => void;
63
+ /** @deprecated Use `enableNavigation()`, or `navigatedTo()` without URL routing. */
34
64
  nav: (screen: string) => void;
65
+ /** @deprecated Use `bc.handledError` — only for an error your code handled and did not log. */
35
66
  error: (type: string, data?: Record<string, unknown>) => void;
67
+ /** An error your code handled and chose not to log — a clue if something else goes wrong. */
68
+ handledError: (type: string, data?: Record<string, unknown>) => void;
36
69
  };
37
70
  //# sourceMappingURL=breadcrumbs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/client/breadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAExE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,KAAK,CAAA;AAMjC,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAGrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAID;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAG9D;AAED,uGAAuG;AACvG,wBAAgB,eAAe,IAAI,gBAAgB,GAAG,SAAS,CAE9D;AAoBD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAC7B,IAAI,EAAE,MAAM,EACZ,IAA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GAAG,IAAI,CAEpE;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAEpD;AAoBD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI,CAQN;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,CAKnE;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAED;;;;GAIG;AACH,eAAO,MAAM,EAAE;mBACE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;kBACvC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpD,oFAAoF;kBACtE,MAAM;IACpB,+FAA+F;kBACjF,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIpD,6FAA6F;yBACxE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAC5D,CAAA"}
@@ -1,13 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.bc = exports.MAX_BREADCRUMBS = void 0;
4
+ exports.setNavigationEnabled = setNavigationEnabled;
5
+ exports.setAdapterActive = setAdapterActive;
6
+ exports.isAdapterActive = isAdapterActive;
7
+ exports.noteHistoryWrapperWired = noteHistoryWrapperWired;
4
8
  exports.setCurrentScreen = setCurrentScreen;
5
9
  exports.getCurrentScreen = getCurrentScreen;
6
10
  exports.setCurrentRoute = setCurrentRoute;
7
11
  exports.getCurrentRoute = getCurrentRoute;
12
+ exports.setViewReader = setViewReader;
13
+ exports.getActiveView = getActiveView;
14
+ exports.getActiveScreen = getActiveScreen;
8
15
  exports.addBreadcrumb = addBreadcrumb;
9
16
  exports.getLastBreadcrumbs = getLastBreadcrumbs;
10
17
  exports.clearBreadcrumbs = clearBreadcrumbs;
18
+ const deprecate_1 = require("../shared/deprecate");
11
19
  /**
12
20
  * How many breadcrumbs are retained — and therefore how many are sent.
13
21
  *
@@ -25,29 +33,97 @@ exports.MAX_BREADCRUMBS = 50;
25
33
  const MAX_AGE_MS = 5 * 60 * 1000; // 5 minutes
26
34
  let currentScreen;
27
35
  let breadcrumbs = [];
28
- function setCurrentScreen(screen) {
36
+ /**
37
+ * Set by `enableNavigation()` and `navigatedTo()` (`client/navigation.ts`), never by
38
+ * the core itself — the setter a helper hands data through, mirroring `setCurrentRoute`.
39
+ * Once true, the legacy `bc.nav`/`setScreen` path is ignored: one page change must give
40
+ * exactly one `nav` breadcrumb, never two for the same event.
41
+ */
42
+ function setNavigationEnabled(enabled) {
43
+ navigationEnabled = enabled;
44
+ }
45
+ let navigationEnabled = false;
46
+ let adapterActive = false;
47
+ let historyWrapperWired = false;
48
+ let adapterWinsWarned = false;
49
+ function warnAdapterWins() {
50
+ if (adapterWinsWarned)
51
+ return;
52
+ adapterWinsWarned = true;
53
+ console.warn('[fsl] a router adapter and enableNavigation() are both active — the adapter wins, and the history wrapper stops recording.');
54
+ }
55
+ /** Called by a router adapter's own registration/`stop()` — never by the core itself. */
56
+ function setAdapterActive(active) {
57
+ if (active && historyWrapperWired)
58
+ warnAdapterWins();
59
+ adapterActive = active;
60
+ }
61
+ function isAdapterActive() {
62
+ return adapterActive;
63
+ }
64
+ /** Called once, by `enableNavigation()`, the first time it wraps `history`. */
65
+ function noteHistoryWrapperWired() {
66
+ if (adapterActive)
67
+ warnAdapterWins();
68
+ historyWrapperWired = true;
69
+ }
70
+ function recordScreenChange(screen) {
71
+ if (navigationEnabled)
72
+ return;
29
73
  currentScreen = screen;
30
74
  addBreadcrumb('nav', `navigate_${screen}`);
31
75
  }
76
+ /** @deprecated Use `enableNavigation()`, or `navigatedTo()` without URL routing. */
77
+ function setCurrentScreen(screen) {
78
+ (0, deprecate_1.warnDeprecated)('setScreen', 'enableNavigation(), or navigatedTo() without URL routing');
79
+ recordScreenChange(screen);
80
+ }
81
+ function legacyNav(screen) {
82
+ (0, deprecate_1.warnDeprecated)('bc.nav', 'enableNavigation(), or navigatedTo() without URL routing');
83
+ recordScreenChange(screen);
84
+ }
32
85
  function getCurrentScreen() {
33
86
  return currentScreen;
34
87
  }
35
88
  let currentRoute;
36
89
  /**
37
- * Called by `enableNavigation()` (`client/navigation.ts`) on the current page and on
38
- * every route change after it — never by the core itself. Mirrors `setCurrentScreen`:
39
- * the one-way setter a helper hands data through, rather than the core reaching out to
40
- * the helper. Adds a `nav` breadcrumb named after the real path, or the route pattern
41
- * when `path` was omitted (`enableNavigation({ path: false })`).
90
+ * Called by `enableNavigation()` and `navigatedTo()` (`client/navigation.ts`) on every
91
+ * page change — never by the core itself. Mirrors `setNavigationEnabled`: the one-way
92
+ * setter a helper hands data through, rather than the core reaching out to the helper.
93
+ * Adds one `nav` breadcrumb named after `labels.screen`, else `labels.route`, else
94
+ * `labels.path`; `labels` itself is stored exactly as given, so a field left out of it
95
+ * stays absent from the entry labels built from `getCurrentRoute()`.
42
96
  */
43
97
  function setCurrentRoute(labels) {
44
98
  currentRoute = labels;
45
- addBreadcrumb('nav', labels.path ?? labels.route, labels.path !== undefined ? { route: labels.route } : undefined);
99
+ const data = {};
100
+ if (labels.route !== undefined)
101
+ data.route = labels.route;
102
+ if (labels.path !== undefined)
103
+ data.path = labels.path;
104
+ addBreadcrumb('nav', labels.screen ?? labels.route ?? labels.path ?? '', Object.keys(data).length > 0 ? data : undefined);
46
105
  }
47
- /** The current page's navigation labels, or `undefined` when `enableNavigation()` was never called. */
106
+ /** The current page's navigation labels, or `undefined` when navigation was never turned on. */
48
107
  function getCurrentRoute() {
49
108
  return currentRoute;
50
109
  }
110
+ let viewReader;
111
+ /** Set by `enableViews()`, never by the core itself. A later call replaces the reader. */
112
+ function setViewReader(reader) {
113
+ viewReader = reader;
114
+ }
115
+ /** What was on screen right now, or `undefined` when `enableViews()` was never called. */
116
+ function getActiveView() {
117
+ return viewReader?.();
118
+ }
119
+ /**
120
+ * The screen to label an entry with right now — navigation's, when it has one,
121
+ * else the legacy `setScreen`/`bc.nav` value. Written once so the label and the
122
+ * repeat signature can never read two different answers to the same question.
123
+ */
124
+ function getActiveScreen() {
125
+ return currentRoute?.screen ?? currentScreen;
126
+ }
51
127
  /**
52
128
  * Drop anything past the age cutoff.
53
129
  *
@@ -84,10 +160,22 @@ function clearBreadcrumbs() {
84
160
  breadcrumbs = [];
85
161
  currentScreen = undefined;
86
162
  }
163
+ /**
164
+ * One way in for each kind of breadcrumb (CLAUDE.md, "Where the user is"). `nav` and
165
+ * `error` are deprecated — `enableNavigation()`/`navigatedTo()` and `handledError`
166
+ * replace them — and each still works, warning once.
167
+ */
87
168
  exports.bc = {
88
169
  action: (name, data) => addBreadcrumb('action', name, data),
89
170
  state: (name, data) => addBreadcrumb('state', name, data),
90
- nav: (screen) => setCurrentScreen(screen),
91
- error: (type, data) => addBreadcrumb('error', type, data),
171
+ /** @deprecated Use `enableNavigation()`, or `navigatedTo()` without URL routing. */
172
+ nav: (screen) => legacyNav(screen),
173
+ /** @deprecated Use `bc.handledError` — only for an error your code handled and did not log. */
174
+ error: (type, data) => {
175
+ (0, deprecate_1.warnDeprecated)('bc.error', 'bc.handledError');
176
+ addBreadcrumb('error', type, data);
177
+ },
178
+ /** An error your code handled and chose not to log — a clue if something else goes wrong. */
179
+ handledError: (type, data) => addBreadcrumb('error', type, data),
92
180
  };
93
181
  //# sourceMappingURL=breadcrumbs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../src/client/breadcrumbs.ts"],"names":[],"mappings":";;;AAqBA,4CAGC;AAED,4CAEC;AAWD,0CAGC;AAGD,0CAEC;AAoBD,sCAYC;AAED,gDAKC;AAED,4CAGC;AAzFD;;;;;;;;;;;;GAYG;AACU,QAAA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,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;IAEtD,iFAAiF;IACjF,oBAAoB,IAAI,IAAI;IAQ5B;;;;;;;;;;;OAWG;YACW,iBAAiB;CAiChC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACzF,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,IAAI,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAWlC;AAED,uCAAuC;AACvC,wBAAgB,cAAc,IAAI,IAAI,CAGrC;AAKD,wBAAgB,UAAU,CACxB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACzF,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAYxD;AAED,wBAAgB,eAAe,CAC7B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KACtF,MAAM,CAAC,SAAS,CAAC,CAGrB"}
@@ -105,7 +105,7 @@ class Logger {
105
105
  errorType: error.name || 'UnknownError',
106
106
  ...labels,
107
107
  };
108
- void this.send(error.message, 'ERROR', errorLabels, context, attachments, (0, error_1.toErrorPayload)(error), (0, rateLimiter_1.signatureFor)(error, (0, breadcrumbs_1.getCurrentScreen)()));
108
+ void this.send(error.message, 'ERROR', errorLabels, context, attachments, (0, error_1.toErrorPayload)(error), (0, rateLimiter_1.signatureFor)(error, (0, breadcrumbs_1.getActiveScreen)()));
109
109
  }
110
110
  info(message, labels, context, attachments) {
111
111
  void this.send(message, 'INFO', labels, context, attachments);
@@ -146,16 +146,12 @@ class Logger {
146
146
  skipBudget = false, timestamp) {
147
147
  if (!bypassVolumeControls && severity_1.SEVERITY_ORDER[severity] > this.minLevel)
148
148
  return false;
149
- // Set only by enableNavigation() (@dasasian/firebase-structured-logger/client/navigation),
150
- // through the setter it calls in breadcrumbs.ts — undefined for an app that never
151
- // imports that entry point.
152
149
  const nav = (0, breadcrumbs_1.getCurrentRoute)();
153
150
  const allLabels = {
154
151
  appId: this.config.appId,
155
152
  releaseId: this.config.releaseId,
156
- // Falls back to the route pattern so an app that never calls setScreen/bc.nav
157
- // still gets a useful screen label once navigation is enabled.
158
- screen: (0, breadcrumbs_1.getCurrentScreen)() ?? nav?.route,
153
+ screen: (0, breadcrumbs_1.getActiveScreen)(),
154
+ view: (0, breadcrumbs_1.getActiveView)(),
159
155
  route: nav?.route,
160
156
  path: nav?.path,
161
157
  routeSource: nav?.routeSource,
@@ -274,6 +270,7 @@ class Logger {
274
270
  releaseId: summary.releaseId ?? this.config.releaseId,
275
271
  userId: summary.userId,
276
272
  screen: summary.screen,
273
+ view: undefined,
277
274
  errorType: summary.errorType,
278
275
  repeatOf: summary.repeatOf,
279
276
  repeatCount: String(summary.repeatCount),