@wildo-ai/saas-frontend-lib 1.1.13 → 1.1.14

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 (101) hide show
  1. package/dist/esm/components/data-display/DisplayValueDispatcher.d.ts.map +1 -1
  2. package/dist/esm/components/data-display/DisplayValueDispatcher.js +17 -1
  3. package/dist/esm/components/data-display/DisplayValueDispatcher.js.map +1 -1
  4. package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.d.ts.map +1 -1
  5. package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js +5 -2
  6. package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js.map +1 -1
  7. package/dist/esm/components/form/automated/ResourceAutomatedForm.d.ts.map +1 -1
  8. package/dist/esm/components/form/automated/ResourceAutomatedForm.js +20 -1
  9. package/dist/esm/components/form/automated/ResourceAutomatedForm.js.map +1 -1
  10. package/dist/esm/components/form/chromes/FormFieldChrome.js +1 -1
  11. package/dist/esm/components/form/chromes/FormFieldChrome.js.map +1 -1
  12. package/dist/esm/components/form/chromes/field-control-aria.d.ts +8 -1
  13. package/dist/esm/components/form/chromes/field-control-aria.d.ts.map +1 -1
  14. package/dist/esm/components/form/chromes/field-control-aria.js +19 -2
  15. package/dist/esm/components/form/chromes/field-control-aria.js.map +1 -1
  16. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts +5 -0
  17. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts.map +1 -1
  18. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js +6 -2
  19. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js.map +1 -1
  20. package/dist/esm/components/resources/ResourceCollectionBody_Table.d.ts.map +1 -1
  21. package/dist/esm/components/resources/ResourceCollectionBody_Table.js +8 -1
  22. package/dist/esm/components/resources/ResourceCollectionBody_Table.js.map +1 -1
  23. package/dist/esm/components/resources/ResourceLayout_DangerZone.d.ts.map +1 -1
  24. package/dist/esm/components/resources/ResourceLayout_DangerZone.js +2 -2
  25. package/dist/esm/components/resources/ResourceLayout_DangerZone.js.map +1 -1
  26. package/dist/esm/components/resources/ResourceLayout_RecordSharing.js +2 -2
  27. package/dist/esm/components/resources/ResourceLayout_RecordSharing.js.map +1 -1
  28. package/dist/esm/components/resources/ResourceListItemRenderer.d.ts.map +1 -1
  29. package/dist/esm/components/resources/ResourceListItemRenderer.js +6 -1
  30. package/dist/esm/components/resources/ResourceListItemRenderer.js.map +1 -1
  31. package/dist/esm/components/resources/skeleton/DisplayLayout.js +2 -2
  32. package/dist/esm/components/resources/skeleton/DisplayLayout.js.map +1 -1
  33. package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.d.ts.map +1 -1
  34. package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js +71 -16
  35. package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js.map +1 -1
  36. package/dist/esm/components/sections/surface.d.ts +12 -0
  37. package/dist/esm/components/sections/surface.d.ts.map +1 -1
  38. package/dist/esm/components/sections/surface.js +14 -0
  39. package/dist/esm/components/sections/surface.js.map +1 -1
  40. package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.d.ts.map +1 -1
  41. package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js +3 -2
  42. package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js.map +1 -1
  43. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts +15 -0
  44. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts.map +1 -1
  45. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js +29 -0
  46. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js.map +1 -1
  47. package/dist/esm/core/app-shell/shell-motion/use-shell-motion.d.ts.map +1 -1
  48. package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js +2 -2
  49. package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js.map +1 -1
  50. package/dist/esm/core/branding/useBrandPresentation.d.ts.map +1 -1
  51. package/dist/esm/core/branding/useBrandPresentation.js +17 -6
  52. package/dist/esm/core/branding/useBrandPresentation.js.map +1 -1
  53. package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.d.ts.map +1 -1
  54. package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js +11 -1
  55. package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js.map +1 -1
  56. package/dist/esm/core/i18n/I18nContext.d.ts.map +1 -1
  57. package/dist/esm/core/i18n/I18nContext.js +8 -2
  58. package/dist/esm/core/i18n/I18nContext.js.map +1 -1
  59. package/dist/esm/core/i18n/component-label-resolution.utils.d.ts.map +1 -1
  60. package/dist/esm/core/i18n/component-label-resolution.utils.js +6 -1
  61. package/dist/esm/core/i18n/component-label-resolution.utils.js.map +1 -1
  62. package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts +0 -15
  63. package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts.map +1 -1
  64. package/dist/esm/core/monitoring/analytics/AnalyticsContext.js +71 -6
  65. package/dist/esm/core/monitoring/analytics/AnalyticsContext.js.map +1 -1
  66. package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.d.ts.map +1 -1
  67. package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js +12 -3
  68. package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js.map +1 -1
  69. package/dist/esm/core/navigation/NavigationContext.d.ts.map +1 -1
  70. package/dist/esm/core/navigation/NavigationContext.js +60 -17
  71. package/dist/esm/core/navigation/NavigationContext.js.map +1 -1
  72. package/dist/esm/core/navigation/launcher-resolution.d.ts +29 -0
  73. package/dist/esm/core/navigation/launcher-resolution.d.ts.map +1 -1
  74. package/dist/esm/core/navigation/launcher-resolution.js +31 -0
  75. package/dist/esm/core/navigation/launcher-resolution.js.map +1 -1
  76. package/dist/esm/core/navigation/navigation-controller-internals.d.ts +48 -0
  77. package/dist/esm/core/navigation/navigation-controller-internals.d.ts.map +1 -1
  78. package/dist/esm/core/navigation/navigation-controller-internals.js +56 -3
  79. package/dist/esm/core/navigation/navigation-controller-internals.js.map +1 -1
  80. package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
  81. package/dist/esm/core/navigation/useNavigationRouterSync.js +30 -2
  82. package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
  83. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts +44 -0
  84. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts.map +1 -0
  85. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js +63 -0
  86. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js.map +1 -0
  87. package/dist/esm/core/resources/useOperationDirectExecution.d.ts.map +1 -1
  88. package/dist/esm/core/resources/useOperationDirectExecution.js +45 -6
  89. package/dist/esm/core/resources/useOperationDirectExecution.js.map +1 -1
  90. package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
  91. package/dist/esm/core/runtime/AppRouter.js +18 -1
  92. package/dist/esm/core/runtime/AppRouter.js.map +1 -1
  93. package/dist/esm/core/security/UserOrgsContext.d.ts.map +1 -1
  94. package/dist/esm/core/security/UserOrgsContext.js +61 -8
  95. package/dist/esm/core/security/UserOrgsContext.js.map +1 -1
  96. package/dist/esm/core/ui/inner-control-activation.utils.d.ts +16 -0
  97. package/dist/esm/core/ui/inner-control-activation.utils.d.ts.map +1 -0
  98. package/dist/esm/core/ui/inner-control-activation.utils.js +44 -0
  99. package/dist/esm/core/ui/inner-control-activation.utils.js.map +1 -0
  100. package/dist/tsconfig.build.tsbuildinfo +1 -1
  101. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"component-label-resolution.utils.d.ts","sourceRoot":"","sources":["../../../../src/core/i18n/component-label-resolution.utils.ts"],"names":[],"mappings":"AAAA,OAAO,K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C,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,CAQT;AAED;;;;;;;GAOG;AACH,wBAAgB,wCAAwC,CAAC,MAAM,EAAE;IAC/D,eAAe,EAAE,CACf,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,OAAO,GAAG,aAAa,EAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACtC,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,GAAG,SAAS,CAGrB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,CAAC,EAAE,CACD,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACtC,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,CAGT"}
1
+ {"version":3,"file":"component-label-resolution.utils.d.ts","sourceRoot":"","sources":["../../../../src/core/i18n/component-label-resolution.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AA2BjF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,UAAU,EAAE,CACV,aAAa,EAAE,qBAAqB,EACpC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACtC,MAAM,CAAC;IACZ,aAAa,EAAE,qBAAqB,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,M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AE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,GAAG,SAAS,CAMrB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,CAAC,EAAE,CACD,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACtC,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,CAGT"}
@@ -73,7 +73,8 @@ export function makeComponentLabelResolver(tComponent, componentType) {
73
73
  }
74
74
  export function resolveResourceHeaderLabel(params) {
75
75
  const resolved = params.tResourceHeader(params.resourceType, params.key, params.params);
76
- // On a miss `resolved` IS `resources.<type>.header.<key>` — the unresolved form. It stands.
76
+ // On a SETTLED miss `resolved` IS `resources.<type>.header.<key>` — the unresolved form. It stands. While the resource's
77
+ // bundle is still in flight it is `''` (`tResourceHeader` is a label family, #3791): say nothing yet.
77
78
  return resolved;
78
79
  }
79
80
  /**
@@ -86,6 +87,10 @@ export function resolveResourceHeaderLabel(params) {
86
87
  */
87
88
  export function resolveOptionalResourceHeaderDescription(params) {
88
89
  const resolved = params.tResourceHeader(params.resourceType, 'description', params.params);
90
+ // `tResourceHeader` answers a supplementary miss with `''` (its family contract, #3791); the key is still accepted for
91
+ // a resolver that answers with the key path, as a test double does.
92
+ if (resolved === '')
93
+ return undefined;
89
94
  return isMissingI18nValue(resolved, `resources.${params.resourceType}.header.description`) ? undefined : resolved;
90
95
  }
91
96
  export function resolveTranslationKey(params) {
@@ -1 +1 @@
1
- {"version":3,"file":"component-label-resolution.utils.js","sourceRoot":"","sources":["../../../../src/core/i18n/component-label-resolution.utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,kBAAkB,CAAC,QAAgB,EAAE,UAAkB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,CAAC,CAAC;IAC3F,OAAO,kBAAkB,CAAC,QAAQ,EAAE,aAAa,MAAM,CAAC,YAAY,qBAAqB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AACpH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAOrC;IACC,kEAAkE;IAClE,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { FrontendComponentType } from '@wildo-ai/presets-components-models';\n\n/**\n * A MISSING LABEL LOOKS MISSING — the contract of every resolver in this module (#1414).\n *\n * `tComponent` / `tResourceHeader` / `t` answer an unresolved key with the KEY PATH itself. Every\n * resolver here hands that answer on unchanged: the key is visible, greppable, obviously not a\n * label, and names exactly what somebody has to author. It is the same unresolved form\n * `unresolvedLabel` in `I18nContext.tsx` gives the rest of the runtime, and it is what\n * `.claude/rules/display-text-comes-from-i18n.md` requires.\n *\n * Until 2026-09-21 this module did the opposite: a miss became `''`, \"instead of leaking the key\n * path into the UI\". An empty string is the LEAST visible answer available. It shipped a\n * relationship tab with no text and 16px of width, found only by listing the page's `role=tab`\n * elements, and it made `resolve(...) || 'English literal'` a live idiom at a dozen sites — a\n * second, untranslatable source for words the label tree owns.\n *\n * So a resolver here never answers a MISS with `''`, and a caller never writes `|| fallback` after\n * one: a miss is a non-empty key path, so the fallback is dead. (An AUTHORED empty string still\n * comes back as authored — that is somebody's decision, not a gap.) Where ABSENCE is a legitimate\n * authored state rather than a gap, say so by calling one of the `resolveOptional…` functions\n * below — a named decision, never a falsy check on a label.\n */\nfunction isMissingI18nValue(resolved: string, missingKey: string): boolean {\n return resolved === missingKey;\n}\n\nexport function resolveComponentLabel(params: {\n tComponent: (\n componentType: FrontendComponentType,\n key: string,\n kvPairs?: Record<string, string | number>,\n ) => string;\n componentType: FrontendComponentType;\n key: string;\n params?: Record<string, string | number>;\n}): string {\n const resolved = params.tComponent(\n params.componentType,\n params.key,\n params.params,\n );\n // On a miss `resolved` IS the key path — the unresolved form. It stands.\n return resolved;\n}\n\n/**\n * The OPTIONAL form of {@link resolveComponentLabel}: `undefined` when the key has no label.\n *\n * Use it only where a missing label is a legitimate state and not a gap somebody must close:\n *\n * - SUPPLEMENTARY text — a description or a tooltip under a primary label that is itself shown.\n * This is the runtime's own convention (`tResourceFieldDisplay`, `tBillingProduct`, … in\n * `I18nContext.tsx` answer the unresolved key for a `label`/`name` and nothing for a\n * `description`), because an absent description collapses cleanly and a key path in its place\n * reads as broken copy under a heading that is fine.\n * - A key built from an APPLICATION-defined identifier no framework declaration can enumerate,\n * where the caller falls back to that identifier — a value, never invented words.\n *\n * Never use it for a primary label (a title, a button, a tab, an accessible name). A primary label\n * that is missing must look missing; hiding it is the defect #1414 records.\n */\nexport function resolveOptionalComponentLabel(\n params: Parameters<typeof resolveComponentLabel>[0],\n): string | undefined {\n const resolved = params.tComponent(params.componentType, params.key, params.params);\n return isMissingI18nValue(resolved, `components.${params.componentType}.${params.key}`) ? undefined : resolved;\n}\n\n/**\n * Curried form of {@link resolveComponentLabel}, for a component that resolves\n * SEVERAL keys or hands its resolver down to a helper. It binds the component\n * type once, so the namespace lives in one place.\n *\n * Like every resolver here it answers a miss with the KEY PATH. Do not write\n * `t('x') || 'Fallback'` after it: the key path is a non-empty string, so the\n * `||` never fires — and it must not, because a component-local English literal\n * is a second source for words the label tree owns. A key that should always\n * exist belongs in that component's `*.labels.ts` so the labelling pipeline\n * generates real text in every locale; until it has, the key is what shows.\n *\n * (Between 2026-08 and #1414 this returned `''` on a miss precisely so that idiom\n * would be live. That traded a visible gap for an invisible one and is retired.)\n *\n * Its cousin `t('File attached') ?? 'File attached'`, on the PLAIN `t` with the\n * English text as the key, was once called benign here because its `??` never\n * hides a miss. It is not: an English sentence used as a key is in no label tree,\n * so no locale but English can have it. The file field's last sites were moved to\n * its component labels (#1557); declare the word in a `*.labels.ts` instead.\n */\nexport function makeComponentLabelResolver(\n tComponent: (\n componentType: FrontendComponentType,\n key: string,\n kvPairs?: Record<string, string | number>,\n ) => string,\n componentType: FrontendComponentType,\n): (key: string, params?: Record<string, string | number>) => string {\n return (key, params) => resolveComponentLabel({ tComponent, componentType, key, params });\n}\n\nexport function resolveResourceHeaderLabel(params: {\n tResourceHeader: (\n resourceType: string,\n key: 'title' | 'description',\n kvPairs?: Record<string, string | number>,\n ) => string;\n resourceType: string;\n key: 'title' | 'description';\n params?: Record<string, string | number>;\n}): string {\n const resolved = params.tResourceHeader(\n params.resourceType,\n params.key,\n params.params,\n );\n // On a miss `resolved` IS `resources.<type>.header.<key>` — the unresolved form. It stands.\n return resolved;\n}\n\n/**\n * A resource header's DESCRIPTION, or `undefined` when none is authored.\n *\n * The key is typed `'description'` alone on purpose: a header TITLE is a primary label and must\n * look missing (use {@link resolveResourceHeaderLabel}); only the description is supplementary\n * text whose absence lets the header collapse cleanly. See {@link resolveOptionalComponentLabel}\n * for the convention this follows.\n */\nexport function resolveOptionalResourceHeaderDescription(params: {\n tResourceHeader: (\n resourceType: string,\n key: 'title' | 'description',\n kvPairs?: Record<string, string | number>,\n ) => string;\n resourceType: string;\n params?: Record<string, string | number>;\n}): string | undefined {\n const resolved = params.tResourceHeader(params.resourceType, 'description', params.params);\n return isMissingI18nValue(resolved, `resources.${params.resourceType}.header.description`) ? undefined : resolved;\n}\n\nexport function resolveTranslationKey(params: {\n t: (\n key: string,\n kvPairs?: Record<string, string | number>,\n ) => string;\n key: string;\n params?: Record<string, string | number>;\n}): string {\n // On a miss `t` answers the key — the unresolved form. It stands.\n return params.t(params.key, params.params);\n}\n"]}
1
+ {"version":3,"file":"component-label-resolution.utils.js","sourceRoot":"","sources":["../../../../src/core/i18n/component-label-resolution.utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,kBAAkB,CAAC,QAAgB,EAAE,UAAkB;IAC9D,OAAO,QAAQ,KAAK,UAAU,CAAC;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H;IACvH,oEAAoE;IACpE,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO,kBAAkB,CAAC,QAAQ,EAAE,aAAa,MAAM,CAAC,YAAY,qBAAqB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AACpH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAOrC;IACC,kEAAkE;IAClE,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { FrontendComponentType } from '@wildo-ai/presets-components-models';\n\n/**\n * A MISSING LABEL LOOKS MISSING — the contract of every resolver in this module (#1414).\n *\n * `tComponent` / `tResourceHeader` / `t` answer an unresolved key with the KEY PATH itself. Every\n * resolver here hands that answer on unchanged: the key is visible, greppable, obviously not a\n * label, and names exactly what somebody has to author. It is the same unresolved form\n * `unresolvedLabel` in `I18nContext.tsx` gives the rest of the runtime, and it is what\n * `.claude/rules/display-text-comes-from-i18n.md` requires.\n *\n * Until 2026-09-21 this module did the opposite: a miss became `''`, \"instead of leaking the key\n * path into the UI\". An empty string is the LEAST visible answer available. It shipped a\n * relationship tab with no text and 16px of width, found only by listing the page's `role=tab`\n * elements, and it made `resolve(...) || 'English literal'` a live idiom at a dozen sites — a\n * second, untranslatable source for words the label tree owns.\n *\n * So a resolver here never answers a MISS with `''`, and a caller never writes `|| fallback` after\n * one: a miss is a non-empty key path, so the fallback is dead. (An AUTHORED empty string still\n * comes back as authored — that is somebody's decision, not a gap.) Where ABSENCE is a legitimate\n * authored state rather than a gap, say so by calling one of the `resolveOptional…` functions\n * below — a named decision, never a falsy check on a label.\n */\nfunction isMissingI18nValue(resolved: string, missingKey: string): boolean {\n return resolved === missingKey;\n}\n\nexport function resolveComponentLabel(params: {\n tComponent: (\n componentType: FrontendComponentType,\n key: string,\n kvPairs?: Record<string, string | number>,\n ) => string;\n componentType: FrontendComponentType;\n key: string;\n params?: Record<string, string | number>;\n}): string {\n const resolved = params.tComponent(\n params.componentType,\n params.key,\n params.params,\n );\n // On a miss `resolved` IS the key path — the unresolved form. It stands.\n return resolved;\n}\n\n/**\n * The OPTIONAL form of {@link resolveComponentLabel}: `undefined` when the key has no label.\n *\n * Use it only where a missing label is a legitimate state and not a gap somebody must close:\n *\n * - SUPPLEMENTARY text — a description or a tooltip under a primary label that is itself shown.\n * This is the runtime's own convention (`tResourceFieldDisplay`, `tBillingProduct`, … in\n * `I18nContext.tsx` answer the unresolved key for a `label`/`name` and nothing for a\n * `description`), because an absent description collapses cleanly and a key path in its place\n * reads as broken copy under a heading that is fine.\n * - A key built from an APPLICATION-defined identifier no framework declaration can enumerate,\n * where the caller falls back to that identifier — a value, never invented words.\n *\n * Never use it for a primary label (a title, a button, a tab, an accessible name). A primary label\n * that is missing must look missing; hiding it is the defect #1414 records.\n */\nexport function resolveOptionalComponentLabel(\n params: Parameters<typeof resolveComponentLabel>[0],\n): string | undefined {\n const resolved = params.tComponent(params.componentType, params.key, params.params);\n return isMissingI18nValue(resolved, `components.${params.componentType}.${params.key}`) ? undefined : resolved;\n}\n\n/**\n * Curried form of {@link resolveComponentLabel}, for a component that resolves\n * SEVERAL keys or hands its resolver down to a helper. It binds the component\n * type once, so the namespace lives in one place.\n *\n * Like every resolver here it answers a miss with the KEY PATH. Do not write\n * `t('x') || 'Fallback'` after it: the key path is a non-empty string, so the\n * `||` never fires — and it must not, because a component-local English literal\n * is a second source for words the label tree owns. A key that should always\n * exist belongs in that component's `*.labels.ts` so the labelling pipeline\n * generates real text in every locale; until it has, the key is what shows.\n *\n * (Between 2026-08 and #1414 this returned `''` on a miss precisely so that idiom\n * would be live. That traded a visible gap for an invisible one and is retired.)\n *\n * Its cousin `t('File attached') ?? 'File attached'`, on the PLAIN `t` with the\n * English text as the key, was once called benign here because its `??` never\n * hides a miss. It is not: an English sentence used as a key is in no label tree,\n * so no locale but English can have it. The file field's last sites were moved to\n * its component labels (#1557); declare the word in a `*.labels.ts` instead.\n */\nexport function makeComponentLabelResolver(\n tComponent: (\n componentType: FrontendComponentType,\n key: string,\n kvPairs?: Record<string, string | number>,\n ) => string,\n componentType: FrontendComponentType,\n): (key: string, params?: Record<string, string | number>) => string {\n return (key, params) => resolveComponentLabel({ tComponent, componentType, key, params });\n}\n\nexport function resolveResourceHeaderLabel(params: {\n tResourceHeader: (\n resourceType: string,\n key: 'title' | 'description',\n kvPairs?: Record<string, string | number>,\n ) => string;\n resourceType: string;\n key: 'title' | 'description';\n params?: Record<string, string | number>;\n}): string {\n const resolved = params.tResourceHeader(\n params.resourceType,\n params.key,\n params.params,\n );\n // On a SETTLED miss `resolved` IS `resources.<type>.header.<key>` — the unresolved form. It stands. While the resource's\n // bundle is still in flight it is `''` (`tResourceHeader` is a label family, #3791): say nothing yet.\n return resolved;\n}\n\n/**\n * A resource header's DESCRIPTION, or `undefined` when none is authored.\n *\n * The key is typed `'description'` alone on purpose: a header TITLE is a primary label and must\n * look missing (use {@link resolveResourceHeaderLabel}); only the description is supplementary\n * text whose absence lets the header collapse cleanly. See {@link resolveOptionalComponentLabel}\n * for the convention this follows.\n */\nexport function resolveOptionalResourceHeaderDescription(params: {\n tResourceHeader: (\n resourceType: string,\n key: 'title' | 'description',\n kvPairs?: Record<string, string | number>,\n ) => string;\n resourceType: string;\n params?: Record<string, string | number>;\n}): string | undefined {\n const resolved = params.tResourceHeader(params.resourceType, 'description', params.params);\n // `tResourceHeader` answers a supplementary miss with `''` (its family contract, #3791); the key is still accepted for\n // a resolver that answers with the key path, as a test double does.\n if (resolved === '') return undefined;\n return isMissingI18nValue(resolved, `resources.${params.resourceType}.header.description`) ? undefined : resolved;\n}\n\nexport function resolveTranslationKey(params: {\n t: (\n key: string,\n kvPairs?: Record<string, string | number>,\n ) => string;\n key: string;\n params?: Record<string, string | number>;\n}): string {\n // On a miss `t` answers the key — the unresolved form. It stands.\n return params.t(params.key, params.params);\n}\n"]}
@@ -38,20 +38,5 @@ export declare const AnalyticsIdentityPublisherContext: React.Context<(identity:
38
38
  export interface AnalyticsContextProviderProps {
39
39
  children: React.ReactNode;
40
40
  }
41
- /**
42
- * Two kinds of destination, and only ONE of them is a vendor (#1704).
43
- *
44
- * - The ENGINE's own destinations (`console`, `backend_proxy`), selected by `analytics.providers`. They send
45
- * nothing to a third party (the proxy posts to the application's own backend), and they keep the gate
46
- * below: `analytics.enabled`, then `analytics.requiresConsent` / the ANALYTICS grant.
47
- * - VENDORS (PostHog, …) arrive as `FRONTEND_PRODUCT_ANALYTICS` provider modules. They are started by the
48
- * consent-based activation consumer once the person grants what they rest on, and stopped on withdrawal
49
- * or sign-out; this context only dispatches to the sinks that are running. That replaced an
50
- * `analyticsProviders` / `customProviders` door which let an application pass a vendor client here,
51
- * behind a second consent gate and outside the CSP footprint — two gates for one decision.
52
- *
53
- * `analytics.enabled` stays the master switch for both: with it off, a `FRONTEND_PRODUCT_ANALYTICS` vendor is not
54
- * even loaded (the consent-based consumer skips it), and any sink that is running receives nothing.
55
- */
56
41
  export declare const AnalyticsContextProvider: React.FC<AnalyticsContextProviderProps>;
57
42
  //# sourceMappingURL=AnalyticsContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsContext.d.ts","sourceRoot":"","sources":["../../../../../src/core/monitoring/analytics/AnalyticsContext.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAuF,MAAM,OAAO,CAAC;AAe5G,MAAM,WAAW,qBAAqB;IACpC,8CAA8C;IAC9C,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpE,wBAAwB;IACxB,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACnE,8DAA8D;IA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le management.
7
7
  */
8
8
  import { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
- import { AnalyticsEventName, BUILTIN_PROVIDER_CAPABILITY, ConsentPurpose, CoreResourceType, hasGrantedConsentPurposes, normalizeConsentPurposes, ValueMomentRole, ValueMomentScope, AnalyticsTriggerSource, ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX } from '@wildo-ai/saas-models';
9
+ import { AnalyticsEventName, BUILTIN_PROVIDER_CAPABILITY, ConsentPurpose, CoreResourceType, hasGrantedConsentPurposes, isReadShapedOperation, normalizeConsentPurposes, ValueMomentRole, ValueMomentScope, AnalyticsTriggerSource, ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX } from '@wildo-ai/saas-models';
10
10
  import { AnalyticsProviderRegistry } from './analytics-provider-registry.frontend.service.js';
11
11
  import { ApplicationContext } from '../../../core/runtime/ApplicationContext.shared.js';
12
12
  import { useEventBus } from '../../../core/events/useEventBus.js';
@@ -39,6 +39,11 @@ const SIGNED_IN_AT_PROPERTY = 'signed_in_at';
39
39
  * `analytics.enabled` stays the master switch for both: with it off, a `FRONTEND_PRODUCT_ANALYTICS` vendor is not
40
40
  * even loaded (the consent-based consumer skips it), and any sink that is running receives nothing.
41
41
  */
42
+ /**
43
+ * How long vendor calls made because of a write to the person's own preferences wait for the stored consent (#3928).
44
+ * The re-read normally answers in a fraction of a second; past this the held calls are dropped, never sent.
45
+ */
46
+ const OWN_PREFERENCES_WRITE_HOLD_MS = 10_000;
42
47
  export const AnalyticsContextProvider = ({ children, }) => {
43
48
  const appContext = useContext(ApplicationContext);
44
49
  const { on } = useEventBus();
@@ -74,6 +79,51 @@ export const AnalyticsContextProvider = ({ children, }) => {
74
79
  */
75
80
  const [accountPurposes, setAccountPurposes] = useState(null);
76
81
  const grantedPurposes = useMemo(() => accountPurposes ?? [], [accountPurposes]);
82
+ /*
83
+ * A write to the person's own preferences can change their consent, so what a vendor receives because of it is
84
+ * decided against the consent the write LEAVES, never the one the page held before it (#3928).
85
+ *
86
+ * Measured in a real browser with PostHog: a withdrawal on the Preferences page let the `resource_operation` event of
87
+ * that very write reach PostHog 3 s later. The bridge captured it on `NOTIFY_RESOURCE_SUCCESS`, while the page still
88
+ * held the grant; `UserOrgsProvider` re-reads the record on the write's `RESOURCE_OPERATION_EXECUTED` (#1973), and
89
+ * the vendor's `deactivate` ran after its SDK had queued the event (posthog-js's opt-out does not empty its send
90
+ * queue, and offers no public way to). So the write OPENS a hold: vendor calls queue while it is open, and the next
91
+ * privacy-carrying `USER_PREFERENCES_CHANGED` (the re-read's) closes it, delivering them only while ANALYTICS is
92
+ * still granted. A form emits the outcome before its success notification, so the hold is open before the bridge
93
+ * captures. A sign-out (`privacy: null`) drops them, and a re-read that never lands drops them after the bound: an
94
+ * event whose consent is unknown is not sent.
95
+ *
96
+ * Vendor sinks only: a built-in destination keeps what it buffered until it flushes, and a withdrawal already drops
97
+ * that buffer (`discardUnsent` below).
98
+ */
99
+ const vendorHoldRef = useRef(null);
100
+ const releaseVendorHold = useCallback((deliver) => {
101
+ const hold = vendorHoldRef.current;
102
+ if (hold === null)
103
+ return;
104
+ vendorHoldRef.current = null;
105
+ clearTimeout(hold.timer);
106
+ if (deliver)
107
+ hold.held.forEach((call) => call());
108
+ }, []);
109
+ /** Open the hold, or restart its bound when it is already open (a second write before the first one's answer). */
110
+ const openVendorHold = useCallback(() => {
111
+ const held = vendorHoldRef.current?.held ?? [];
112
+ if (vendorHoldRef.current)
113
+ clearTimeout(vendorHoldRef.current.timer);
114
+ vendorHoldRef.current = { held, timer: setTimeout(() => releaseVendorHold(false), OWN_PREFERENCES_WRITE_HOLD_MS) };
115
+ }, [releaseVendorHold]);
116
+ /*
117
+ * Two doors open it, because the two announcements of one write arrive in either order. A form's SECTION save announces
118
+ * the outcome (`RESOURCE_OPERATION_EXECUTED`) before its success notification; its MAIN save notifies success first,
119
+ * and the bridge captures `resource_operation` from that notification before the outcome is announced (measured in the
120
+ * browser: the hold opened by the outcome alone missed the Preferences page's Save). So an analytics event ABOUT a
121
+ * write to the person's own preferences opens the hold itself, in `track`, and the outcome opens it for whatever else
122
+ * follows the write.
123
+ */
124
+ useEffect(() => on(FrontendEvents.RESOURCE_OPERATION_EXECUTED, () => openVendorHold(), (payload) => payload.resourceType === CoreResourceType.USER_SELF_PREFERENCES
125
+ && !isReadShapedOperation(payload.operation ?? { operationIdentifier: payload.operationIdentifier })), [on, openVendorHold]);
126
+ useEffect(() => () => releaseVendorHold(false), [releaseVendorHold]);
77
127
  useEffect(() => {
78
128
  return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {
79
129
  /*
@@ -91,6 +141,7 @@ export const AnalyticsContextProvider = ({ children, }) => {
91
141
  providersRef.current.forEach(p => p.discard());
92
142
  };
93
143
  if (payload.privacy === null) {
144
+ releaseVendorHold(false);
94
145
  discardUnsent();
95
146
  setAccountPurposes([]);
96
147
  return;
@@ -100,12 +151,15 @@ export const AnalyticsContextProvider = ({ children, }) => {
100
151
  // must reach the gate below, which is why this does not test truthiness.
101
152
  if (purposes !== undefined) {
102
153
  const granted = normalizeConsentPurposes(purposes);
103
- if (!hasGrantedConsentPurposes(granted, [ConsentPurpose.ANALYTICS]))
154
+ const analyticsGranted = hasGrantedConsentPurposes(granted, [ConsentPurpose.ANALYTICS]);
155
+ // Before the gate changes: what an own-preferences write held is decided by this, the stored consent.
156
+ releaseVendorHold(analyticsGranted);
157
+ if (!analyticsGranted)
104
158
  discardUnsent();
105
159
  setAccountPurposes(granted);
106
160
  }
107
161
  });
108
- }, [on]);
162
+ }, [on, releaseVendorHold]);
109
163
  /*
110
164
  * The person `USER_LOGIN` announced, until `USER_LOGOUT` (#1977). Kept because the two arrive in the
111
165
  * wrong order for the built-in destinations: `UserOrgsProvider` announces the person once their
@@ -394,10 +448,17 @@ export const AnalyticsContextProvider = ({ children, }) => {
394
448
  const event = { name, properties, timestamp: Date.now() };
395
449
  if (isActive)
396
450
  providersRef.current.forEach(p => p.track(event));
397
- vendorSinks.forEach(sink => sink.track({ name, properties }));
451
+ // An event about a write to the person's own preferences waits for the consent that write leaves (see the hold).
452
+ if (name === AnalyticsEventName.RESOURCE_OPERATION && properties?.resourceType === CoreResourceType.USER_SELF_PREFERENCES)
453
+ openVendorHold();
454
+ const toVendors = () => vendorSinks.forEach(sink => sink.track({ name, properties }));
455
+ if (vendorHoldRef.current)
456
+ vendorHoldRef.current.held.push(toVendors);
457
+ else
458
+ toVendors();
398
459
  // Forward to bridge interceptor for CUSTOM_EVENT / FEATURE_ACCESS signal evaluation
399
460
  onTrackRef.current?.(name, properties);
400
- }, [isActive, isDispatching, vendorSinks]);
461
+ }, [isActive, isDispatching, vendorSinks, openVendorHold]);
401
462
  lifecycleTrackRef.current = track;
402
463
  // Deliver a decided sign-in to each kind of destination as that kind starts — see the block above.
403
464
  useEffect(() => {
@@ -426,7 +487,11 @@ export const AnalyticsContextProvider = ({ children, }) => {
426
487
  return;
427
488
  if (isActive)
428
489
  providersRef.current.forEach(p => p.page(path, properties));
429
- vendorSinks.forEach(sink => sink.page(path, properties));
490
+ const toVendors = () => vendorSinks.forEach(sink => sink.page(path, properties));
491
+ if (vendorHoldRef.current)
492
+ vendorHoldRef.current.held.push(toVendors);
493
+ else
494
+ toVendors();
430
495
  }, [isActive, isDispatching, vendorSinks]);
431
496
  // ─── Render ───────────────────────────────────────────────────
432
497
  const contextValue = useMemo(() => ({
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsContext.js","sourceRoot":"","sources":["../../../../../src/core/monitoring/analytics/AnalyticsContext.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,cAAc,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,eAAe,EAAE,g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ytics tracking, value moment achievement persistence,\n * consent gating, and provider lifecycle management.\n */\n\nimport React, { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { AnalyticsEventName, BUILTIN_PROVIDER_CAPABILITY, ConsentPurpose, CoreResourceType, hasGrantedConsentPurposes, normalizeConsentPurposes, ValueMomentRole, ValueMomentScope, AnalyticsTriggerSource, type AnalyticsConfig, ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX } from '@wildo-ai/saas-models';\nimport type { IAnalyticsProvider, AnalyticsEvent } from './analytics-provider.frontend.interface';\nimport { AnalyticsProviderRegistry } from './analytics-provider-registry.frontend.service';\nimport { ApplicationContext } from '~wildo-frontend-lib/core/runtime/ApplicationContext.shared';\nimport { useEventBus } from '~wildo-frontend-lib/core/events/useEventBus';\nimport { FrontendEvents, SessionEndReason, SessionEstablishment } from '~wildo-frontend-lib/core/events/events.frontend.schemas';\nimport { getManualCallsHttpClient } from '~wildo-frontend-lib/core/requests/wildo-http-client-manual-calls.frontend.service';\nimport { useResourceReachability } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport { AnalyticsEventBridge, type AnalyticsMomentProgress } from './AnalyticsEventBridge';\nimport { isFrontendProductAnalyticsSink, type FrontendProductAnalyticsSink } from '@wildo-ai/saas-models/public-runtime';\nimport { useConsentBasedProviderActivations } from '~wildo-frontend-lib/core/external-providers/ConsentBasedProviderSdks';\n\n// ─── Context Value Interface ────────────────────────────────────\n\nexport interface AnalyticsContextValue {\n /** Track a custom event (app-custom usage) */\n track: (name: string, properties?: Record<string, unknown>) => void;\n /** Track a page view */\n page: (path: string, properties?: Record<string, unknown>) => void;\n /** Whether analytics is active (enabled + consent granted) */\n isActive: boolean;\n /** Session start timestamp (for TTFV computation) */\n sessionStartTimestamp: number;\n /** Set of achieved value moment identifiers (scope-aware, persisted) */\n achievedMoments: Set<string>;\n /** Mark a value moment as achieved (persists to localStorage + backend sync) */\n markMomentAchieved: (identifier: string) => boolean | Promise<boolean>;\n /**\n * Internal: ref for track() call interception (used by AnalyticsEventBridge).\n * The bridge registers a callback on mount to evaluate CUSTOM_EVENT and\n * FEATURE_ACCESS signals when track() is called.\n * @internal\n */\n _onTrackRef: React.MutableRefObject<((name: string, properties?: Record<string, unknown>) => void) | null>;\n}\n\n// ─── Context ────────────────────────────────────────────────────\n\n// Note: useAnalytics hook is in a separate file (useAnalytics.ts) for React Fast Refresh compatibility.\nexport const AnalyticsContext = createContext<AnalyticsContextValue | null>(null);\n\n/** Identity snapshots come from the mounted AppScope owner, never a decoded token or a late event. */\nexport interface AnalyticsIdentity {\n userId: string | null;\n organizationId: string | null;\n applicationId: string | null;\n anonymousUserId: string | null;\n}\nexport const AnalyticsIdentityPublisherContext = createContext<((identity: AnalyticsIdentity) => () => void) | null>(null);\n\n// ─── Provider Registry (singleton) ──────────────────────────────\n\nconst providerRegistry = new AnalyticsProviderRegistry();\n\n/** The event property carrying when a held sign-in happened, for destinations that stamp events themselves. */\nconst SIGNED_IN_AT_PROPERTY = 'signed_in_at';\n\n/**\n * A sign-in announced before this tab knows whether the person consented to analytics (#1977): when it\n * happened, whether the person's own preferences have decided it, and which kinds of destination it\n * is still owed to.\n */\ninterface HeldSignIn {\n readonly occurredAt: number;\n readonly decided: boolean;\n readonly owedToBuiltIns: boolean;\n readonly owedToVendorSinks: boolean;\n}\n\n// ─── Provider Component ─────────────────────────────────────────\n\nexport interface AnalyticsContextProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Two kinds of destination, and only ONE of them is a vendor (#1704).\n *\n * - The ENGINE's own destinations (`console`, `backend_proxy`), selected by `analytics.providers`. They send\n * nothing to a third party (the proxy posts to the application's own backend), and they keep the gate\n * below: `analytics.enabled`, then `analytics.requiresConsent` / the ANALYTICS grant.\n * - VENDORS (PostHog, …) arrive as `FRONTEND_PRODUCT_ANALYTICS` provider modules. They are started by the\n * consent-based activation consumer once the person grants what they rest on, and stopped on withdrawal\n * or sign-out; this context only dispatches to the sinks that are running. That replaced an\n * `analyticsProviders` / `customProviders` door which let an application pass a vendor client here,\n * behind a second consent gate and outside the CSP footprint — two gates for one decision.\n *\n * `analytics.enabled` stays the master switch for both: with it off, a `FRONTEND_PRODUCT_ANALYTICS` vendor is not\n * even loaded (the consent-based consumer skips it), and any sink that is running receives nothing.\n */\nexport const AnalyticsContextProvider: React.FC<AnalyticsContextProviderProps> = ({\n children,\n}) => {\n const appContext = useContext(ApplicationContext);\n const { on } = useEventBus();\n // Whether this consumer serves the progression-backed analytics routes at all (#1069).\n const momentsReachable = useResourceReachability(CoreResourceType.USER_PROGRESSION_STATE);\n const providersRef = useRef<IAnalyticsProvider[]>([]);\n const [isActive, setIsActive] = useState(false);\n\n // Session start: captured once at mount\n const sessionStartTimestamp = useRef(Date.now()).current;\n\n // Resolve analytics config from ApplicationContext\n const analyticsConfig = useMemo<AnalyticsConfig | undefined>(\n () => appContext?.appConfig?.analytics,\n [appContext?.appConfig?.analytics],\n );\n\n // ─── Consent gating ─────────────────────────────────────────\n\n /*\n * The purposes the signed-in person granted — a SET (#534). Starts EMPTY, never at a level: nothing\n * is known to be granted until the person's preferences arrive, and analytics that started on an\n * assumed consent would already have sent data by the time the real answer said otherwise.\n *\n * This used to hold one `DataProcessingConsent` and compare it against a module-private\n * `CONSENT_ORDER` with `>=`, which asserted that agreeing to marketing implied agreeing to analytics\n * — a claim nobody decided. Membership of ANALYTICS is the whole test now.\n */\n /*\n * ONE subject grants: the signed-in ACCOUNT.\n *\n * A second, VISITOR tier lived here briefly (#1258 Step 1d) and was removed on 2026-09-20 with the\n * pre-auth panel that fed it — see `PublicLayout_MainContainer` for why that panel went. Nothing\n * publishes a visitor decision to this provider any more, so a visitor tier here would be a state\n * nothing can ever set: the application's public pages run no consent-based analytics, which is the\n * behaviour they had before the panel existed and is the safe direction.\n *\n * `null` means \"nothing has been said\", which is not the same as granting nothing — an empty array\n * is a real, recorded withdrawal and must gate. That distinction is why this is not a bare array.\n */\n const [accountPurposes, setAccountPurposes] = useState<readonly ConsentPurpose[] | null>(null);\n const grantedPurposes = useMemo<readonly ConsentPurpose[]>(() => accountPurposes ?? [], [accountPurposes]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {\n /*\n * `privacy: null` is the CLEARED state — sign-out, or an identity with no preferences. It must\n * revoke: the old handler ignored it, so a signed-out browser kept the previous person's consent\n * and analytics kept running for whoever used it next.\n */\n /*\n * A withdrawal drops what the destinations buffered, before the gate below shuts them down: their\n * shutdown flushes, and events collected under the grant are not sent after it is withdrawn (#1977\n * review). A sign-out already sent its person's buffer, under their consent, on `USER_LOGOUT`.\n */\n const discardUnsent = (): void => {\n if (requiresConsentRef.current) providersRef.current.forEach(p => p.discard());\n };\n if (payload.privacy === null) {\n discardUnsent();\n setAccountPurposes([]);\n return;\n }\n const purposes = payload.privacy?.consentedPurposes;\n // `undefined` means this event carried no privacy block; an EMPTY set is a real withdrawal and\n // must reach the gate below, which is why this does not test truthiness.\n if (purposes !== undefined) {\n const granted = normalizeConsentPurposes(purposes);\n if (!hasGrantedConsentPurposes(granted, [ConsentPurpose.ANALYTICS])) discardUnsent();\n setAccountPurposes(granted);\n }\n });\n }, [on]);\n\n\n /*\n * The person `USER_LOGIN` announced, until `USER_LOGOUT` (#1977). Kept because the two arrive in the\n * wrong order for the built-in destinations: `UserOrgsProvider` announces the person once their\n * context has loaded, which is also when their preferences — and so their ANALYTICS grant — arrive,\n * and the destinations below are initialised asynchronously after that grant. An identify sent only\n * when the event fires would reach no destination, so each one is identified again as it starts.\n */\n const signedInUserIdRef = useRef<string | null>(null);\n const [builtInsStartedVersion, setBuiltInsStartedVersion] = useState(0);\n /** The latest `track`, for the departure listener, which must send while the grant still holds. */\n const lifecycleTrackRef = useRef<(name: string) => void>(() => {});\n\n // Initialize/teardown providers based on config + consent\n useEffect(() => {\n if (!analyticsConfig?.enabled) {\n setIsActive(false);\n return;\n }\n\n const hasConsent = analyticsConfig.requiresConsent === false\n || hasGrantedConsentPurposes(grantedPurposes, [ConsentPurpose.ANALYTICS]);\n\n if (!hasConsent) {\n providersRef.current.forEach(p => p.reset());\n setIsActive(false);\n return;\n }\n\n let aborted = false;\n\n const httpClient = getManualCallsHttpClient();\n const builtInProviders = providerRegistry.resolveFromConfig(\n analyticsConfig.providers ?? [],\n httpClient,\n );\n const allProviders = [...builtInProviders];\n\n Promise.all(\n allProviders.map(p =>\n p.initialize(analyticsConfig.providers?.find(c => c.providerType === p.name)?.config).catch(err => {\n console.warn(`[Analytics] Failed to initialize provider \"${p.name}\":`, err);\n })\n )\n ).then(() => {\n if (aborted) return;\n providersRef.current = allProviders;\n const signedInUserId = signedInUserIdRef.current;\n if (signedInUserId !== null) allProviders.forEach(p => p.identify({ userId: signedInUserId }));\n setIsActive(true);\n // `isActive` may already be true (a re-initialisation on a changed grant), so this is what tells a\n // held sign-in that a fresh set of destinations has started.\n setBuiltInsStartedVersion(version => version + 1);\n });\n\n return () => {\n aborted = true;\n allProviders.forEach(p => p.shutdown().catch(() => {}));\n providersRef.current = [];\n };\n }, [analyticsConfig, grantedPurposes]);\n\n // The vendor sinks currently running (#1704) — empty until the person grants ANALYTICS, emptied on\n // withdrawal or sign-out. Behind the same master switch as the built-in destinations.\n const consentBasedActivations = useConsentBasedProviderActivations();\n const vendorSinks = useMemo<readonly FrontendProductAnalyticsSink[]>(() => {\n if (!analyticsConfig?.enabled) return [];\n return consentBasedActivations\n .filter((running) => running.providerCapabilities.includes(BUILTIN_PROVIDER_CAPABILITY.FRONTEND_PRODUCT_ANALYTICS))\n .map((running) => running.activation.handle)\n .filter(isFrontendProductAnalyticsSink);\n }, [analyticsConfig?.enabled, consentBasedActivations]);\n const isDispatching = isActive || vendorSinks.length > 0;\n\n /*\n * The person's arrival and departure (#1977) — identity for every destination, and the sign-in /\n * sign-out analytics events (`autoInstrumentation.userLifecycle`).\n *\n * Handled HERE rather than in `AnalyticsEventBridge`, which is keyed on the published identity and is\n * therefore remounted by exactly the transitions these events announce, and which only listens while\n * analytics is already dispatching. Two consequences of the order things happen in:\n *\n * - A sign-in is announced when the person's context loads, and their ANALYTICS grant arrives with\n * their preferences a moment later; so the sign-in event is HELD, stamped with the instant it\n * happened. It is decided by the person's own preferences: if they carry the ANALYTICS grant (the\n * grant the person had already recorded before this sign-in, so the sign-in happened under it), the\n * event is sent to each kind of destination as that kind starts — the built-in destinations after\n * their asynchronous initialisation, the vendor sinks when the consent-based phase starts them. If\n * they do not, the event is DROPPED rather than sent after some later grant: an event that happened\n * while the person had not consented is not collected retroactively. A departure drops it too, and\n * a later withdrawal drops whatever has not been delivered yet. An application whose analytics does\n * not rest on consent (`requiresConsent: false`) needs no decision.\n * - A sign-out is announced BEFORE the sign-out publishes `privacy: null` (see `UserOrgsProvider`), so\n * the event is sent while the person's grant still holds, and only then is the identity reset —\n * `track` then `reset`, the order an analytics client expects.\n *\n * Only a sign-in in this tab and the person's own sign-out are COUNTED; a resumed session, a session\n * the backend ended, one ended in another tab and one replaced by another person are identity changes\n * only (see `SessionEstablishment` / `SessionEndReason`).\n */\n const userLifecycleTracking = analyticsConfig?.autoInstrumentation?.userLifecycle === true;\n const userLifecycleTrackingRef = useRef(userLifecycleTracking);\n userLifecycleTrackingRef.current = userLifecycleTracking;\n const requiresConsent = analyticsConfig?.requiresConsent !== false;\n const requiresConsentRef = useRef(requiresConsent);\n requiresConsentRef.current = requiresConsent;\n const heldSignInRef = useRef<HeldSignIn | null>(null);\n /** Re-runs the delivery effect below when a held sign-in is decided (a ref alone would not). */\n const [heldSignInVersion, setHeldSignInVersion] = useState(0);\n const holdSignIn = useCallback((next: HeldSignIn | null) => {\n heldSignInRef.current = next;\n setHeldSignInVersion(version => version + 1);\n }, []);\n useEffect(() => {\n return on(FrontendEvents.USER_LOGIN, (payload) => {\n signedInUserIdRef.current = payload.userId;\n providersRef.current.forEach(p =>\n p.identify({ userId: payload.userId })\n );\n if (payload.establishment === SessionEstablishment.SIGNED_IN) {\n holdSignIn({ occurredAt: Date.now(), decided: !requiresConsentRef.current, owedToBuiltIns: true, owedToVendorSinks: true });\n }\n });\n }, [on, holdSignIn]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {\n const held = heldSignInRef.current;\n // `privacy: null` is a sign-out's clearing, not this person's decision; a departure already dropped the hold.\n if (held === null || !requiresConsentRef.current || !payload.privacy) return;\n const purposes = payload.privacy.consentedPurposes;\n if (purposes === undefined) return;\n holdSignIn(hasGrantedConsentPurposes(normalizeConsentPurposes(purposes), [ConsentPurpose.ANALYTICS]) ? { ...held, decided: true } : null);\n });\n }, [on, holdSignIn]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_LOGOUT, (payload) => {\n if (payload.reason === SessionEndReason.SIGNED_OUT && userLifecycleTrackingRef.current) {\n lifecycleTrackRef.current(AnalyticsEventName.USER_LOGOUT);\n }\n holdSignIn(null);\n signedInUserIdRef.current = null;\n providersRef.current.forEach(p => p.reset());\n });\n }, [on, holdSignIn]);\n\n // ─── Achieved moments persistence ─────────────────────────────\n\n const [identity, setIdentity] = useState<AnalyticsIdentity | null>(null);\n const identityOwner = useRef<symbol | null>(null);\n const publishIdentity = useCallback((next: AnalyticsIdentity) => {\n const owner = Symbol();\n identityOwner.current = owner;\n setIdentity(next);\n return () => {\n if (identityOwner.current === owner) { identityOwner.current = null; setIdentity(null); }\n };\n }, []);\n const identityKey = JSON.stringify(identity);\n\n /*\n * Who a running vendor sink attributes events to (#1704): the person the mounted app scope publishes\n * (`publishIdentity`), which is the identity this provider already trusts for value moments. Keyed on the\n * user id and on WHICH sinks run, so a sink started later is identified on its first render, and a person\n * who leaves (identity lost) is forgotten by every sink still running. The published identity rather\n * than `USER_LOGIN` / `USER_LOGOUT` because a sink starts whenever the grant arrives, and the identity\n * is STATE a sink started later can read, where the announcement is a moment it would have missed.\n */\n const identifiedUserId = identity?.userId ?? null;\n useEffect(() => {\n if (vendorSinks.length === 0) return;\n if (identifiedUserId !== null) vendorSinks.forEach(sink => sink.identify({ userId: identifiedUserId }));\n else vendorSinks.forEach(sink => sink.reset());\n }, [vendorSinks, identifiedUserId]);\n const currentIdentityKey = useRef(identityKey);\n currentIdentityKey.current = identityKey;\n const momentProgress = useRef<AnalyticsMomentProgress>({ signals: new Map(), counts: new Map(), lastFired: new Map(), completed: new Set() });\n const userStorageKey = identity?.userId\n ? `${ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX}${JSON.stringify([identity.applicationId, ValueMomentScope.USER, identity.userId])}` : null;\n const organizationStorageKey = identity?.organizationId\n ? `${ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX}${JSON.stringify([identity.applicationId, ValueMomentScope.ORGANIZATION, identity.organizationId])}` : null;\n const storageKey = JSON.stringify([userStorageKey, organizationStorageKey]);\n const isOrganizationMoment = useCallback((id: string) =>\n analyticsConfig?.valueMoments?.find(moment => moment.identifier === id)?.scope === ValueMomentScope.ORGANIZATION,\n [analyticsConfig?.valueMoments]);\n const isPersistentMoment = useCallback((id: string) =>\n analyticsConfig?.valueMoments?.find(moment => moment.identifier === id)?.role !== ValueMomentRole.ANTI_PATTERN,\n [analyticsConfig?.valueMoments]);\n\n const [achievementState, setAchievementState] = useState<{key: string; moments: Set<string>}>({key: identityKey, moments: new Set()});\n const achievedMoments = useMemo(() => achievementState.key === identityKey ? achievementState.moments : new Set<string>(), [achievementState, identityKey]);\n const setAchievedMoments = useCallback((update: React.SetStateAction<Set<string>>) => {\n setAchievementState(previous => ({key: identityKey, moments: typeof update === 'function'\n ? update(previous.key === identityKey ? previous.moments : new Set()) : update}));\n }, [identityKey]);\n\n // Helper: persist to localStorage\n const persistToStorage = useCallback((moments: Set<string>) => {\n try {\n if (userStorageKey) localStorage.setItem(userStorageKey, JSON.stringify([...moments].filter(id => !isOrganizationMoment(id))));\n if (organizationStorageKey) localStorage.setItem(organizationStorageKey, JSON.stringify([...moments].filter(isOrganizationMoment)));\n } catch {\n /* quota exceeded — best effort */\n }\n }, [userStorageKey, organizationStorageKey, isOrganizationMoment]);\n\n // Load from localStorage on mount + fetch from backend if backendSync\n useEffect(() => {\n setAchievedMoments(new Set());\n if (!analyticsConfig?.enabled || !identity || (!identity.userId && !identity.organizationId)) return;\n\n // Load from localStorage\n try {\n const loaded = new Set<string>();\n for (const [key, organization] of [[userStorageKey, false], [organizationStorageKey, true]] as const) {\n if (!key) continue;\n const stored = localStorage.getItem(key);\n if (stored) for (const id of JSON.parse(stored) as string[]) {\n if (isPersistentMoment(id) && isOrganizationMoment(id) === organization) loaded.add(id);\n }\n }\n setAchievedMoments(loaded);\n } catch {\n /* corrupt storage — start fresh */\n }\n\n // Fetch from backend if backendSync enabled AND this consumer can reach the route (#1069, the\n // #268 rule): achieved moments are read from the progression store, which a consumer whose\n // registry excludes it does not serve. localStorage still loads above.\n if (analyticsConfig?.persistence?.backendSync && momentsReachable) {\n let aborted = false;\n getManualCallsHttpClient()\n .getAnalyticsMomentsAchieved()\n .then((response: unknown) => {\n if (aborted || currentIdentityKey.current !== identityKey) return;\n const res = response as { moments?: string[] };\n if (res.moments) {\n setAchievedMoments(prev => {\n const merged = new Set([...prev, ...res.moments!].filter(isPersistentMoment));\n persistToStorage(merged);\n return merged;\n });\n }\n })\n .catch(() => {\n /* Backend unavailable — use localStorage only */\n });\n\n return () => { aborted = true; };\n }\n }, [analyticsConfig?.enabled, analyticsConfig?.persistence?.backendSync, momentsReachable, storageKey, identityKey, persistToStorage, isPersistentMoment, isOrganizationMoment]);\n\n // Subscribe to ANALYTICS_MOMENT_ACHIEVED events (backend-pushed via WS)\n useEffect(() => {\n return on(FrontendEvents.ANALYTICS_MOMENT_ACHIEVED, (payload) => {\n if (!identity || payload.triggerSource === AnalyticsTriggerSource.FRONTEND || payload.role === ValueMomentRole.ANTI_PATTERN || !isPersistentMoment(payload.momentIdentifier)) return;\n setAchievedMoments(prev => {\n const next = new Set(prev);\n next.add(payload.momentIdentifier);\n persistToStorage(next);\n return next;\n });\n });\n }, [on, persistToStorage, identityKey, isPersistentMoment]);\n\n const markMomentAchieved = useCallback((identifier: string): boolean | Promise<boolean> => {\n if (!identity || !isPersistentMoment(identifier)) return false;\n const definition = analyticsConfig?.valueMoments?.find(moment => moment.identifier === identifier);\n if (definition?.requires?.some(id => !achievedMoments.has(id)) || definition?.beforeStage?.some(id => achievedMoments.has(id))) return false;\n const record = (): boolean => {\n if (currentIdentityKey.current !== identityKey) return false;\n setAchievedMoments(prev => {\n const next = new Set(prev); next.add(identifier); persistToStorage(next); return next;\n });\n return true;\n };\n if (!analyticsConfig?.persistence?.backendSync) return record();\n // A refused report is not an achievement. Network failures retain the documented best-effort\n // local behavior; explicit server refusals must never be merged back as local truth.\n return getManualCallsHttpClient().postAnalyticsMomentsAchieved({ momentIdentifier: identifier, scope: definition?.scope })\n .then(result => result.success === false ? false : record())\n .catch((error: unknown) => {\n const response = error as {httpStatus?: number; response?: {status?: number}};\n const status = response?.httpStatus ?? response?.response?.status;\n return status && status >= 400 && status < 500 ? false : record();\n });\n }, [analyticsConfig, persistToStorage, identityKey, isPersistentMoment, achievedMoments]);\n\n // ─── Track interceptor ref ────────────────────────────────────\n\n const onTrackRef = useRef<((name: string, properties?: Record<string, unknown>) => void) | null>(null);\n\n const track = useCallback((name: string, properties?: Record<string, unknown>) => {\n if (!isDispatching) return;\n const event: AnalyticsEvent = { name, properties, timestamp: Date.now() };\n if (isActive) providersRef.current.forEach(p => p.track(event));\n vendorSinks.forEach(sink => sink.track({ name, properties }));\n // Forward to bridge interceptor for CUSTOM_EVENT / FEATURE_ACCESS signal evaluation\n onTrackRef.current?.(name, properties);\n }, [isActive, isDispatching, vendorSinks]);\n lifecycleTrackRef.current = track;\n\n // Deliver a decided sign-in to each kind of destination as that kind starts — see the block above.\n useEffect(() => {\n const held = heldSignInRef.current;\n if (held === null || !held.decided || !userLifecycleTracking) return;\n const event: AnalyticsEvent = { name: AnalyticsEventName.USER_LOGIN, timestamp: held.occurredAt };\n let owedToBuiltIns = held.owedToBuiltIns;\n let owedToVendorSinks = held.owedToVendorSinks;\n if (owedToBuiltIns && isActive && providersRef.current.length > 0) {\n providersRef.current.forEach(p => p.track(event));\n owedToBuiltIns = false;\n }\n if (owedToVendorSinks && vendorSinks.length > 0) {\n // A vendor sink's `track` takes no timestamp — the vendor stamps receipt — so when the sign-in\n // happened travels as a property, and the vendor-side time may be later than the sign-in.\n vendorSinks.forEach(sink => sink.track({ name: event.name, properties: { [SIGNED_IN_AT_PROPERTY]: new Date(held.occurredAt).toISOString() } }));\n owedToVendorSinks = false;\n }\n if (owedToBuiltIns !== held.owedToBuiltIns || owedToVendorSinks !== held.owedToVendorSinks) {\n heldSignInRef.current = owedToBuiltIns || owedToVendorSinks ? { ...held, owedToBuiltIns, owedToVendorSinks } : null;\n }\n }, [heldSignInVersion, builtInsStartedVersion, isActive, vendorSinks, userLifecycleTracking]);\n\n const page = useCallback((path: string, properties?: Record<string, unknown>) => {\n if (!isDispatching) return;\n if (isActive) providersRef.current.forEach(p => p.page(path, properties));\n vendorSinks.forEach(sink => sink.page(path, properties));\n }, [isActive, isDispatching, vendorSinks]);\n\n // ─── Render ───────────────────────────────────────────────────\n\n const contextValue = useMemo<AnalyticsContextValue>(() => ({\n track,\n page,\n isActive: isDispatching,\n sessionStartTimestamp,\n achievedMoments,\n markMomentAchieved,\n _onTrackRef: onTrackRef,\n }), [track, page, isDispatching, sessionStartTimestamp, achievedMoments, markMomentAchieved]);\n\n return (\n <AnalyticsIdentityPublisherContext.Provider value={publishIdentity}>\n <AnalyticsContext.Provider value={contextValue}>\n {isDispatching && identity && analyticsConfig && (\n <AnalyticsEventBridge\n key={`${identityKey}:${JSON.stringify(analyticsConfig.valueMoments)}`}\n identity={identity}\n progress={momentProgress.current}\n config={analyticsConfig.autoInstrumentation}\n valueMoments={analyticsConfig.valueMoments} \n />\n )}\n {children}\n </AnalyticsContext.Provider>\n </AnalyticsIdentityPublisherContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"AnalyticsContext.js","sourceRoot":"","sources":["../../../../../src/core/monitoring/analytics/Analy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EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QACvF,IAAI,aAAa,CAAC,OAAO;YAAE,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;YACjE,SAAS,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;IAE3C,iEAAiE;IAEjE,MAAM,YAAY,GAAG,OAAO,CAAwB,GAAG,EAAE,CAAC,CAAC;QACzD,KAAK;QACL,IAAI;QACJ,QAAQ,EAAE,aAAa;QACvB,qBAAqB;QACrB,eAAe;QACf,kBAAkB;QAClB,WAAW,EAAE,UAAU;KACxB,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAE9F,OAAO,CACL,KAAC,iCAAiC,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YAClE,MAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,aAC3C,aAAa,IAAI,QAAQ,IAAI,eAAe,IAAI,CAC/C,KAAC,oBAAoB,IAEnB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,cAAc,CAAC,OAAO,EAChC,MAAM,EAAE,eAAe,CAAC,mBAAmB,EAC3C,YAAY,EAAE,eAAe,CAAC,YAAY,IAJrC,GAAG,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,CAKrE,CACH,EACA,QAAQ,IACiB,GACiB,CAC9C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Analytics Context Provider\n * \n * Provides analytics tracking, value moment achievement persistence,\n * consent gating, and provider lifecycle management.\n */\n\nimport React, { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { AnalyticsEventName, BUILTIN_PROVIDER_CAPABILITY, ConsentPurpose, CoreResourceType, hasGrantedConsentPurposes, isReadShapedOperation, normalizeConsentPurposes, ValueMomentRole, ValueMomentScope, AnalyticsTriggerSource, type AnalyticsConfig, ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX } from '@wildo-ai/saas-models';\nimport type { IAnalyticsProvider, AnalyticsEvent } from './analytics-provider.frontend.interface';\nimport { AnalyticsProviderRegistry } from './analytics-provider-registry.frontend.service';\nimport { ApplicationContext } from '~wildo-frontend-lib/core/runtime/ApplicationContext.shared';\nimport { useEventBus } from '~wildo-frontend-lib/core/events/useEventBus';\nimport { FrontendEvents, SessionEndReason, SessionEstablishment } from '~wildo-frontend-lib/core/events/events.frontend.schemas';\nimport { getManualCallsHttpClient } from '~wildo-frontend-lib/core/requests/wildo-http-client-manual-calls.frontend.service';\nimport { useResourceReachability } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport { AnalyticsEventBridge, type AnalyticsMomentProgress } from './AnalyticsEventBridge';\nimport { isFrontendProductAnalyticsSink, type FrontendProductAnalyticsSink } from '@wildo-ai/saas-models/public-runtime';\nimport { useConsentBasedProviderActivations } from '~wildo-frontend-lib/core/external-providers/ConsentBasedProviderSdks';\n\n// ─── Context Value Interface ────────────────────────────────────\n\nexport interface AnalyticsContextValue {\n /** Track a custom event (app-custom usage) */\n track: (name: string, properties?: Record<string, unknown>) => void;\n /** Track a page view */\n page: (path: string, properties?: Record<string, unknown>) => void;\n /** Whether analytics is active (enabled + consent granted) */\n isActive: boolean;\n /** Session start timestamp (for TTFV computation) */\n sessionStartTimestamp: number;\n /** Set of achieved value moment identifiers (scope-aware, persisted) */\n achievedMoments: Set<string>;\n /** Mark a value moment as achieved (persists to localStorage + backend sync) */\n markMomentAchieved: (identifier: string) => boolean | Promise<boolean>;\n /**\n * Internal: ref for track() call interception (used by AnalyticsEventBridge).\n * The bridge registers a callback on mount to evaluate CUSTOM_EVENT and\n * FEATURE_ACCESS signals when track() is called.\n * @internal\n */\n _onTrackRef: React.MutableRefObject<((name: string, properties?: Record<string, unknown>) => void) | null>;\n}\n\n// ─── Context ────────────────────────────────────────────────────\n\n// Note: useAnalytics hook is in a separate file (useAnalytics.ts) for React Fast Refresh compatibility.\nexport const AnalyticsContext = createContext<AnalyticsContextValue | null>(null);\n\n/** Identity snapshots come from the mounted AppScope owner, never a decoded token or a late event. */\nexport interface AnalyticsIdentity {\n userId: string | null;\n organizationId: string | null;\n applicationId: string | null;\n anonymousUserId: string | null;\n}\nexport const AnalyticsIdentityPublisherContext = createContext<((identity: AnalyticsIdentity) => () => void) | null>(null);\n\n// ─── Provider Registry (singleton) ──────────────────────────────\n\nconst providerRegistry = new AnalyticsProviderRegistry();\n\n/** The event property carrying when a held sign-in happened, for destinations that stamp events themselves. */\nconst SIGNED_IN_AT_PROPERTY = 'signed_in_at';\n\n/**\n * A sign-in announced before this tab knows whether the person consented to analytics (#1977): when it\n * happened, whether the person's own preferences have decided it, and which kinds of destination it\n * is still owed to.\n */\ninterface HeldSignIn {\n readonly occurredAt: number;\n readonly decided: boolean;\n readonly owedToBuiltIns: boolean;\n readonly owedToVendorSinks: boolean;\n}\n\n// ─── Provider Component ─────────────────────────────────────────\n\nexport interface AnalyticsContextProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Two kinds of destination, and only ONE of them is a vendor (#1704).\n *\n * - The ENGINE's own destinations (`console`, `backend_proxy`), selected by `analytics.providers`. They send\n * nothing to a third party (the proxy posts to the application's own backend), and they keep the gate\n * below: `analytics.enabled`, then `analytics.requiresConsent` / the ANALYTICS grant.\n * - VENDORS (PostHog, …) arrive as `FRONTEND_PRODUCT_ANALYTICS` provider modules. They are started by the\n * consent-based activation consumer once the person grants what they rest on, and stopped on withdrawal\n * or sign-out; this context only dispatches to the sinks that are running. That replaced an\n * `analyticsProviders` / `customProviders` door which let an application pass a vendor client here,\n * behind a second consent gate and outside the CSP footprint — two gates for one decision.\n *\n * `analytics.enabled` stays the master switch for both: with it off, a `FRONTEND_PRODUCT_ANALYTICS` vendor is not\n * even loaded (the consent-based consumer skips it), and any sink that is running receives nothing.\n */\n/**\n * How long vendor calls made because of a write to the person's own preferences wait for the stored consent (#3928).\n * The re-read normally answers in a fraction of a second; past this the held calls are dropped, never sent.\n */\nconst OWN_PREFERENCES_WRITE_HOLD_MS = 10_000;\n\nexport const AnalyticsContextProvider: React.FC<AnalyticsContextProviderProps> = ({\n children,\n}) => {\n const appContext = useContext(ApplicationContext);\n const { on } = useEventBus();\n // Whether this consumer serves the progression-backed analytics routes at all (#1069).\n const momentsReachable = useResourceReachability(CoreResourceType.USER_PROGRESSION_STATE);\n const providersRef = useRef<IAnalyticsProvider[]>([]);\n const [isActive, setIsActive] = useState(false);\n\n // Session start: captured once at mount\n const sessionStartTimestamp = useRef(Date.now()).current;\n\n // Resolve analytics config from ApplicationContext\n const analyticsConfig = useMemo<AnalyticsConfig | undefined>(\n () => appContext?.appConfig?.analytics,\n [appContext?.appConfig?.analytics],\n );\n\n // ─── Consent gating ─────────────────────────────────────────\n\n /*\n * The purposes the signed-in person granted — a SET (#534). Starts EMPTY, never at a level: nothing\n * is known to be granted until the person's preferences arrive, and analytics that started on an\n * assumed consent would already have sent data by the time the real answer said otherwise.\n *\n * This used to hold one `DataProcessingConsent` and compare it against a module-private\n * `CONSENT_ORDER` with `>=`, which asserted that agreeing to marketing implied agreeing to analytics\n * — a claim nobody decided. Membership of ANALYTICS is the whole test now.\n */\n /*\n * ONE subject grants: the signed-in ACCOUNT.\n *\n * A second, VISITOR tier lived here briefly (#1258 Step 1d) and was removed on 2026-09-20 with the\n * pre-auth panel that fed it — see `PublicLayout_MainContainer` for why that panel went. Nothing\n * publishes a visitor decision to this provider any more, so a visitor tier here would be a state\n * nothing can ever set: the application's public pages run no consent-based analytics, which is the\n * behaviour they had before the panel existed and is the safe direction.\n *\n * `null` means \"nothing has been said\", which is not the same as granting nothing — an empty array\n * is a real, recorded withdrawal and must gate. That distinction is why this is not a bare array.\n */\n const [accountPurposes, setAccountPurposes] = useState<readonly ConsentPurpose[] | null>(null);\n const grantedPurposes = useMemo<readonly ConsentPurpose[]>(() => accountPurposes ?? [], [accountPurposes]);\n\n /*\n * A write to the person's own preferences can change their consent, so what a vendor receives because of it is\n * decided against the consent the write LEAVES, never the one the page held before it (#3928).\n *\n * Measured in a real browser with PostHog: a withdrawal on the Preferences page let the `resource_operation` event of\n * that very write reach PostHog 3 s later. The bridge captured it on `NOTIFY_RESOURCE_SUCCESS`, while the page still\n * held the grant; `UserOrgsProvider` re-reads the record on the write's `RESOURCE_OPERATION_EXECUTED` (#1973), and\n * the vendor's `deactivate` ran after its SDK had queued the event (posthog-js's opt-out does not empty its send\n * queue, and offers no public way to). So the write OPENS a hold: vendor calls queue while it is open, and the next\n * privacy-carrying `USER_PREFERENCES_CHANGED` (the re-read's) closes it, delivering them only while ANALYTICS is\n * still granted. A form emits the outcome before its success notification, so the hold is open before the bridge\n * captures. A sign-out (`privacy: null`) drops them, and a re-read that never lands drops them after the bound: an\n * event whose consent is unknown is not sent.\n *\n * Vendor sinks only: a built-in destination keeps what it buffered until it flushes, and a withdrawal already drops\n * that buffer (`discardUnsent` below).\n */\n const vendorHoldRef = useRef<{ held: Array<() => void>; timer: ReturnType<typeof setTimeout> } | null>(null);\n const releaseVendorHold = useCallback((deliver: boolean): void => {\n const hold = vendorHoldRef.current;\n if (hold === null) return;\n vendorHoldRef.current = null;\n clearTimeout(hold.timer);\n if (deliver) hold.held.forEach((call) => call());\n }, []);\n /** Open the hold, or restart its bound when it is already open (a second write before the first one's answer). */\n const openVendorHold = useCallback((): void => {\n const held = vendorHoldRef.current?.held ?? [];\n if (vendorHoldRef.current) clearTimeout(vendorHoldRef.current.timer);\n vendorHoldRef.current = { held, timer: setTimeout(() => releaseVendorHold(false), OWN_PREFERENCES_WRITE_HOLD_MS) };\n }, [releaseVendorHold]);\n /*\n * Two doors open it, because the two announcements of one write arrive in either order. A form's SECTION save announces\n * the outcome (`RESOURCE_OPERATION_EXECUTED`) before its success notification; its MAIN save notifies success first,\n * and the bridge captures `resource_operation` from that notification before the outcome is announced (measured in the\n * browser: the hold opened by the outcome alone missed the Preferences page's Save). So an analytics event ABOUT a\n * write to the person's own preferences opens the hold itself, in `track`, and the outcome opens it for whatever else\n * follows the write.\n */\n useEffect(() => on(\n FrontendEvents.RESOURCE_OPERATION_EXECUTED,\n () => openVendorHold(),\n (payload) => payload.resourceType === CoreResourceType.USER_SELF_PREFERENCES\n && !isReadShapedOperation(payload.operation ?? { operationIdentifier: payload.operationIdentifier }),\n ), [on, openVendorHold]);\n useEffect(() => () => releaseVendorHold(false), [releaseVendorHold]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {\n /*\n * `privacy: null` is the CLEARED state — sign-out, or an identity with no preferences. It must\n * revoke: the old handler ignored it, so a signed-out browser kept the previous person's consent\n * and analytics kept running for whoever used it next.\n */\n /*\n * A withdrawal drops what the destinations buffered, before the gate below shuts them down: their\n * shutdown flushes, and events collected under the grant are not sent after it is withdrawn (#1977\n * review). A sign-out already sent its person's buffer, under their consent, on `USER_LOGOUT`.\n */\n const discardUnsent = (): void => {\n if (requiresConsentRef.current) providersRef.current.forEach(p => p.discard());\n };\n if (payload.privacy === null) {\n releaseVendorHold(false);\n discardUnsent();\n setAccountPurposes([]);\n return;\n }\n const purposes = payload.privacy?.consentedPurposes;\n // `undefined` means this event carried no privacy block; an EMPTY set is a real withdrawal and\n // must reach the gate below, which is why this does not test truthiness.\n if (purposes !== undefined) {\n const granted = normalizeConsentPurposes(purposes);\n const analyticsGranted = hasGrantedConsentPurposes(granted, [ConsentPurpose.ANALYTICS]);\n // Before the gate changes: what an own-preferences write held is decided by this, the stored consent.\n releaseVendorHold(analyticsGranted);\n if (!analyticsGranted) discardUnsent();\n setAccountPurposes(granted);\n }\n });\n }, [on, releaseVendorHold]);\n\n\n /*\n * The person `USER_LOGIN` announced, until `USER_LOGOUT` (#1977). Kept because the two arrive in the\n * wrong order for the built-in destinations: `UserOrgsProvider` announces the person once their\n * context has loaded, which is also when their preferences — and so their ANALYTICS grant — arrive,\n * and the destinations below are initialised asynchronously after that grant. An identify sent only\n * when the event fires would reach no destination, so each one is identified again as it starts.\n */\n const signedInUserIdRef = useRef<string | null>(null);\n const [builtInsStartedVersion, setBuiltInsStartedVersion] = useState(0);\n /** The latest `track`, for the departure listener, which must send while the grant still holds. */\n const lifecycleTrackRef = useRef<(name: string) => void>(() => {});\n\n // Initialize/teardown providers based on config + consent\n useEffect(() => {\n if (!analyticsConfig?.enabled) {\n setIsActive(false);\n return;\n }\n\n const hasConsent = analyticsConfig.requiresConsent === false\n || hasGrantedConsentPurposes(grantedPurposes, [ConsentPurpose.ANALYTICS]);\n\n if (!hasConsent) {\n providersRef.current.forEach(p => p.reset());\n setIsActive(false);\n return;\n }\n\n let aborted = false;\n\n const httpClient = getManualCallsHttpClient();\n const builtInProviders = providerRegistry.resolveFromConfig(\n analyticsConfig.providers ?? [],\n httpClient,\n );\n const allProviders = [...builtInProviders];\n\n Promise.all(\n allProviders.map(p =>\n p.initialize(analyticsConfig.providers?.find(c => c.providerType === p.name)?.config).catch(err => {\n console.warn(`[Analytics] Failed to initialize provider \"${p.name}\":`, err);\n })\n )\n ).then(() => {\n if (aborted) return;\n providersRef.current = allProviders;\n const signedInUserId = signedInUserIdRef.current;\n if (signedInUserId !== null) allProviders.forEach(p => p.identify({ userId: signedInUserId }));\n setIsActive(true);\n // `isActive` may already be true (a re-initialisation on a changed grant), so this is what tells a\n // held sign-in that a fresh set of destinations has started.\n setBuiltInsStartedVersion(version => version + 1);\n });\n\n return () => {\n aborted = true;\n allProviders.forEach(p => p.shutdown().catch(() => {}));\n providersRef.current = [];\n };\n }, [analyticsConfig, grantedPurposes]);\n\n // The vendor sinks currently running (#1704) — empty until the person grants ANALYTICS, emptied on\n // withdrawal or sign-out. Behind the same master switch as the built-in destinations.\n const consentBasedActivations = useConsentBasedProviderActivations();\n const vendorSinks = useMemo<readonly FrontendProductAnalyticsSink[]>(() => {\n if (!analyticsConfig?.enabled) return [];\n return consentBasedActivations\n .filter((running) => running.providerCapabilities.includes(BUILTIN_PROVIDER_CAPABILITY.FRONTEND_PRODUCT_ANALYTICS))\n .map((running) => running.activation.handle)\n .filter(isFrontendProductAnalyticsSink);\n }, [analyticsConfig?.enabled, consentBasedActivations]);\n const isDispatching = isActive || vendorSinks.length > 0;\n\n /*\n * The person's arrival and departure (#1977) — identity for every destination, and the sign-in /\n * sign-out analytics events (`autoInstrumentation.userLifecycle`).\n *\n * Handled HERE rather than in `AnalyticsEventBridge`, which is keyed on the published identity and is\n * therefore remounted by exactly the transitions these events announce, and which only listens while\n * analytics is already dispatching. Two consequences of the order things happen in:\n *\n * - A sign-in is announced when the person's context loads, and their ANALYTICS grant arrives with\n * their preferences a moment later; so the sign-in event is HELD, stamped with the instant it\n * happened. It is decided by the person's own preferences: if they carry the ANALYTICS grant (the\n * grant the person had already recorded before this sign-in, so the sign-in happened under it), the\n * event is sent to each kind of destination as that kind starts — the built-in destinations after\n * their asynchronous initialisation, the vendor sinks when the consent-based phase starts them. If\n * they do not, the event is DROPPED rather than sent after some later grant: an event that happened\n * while the person had not consented is not collected retroactively. A departure drops it too, and\n * a later withdrawal drops whatever has not been delivered yet. An application whose analytics does\n * not rest on consent (`requiresConsent: false`) needs no decision.\n * - A sign-out is announced BEFORE the sign-out publishes `privacy: null` (see `UserOrgsProvider`), so\n * the event is sent while the person's grant still holds, and only then is the identity reset —\n * `track` then `reset`, the order an analytics client expects.\n *\n * Only a sign-in in this tab and the person's own sign-out are COUNTED; a resumed session, a session\n * the backend ended, one ended in another tab and one replaced by another person are identity changes\n * only (see `SessionEstablishment` / `SessionEndReason`).\n */\n const userLifecycleTracking = analyticsConfig?.autoInstrumentation?.userLifecycle === true;\n const userLifecycleTrackingRef = useRef(userLifecycleTracking);\n userLifecycleTrackingRef.current = userLifecycleTracking;\n const requiresConsent = analyticsConfig?.requiresConsent !== false;\n const requiresConsentRef = useRef(requiresConsent);\n requiresConsentRef.current = requiresConsent;\n const heldSignInRef = useRef<HeldSignIn | null>(null);\n /** Re-runs the delivery effect below when a held sign-in is decided (a ref alone would not). */\n const [heldSignInVersion, setHeldSignInVersion] = useState(0);\n const holdSignIn = useCallback((next: HeldSignIn | null) => {\n heldSignInRef.current = next;\n setHeldSignInVersion(version => version + 1);\n }, []);\n useEffect(() => {\n return on(FrontendEvents.USER_LOGIN, (payload) => {\n signedInUserIdRef.current = payload.userId;\n providersRef.current.forEach(p =>\n p.identify({ userId: payload.userId })\n );\n if (payload.establishment === SessionEstablishment.SIGNED_IN) {\n holdSignIn({ occurredAt: Date.now(), decided: !requiresConsentRef.current, owedToBuiltIns: true, owedToVendorSinks: true });\n }\n });\n }, [on, holdSignIn]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {\n const held = heldSignInRef.current;\n // `privacy: null` is a sign-out's clearing, not this person's decision; a departure already dropped the hold.\n if (held === null || !requiresConsentRef.current || !payload.privacy) return;\n const purposes = payload.privacy.consentedPurposes;\n if (purposes === undefined) return;\n holdSignIn(hasGrantedConsentPurposes(normalizeConsentPurposes(purposes), [ConsentPurpose.ANALYTICS]) ? { ...held, decided: true } : null);\n });\n }, [on, holdSignIn]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_LOGOUT, (payload) => {\n if (payload.reason === SessionEndReason.SIGNED_OUT && userLifecycleTrackingRef.current) {\n lifecycleTrackRef.current(AnalyticsEventName.USER_LOGOUT);\n }\n holdSignIn(null);\n signedInUserIdRef.current = null;\n providersRef.current.forEach(p => p.reset());\n });\n }, [on, holdSignIn]);\n\n // ─── Achieved moments persistence ─────────────────────────────\n\n const [identity, setIdentity] = useState<AnalyticsIdentity | null>(null);\n const identityOwner = useRef<symbol | null>(null);\n const publishIdentity = useCallback((next: AnalyticsIdentity) => {\n const owner = Symbol();\n identityOwner.current = owner;\n setIdentity(next);\n return () => {\n if (identityOwner.current === owner) { identityOwner.current = null; setIdentity(null); }\n };\n }, []);\n const identityKey = JSON.stringify(identity);\n\n /*\n * Who a running vendor sink attributes events to (#1704): the person the mounted app scope publishes\n * (`publishIdentity`), which is the identity this provider already trusts for value moments. Keyed on the\n * user id and on WHICH sinks run, so a sink started later is identified on its first render, and a person\n * who leaves (identity lost) is forgotten by every sink still running. The published identity rather\n * than `USER_LOGIN` / `USER_LOGOUT` because a sink starts whenever the grant arrives, and the identity\n * is STATE a sink started later can read, where the announcement is a moment it would have missed.\n */\n const identifiedUserId = identity?.userId ?? null;\n useEffect(() => {\n if (vendorSinks.length === 0) return;\n if (identifiedUserId !== null) vendorSinks.forEach(sink => sink.identify({ userId: identifiedUserId }));\n else vendorSinks.forEach(sink => sink.reset());\n }, [vendorSinks, identifiedUserId]);\n const currentIdentityKey = useRef(identityKey);\n currentIdentityKey.current = identityKey;\n const momentProgress = useRef<AnalyticsMomentProgress>({ signals: new Map(), counts: new Map(), lastFired: new Map(), completed: new Set() });\n const userStorageKey = identity?.userId\n ? `${ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX}${JSON.stringify([identity.applicationId, ValueMomentScope.USER, identity.userId])}` : null;\n const organizationStorageKey = identity?.organizationId\n ? `${ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX}${JSON.stringify([identity.applicationId, ValueMomentScope.ORGANIZATION, identity.organizationId])}` : null;\n const storageKey = JSON.stringify([userStorageKey, organizationStorageKey]);\n const isOrganizationMoment = useCallback((id: string) =>\n analyticsConfig?.valueMoments?.find(moment => moment.identifier === id)?.scope === ValueMomentScope.ORGANIZATION,\n [analyticsConfig?.valueMoments]);\n const isPersistentMoment = useCallback((id: string) =>\n analyticsConfig?.valueMoments?.find(moment => moment.identifier === id)?.role !== ValueMomentRole.ANTI_PATTERN,\n [analyticsConfig?.valueMoments]);\n\n const [achievementState, setAchievementState] = useState<{key: string; moments: Set<string>}>({key: identityKey, moments: new Set()});\n const achievedMoments = useMemo(() => achievementState.key === identityKey ? achievementState.moments : new Set<string>(), [achievementState, identityKey]);\n const setAchievedMoments = useCallback((update: React.SetStateAction<Set<string>>) => {\n setAchievementState(previous => ({key: identityKey, moments: typeof update === 'function'\n ? update(previous.key === identityKey ? previous.moments : new Set()) : update}));\n }, [identityKey]);\n\n // Helper: persist to localStorage\n const persistToStorage = useCallback((moments: Set<string>) => {\n try {\n if (userStorageKey) localStorage.setItem(userStorageKey, JSON.stringify([...moments].filter(id => !isOrganizationMoment(id))));\n if (organizationStorageKey) localStorage.setItem(organizationStorageKey, JSON.stringify([...moments].filter(isOrganizationMoment)));\n } catch {\n /* quota exceeded — best effort */\n }\n }, [userStorageKey, organizationStorageKey, isOrganizationMoment]);\n\n // Load from localStorage on mount + fetch from backend if backendSync\n useEffect(() => {\n setAchievedMoments(new Set());\n if (!analyticsConfig?.enabled || !identity || (!identity.userId && !identity.organizationId)) return;\n\n // Load from localStorage\n try {\n const loaded = new Set<string>();\n for (const [key, organization] of [[userStorageKey, false], [organizationStorageKey, true]] as const) {\n if (!key) continue;\n const stored = localStorage.getItem(key);\n if (stored) for (const id of JSON.parse(stored) as string[]) {\n if (isPersistentMoment(id) && isOrganizationMoment(id) === organization) loaded.add(id);\n }\n }\n setAchievedMoments(loaded);\n } catch {\n /* corrupt storage — start fresh */\n }\n\n // Fetch from backend if backendSync enabled AND this consumer can reach the route (#1069, the\n // #268 rule): achieved moments are read from the progression store, which a consumer whose\n // registry excludes it does not serve. localStorage still loads above.\n if (analyticsConfig?.persistence?.backendSync && momentsReachable) {\n let aborted = false;\n getManualCallsHttpClient()\n .getAnalyticsMomentsAchieved()\n .then((response: unknown) => {\n if (aborted || currentIdentityKey.current !== identityKey) return;\n const res = response as { moments?: string[] };\n if (res.moments) {\n setAchievedMoments(prev => {\n const merged = new Set([...prev, ...res.moments!].filter(isPersistentMoment));\n persistToStorage(merged);\n return merged;\n });\n }\n })\n .catch(() => {\n /* Backend unavailable — use localStorage only */\n });\n\n return () => { aborted = true; };\n }\n }, [analyticsConfig?.enabled, analyticsConfig?.persistence?.backendSync, momentsReachable, storageKey, identityKey, persistToStorage, isPersistentMoment, isOrganizationMoment]);\n\n // Subscribe to ANALYTICS_MOMENT_ACHIEVED events (backend-pushed via WS)\n useEffect(() => {\n return on(FrontendEvents.ANALYTICS_MOMENT_ACHIEVED, (payload) => {\n if (!identity || payload.triggerSource === AnalyticsTriggerSource.FRONTEND || payload.role === ValueMomentRole.ANTI_PATTERN || !isPersistentMoment(payload.momentIdentifier)) return;\n setAchievedMoments(prev => {\n const next = new Set(prev);\n next.add(payload.momentIdentifier);\n persistToStorage(next);\n return next;\n });\n });\n }, [on, persistToStorage, identityKey, isPersistentMoment]);\n\n const markMomentAchieved = useCallback((identifier: string): boolean | Promise<boolean> => {\n if (!identity || !isPersistentMoment(identifier)) return false;\n const definition = analyticsConfig?.valueMoments?.find(moment => moment.identifier === identifier);\n if (definition?.requires?.some(id => !achievedMoments.has(id)) || definition?.beforeStage?.some(id => achievedMoments.has(id))) return false;\n const record = (): boolean => {\n if (currentIdentityKey.current !== identityKey) return false;\n setAchievedMoments(prev => {\n const next = new Set(prev); next.add(identifier); persistToStorage(next); return next;\n });\n return true;\n };\n if (!analyticsConfig?.persistence?.backendSync) return record();\n // A refused report is not an achievement. Network failures retain the documented best-effort\n // local behavior; explicit server refusals must never be merged back as local truth.\n return getManualCallsHttpClient().postAnalyticsMomentsAchieved({ momentIdentifier: identifier, scope: definition?.scope })\n .then(result => result.success === false ? false : record())\n .catch((error: unknown) => {\n const response = error as {httpStatus?: number; response?: {status?: number}};\n const status = response?.httpStatus ?? response?.response?.status;\n return status && status >= 400 && status < 500 ? false : record();\n });\n }, [analyticsConfig, persistToStorage, identityKey, isPersistentMoment, achievedMoments]);\n\n // ─── Track interceptor ref ────────────────────────────────────\n\n const onTrackRef = useRef<((name: string, properties?: Record<string, unknown>) => void) | null>(null);\n\n const track = useCallback((name: string, properties?: Record<string, unknown>) => {\n if (!isDispatching) return;\n const event: AnalyticsEvent = { name, properties, timestamp: Date.now() };\n if (isActive) providersRef.current.forEach(p => p.track(event));\n // An event about a write to the person's own preferences waits for the consent that write leaves (see the hold).\n if (name === AnalyticsEventName.RESOURCE_OPERATION && properties?.resourceType === CoreResourceType.USER_SELF_PREFERENCES) openVendorHold();\n const toVendors = (): void => vendorSinks.forEach(sink => sink.track({ name, properties }));\n if (vendorHoldRef.current) vendorHoldRef.current.held.push(toVendors);\n else toVendors();\n // Forward to bridge interceptor for CUSTOM_EVENT / FEATURE_ACCESS signal evaluation\n onTrackRef.current?.(name, properties);\n }, [isActive, isDispatching, vendorSinks, openVendorHold]);\n lifecycleTrackRef.current = track;\n\n // Deliver a decided sign-in to each kind of destination as that kind starts — see the block above.\n useEffect(() => {\n const held = heldSignInRef.current;\n if (held === null || !held.decided || !userLifecycleTracking) return;\n const event: AnalyticsEvent = { name: AnalyticsEventName.USER_LOGIN, timestamp: held.occurredAt };\n let owedToBuiltIns = held.owedToBuiltIns;\n let owedToVendorSinks = held.owedToVendorSinks;\n if (owedToBuiltIns && isActive && providersRef.current.length > 0) {\n providersRef.current.forEach(p => p.track(event));\n owedToBuiltIns = false;\n }\n if (owedToVendorSinks && vendorSinks.length > 0) {\n // A vendor sink's `track` takes no timestamp — the vendor stamps receipt — so when the sign-in\n // happened travels as a property, and the vendor-side time may be later than the sign-in.\n vendorSinks.forEach(sink => sink.track({ name: event.name, properties: { [SIGNED_IN_AT_PROPERTY]: new Date(held.occurredAt).toISOString() } }));\n owedToVendorSinks = false;\n }\n if (owedToBuiltIns !== held.owedToBuiltIns || owedToVendorSinks !== held.owedToVendorSinks) {\n heldSignInRef.current = owedToBuiltIns || owedToVendorSinks ? { ...held, owedToBuiltIns, owedToVendorSinks } : null;\n }\n }, [heldSignInVersion, builtInsStartedVersion, isActive, vendorSinks, userLifecycleTracking]);\n\n const page = useCallback((path: string, properties?: Record<string, unknown>) => {\n if (!isDispatching) return;\n if (isActive) providersRef.current.forEach(p => p.page(path, properties));\n const toVendors = (): void => vendorSinks.forEach(sink => sink.page(path, properties));\n if (vendorHoldRef.current) vendorHoldRef.current.held.push(toVendors);\n else toVendors();\n }, [isActive, isDispatching, vendorSinks]);\n\n // ─── Render ───────────────────────────────────────────────────\n\n const contextValue = useMemo<AnalyticsContextValue>(() => ({\n track,\n page,\n isActive: isDispatching,\n sessionStartTimestamp,\n achievedMoments,\n markMomentAchieved,\n _onTrackRef: onTrackRef,\n }), [track, page, isDispatching, sessionStartTimestamp, achievedMoments, markMomentAchieved]);\n\n return (\n <AnalyticsIdentityPublisherContext.Provider value={publishIdentity}>\n <AnalyticsContext.Provider value={contextValue}>\n {isDispatching && identity && analyticsConfig && (\n <AnalyticsEventBridge\n key={`${identityKey}:${JSON.stringify(analyticsConfig.valueMoments)}`}\n identity={identity}\n progress={momentProgress.current}\n config={analyticsConfig.autoInstrumentation}\n valueMoments={analyticsConfig.valueMoments} \n />\n )}\n {children}\n </AnalyticsContext.Provider>\n </AnalyticsIdentityPublisherContext.Provider>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsEventBridge.d.ts","sourceRoot":"","sources":["../../../../../src/core/monitoring/analytics/AnalyticsEventBridge.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAYjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAQ5D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AACD,UAAU,yBAAyB;IACjC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAC9B;AAID,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAubpE,CAAC"}
1
+ {"version":3,"file":"AnalyticsEventBridge.d.ts","sourceRoot":"","sources":["../../../../../src/core/monitoring/analytics/AnalyticsEventBridge.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAYjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAQ5D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AACD,UAAU,yBAAyB;IACjC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAC9B;AAID,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAicpE,CAAC"}
@@ -200,13 +200,22 @@ export const AnalyticsEventBridge = ({ config, valueMoments, identity, progress
200
200
  // ═══════════════════════════════════════════════════════════════
201
201
  // PAGE VIEWS + VIEW_VISIT value signals
202
202
  // ═══════════════════════════════════════════════════════════════
203
+ /**
204
+ * The path the last page view named (#3789). One route change moves several navigation zones, and each zone
205
+ * announces itself, so a page view per zone event sent the vendor three identical page views per navigation and
206
+ * tripled every page metric. A page view is a change of PATH; a zone change on the same path (a panel, an overlay
207
+ * whose URL does not move) is not one. Value-moment VIEW_VISIT signals still read every zone event below.
208
+ */
209
+ const lastPageViewPathRef = useRef(null);
203
210
  useEffect(() => {
204
211
  if (!isActive)
205
212
  return;
206
213
  return on(FrontendEvents.NAVIGATION_ZONE_CHANGED, (payload) => {
207
- // Page view auto-instrumentation
208
- if (config?.pageViews) {
209
- page(window.location.pathname, {
214
+ // Page view auto-instrumentation: once per path change, never once per zone.
215
+ const path = window.location.pathname;
216
+ if (config?.pageViews && path !== lastPageViewPathRef.current) {
217
+ lastPageViewPathRef.current = path;
218
+ page(path, {
210
219
  contentType: payload.currentContent?.contentType,
211
220
  zone: payload.zone,
212
221
  stackDepth: payload.stackDepth,