@wildo-ai/saas-frontend-lib 1.1.14 → 1.1.16
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/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/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/flows-actors/approval.labels.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/approval.labels.js +3 -0
- package/dist/esm/components/flows-actors/approval.labels.js.map +1 -1
- package/dist/esm/components/flows-actors/task-detail.d.ts +12 -1
- package/dist/esm/components/flows-actors/task-detail.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/task-detail.js +2 -2
- package/dist/esm/components/flows-actors/task-detail.js.map +1 -1
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts +79 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js +271 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts +3 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js +66 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js.map +1 -0
- package/dist/esm/components/settings/SettingsHub.d.ts.map +1 -1
- package/dist/esm/components/settings/SettingsHub.js +6 -0
- package/dist/esm/components/settings/SettingsHub.js.map +1 -1
- package/dist/esm/components/views/composite-view/CompositeView.d.ts +6 -0
- package/dist/esm/components/views/composite-view/CompositeView.d.ts.map +1 -1
- package/dist/esm/components/views/composite-view/CompositeView.js +12 -2
- package/dist/esm/components/views/composite-view/CompositeView.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts +57 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts.map +1 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js +136 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js.map +1 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts +20 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js +139 -22
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js +5 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts +4 -0
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js +19 -0
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts +26 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts.map +1 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js +3 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js.map +1 -0
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.d.ts.map +1 -1
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js +1 -0
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js.map +1 -1
- package/dist/esm/core/config/composite-view.schemas.d.ts +19 -0
- package/dist/esm/core/config/composite-view.schemas.d.ts.map +1 -1
- package/dist/esm/core/config/composite-view.schemas.js.map +1 -1
- package/dist/esm/core/config/engine-settings-destinations.d.ts.map +1 -1
- package/dist/esm/core/config/engine-settings-destinations.js +23 -0
- package/dist/esm/core/config/engine-settings-destinations.js.map +1 -1
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.d.ts.map +1 -1
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js +3 -0
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js.map +1 -1
- package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts +12 -0
- package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts.map +1 -1
- package/dist/esm/core/config/settings-hub.frontend.schemas.js +12 -0
- package/dist/esm/core/config/settings-hub.frontend.schemas.js.map +1 -1
- package/dist/esm/core/events/events.frontend.schemas.d.ts +56 -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/flows-actors/FlowsActorsContext.d.ts +10 -1
- package/dist/esm/core/flows-actors/FlowsActorsContext.d.ts.map +1 -1
- package/dist/esm/core/flows-actors/FlowsActorsContext.js +12 -3
- package/dist/esm/core/flows-actors/FlowsActorsContext.js.map +1 -1
- package/dist/esm/core/flows-actors/conversation-history.model.d.ts +19 -1
- package/dist/esm/core/flows-actors/conversation-history.model.d.ts.map +1 -1
- package/dist/esm/core/flows-actors/conversation-history.model.js +45 -4
- package/dist/esm/core/flows-actors/conversation-history.model.js.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js +50 -18
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js.map +1 -1
- package/dist/esm/core/navigation/NavigationContentAreas.d.ts +0 -5
- package/dist/esm/core/navigation/NavigationContentAreas.d.ts.map +1 -1
- package/dist/esm/core/navigation/NavigationContentAreas.js +27 -1
- package/dist/esm/core/navigation/NavigationContentAreas.js.map +1 -1
- package/dist/esm/core/navigation/navigation.schemas.d.ts +20 -0
- package/dist/esm/core/navigation/navigation.schemas.d.ts.map +1 -1
- package/dist/esm/core/navigation/navigation.schemas.js +4 -0
- package/dist/esm/core/navigation/navigation.schemas.js.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js +5 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts +20 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js +25 -0
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.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/resources-repository.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/resources/resources-repository.frontend.service.js +2 -0
- package/dist/esm/core/resources/resources-repository.frontend.service.js.map +1 -1
- package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
- package/dist/esm/core/runtime/AppRouter.js +2 -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/runtime/routes.frontend.definitions.d.ts +6 -0
- package/dist/esm/core/runtime/routes.frontend.definitions.d.ts.map +1 -1
- package/dist/esm/core/runtime/routes.frontend.definitions.js +7 -1
- package/dist/esm/core/runtime/routes.frontend.definitions.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 +35 -11
- 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/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 +6 -6
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* consent gating, and provider lifecycle management.
|
|
7
7
|
*/
|
|
8
8
|
import { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
-
import { AnalyticsEventName, BUILTIN_PROVIDER_CAPABILITY, ConsentPurpose, CoreResourceType, hasGrantedConsentPurposes,
|
|
9
|
+
import { AnalyticsEventName, BUILTIN_PROVIDER_CAPABILITY, ConsentPurpose, CoreResourceType, hasGrantedConsentPurposes, normalizeConsentPurposes, ValueMomentRole, ValueMomentScope, AnalyticsTriggerSource, ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX } from '@wildo-ai/saas-models';
|
|
10
10
|
import { AnalyticsProviderRegistry } from './analytics-provider-registry.frontend.service.js';
|
|
11
11
|
import { ApplicationContext } from '../../../core/runtime/ApplicationContext.shared.js';
|
|
12
12
|
import { useEventBus } from '../../../core/events/useEventBus.js';
|
|
@@ -87,15 +87,18 @@ export const AnalyticsContextProvider = ({ children, }) => {
|
|
|
87
87
|
* that very write reach PostHog 3 s later. The bridge captured it on `NOTIFY_RESOURCE_SUCCESS`, while the page still
|
|
88
88
|
* held the grant; `UserOrgsProvider` re-reads the record on the write's `RESOURCE_OPERATION_EXECUTED` (#1973), and
|
|
89
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
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* event
|
|
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.
|
|
95
97
|
*
|
|
96
98
|
* Vendor sinks only: a built-in destination keeps what it buffered until it flushes, and a withdrawal already drops
|
|
97
99
|
* that buffer (`discardUnsent` below).
|
|
98
100
|
*/
|
|
101
|
+
/** `readId` is the re-read this hold waits for: `null` until one starts while the hold is open. */
|
|
99
102
|
const vendorHoldRef = useRef(null);
|
|
100
103
|
const releaseVendorHold = useCallback((deliver) => {
|
|
101
104
|
const hold = vendorHoldRef.current;
|
|
@@ -107,22 +110,49 @@ export const AnalyticsContextProvider = ({ children, }) => {
|
|
|
107
110
|
hold.held.forEach((call) => call());
|
|
108
111
|
}, []);
|
|
109
112
|
/** Open the hold, or restart its bound when it is already open (a second write before the first one's answer). */
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
};
|
|
115
134
|
}, [releaseVendorHold]);
|
|
116
135
|
/*
|
|
117
136
|
* Two doors open it, because the two announcements of one write arrive in either order. A form's SECTION save announces
|
|
118
137
|
* the outcome (`RESOURCE_OPERATION_EXECUTED`) before its success notification; its MAIN save notifies success first,
|
|
119
138
|
* and the bridge captures `resource_operation` from that notification before the outcome is announced (measured in the
|
|
120
139
|
* browser: the hold opened by the outcome alone missed the Preferences page's Save). So an analytics event ABOUT a
|
|
121
|
-
* write to the person's own preferences opens the hold itself, in `track`, and the
|
|
122
|
-
*
|
|
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.
|
|
123
143
|
*/
|
|
124
|
-
useEffect(() => on(FrontendEvents.
|
|
125
|
-
|
|
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]);
|
|
126
156
|
useEffect(() => () => releaseVendorHold(false), [releaseVendorHold]);
|
|
127
157
|
useEffect(() => {
|
|
128
158
|
return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {
|
|
@@ -152,10 +182,12 @@ export const AnalyticsContextProvider = ({ children, }) => {
|
|
|
152
182
|
if (purposes !== undefined) {
|
|
153
183
|
const granted = normalizeConsentPurposes(purposes);
|
|
154
184
|
const analyticsGranted = hasGrantedConsentPurposes(granted, [ConsentPurpose.ANALYTICS]);
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
if (!analyticsGranted)
|
|
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);
|
|
158
189
|
discardUnsent();
|
|
190
|
+
}
|
|
159
191
|
setAccountPurposes(granted);
|
|
160
192
|
}
|
|
161
193
|
});
|
|
@@ -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,qBAAqB,EAAE,wBAAwB,EAAE,eAAe,EAAE,gBAAgB,EAAE,sBAAsB,EAAwB,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAE9T,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4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qBAAqB;QACrB,eAAe;QACf,kBAAkB;QAClB,WAAW,EAAE,UAAU;KACxB,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAE9F,OAAO,CACL,KAAC,iCAAiC,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YAClE,MAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,aAC3C,aAAa,IAAI,QAAQ,IAAI,eAAe,IAAI,CAC/C,KAAC,oBAAoB,IAEnB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,cAAc,CAAC,OAAO,EAChC,MAAM,EAAE,eAAe,CAAC,mBAAmB,EAC3C,YAAY,EAAE,eAAe,CAAC,YAAY,IAJrC,GAAG,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,CAKrE,CACH,EACA,QAAQ,IACiB,GACiB,CAC9C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Analytics Context Provider\n * \n * Provides analytics tracking, value moment achievement persistence,\n * consent gating, and provider lifecycle management.\n */\n\nimport React, { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { AnalyticsEventName, BUILTIN_PROVIDER_CAPABILITY, ConsentPurpose, CoreResourceType, hasGrantedConsentPurposes, isReadShapedOperation, normalizeConsentPurposes, ValueMomentRole, ValueMomentScope, AnalyticsTriggerSource, type AnalyticsConfig, ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX } from '@wildo-ai/saas-models';\nimport type { IAnalyticsProvider, AnalyticsEvent } from './analytics-provider.frontend.interface';\nimport { AnalyticsProviderRegistry } from './analytics-provider-registry.frontend.service';\nimport { ApplicationContext } from '~wildo-frontend-lib/core/runtime/ApplicationContext.shared';\nimport { useEventBus } from '~wildo-frontend-lib/core/events/useEventBus';\nimport { FrontendEvents, SessionEndReason, SessionEstablishment } from '~wildo-frontend-lib/core/events/events.frontend.schemas';\nimport { getManualCallsHttpClient } from '~wildo-frontend-lib/core/requests/wildo-http-client-manual-calls.frontend.service';\nimport { useResourceReachability } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport { AnalyticsEventBridge, type AnalyticsMomentProgress } from './AnalyticsEventBridge';\nimport { isFrontendProductAnalyticsSink, type FrontendProductAnalyticsSink } from '@wildo-ai/saas-models/public-runtime';\nimport { useConsentBasedProviderActivations } from '~wildo-frontend-lib/core/external-providers/ConsentBasedProviderSdks';\n\n// ─── Context Value Interface ────────────────────────────────────\n\nexport interface AnalyticsContextValue {\n /** Track a custom event (app-custom usage) */\n track: (name: string, properties?: Record<string, unknown>) => void;\n /** Track a page view */\n page: (path: string, properties?: Record<string, unknown>) => void;\n /** Whether analytics is active (enabled + consent granted) */\n isActive: boolean;\n /** Session start timestamp (for TTFV computation) */\n sessionStartTimestamp: number;\n /** Set of achieved value moment identifiers (scope-aware, persisted) */\n achievedMoments: Set<string>;\n /** Mark a value moment as achieved (persists to localStorage + backend sync) */\n markMomentAchieved: (identifier: string) => boolean | Promise<boolean>;\n /**\n * Internal: ref for track() call interception (used by AnalyticsEventBridge).\n * The bridge registers a callback on mount to evaluate CUSTOM_EVENT and\n * FEATURE_ACCESS signals when track() is called.\n * @internal\n */\n _onTrackRef: React.MutableRefObject<((name: string, properties?: Record<string, unknown>) => void) | null>;\n}\n\n// ─── Context ────────────────────────────────────────────────────\n\n// Note: useAnalytics hook is in a separate file (useAnalytics.ts) for React Fast Refresh compatibility.\nexport const AnalyticsContext = createContext<AnalyticsContextValue | null>(null);\n\n/** Identity snapshots come from the mounted AppScope owner, never a decoded token or a late event. */\nexport interface AnalyticsIdentity {\n userId: string | null;\n organizationId: string | null;\n applicationId: string | null;\n anonymousUserId: string | null;\n}\nexport const AnalyticsIdentityPublisherContext = createContext<((identity: AnalyticsIdentity) => () => void) | null>(null);\n\n// ─── Provider Registry (singleton) ──────────────────────────────\n\nconst providerRegistry = new AnalyticsProviderRegistry();\n\n/** The event property carrying when a held sign-in happened, for destinations that stamp events themselves. */\nconst SIGNED_IN_AT_PROPERTY = 'signed_in_at';\n\n/**\n * A sign-in announced before this tab knows whether the person consented to analytics (#1977): when it\n * happened, whether the person's own preferences have decided it, and which kinds of destination it\n * is still owed to.\n */\ninterface HeldSignIn {\n readonly occurredAt: number;\n readonly decided: boolean;\n readonly owedToBuiltIns: boolean;\n readonly owedToVendorSinks: boolean;\n}\n\n// ─── Provider Component ─────────────────────────────────────────\n\nexport interface AnalyticsContextProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Two kinds of destination, and only ONE of them is a vendor (#1704).\n *\n * - The ENGINE's own destinations (`console`, `backend_proxy`), selected by `analytics.providers`. They send\n * nothing to a third party (the proxy posts to the application's own backend), and they keep the gate\n * below: `analytics.enabled`, then `analytics.requiresConsent` / the ANALYTICS grant.\n * - VENDORS (PostHog, …) arrive as `FRONTEND_PRODUCT_ANALYTICS` provider modules. They are started by the\n * consent-based activation consumer once the person grants what they rest on, and stopped on withdrawal\n * or sign-out; this context only dispatches to the sinks that are running. That replaced an\n * `analyticsProviders` / `customProviders` door which let an application pass a vendor client here,\n * behind a second consent gate and outside the CSP footprint — two gates for one decision.\n *\n * `analytics.enabled` stays the master switch for both: with it off, a `FRONTEND_PRODUCT_ANALYTICS` vendor is not\n * even loaded (the consent-based consumer skips it), and any sink that is running receives nothing.\n */\n/**\n * How long vendor calls made because of a write to the person's own preferences wait for the stored consent (#3928).\n * The re-read normally answers in a fraction of a second; past this the held calls are dropped, never sent.\n */\nconst OWN_PREFERENCES_WRITE_HOLD_MS = 10_000;\n\nexport const AnalyticsContextProvider: React.FC<AnalyticsContextProviderProps> = ({\n children,\n}) => {\n const appContext = useContext(ApplicationContext);\n const { on } = useEventBus();\n // Whether this consumer serves the progression-backed analytics routes at all (#1069).\n const momentsReachable = useResourceReachability(CoreResourceType.USER_PROGRESSION_STATE);\n const providersRef = useRef<IAnalyticsProvider[]>([]);\n const [isActive, setIsActive] = useState(false);\n\n // Session start: captured once at mount\n const sessionStartTimestamp = useRef(Date.now()).current;\n\n // Resolve analytics config from ApplicationContext\n const analyticsConfig = useMemo<AnalyticsConfig | undefined>(\n () => appContext?.appConfig?.analytics,\n [appContext?.appConfig?.analytics],\n );\n\n // ─── Consent gating ─────────────────────────────────────────\n\n /*\n * The purposes the signed-in person granted — a SET (#534). Starts EMPTY, never at a level: nothing\n * is known to be granted until the person's preferences arrive, and analytics that started on an\n * assumed consent would already have sent data by the time the real answer said otherwise.\n *\n * This used to hold one `DataProcessingConsent` and compare it against a module-private\n * `CONSENT_ORDER` with `>=`, which asserted that agreeing to marketing implied agreeing to analytics\n * — a claim nobody decided. Membership of ANALYTICS is the whole test now.\n */\n /*\n * ONE subject grants: the signed-in ACCOUNT.\n *\n * A second, VISITOR tier lived here briefly (#1258 Step 1d) and was removed on 2026-09-20 with the\n * pre-auth panel that fed it — see `PublicLayout_MainContainer` for why that panel went. Nothing\n * publishes a visitor decision to this provider any more, so a visitor tier here would be a state\n * nothing can ever set: the application's public pages run no consent-based analytics, which is the\n * behaviour they had before the panel existed and is the safe direction.\n *\n * `null` means \"nothing has been said\", which is not the same as granting nothing — an empty array\n * is a real, recorded withdrawal and must gate. That distinction is why this is not a bare array.\n */\n const [accountPurposes, setAccountPurposes] = useState<readonly ConsentPurpose[] | null>(null);\n const grantedPurposes = useMemo<readonly ConsentPurpose[]>(() => accountPurposes ?? [], [accountPurposes]);\n\n /*\n * A write to the person's own preferences can change their consent, so what a vendor receives because of it is\n * decided against the consent the write LEAVES, never the one the page held before it (#3928).\n *\n * Measured in a real browser with PostHog: a withdrawal on the Preferences page let the `resource_operation` event of\n * that very write reach PostHog 3 s later. The bridge captured it on `NOTIFY_RESOURCE_SUCCESS`, while the page still\n * held the grant; `UserOrgsProvider` re-reads the record on the write's `RESOURCE_OPERATION_EXECUTED` (#1973), and\n * the vendor's `deactivate` ran after its SDK had queued the event (posthog-js's opt-out does not empty its send\n * queue, and offers no public way to). So the write OPENS a hold: vendor calls queue while it is open, and the next\n * privacy-carrying `USER_PREFERENCES_CHANGED` (the re-read's) closes it, delivering them only while ANALYTICS is\n * still granted. A form emits the outcome before its success notification, so the hold is open before the bridge\n * captures. A sign-out (`privacy: null`) drops them, and a re-read that never lands drops them after the bound: an\n * event whose consent is unknown is not sent.\n *\n * Vendor sinks only: a built-in destination keeps what it buffered until it flushes, and a withdrawal already drops\n * that buffer (`discardUnsent` below).\n */\n const vendorHoldRef = useRef<{ held: Array<() => void>; timer: ReturnType<typeof setTimeout> } | null>(null);\n const releaseVendorHold = useCallback((deliver: boolean): void => {\n const hold = vendorHoldRef.current;\n if (hold === null) return;\n vendorHoldRef.current = null;\n clearTimeout(hold.timer);\n if (deliver) hold.held.forEach((call) => call());\n }, []);\n /** Open the hold, or restart its bound when it is already open (a second write before the first one's answer). */\n const openVendorHold = useCallback((): void => {\n const held = vendorHoldRef.current?.held ?? [];\n if (vendorHoldRef.current) clearTimeout(vendorHoldRef.current.timer);\n vendorHoldRef.current = { held, timer: setTimeout(() => releaseVendorHold(false), OWN_PREFERENCES_WRITE_HOLD_MS) };\n }, [releaseVendorHold]);\n /*\n * Two doors open it, because the two announcements of one write arrive in either order. A form's SECTION save announces\n * the outcome (`RESOURCE_OPERATION_EXECUTED`) before its success notification; its MAIN save notifies success first,\n * and the bridge captures `resource_operation` from that notification before the outcome is announced (measured in the\n * browser: the hold opened by the outcome alone missed the Preferences page's Save). So an analytics event ABOUT a\n * write to the person's own preferences opens the hold itself, in `track`, and the outcome opens it for whatever else\n * follows the write.\n */\n useEffect(() => on(\n FrontendEvents.RESOURCE_OPERATION_EXECUTED,\n () => openVendorHold(),\n (payload) => payload.resourceType === CoreResourceType.USER_SELF_PREFERENCES\n && !isReadShapedOperation(payload.operation ?? { operationIdentifier: payload.operationIdentifier }),\n ), [on, openVendorHold]);\n useEffect(() => () => releaseVendorHold(false), [releaseVendorHold]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {\n /*\n * `privacy: null` is the CLEARED state — sign-out, or an identity with no preferences. It must\n * revoke: the old handler ignored it, so a signed-out browser kept the previous person's consent\n * and analytics kept running for whoever used it next.\n */\n /*\n * A withdrawal drops what the destinations buffered, before the gate below shuts them down: their\n * shutdown flushes, and events collected under the grant are not sent after it is withdrawn (#1977\n * review). A sign-out already sent its person's buffer, under their consent, on `USER_LOGOUT`.\n */\n const discardUnsent = (): void => {\n if (requiresConsentRef.current) providersRef.current.forEach(p => p.discard());\n };\n if (payload.privacy === null) {\n releaseVendorHold(false);\n discardUnsent();\n setAccountPurposes([]);\n return;\n }\n const purposes = payload.privacy?.consentedPurposes;\n // `undefined` means this event carried no privacy block; an EMPTY set is a real withdrawal and\n // must reach the gate below, which is why this does not test truthiness.\n if (purposes !== undefined) {\n const granted = normalizeConsentPurposes(purposes);\n const analyticsGranted = hasGrantedConsentPurposes(granted, [ConsentPurpose.ANALYTICS]);\n // Before the gate changes: what an own-preferences write held is decided by this, the stored consent.\n releaseVendorHold(analyticsGranted);\n if (!analyticsGranted) discardUnsent();\n setAccountPurposes(granted);\n }\n });\n }, [on, releaseVendorHold]);\n\n\n /*\n * The person `USER_LOGIN` announced, until `USER_LOGOUT` (#1977). Kept because the two arrive in the\n * wrong order for the built-in destinations: `UserOrgsProvider` announces the person once their\n * context has loaded, which is also when their preferences — and so their ANALYTICS grant — arrive,\n * and the destinations below are initialised asynchronously after that grant. An identify sent only\n * when the event fires would reach no destination, so each one is identified again as it starts.\n */\n const signedInUserIdRef = useRef<string | null>(null);\n const [builtInsStartedVersion, setBuiltInsStartedVersion] = useState(0);\n /** The latest `track`, for the departure listener, which must send while the grant still holds. */\n const lifecycleTrackRef = useRef<(name: string) => void>(() => {});\n\n // Initialize/teardown providers based on config + consent\n useEffect(() => {\n if (!analyticsConfig?.enabled) {\n setIsActive(false);\n return;\n }\n\n const hasConsent = analyticsConfig.requiresConsent === false\n || hasGrantedConsentPurposes(grantedPurposes, [ConsentPurpose.ANALYTICS]);\n\n if (!hasConsent) {\n providersRef.current.forEach(p => p.reset());\n setIsActive(false);\n return;\n }\n\n let aborted = false;\n\n const httpClient = getManualCallsHttpClient();\n const builtInProviders = providerRegistry.resolveFromConfig(\n analyticsConfig.providers ?? [],\n httpClient,\n );\n const allProviders = [...builtInProviders];\n\n Promise.all(\n allProviders.map(p =>\n p.initialize(analyticsConfig.providers?.find(c => c.providerType === p.name)?.config).catch(err => {\n console.warn(`[Analytics] Failed to initialize provider \"${p.name}\":`, err);\n })\n )\n ).then(() => {\n if (aborted) return;\n providersRef.current = allProviders;\n const signedInUserId = signedInUserIdRef.current;\n if (signedInUserId !== null) allProviders.forEach(p => p.identify({ userId: signedInUserId }));\n setIsActive(true);\n // `isActive` may already be true (a re-initialisation on a changed grant), so this is what tells a\n // held sign-in that a fresh set of destinations has started.\n setBuiltInsStartedVersion(version => version + 1);\n });\n\n return () => {\n aborted = true;\n allProviders.forEach(p => p.shutdown().catch(() => {}));\n providersRef.current = [];\n };\n }, [analyticsConfig, grantedPurposes]);\n\n // The vendor sinks currently running (#1704) — empty until the person grants ANALYTICS, emptied on\n // withdrawal or sign-out. Behind the same master switch as the built-in destinations.\n const consentBasedActivations = useConsentBasedProviderActivations();\n const vendorSinks = useMemo<readonly FrontendProductAnalyticsSink[]>(() => {\n if (!analyticsConfig?.enabled) return [];\n return consentBasedActivations\n .filter((running) => running.providerCapabilities.includes(BUILTIN_PROVIDER_CAPABILITY.FRONTEND_PRODUCT_ANALYTICS))\n .map((running) => running.activation.handle)\n .filter(isFrontendProductAnalyticsSink);\n }, [analyticsConfig?.enabled, consentBasedActivations]);\n const isDispatching = isActive || vendorSinks.length > 0;\n\n /*\n * The person's arrival and departure (#1977) — identity for every destination, and the sign-in /\n * sign-out analytics events (`autoInstrumentation.userLifecycle`).\n *\n * Handled HERE rather than in `AnalyticsEventBridge`, which is keyed on the published identity and is\n * therefore remounted by exactly the transitions these events announce, and which only listens while\n * analytics is already dispatching. Two consequences of the order things happen in:\n *\n * - A sign-in is announced when the person's context loads, and their ANALYTICS grant arrives with\n * their preferences a moment later; so the sign-in event is HELD, stamped with the instant it\n * happened. It is decided by the person's own preferences: if they carry the ANALYTICS grant (the\n * grant the person had already recorded before this sign-in, so the sign-in happened under it), the\n * event is sent to each kind of destination as that kind starts — the built-in destinations after\n * their asynchronous initialisation, the vendor sinks when the consent-based phase starts them. If\n * they do not, the event is DROPPED rather than sent after some later grant: an event that happened\n * while the person had not consented is not collected retroactively. A departure drops it too, and\n * a later withdrawal drops whatever has not been delivered yet. An application whose analytics does\n * not rest on consent (`requiresConsent: false`) needs no decision.\n * - A sign-out is announced BEFORE the sign-out publishes `privacy: null` (see `UserOrgsProvider`), so\n * the event is sent while the person's grant still holds, and only then is the identity reset —\n * `track` then `reset`, the order an analytics client expects.\n *\n * Only a sign-in in this tab and the person's own sign-out are COUNTED; a resumed session, a session\n * the backend ended, one ended in another tab and one replaced by another person are identity changes\n * only (see `SessionEstablishment` / `SessionEndReason`).\n */\n const userLifecycleTracking = analyticsConfig?.autoInstrumentation?.userLifecycle === true;\n const userLifecycleTrackingRef = useRef(userLifecycleTracking);\n userLifecycleTrackingRef.current = userLifecycleTracking;\n const requiresConsent = analyticsConfig?.requiresConsent !== false;\n const requiresConsentRef = useRef(requiresConsent);\n requiresConsentRef.current = requiresConsent;\n const heldSignInRef = useRef<HeldSignIn | null>(null);\n /** Re-runs the delivery effect below when a held sign-in is decided (a ref alone would not). */\n const [heldSignInVersion, setHeldSignInVersion] = useState(0);\n const holdSignIn = useCallback((next: HeldSignIn | null) => {\n heldSignInRef.current = next;\n setHeldSignInVersion(version => version + 1);\n }, []);\n useEffect(() => {\n return on(FrontendEvents.USER_LOGIN, (payload) => {\n signedInUserIdRef.current = payload.userId;\n providersRef.current.forEach(p =>\n p.identify({ userId: payload.userId })\n );\n if (payload.establishment === SessionEstablishment.SIGNED_IN) {\n holdSignIn({ occurredAt: Date.now(), decided: !requiresConsentRef.current, owedToBuiltIns: true, owedToVendorSinks: true });\n }\n });\n }, [on, holdSignIn]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_PREFERENCES_CHANGED, (payload) => {\n const held = heldSignInRef.current;\n // `privacy: null` is a sign-out's clearing, not this person's decision; a departure already dropped the hold.\n if (held === null || !requiresConsentRef.current || !payload.privacy) return;\n const purposes = payload.privacy.consentedPurposes;\n if (purposes === undefined) return;\n holdSignIn(hasGrantedConsentPurposes(normalizeConsentPurposes(purposes), [ConsentPurpose.ANALYTICS]) ? { ...held, decided: true } : null);\n });\n }, [on, holdSignIn]);\n\n useEffect(() => {\n return on(FrontendEvents.USER_LOGOUT, (payload) => {\n if (payload.reason === SessionEndReason.SIGNED_OUT && userLifecycleTrackingRef.current) {\n lifecycleTrackRef.current(AnalyticsEventName.USER_LOGOUT);\n }\n holdSignIn(null);\n signedInUserIdRef.current = null;\n providersRef.current.forEach(p => p.reset());\n });\n }, [on, holdSignIn]);\n\n // ─── Achieved moments persistence ─────────────────────────────\n\n const [identity, setIdentity] = useState<AnalyticsIdentity | null>(null);\n const identityOwner = useRef<symbol | null>(null);\n const publishIdentity = useCallback((next: AnalyticsIdentity) => {\n const owner = Symbol();\n identityOwner.current = owner;\n setIdentity(next);\n return () => {\n if (identityOwner.current === owner) { identityOwner.current = null; setIdentity(null); }\n };\n }, []);\n const identityKey = JSON.stringify(identity);\n\n /*\n * Who a running vendor sink attributes events to (#1704): the person the mounted app scope publishes\n * (`publishIdentity`), which is the identity this provider already trusts for value moments. Keyed on the\n * user id and on WHICH sinks run, so a sink started later is identified on its first render, and a person\n * who leaves (identity lost) is forgotten by every sink still running. The published identity rather\n * than `USER_LOGIN` / `USER_LOGOUT` because a sink starts whenever the grant arrives, and the identity\n * is STATE a sink started later can read, where the announcement is a moment it would have missed.\n */\n const identifiedUserId = identity?.userId ?? null;\n useEffect(() => {\n if (vendorSinks.length === 0) return;\n if (identifiedUserId !== null) vendorSinks.forEach(sink => sink.identify({ userId: identifiedUserId }));\n else vendorSinks.forEach(sink => sink.reset());\n }, [vendorSinks, identifiedUserId]);\n const currentIdentityKey = useRef(identityKey);\n currentIdentityKey.current = identityKey;\n const momentProgress = useRef<AnalyticsMomentProgress>({ signals: new Map(), counts: new Map(), lastFired: new Map(), completed: new Set() });\n const userStorageKey = identity?.userId\n ? `${ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX}${JSON.stringify([identity.applicationId, ValueMomentScope.USER, identity.userId])}` : null;\n const organizationStorageKey = identity?.organizationId\n ? `${ANALYTICS_ACHIEVED_STORAGE_KEY_PREFIX}${JSON.stringify([identity.applicationId, ValueMomentScope.ORGANIZATION, identity.organizationId])}` : null;\n const storageKey = JSON.stringify([userStorageKey, organizationStorageKey]);\n const isOrganizationMoment = useCallback((id: string) =>\n analyticsConfig?.valueMoments?.find(moment => moment.identifier === id)?.scope === ValueMomentScope.ORGANIZATION,\n [analyticsConfig?.valueMoments]);\n const isPersistentMoment = useCallback((id: string) =>\n analyticsConfig?.valueMoments?.find(moment => moment.identifier === id)?.role !== ValueMomentRole.ANTI_PATTERN,\n [analyticsConfig?.valueMoments]);\n\n const [achievementState, setAchievementState] = useState<{key: string; moments: Set<string>}>({key: identityKey, moments: new Set()});\n const achievedMoments = useMemo(() => achievementState.key === identityKey ? achievementState.moments : new Set<string>(), [achievementState, identityKey]);\n const setAchievedMoments = useCallback((update: React.SetStateAction<Set<string>>) => {\n setAchievementState(previous => ({key: identityKey, moments: typeof update === 'function'\n ? update(previous.key === identityKey ? previous.moments : new Set()) : update}));\n }, [identityKey]);\n\n // Helper: persist to localStorage\n const persistToStorage = useCallback((moments: Set<string>) => {\n try {\n if (userStorageKey) localStorage.setItem(userStorageKey, JSON.stringify([...moments].filter(id => !isOrganizationMoment(id))));\n if (organizationStorageKey) localStorage.setItem(organizationStorageKey, JSON.stringify([...moments].filter(isOrganizationMoment)));\n } catch {\n /* quota exceeded — best effort */\n }\n }, [userStorageKey, organizationStorageKey, isOrganizationMoment]);\n\n // Load from localStorage on mount + fetch from backend if backendSync\n useEffect(() => {\n setAchievedMoments(new Set());\n if (!analyticsConfig?.enabled || !identity || (!identity.userId && !identity.organizationId)) return;\n\n // Load from localStorage\n try {\n const loaded = new Set<string>();\n for (const [key, organization] of [[userStorageKey, false], [organizationStorageKey, true]] as const) {\n if (!key) continue;\n const stored = localStorage.getItem(key);\n if (stored) for (const id of JSON.parse(stored) as string[]) {\n if (isPersistentMoment(id) && isOrganizationMoment(id) === organization) loaded.add(id);\n }\n }\n setAchievedMoments(loaded);\n } catch {\n /* corrupt storage — start fresh */\n }\n\n // Fetch from backend if backendSync enabled AND this consumer can reach the route (#1069, the\n // #268 rule): achieved moments are read from the progression store, which a consumer whose\n // registry excludes it does not serve. localStorage still loads above.\n if (analyticsConfig?.persistence?.backendSync && momentsReachable) {\n let aborted = false;\n getManualCallsHttpClient()\n .getAnalyticsMomentsAchieved()\n .then((response: unknown) => {\n if (aborted || currentIdentityKey.current !== identityKey) return;\n const res = response as { moments?: string[] };\n if (res.moments) {\n setAchievedMoments(prev => {\n const merged = new Set([...prev, ...res.moments!].filter(isPersistentMoment));\n persistToStorage(merged);\n return merged;\n });\n }\n })\n .catch(() => {\n /* Backend unavailable — use localStorage only */\n });\n\n return () => { aborted = true; };\n }\n }, [analyticsConfig?.enabled, analyticsConfig?.persistence?.backendSync, momentsReachable, storageKey, identityKey, persistToStorage, isPersistentMoment, isOrganizationMoment]);\n\n // Subscribe to ANALYTICS_MOMENT_ACHIEVED events (backend-pushed via WS)\n useEffect(() => {\n return on(FrontendEvents.ANALYTICS_MOMENT_ACHIEVED, (payload) => {\n if (!identity || payload.triggerSource === AnalyticsTriggerSource.FRONTEND || payload.role === ValueMomentRole.ANTI_PATTERN || !isPersistentMoment(payload.momentIdentifier)) return;\n setAchievedMoments(prev => {\n const next = new Set(prev);\n next.add(payload.momentIdentifier);\n persistToStorage(next);\n return next;\n });\n });\n }, [on, persistToStorage, identityKey, isPersistentMoment]);\n\n const markMomentAchieved = useCallback((identifier: string): boolean | Promise<boolean> => {\n if (!identity || !isPersistentMoment(identifier)) return false;\n const definition = analyticsConfig?.valueMoments?.find(moment => moment.identifier === identifier);\n if (definition?.requires?.some(id => !achievedMoments.has(id)) || definition?.beforeStage?.some(id => achievedMoments.has(id))) return false;\n const record = (): boolean => {\n if (currentIdentityKey.current !== identityKey) return false;\n setAchievedMoments(prev => {\n const next = new Set(prev); next.add(identifier); persistToStorage(next); return next;\n });\n return true;\n };\n if (!analyticsConfig?.persistence?.backendSync) return record();\n // A refused report is not an achievement. Network failures retain the documented best-effort\n // local behavior; explicit server refusals must never be merged back as local truth.\n return getManualCallsHttpClient().postAnalyticsMomentsAchieved({ momentIdentifier: identifier, scope: definition?.scope })\n .then(result => result.success === false ? false : record())\n .catch((error: unknown) => {\n const response = error as {httpStatus?: number; response?: {status?: number}};\n const status = response?.httpStatus ?? response?.response?.status;\n return status && status >= 400 && status < 500 ? false : record();\n });\n }, [analyticsConfig, persistToStorage, identityKey, isPersistentMoment, achievedMoments]);\n\n // ─── Track interceptor ref ────────────────────────────────────\n\n const onTrackRef = useRef<((name: string, properties?: Record<string, unknown>) => void) | null>(null);\n\n const track = useCallback((name: string, properties?: Record<string, unknown>) => {\n if (!isDispatching) return;\n const event: AnalyticsEvent = { name, properties, timestamp: Date.now() };\n if (isActive) providersRef.current.forEach(p => p.track(event));\n // An event about a write to the person's own preferences waits for the consent that write leaves (see the hold).\n if (name === AnalyticsEventName.RESOURCE_OPERATION && properties?.resourceType === CoreResourceType.USER_SELF_PREFERENCES) openVendorHold();\n const toVendors = (): void => vendorSinks.forEach(sink => sink.track({ name, properties }));\n if (vendorHoldRef.current) vendorHoldRef.current.held.push(toVendors);\n else toVendors();\n // Forward to bridge interceptor for CUSTOM_EVENT / FEATURE_ACCESS signal evaluation\n onTrackRef.current?.(name, properties);\n }, [isActive, isDispatching, vendorSinks, openVendorHold]);\n lifecycleTrackRef.current = track;\n\n // Deliver a decided sign-in to each kind of destination as that kind starts — see the block above.\n useEffect(() => {\n const held = heldSignInRef.current;\n if (held === null || !held.decided || !userLifecycleTracking) return;\n const event: AnalyticsEvent = { name: AnalyticsEventName.USER_LOGIN, timestamp: held.occurredAt };\n let owedToBuiltIns = held.owedToBuiltIns;\n let owedToVendorSinks = held.owedToVendorSinks;\n if (owedToBuiltIns && isActive && providersRef.current.length > 0) {\n providersRef.current.forEach(p => p.track(event));\n owedToBuiltIns = false;\n }\n if (owedToVendorSinks && vendorSinks.length > 0) {\n // A vendor sink's `track` takes no timestamp — the vendor stamps receipt — so when the sign-in\n // happened travels as a property, and the vendor-side time may be later than the sign-in.\n vendorSinks.forEach(sink => sink.track({ name: event.name, properties: { [SIGNED_IN_AT_PROPERTY]: new Date(held.occurredAt).toISOString() } }));\n owedToVendorSinks = false;\n }\n if (owedToBuiltIns !== held.owedToBuiltIns || owedToVendorSinks !== held.owedToVendorSinks) {\n heldSignInRef.current = owedToBuiltIns || owedToVendorSinks ? { ...held, owedToBuiltIns, owedToVendorSinks } : null;\n }\n }, [heldSignInVersion, builtInsStartedVersion, isActive, vendorSinks, userLifecycleTracking]);\n\n const page = useCallback((path: string, properties?: Record<string, unknown>) => {\n if (!isDispatching) return;\n if (isActive) providersRef.current.forEach(p => p.page(path, properties));\n const toVendors = (): void => vendorSinks.forEach(sink => sink.page(path, properties));\n if (vendorHoldRef.current) vendorHoldRef.current.held.push(toVendors);\n else toVendors();\n }, [isActive, isDispatching, vendorSinks]);\n\n // ─── Render ───────────────────────────────────────────────────\n\n const contextValue = useMemo<AnalyticsContextValue>(() => ({\n track,\n page,\n isActive: isDispatching,\n sessionStartTimestamp,\n achievedMoments,\n markMomentAchieved,\n _onTrackRef: onTrackRef,\n }), [track, page, isDispatching, sessionStartTimestamp, achievedMoments, markMomentAchieved]);\n\n return (\n <AnalyticsIdentityPublisherContext.Provider value={publishIdentity}>\n <AnalyticsContext.Provider value={contextValue}>\n {isDispatching && identity && analyticsConfig && (\n <AnalyticsEventBridge\n key={`${identityKey}:${JSON.stringify(analyticsConfig.valueMoments)}`}\n identity={identity}\n progress={momentProgress.current}\n config={analyticsConfig.autoInstrumentation}\n valueMoments={analyticsConfig.valueMoments} \n />\n )}\n {children}\n </AnalyticsContext.Provider>\n </AnalyticsIdentityPublisherContext.Provider>\n );\n};\n"]}
|
|
1
|
+
{"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,EAAE,MAAM,uBAAuB,CAAC;AAEvS,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AACjI,OAAO,EAAE,wBAAwB,EAAE,MAAM,mFAAmF,CAAC;AAC7H,OAAO,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAgC,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,8BAA8B,EAAqC,MAAM,sCAAsC,CAAC;AACzH,OAAO,EAAE,kCAAkC,EAAE,MAAM,sEAAsE,CAAC;AA0B1H,mEAAmE;AAEnE,wGAAwG;AACxG,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAC;AASl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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 */\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"]}
|
|
@@ -22,11 +22,6 @@ interface NavigationContentAreasProps {
|
|
|
22
22
|
* or DESTROYS a mounted surface, and that is not observable from anything else in this module.
|
|
23
23
|
*/
|
|
24
24
|
export declare function getContentKey(content: NavigationContent, entryId?: string): string;
|
|
25
|
-
/**
|
|
26
|
-
* Render content based on NavigationContent type.
|
|
27
|
-
*
|
|
28
|
-
* Exported for reuse by overlay presets (e.g., ContainerDialogs_Default).
|
|
29
|
-
*/
|
|
30
25
|
export declare const NavigationContentRenderer: React.FC<{
|
|
31
26
|
content: NavigationContent;
|
|
32
27
|
zone: NavigationZone;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationContentAreas.d.ts","sourceRoot":"","sources":["../../../../src/core/navigation/NavigationContentAreas.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EACL,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAsB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAShF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAyB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"NavigationContentAreas.d.ts","sourceRoot":"","sources":["../../../../src/core/navigation/NavigationContentAreas.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EACL,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAsB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAShF,OAAO,EAAE,cAAc,EAAE,iBAAiB,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CAAC,EAAE,CAAC,2BAA2B,CA0mBxE,CAAC;AAuHF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAEtC,CAAC"}
|
|
@@ -34,6 +34,7 @@ import { Tabs, TabsList, TabsTrigger } from '../../components/sections/tabs.js';
|
|
|
34
34
|
import { ResourceOperationSurface } from '../../components/resources/ResourceOperationSurface.js';
|
|
35
35
|
import { FullCustomView } from '../../components/views/full-custom-view/FullCustomView.js';
|
|
36
36
|
import { FlowsActorsView } from '../../components/views/flows-actors-view/FlowsActorsView.js';
|
|
37
|
+
import { useLinkedConversationParam } from '../../components/views/flows-actors-view/ConversationLinkPage.js';
|
|
37
38
|
import { ExecutionView } from '../../components/views/execution-view/ExecutionView.js';
|
|
38
39
|
import { CompositeView } from '../../components/views/composite-view/CompositeView.js';
|
|
39
40
|
const ChartView = React.lazy(() => import('../../components/views/chart-view/ChartView.js'));
|
|
@@ -152,6 +153,28 @@ export function getContentKey(content, entryId) {
|
|
|
152
153
|
*
|
|
153
154
|
* Exported for reuse by overlay presets (e.g., ContainerDialogs_Default).
|
|
154
155
|
*/
|
|
156
|
+
/**
|
|
157
|
+
* A flows-actors view placed with a conversation a link named (#4013): it hands the view the conversation and, once the
|
|
158
|
+
* view has settled it, drops `?conversation=` from the address, so a reload does not reopen it. Only content the URL
|
|
159
|
+
* sync built carries the field, so this runs only where the address is the view's own.
|
|
160
|
+
*/
|
|
161
|
+
const LinkedFlowsActorsView = ({ content, entryId }) => {
|
|
162
|
+
const { dropLinkedConversation } = useLinkedConversationParam();
|
|
163
|
+
return (_jsx(FlowsActorsView, { viewRef: content.viewRef, contextResourceIdentifiers: content.contextResourceIdentifiers, linkedConversationId: content.linkedConversationId, onLinkedConversationSettled: dropLinkedConversation,
|
|
164
|
+
// The entry, so a remount of it never applies its settled link again; a new visit is a new entry.
|
|
165
|
+
linkKey: entryId }));
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* A resource composite placed with a conversation a link named (#4043): the conversation was opened on this view's
|
|
169
|
+
* record, so the view hands it to the conversation it hosts and, once settled, the parameter leaves the address.
|
|
170
|
+
*/
|
|
171
|
+
const LinkedCompositeView = ({ content, zone, initiator, entryId }) => {
|
|
172
|
+
const { dropLinkedConversation } = useLinkedConversationParam();
|
|
173
|
+
const linkedConversation = React.useMemo(() => (content.linkedConversationId
|
|
174
|
+
? { conversationId: content.linkedConversationId, onSettled: dropLinkedConversation, ...(entryId ? { linkKey: entryId } : {}) }
|
|
175
|
+
: undefined), [content.linkedConversationId, dropLinkedConversation, entryId]);
|
|
176
|
+
return (_jsx(CompositeView, { viewRef: content.viewRef, contextResourceIdentifiers: content.contextResourceIdentifiers, navigationZone: zone, navigationInitiator: initiator, linkedConversation: linkedConversation }));
|
|
177
|
+
};
|
|
155
178
|
export const NavigationContentRenderer = ({ content, zone, initiator, entryId }) => {
|
|
156
179
|
const { tComponent, isReady } = useI18n({ component: FrontendComponentType.HIGH_LEVEL_VIEWS_CHART });
|
|
157
180
|
const { registry } = useResourceRegistry();
|
|
@@ -161,6 +184,9 @@ export const NavigationContentRenderer = ({ content, zone, initiator, entryId })
|
|
|
161
184
|
return (_jsx(ResourceOperationSurface, { resourceContext: content.resourceContext, navigationZone: zone, navigationInitiator: initiator }, contentKey));
|
|
162
185
|
}
|
|
163
186
|
if (content.contentType === NavigationContentType.COMPOSITE_VIEW) {
|
|
187
|
+
if (content.linkedConversationId) {
|
|
188
|
+
return _jsx(LinkedCompositeView, { content: content, zone: zone, initiator: initiator, entryId: entryId }, contentKey);
|
|
189
|
+
}
|
|
164
190
|
return (_jsx(CompositeView, { viewRef: content.viewRef, contextResourceIdentifiers: content.contextResourceIdentifiers, navigationZone: zone, navigationInitiator: initiator }, contentKey));
|
|
165
191
|
}
|
|
166
192
|
if (content.contentType === NavigationContentType.CHART_VIEW) {
|
|
@@ -180,7 +206,7 @@ export const NavigationContentRenderer = ({ content, zone, initiator, entryId })
|
|
|
180
206
|
return (_jsx(FullCustomView, { viewRef: content.viewRef, contextResourceIdentifiers: content.contextResourceIdentifiers, navigationZone: zone }, contentKey));
|
|
181
207
|
}
|
|
182
208
|
if (content.contentType === NavigationContentType.FLOWS_ACTORS_VIEW) {
|
|
183
|
-
return (_jsx(FlowsActorsView, { viewRef: content.viewRef, contextResourceIdentifiers: content.contextResourceIdentifiers }, contentKey));
|
|
209
|
+
return content.linkedConversationId ? (_jsx(LinkedFlowsActorsView, { content: content, entryId: entryId }, contentKey)) : (_jsx(FlowsActorsView, { viewRef: content.viewRef, contextResourceIdentifiers: content.contextResourceIdentifiers }, contentKey));
|
|
184
210
|
}
|
|
185
211
|
if (content.contentType === NavigationContentType.EXECUTION_VIEW) {
|
|
186
212
|
return (_jsx(ExecutionView, { viewRef: content.viewRef, contextResourceIdentifiers: content.contextResourceIdentifiers, navigationZone: zone }, contentKey));
|