@dasasian/firebase-structured-logger 1.1.0 → 1.3.0-rc.0

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 (45) hide show
  1. package/README.md +202 -33
  2. package/dist/client/breadcrumbs.d.ts +35 -6
  3. package/dist/client/breadcrumbs.d.ts.map +1 -1
  4. package/dist/client/breadcrumbs.js +87 -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 +2 -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/timing.d.ts +20 -0
  26. package/dist/client/timing.d.ts.map +1 -0
  27. package/dist/client/timing.js +133 -0
  28. package/dist/client/timing.js.map +1 -0
  29. package/dist/functions/index.d.ts +2 -0
  30. package/dist/functions/index.d.ts.map +1 -1
  31. package/dist/functions/index.js +5 -1
  32. package/dist/functions/index.js.map +1 -1
  33. package/dist/functions/trace.d.ts +13 -0
  34. package/dist/functions/trace.d.ts.map +1 -0
  35. package/dist/functions/trace.js +68 -0
  36. package/dist/functions/trace.js.map +1 -0
  37. package/dist/shared/trace.d.ts +59 -0
  38. package/dist/shared/trace.d.ts.map +1 -0
  39. package/dist/shared/trace.js +131 -0
  40. package/dist/shared/trace.js.map +1 -0
  41. package/dist/shared/types.d.ts +14 -9
  42. package/dist/shared/types.d.ts.map +1 -1
  43. package/package.json +31 -4
  44. package/skills/logs/SKILL.md +20 -13
  45. package/skills/query-logs/SKILL.md +5 -1
@@ -58,23 +58,22 @@ Using the Explore agent's output, check the target file against the rules below.
58
58
  Breadcrumbs reconstruct what the user was doing before an error — a session timeline, not just a wrapper around service calls. They belong primarily in components and screens, not service files.
59
59
 
60
60
  UX-layer breadcrumbs to check for (flag if missing):
61
- - Screen/route changes → `bc.nav('ScreenName')`
62
- - Modal open/close → `bc.action('open_item_modal', { itemId })`
63
- - Tab switches → `bc.action('switch_tab', { tab })`
61
+ - Page changes → `enableNavigation()` once at startup (or `navigatedTo('ScreenName')` when the URL does not change). Flag hand-written `bc.nav` / `setScreen` — deprecated, and ignored once navigation is on
62
+ - Opening a modal or switching a tab → `bc.action('open_item_modal', { itemId })`, `bc.action('switch_tab', { tab })` — the step the user took
64
63
  - Explicit user decisions → `bc.action('merge_chosen')`, `bc.action('discard_changes')`
65
64
  - Scan/camera events → `bc.action('barcode_scanned', { barcode })`
66
65
 
67
66
  Service-layer breadcrumbs (secondary — useful but not sufficient on their own):
68
67
  - Before a Firestore/API call → `bc.action('save_item', { itemId })`
69
- - On error → `bc.error('save_failed', { itemId })`
68
+ - An error the code handled and did not log (a retry that worked) → `bc.handledError('save_failed', { itemId })`. An error that is logged needs no breadcrumb — flag `bc.handledError` next to a `logger.error` for the same failure as redundant
70
69
 
71
70
  **A component file with no UX-layer breadcrumbs is almost certainly missing them. A service file with only service-layer breadcrumbs may be fine.**
72
71
 
73
72
  API:
74
73
  - `bc.action(name: string, data?)` — user-initiated operations and decisions
75
74
  - `bc.state(name: string, data?)` — significant state changes
76
- - `bc.nav(screen: string)` — screen/route changes
77
- - `bc.error(type: string, data?)` — when an error occurs
75
+ - `bc.handledError(type: string, data?)` — an error handled and not logged (`bc.error` is its deprecated old name)
76
+ - Page changes are not a `bc.*` call — see navigation below
78
77
 
79
78
  **Label completeness**
80
79
  - For each function, check which `AppLabels` fields are in scope as variables
@@ -166,18 +165,26 @@ Import `bc` from `firebase-structured-logger/client`:
166
165
  ```ts
167
166
  bc.action(name: string, data?: Record<string, unknown>): void // before operations
168
167
  bc.state(name: string, data?: Record<string, unknown>): void // on state changes
169
- bc.nav(screen: string): void // on navigation
170
- bc.error(type: string, data?: Record<string, unknown>): void // on errors
168
+ bc.handledError(type: string, data?: Record<string, unknown>): void // an error handled, not logged
171
169
  ```
170
+ `bc.nav` and `bc.error` are deprecated in 1.3 and removed in 2.0 — flag them.
172
171
 
173
172
  Import `enableNavigation` from `firebase-structured-logger/client/navigation`:
174
173
  ```ts
175
- enableNavigation(options?: { routeFor?: (path: string) => string | undefined; cleanPath?: (path: string) => string; path?: false }): void
174
+ enableNavigation(options?: { labelsFor?: (path: string) => { route?: string; screen?: string; path?: string } }): void
175
+ navigatedTo(screen: string, labels?: { route?: string; path?: string }): void
176
+ defaultLabelsFor(path: string): { route: string; screen: string; path: string }
176
177
  ```
177
- - Call once at startup. Every route change becomes a `nav` breadcrumb, and every entry
178
- gets `route` (the pattern, `/orders/:id`), `path` (the real path) and `routeSource`.
179
- - When an app has called it, do not flag a missing `bc.nav` on route changes — it is
180
- automatic. Suggest it for a single-page app that hand-writes `bc.nav` everywhere.
178
+ - Call `enableNavigation` once at startup. Every page change becomes one `nav` breadcrumb, and
179
+ every entry gets `route` (the pattern, `/orders/:id`), `path` (the real path) and `screen`.
180
+ - `labelsFor` names routes the app's own way; it must be synchronous. Flag the deprecated
181
+ `routeFor`, `cleanPath` and `path: false` options — `labelsFor` replaces all three.
182
+ - Suggest `navigatedTo` only for apps whose screens change without the URL changing.
183
+ - An app on Vue Router 4 or a React Router data router (6.4+, 7) should use the adapter
184
+ instead: `enableVueRouterNavigation(router)` from `/client/navigation/vue-router`, or
185
+ `enableReactRouterNavigation(router)` from `/client/navigation/react-router`. It takes
186
+ names from the router (Vue route `name`, React `handle.screen`). Flag a `labelsFor` that
187
+ re-lists the app's routes by hand in such an app.
181
188
  - A separate import on purpose: apps that do not use it ship none of it.
182
189
 
183
190
  Import `sendFeedback` from `firebase-structured-logger/client`:
@@ -33,7 +33,11 @@ All entries written by firebase-structured-logger include these labels:
33
33
  | `screen` | Current screen name (falls back to `route` when the app never set one) |
34
34
  | `route` | Route pattern, e.g. `/orders/:id/items` — group by this (apps using `enableNavigation`) |
35
35
  | `path` | Real path, e.g. `/orders/1042/items` — one specific page or record; query string never stored |
36
- | `routeSource` | `router` (the app named the route) or `pattern` (ids replaced by rule) |
36
+ | `routeSource` | **Deprecated, removed in 2.0.** `pattern` when the default id rule made the route |
37
+ | `trace` | On a slow-trace WARNING: the trace's name, e.g. `app_boot` |
38
+ | `run` | On a slow-trace WARNING: tells overlapping runs of one trace apart |
39
+ | `slow` | `trace` (the whole run passed its limit) or `step` (one step passed its own) |
40
+ | `step` | When `slow="step"`: the step that was late. `jsonPayload.timing` has every step's ms and what was still waiting |
37
41
  | `releaseId` | Git short hash or explicit release ID |
38
42
  | `platform` | `ios`, `android`, `macos`, `windows`, `web` |
39
43
  | `browser` | `chrome`, `firefox`, `safari`, `edge` |