@wildo-ai/saas-frontend-lib 1.1.13 → 1.1.15
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.
- package/dist/esm/components/ai-elements/meta/agent-wrappers.d.ts +1 -0
- package/dist/esm/components/ai-elements/meta/agent-wrappers.d.ts.map +1 -1
- package/dist/esm/components/ai-elements/meta/agent-wrappers.js.map +1 -1
- package/dist/esm/components/compliance/EmbeddedSigningFrame.d.ts +38 -0
- package/dist/esm/components/compliance/EmbeddedSigningFrame.d.ts.map +1 -0
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js +106 -0
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js.map +1 -0
- package/dist/esm/components/data-display/DisplayValueDispatcher.d.ts.map +1 -1
- package/dist/esm/components/data-display/DisplayValueDispatcher.js +17 -1
- package/dist/esm/components/data-display/DisplayValueDispatcher.js.map +1 -1
- package/dist/esm/components/data-display/ResourceAutomaticDisplayer.d.ts.map +1 -1
- package/dist/esm/components/data-display/ResourceAutomaticDisplayer.js +22 -0
- package/dist/esm/components/data-display/ResourceAutomaticDisplayer.js.map +1 -1
- package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.d.ts.map +1 -1
- package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js +5 -2
- package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js.map +1 -1
- package/dist/esm/components/flows-actors/agent-config.labels.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/agent-config.labels.js +2 -0
- package/dist/esm/components/flows-actors/agent-config.labels.js.map +1 -1
- package/dist/esm/components/flows-actors/approval.d.ts +7 -1
- package/dist/esm/components/flows-actors/approval.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/approval.js +22 -5
- package/dist/esm/components/flows-actors/approval.js.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.d.ts.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js +20 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js.map +1 -1
- package/dist/esm/components/form/chromes/FormFieldChrome.js +1 -1
- package/dist/esm/components/form/chromes/FormFieldChrome.js.map +1 -1
- package/dist/esm/components/form/chromes/field-control-aria.d.ts +8 -1
- package/dist/esm/components/form/chromes/field-control-aria.d.ts.map +1 -1
- package/dist/esm/components/form/chromes/field-control-aria.js +19 -2
- package/dist/esm/components/form/chromes/field-control-aria.js.map +1 -1
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts +5 -0
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts.map +1 -1
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js +6 -2
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js.map +1 -1
- package/dist/esm/components/resources/ResourceCollectionBody_Table.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceCollectionBody_Table.js +8 -1
- package/dist/esm/components/resources/ResourceCollectionBody_Table.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js +2 -2
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js +2 -2
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js.map +1 -1
- package/dist/esm/components/resources/ResourceListItemRenderer.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceListItemRenderer.js +6 -1
- package/dist/esm/components/resources/ResourceListItemRenderer.js.map +1 -1
- package/dist/esm/components/resources/skeleton/DisplayLayout.js +2 -2
- package/dist/esm/components/resources/skeleton/DisplayLayout.js.map +1 -1
- package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.d.ts.map +1 -1
- package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js +71 -16
- package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js.map +1 -1
- package/dist/esm/components/sections/surface.d.ts +12 -0
- package/dist/esm/components/sections/surface.d.ts.map +1 -1
- package/dist/esm/components/sections/surface.js +14 -0
- package/dist/esm/components/sections/surface.js.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.d.ts.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js +3 -2
- package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts +15 -0
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js +29 -0
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/use-shell-motion.d.ts.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js +2 -2
- package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js.map +1 -1
- package/dist/esm/core/branding/useBrandPresentation.d.ts.map +1 -1
- package/dist/esm/core/branding/useBrandPresentation.js +17 -6
- package/dist/esm/core/branding/useBrandPresentation.js.map +1 -1
- package/dist/esm/core/events/events.frontend.schemas.d.ts +40 -0
- package/dist/esm/core/events/events.frontend.schemas.d.ts.map +1 -1
- package/dist/esm/core/events/events.frontend.schemas.js +24 -1
- package/dist/esm/core/events/events.frontend.schemas.js.map +1 -1
- package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.d.ts.map +1 -1
- package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js +11 -1
- package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js.map +1 -1
- package/dist/esm/core/i18n/I18nContext.d.ts.map +1 -1
- package/dist/esm/core/i18n/I18nContext.js +8 -2
- package/dist/esm/core/i18n/I18nContext.js.map +1 -1
- package/dist/esm/core/i18n/component-label-resolution.utils.d.ts.map +1 -1
- package/dist/esm/core/i18n/component-label-resolution.utils.js +6 -1
- package/dist/esm/core/i18n/component-label-resolution.utils.js.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts +0 -15
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js +102 -5
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.d.ts.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js +12 -3
- package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js.map +1 -1
- package/dist/esm/core/navigation/NavigationContext.d.ts.map +1 -1
- package/dist/esm/core/navigation/NavigationContext.js +60 -17
- package/dist/esm/core/navigation/NavigationContext.js.map +1 -1
- package/dist/esm/core/navigation/launcher-resolution.d.ts +29 -0
- package/dist/esm/core/navigation/launcher-resolution.d.ts.map +1 -1
- package/dist/esm/core/navigation/launcher-resolution.js +31 -0
- package/dist/esm/core/navigation/launcher-resolution.js.map +1 -1
- package/dist/esm/core/navigation/navigation-controller-internals.d.ts +48 -0
- package/dist/esm/core/navigation/navigation-controller-internals.d.ts.map +1 -1
- package/dist/esm/core/navigation/navigation-controller-internals.js +56 -3
- package/dist/esm/core/navigation/navigation-controller-internals.js.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js +30 -2
- package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.d.ts +6 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.js +11 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.js.map +1 -1
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts +44 -0
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts.map +1 -0
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js +63 -0
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js.map +1 -0
- package/dist/esm/core/resources/useOperationDirectExecution.d.ts.map +1 -1
- package/dist/esm/core/resources/useOperationDirectExecution.js +45 -6
- package/dist/esm/core/resources/useOperationDirectExecution.js.map +1 -1
- package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
- package/dist/esm/core/runtime/AppRouter.js +18 -1
- package/dist/esm/core/runtime/AppRouter.js.map +1 -1
- package/dist/esm/core/runtime/ApplicationMainContext.d.ts +1 -1
- package/dist/esm/core/runtime/ApplicationMainContext.d.ts.map +1 -1
- package/dist/esm/core/runtime/ApplicationMainContext.js +12 -3
- package/dist/esm/core/runtime/ApplicationMainContext.js.map +1 -1
- package/dist/esm/core/security/UserOrgsContext.d.ts +6 -1
- package/dist/esm/core/security/UserOrgsContext.d.ts.map +1 -1
- package/dist/esm/core/security/UserOrgsContext.js +87 -10
- package/dist/esm/core/security/UserOrgsContext.js.map +1 -1
- package/dist/esm/core/security/consent-gate.frontend.utils.d.ts +17 -5
- package/dist/esm/core/security/consent-gate.frontend.utils.d.ts.map +1 -1
- package/dist/esm/core/security/consent-gate.frontend.utils.js +16 -7
- package/dist/esm/core/security/consent-gate.frontend.utils.js.map +1 -1
- package/dist/esm/core/security/useConsentGateBehavior.js +1 -1
- package/dist/esm/core/security/useConsentGateBehavior.js.map +1 -1
- package/dist/esm/core/security/useGrantedConsentPurposes.js +1 -1
- package/dist/esm/core/security/useGrantedConsentPurposes.js.map +1 -1
- package/dist/esm/core/ui/inner-control-activation.utils.d.ts +16 -0
- package/dist/esm/core/ui/inner-control-activation.utils.d.ts.map +1 -0
- package/dist/esm/core/ui/inner-control-activation.utils.js +44 -0
- package/dist/esm/core/ui/inner-control-activation.utils.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- 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,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,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,CAQT;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAClD,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,CACV,aAAa,EAAE,qBAAqB,EACpC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACtC,MAAM,EACX,aAAa,EAAE,qBAAqB,GACnC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM,CAEnE;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE;IACjD,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,GAAG,EAAE,OAAO,GAAG,aAAa,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,
|
|
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,MAAM,CAAC,CAAC;CAC1C,GAAG,MAAM,CAQT;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAClD,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,CACV,aAAa,EAAE,qBAAqB,EACpC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACtC,MAAM,EACX,aAAa,EAAE,qBAAqB,GACnC,CAAC,GAAG,EAAE,MAAM,EA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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;IAC9D,OAAO,QAAQ,KAAK,UAAU,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MASrC;IACC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAChC,MAAM,CAAC,aAAa,EACpB,MAAM,CAAC,GAAG,EACV,MAAM,CAAC,MAAM,CACd,CAAC;IACF,yEAAyE;IACzE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAmD;IAEnD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACpF,OAAO,kBAAkB,CAAC,QAAQ,EAAE,cAAc,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAIW,EACX,aAAoC;IAEpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,qBAAqB,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,MAS1C;IACC,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CACrC,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,GAAG,EACV,MAAM,CAAC,MAAM,CACd,CAAC;IACF,
|
|
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;AACjC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MASrC;IACC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAChC,MAAM,CAAC,aAAa,EACpB,MAAM,CAAC,GAAG,EACV,MAAM,CAAC,MAAM,CACd,CAAC;IACF,yEAAyE;IACzE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,6BAA6B,CAC3C,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AM,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;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,eAAe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;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,gFAAgF;IAChF,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvE;;;;;OAKG;IACH,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;CAC5G;AAKD,eAAO,MAAM,gBAAgB,sCAAoD,CAAC;AAElF,sGAAsG;AACtG,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AACD,eAAO,MAAM,iCAAiC,2BAA6B,iBAAiB,KAAK,MAAM,IAAI,CAAe,CAAC;AAuB3H,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAuBD,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CAugB5E,CAAC"}
|
|
@@ -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,81 @@ 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 answer
|
|
91
|
+
* to the re-read the write started (`OWN_PREFERENCES_REREAD_SETTLED` with that read's number) closes it, delivering
|
|
92
|
+
* them only while ANALYTICS is still granted. Nothing else closes it with a delivery: `UserOrgsProvider` re-announces
|
|
93
|
+
* the PRE-write record whenever its organizations change, and an earlier write's re-read can land inside this one's
|
|
94
|
+
* window, and either would have released the withdrawal's own event under the old grant (#3928 review). A sign-out
|
|
95
|
+
* (`privacy: null`) drops them, and so does a re-read that fails or never lands (after the bound): an event whose
|
|
96
|
+
* consent is unknown is not sent.
|
|
97
|
+
*
|
|
98
|
+
* Vendor sinks only: a built-in destination keeps what it buffered until it flushes, and a withdrawal already drops
|
|
99
|
+
* that buffer (`discardUnsent` below).
|
|
100
|
+
*/
|
|
101
|
+
/** `readId` is the re-read this hold waits for: `null` until one starts while the hold is open. */
|
|
102
|
+
const vendorHoldRef = useRef(null);
|
|
103
|
+
const releaseVendorHold = useCallback((deliver) => {
|
|
104
|
+
const hold = vendorHoldRef.current;
|
|
105
|
+
if (hold === null)
|
|
106
|
+
return;
|
|
107
|
+
vendorHoldRef.current = null;
|
|
108
|
+
clearTimeout(hold.timer);
|
|
109
|
+
if (deliver)
|
|
110
|
+
hold.held.forEach((call) => call());
|
|
111
|
+
}, []);
|
|
112
|
+
/** Open the hold, or restart its bound when it is already open (a second write before the first one's answer). */
|
|
113
|
+
/**
|
|
114
|
+
* The re-read started in the CURRENT synchronous turn, if any; cleared at the end of the turn. A write's success
|
|
115
|
+
* notification, its outcome and the re-read it starts are emitted in ONE turn, in either order (`handleSubmit` →
|
|
116
|
+
* `NOTIFY_RESOURCE_SUCCESS` → `onSuccess` → `announceOutcome` for a main save; outcome first for a section save), so a
|
|
117
|
+
* network answer can never land between them. An event tracked about a write therefore belongs to the re-read started
|
|
118
|
+
* in its turn, or to the next one; a re-read started in an earlier turn answers an earlier write.
|
|
119
|
+
*/
|
|
120
|
+
const rereadStartedThisTurnRef = useRef(null);
|
|
121
|
+
/**
|
|
122
|
+
* Open the hold, or restart its bound when it is already open. `readId`: the re-read that just started, which every
|
|
123
|
+
* earlier write is also seen by. Without one (the `track` door), the hold waits for the re-read of this turn, or the next.
|
|
124
|
+
*/
|
|
125
|
+
const openVendorHold = useCallback((readId) => {
|
|
126
|
+
const previous = vendorHoldRef.current;
|
|
127
|
+
if (previous)
|
|
128
|
+
clearTimeout(previous.timer);
|
|
129
|
+
vendorHoldRef.current = {
|
|
130
|
+
held: previous?.held ?? [],
|
|
131
|
+
timer: setTimeout(() => releaseVendorHold(false), OWN_PREFERENCES_WRITE_HOLD_MS),
|
|
132
|
+
readId: readId ?? rereadStartedThisTurnRef.current,
|
|
133
|
+
};
|
|
134
|
+
}, [releaseVendorHold]);
|
|
135
|
+
/*
|
|
136
|
+
* Two doors open it, because the two announcements of one write arrive in either order. A form's SECTION save announces
|
|
137
|
+
* the outcome (`RESOURCE_OPERATION_EXECUTED`) before its success notification; its MAIN save notifies success first,
|
|
138
|
+
* and the bridge captures `resource_operation` from that notification before the outcome is announced (measured in the
|
|
139
|
+
* browser: the hold opened by the outcome alone missed the Preferences page's Save). So an analytics event ABOUT a
|
|
140
|
+
* write to the person's own preferences opens the hold itself, in `track`, and the re-read the write starts opens it
|
|
141
|
+
* (or, if `track` opened it, names the read it waits for). The re-read rather than the outcome: it is the one thing
|
|
142
|
+
* the hold waits on, so opening on it cannot miss it whichever provider hears the outcome first.
|
|
143
|
+
*/
|
|
144
|
+
useEffect(() => on(FrontendEvents.OWN_PREFERENCES_REREAD_STARTED, ({ readId }) => {
|
|
145
|
+
rereadStartedThisTurnRef.current = readId;
|
|
146
|
+
queueMicrotask(() => { if (rereadStartedThisTurnRef.current === readId)
|
|
147
|
+
rereadStartedThisTurnRef.current = null; });
|
|
148
|
+
openVendorHold(readId);
|
|
149
|
+
}), [on, openVendorHold]);
|
|
150
|
+
useEffect(() => on(FrontendEvents.OWN_PREFERENCES_REREAD_SETTLED, ({ readId, privacy }) => {
|
|
151
|
+
// Only the answer this hold waits for: an earlier read's answer, or none started yet, decides nothing about it.
|
|
152
|
+
if (vendorHoldRef.current?.readId !== readId)
|
|
153
|
+
return;
|
|
154
|
+
releaseVendorHold(privacy !== null && hasGrantedConsentPurposes(normalizeConsentPurposes(privacy.consentedPurposes), [ConsentPurpose.ANALYTICS]));
|
|
155
|
+
}), [on, releaseVendorHold]);
|
|
156
|
+
useEffect(() => () => releaseVendorHold(false), [releaseVendorHold]);
|
|
77
157
|
useEffect(() => {
|
|
78
158
|
return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {
|
|
79
159
|
/*
|
|
@@ -91,6 +171,7 @@ export const AnalyticsContextProvider = ({ children, }) => {
|
|
|
91
171
|
providersRef.current.forEach(p => p.discard());
|
|
92
172
|
};
|
|
93
173
|
if (payload.privacy === null) {
|
|
174
|
+
releaseVendorHold(false);
|
|
94
175
|
discardUnsent();
|
|
95
176
|
setAccountPurposes([]);
|
|
96
177
|
return;
|
|
@@ -100,12 +181,17 @@ export const AnalyticsContextProvider = ({ children, }) => {
|
|
|
100
181
|
// must reach the gate below, which is why this does not test truthiness.
|
|
101
182
|
if (purposes !== undefined) {
|
|
102
183
|
const granted = normalizeConsentPurposes(purposes);
|
|
103
|
-
|
|
184
|
+
const analyticsGranted = hasGrantedConsentPurposes(granted, [ConsentPurpose.ANALYTICS]);
|
|
185
|
+
// A held own-preferences write is NOT decided here: this announcement may carry the pre-write record (see the
|
|
186
|
+
// hold above). Only a withdrawal acts on it, by dropping what was held, which can never send too much.
|
|
187
|
+
if (!analyticsGranted) {
|
|
188
|
+
releaseVendorHold(false);
|
|
104
189
|
discardUnsent();
|
|
190
|
+
}
|
|
105
191
|
setAccountPurposes(granted);
|
|
106
192
|
}
|
|
107
193
|
});
|
|
108
|
-
}, [on]);
|
|
194
|
+
}, [on, releaseVendorHold]);
|
|
109
195
|
/*
|
|
110
196
|
* The person `USER_LOGIN` announced, until `USER_LOGOUT` (#1977). Kept because the two arrive in the
|
|
111
197
|
* wrong order for the built-in destinations: `UserOrgsProvider` announces the person once their
|
|
@@ -394,10 +480,17 @@ export const AnalyticsContextProvider = ({ children, }) => {
|
|
|
394
480
|
const event = { name, properties, timestamp: Date.now() };
|
|
395
481
|
if (isActive)
|
|
396
482
|
providersRef.current.forEach(p => p.track(event));
|
|
397
|
-
|
|
483
|
+
// An event about a write to the person's own preferences waits for the consent that write leaves (see the hold).
|
|
484
|
+
if (name === AnalyticsEventName.RESOURCE_OPERATION && properties?.resourceType === CoreResourceType.USER_SELF_PREFERENCES)
|
|
485
|
+
openVendorHold();
|
|
486
|
+
const toVendors = () => vendorSinks.forEach(sink => sink.track({ name, properties }));
|
|
487
|
+
if (vendorHoldRef.current)
|
|
488
|
+
vendorHoldRef.current.held.push(toVendors);
|
|
489
|
+
else
|
|
490
|
+
toVendors();
|
|
398
491
|
// Forward to bridge interceptor for CUSTOM_EVENT / FEATURE_ACCESS signal evaluation
|
|
399
492
|
onTrackRef.current?.(name, properties);
|
|
400
|
-
}, [isActive, isDispatching, vendorSinks]);
|
|
493
|
+
}, [isActive, isDispatching, vendorSinks, openVendorHold]);
|
|
401
494
|
lifecycleTrackRef.current = track;
|
|
402
495
|
// Deliver a decided sign-in to each kind of destination as that kind starts — see the block above.
|
|
403
496
|
useEffect(() => {
|
|
@@ -426,7 +519,11 @@ export const AnalyticsContextProvider = ({ children, }) => {
|
|
|
426
519
|
return;
|
|
427
520
|
if (isActive)
|
|
428
521
|
providersRef.current.forEach(p => p.page(path, properties));
|
|
429
|
-
vendorSinks.forEach(sink => sink.page(path, properties));
|
|
522
|
+
const toVendors = () => vendorSinks.forEach(sink => sink.page(path, properties));
|
|
523
|
+
if (vendorHoldRef.current)
|
|
524
|
+
vendorHoldRef.current.held.push(toVendors);
|
|
525
|
+
else
|
|
526
|
+
toVendors();
|
|
430
527
|
}, [isActive, isDispatching, vendorSinks]);
|
|
431
528
|
// ─── Render ───────────────────────────────────────────────────
|
|
432
529
|
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,gBAAgB,EAAE,sBAAsB,EAAwB,qCAAqC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AC9E,IAAI,CAAC,aAAa;YAAE,OAAO;QAC3B,IAAI,QAAQ;YAAE,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QAC1E,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3D,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, 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/AnalyticsContext.tsx"],"names":[],"mappings":";AAA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AAe,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, 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 answer\n * to the re-read the write started (`OWN_PREFERENCES_REREAD_SETTLED` with that read's number) closes it, delivering\n * them only while ANALYTICS is still granted. Nothing else closes it with a delivery: `UserOrgsProvider` re-announces\n * the PRE-write record whenever its organizations change, and an earlier write's re-read can land inside this one's\n * window, and either would have released the withdrawal's own event under the old grant (#3928 review). A sign-out\n * (`privacy: null`) drops them, and so does a re-read that fails or never lands (after the bound): an event whose\n * 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 /** `readId` is the re-read this hold waits for: `null` until one starts while the hold is open. */\n const vendorHoldRef = useRef<{ held: Array<() => void>; timer: ReturnType<typeof setTimeout>; readId: number | null } | 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 /**\n * The re-read started in the CURRENT synchronous turn, if any; cleared at the end of the turn. A write's success\n * notification, its outcome and the re-read it starts are emitted in ONE turn, in either order (`handleSubmit` →\n * `NOTIFY_RESOURCE_SUCCESS` → `onSuccess` → `announceOutcome` for a main save; outcome first for a section save), so a\n * network answer can never land between them. An event tracked about a write therefore belongs to the re-read started\n * in its turn, or to the next one; a re-read started in an earlier turn answers an earlier write.\n */\n const rereadStartedThisTurnRef = useRef<number | null>(null);\n /**\n * Open the hold, or restart its bound when it is already open. `readId`: the re-read that just started, which every\n * earlier write is also seen by. Without one (the `track` door), the hold waits for the re-read of this turn, or the next.\n */\n const openVendorHold = useCallback((readId?: number): void => {\n const previous = vendorHoldRef.current;\n if (previous) clearTimeout(previous.timer);\n vendorHoldRef.current = {\n held: previous?.held ?? [],\n timer: setTimeout(() => releaseVendorHold(false), OWN_PREFERENCES_WRITE_HOLD_MS),\n readId: readId ?? rereadStartedThisTurnRef.current,\n };\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 re-read the write starts opens it\n * (or, if `track` opened it, names the read it waits for). The re-read rather than the outcome: it is the one thing\n * the hold waits on, so opening on it cannot miss it whichever provider hears the outcome first.\n */\n useEffect(() => on(FrontendEvents.OWN_PREFERENCES_REREAD_STARTED, ({ readId }) => {\n rereadStartedThisTurnRef.current = readId;\n queueMicrotask(() => { if (rereadStartedThisTurnRef.current === readId) rereadStartedThisTurnRef.current = null; });\n openVendorHold(readId);\n }), [on, openVendorHold]);\n useEffect(() => on(FrontendEvents.OWN_PREFERENCES_REREAD_SETTLED, ({ readId, privacy }) => {\n // Only the answer this hold waits for: an earlier read's answer, or none started yet, decides nothing about it.\n if (vendorHoldRef.current?.readId !== readId) return;\n releaseVendorHold(privacy !== null && hasGrantedConsentPurposes(normalizeConsentPurposes(privacy.consentedPurposes), [ConsentPurpose.ANALYTICS]));\n }), [on, releaseVendorHold]);\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 // A held own-preferences write is NOT decided here: this announcement may carry the pre-write record (see the\n // hold above). Only a withdrawal acts on it, by dropping what was held, which can never send too much.\n if (!analyticsGranted) {\n releaseVendorHold(false);\n discardUnsent();\n }\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,W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AAU,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
|
-
|
|
209
|
-
|
|
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,
|