@envive-ai/react-hooks 0.3.63 → 0.3.64
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/application/models/featureGates.cjs +2 -1
- package/dist/application/models/featureGates.d.cts +2 -1
- package/dist/application/models/featureGates.d.ts +2 -1
- package/dist/application/models/featureGates.js +2 -1
- package/dist/application/utils/elementObserver.d.cts +2 -2
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/variant.d.cts +6 -6
- package/dist/atoms/chat/chatState.d.cts +19 -19
- package/dist/atoms/chat/chatState.d.ts +19 -19
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/form.d.ts +2 -2
- package/dist/atoms/chat/index.d.cts +2 -2
- package/dist/atoms/chat/index.d.ts +3 -3
- package/dist/atoms/chat/lastMessage.d.cts +2 -2
- package/dist/atoms/chat/lastMessage.d.ts +2 -2
- package/dist/atoms/chat/messageQueue.d.cts +7 -7
- package/dist/atoms/chat/messageQueue.d.ts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
- package/dist/atoms/chat/renderedWidgetRefs.d.cts +3 -3
- package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
- package/dist/atoms/chat/replies.d.cts +3 -3
- package/dist/atoms/chat/replies.d.ts +3 -3
- package/dist/atoms/chat/suggestions.d.cts +3 -3
- package/dist/atoms/chat/suggestions.d.ts +2 -2
- package/dist/atoms/envive/enviveConfig.d.cts +14 -14
- package/dist/atoms/envive/enviveConfig.d.ts +14 -14
- package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
- package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
- package/dist/atoms/org/customerService.d.cts +6 -6
- package/dist/atoms/org/customerService.d.ts +6 -6
- package/dist/atoms/org/graphqlConfig.d.cts +4 -4
- package/dist/atoms/org/graphqlConfig.d.ts +4 -4
- package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +4 -4
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +4 -4
- package/dist/atoms/search/chatSearch.d.cts +17 -17
- package/dist/atoms/search/chatSearch.d.ts +17 -17
- package/dist/atoms/search/searchAPI.d.cts +13 -13
- package/dist/atoms/search/searchAPI.d.ts +13 -13
- package/dist/atoms/search/types.d.cts +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/widget/chatPreviewLoading.d.cts +2 -2
- package/dist/atoms/widget/chatPreviewLoading.d.ts +2 -2
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
- package/dist/contexts/types.d.cts +1 -1
- package/dist/contexts/types.d.ts +1 -1
- package/dist/contexts/typesV3.d.cts +1 -1
- package/dist/contexts/typesV3.d.ts +1 -1
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
- package/dist/hooks/Intersection/useIntersection.cjs +9 -2
- package/dist/hooks/Intersection/useIntersection.d.cts +2 -2
- package/dist/hooks/Intersection/useIntersection.d.ts +2 -2
- package/dist/hooks/Intersection/useIntersection.js +9 -2
- package/dist/hooks/SystemSettingsContext/useSystemSettingsContext.d.cts +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.cjs +12 -3
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.cts +2 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.ts +2 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +13 -4
- package/dist/hooks/WidgetLoadDiagnostics/index.cjs +4 -0
- package/dist/hooks/WidgetLoadDiagnostics/index.d.cts +2 -0
- package/dist/hooks/WidgetLoadDiagnostics/index.d.ts +2 -0
- package/dist/hooks/WidgetLoadDiagnostics/index.js +3 -0
- package/dist/hooks/WidgetLoadDiagnostics/useWidgetLoadDiagnostics.cjs +122 -0
- package/dist/hooks/WidgetLoadDiagnostics/useWidgetLoadDiagnostics.d.cts +48 -0
- package/dist/hooks/WidgetLoadDiagnostics/useWidgetLoadDiagnostics.d.ts +48 -0
- package/dist/hooks/WidgetLoadDiagnostics/useWidgetLoadDiagnostics.js +120 -0
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/hooks/utils.d.ts +1 -1
- package/dist/services/amplitudeService/eventNames.cjs +2 -1
- package/dist/services/amplitudeService/eventNames.d.cts +2 -1
- package/dist/services/amplitudeService/eventNames.d.ts +2 -1
- package/dist/services/amplitudeService/eventNames.js +2 -1
- package/dist/services/ga4ProjectionService/ga4EventSchema.cjs +3 -2
- package/dist/services/ga4ProjectionService/ga4EventSchema.js +3 -2
- package/dist/services/hardcopyService/hardcopyService.cjs +12 -3
- package/dist/services/hardcopyService/hardcopyService.d.cts +3 -1
- package/dist/services/hardcopyService/hardcopyService.d.ts +3 -1
- package/dist/services/hardcopyService/hardcopyService.js +12 -3
- package/package.json +5 -1
- package/src/application/models/featureGates.ts +6 -0
- package/src/hooks/Intersection/useIntersection.ts +11 -0
- package/src/hooks/TrackComponentVisibleEvent/__tests__/useTrackComponentVisibleEvent.test.tsx +64 -0
- package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +23 -4
- package/src/hooks/WidgetLoadDiagnostics/__tests__/useWidgetLoadDiagnostics.test.ts +161 -0
- package/src/hooks/WidgetLoadDiagnostics/index.ts +5 -0
- package/src/hooks/WidgetLoadDiagnostics/useWidgetLoadDiagnostics.ts +178 -0
- package/src/services/amplitudeService/eventNames.ts +4 -0
- package/src/services/ga4ProjectionService/ga4EventSchema.ts +5 -0
- package/src/services/hardcopyService/__tests__/hardcopyService.test.ts +16 -5
- package/src/services/hardcopyService/hardcopyService.ts +10 -2
|
@@ -48,4 +48,8 @@ export enum EnviveMetricsEventName {
|
|
|
48
48
|
WidgetTextRequest = 'Widget Text Request',
|
|
49
49
|
WidgetTextResponse = 'Widget Text Response',
|
|
50
50
|
WidgetTextClicked = 'Widget Text Clicked',
|
|
51
|
+
// Operational diagnostics for widget loading (see useWidgetLoadDiagnostics). A single event
|
|
52
|
+
// with a `type` discriminator (widget_mounted | widget_load_outcome | widget_load_stalled)
|
|
53
|
+
// so eng can measure the layered load net and, crucially, the negative space between layers.
|
|
54
|
+
Diagnostics = 'Diagnostics',
|
|
51
55
|
}
|
|
@@ -156,4 +156,9 @@ export const GA4_EVENT_SCHEMA: Record<EnviveMetricsEventName, GA4EventSchemaEntr
|
|
|
156
156
|
[EnviveMetricsEventName.WidgetTextClicked]: {
|
|
157
157
|
gaEventName: null,
|
|
158
158
|
},
|
|
159
|
+
|
|
160
|
+
// Internal eng operational monitoring — never projected to merchant GA4.
|
|
161
|
+
[EnviveMetricsEventName.Diagnostics]: {
|
|
162
|
+
gaEventName: null,
|
|
163
|
+
},
|
|
159
164
|
};
|
|
@@ -92,6 +92,7 @@ describe('HardcopyService', () => {
|
|
|
92
92
|
titleLabel: 'Hello World',
|
|
93
93
|
promptButtonTexts: ['Prompt 1', 'Prompt 2'],
|
|
94
94
|
},
|
|
95
|
+
servedFrom: 'api',
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
|
|
@@ -383,7 +384,11 @@ describe('HardcopyService', () => {
|
|
|
383
384
|
userEvent: {} as any,
|
|
384
385
|
});
|
|
385
386
|
|
|
386
|
-
expect(result).
|
|
387
|
+
expect(result).toEqual({
|
|
388
|
+
...MOCK_HARDCOPY_RESPONSE[WidgetTypeV3.PromptCarouselV3],
|
|
389
|
+
servedFrom: 'static',
|
|
390
|
+
fallbackReason: 'error',
|
|
391
|
+
});
|
|
387
392
|
});
|
|
388
393
|
|
|
389
394
|
it('returns the MOCK_HARDCOPY_RESPONSE entry when the API returns falsy', async () => {
|
|
@@ -394,7 +399,11 @@ describe('HardcopyService', () => {
|
|
|
394
399
|
userEvent: {} as any,
|
|
395
400
|
});
|
|
396
401
|
|
|
397
|
-
expect(result).
|
|
402
|
+
expect(result).toEqual({
|
|
403
|
+
...MOCK_HARDCOPY_RESPONSE[WidgetTypeV3.SocialProofV3],
|
|
404
|
+
servedFrom: 'static',
|
|
405
|
+
fallbackReason: 'error',
|
|
406
|
+
});
|
|
398
407
|
});
|
|
399
408
|
|
|
400
409
|
it('does not fire WidgetTextResponse when falling back to mock', async () => {
|
|
@@ -437,9 +446,11 @@ describe('HardcopyService', () => {
|
|
|
437
446
|
|
|
438
447
|
await vi.advanceTimersByTimeAsync(HARDCOPY_TIMEOUT_MS);
|
|
439
448
|
|
|
440
|
-
await expect(resultPromise).resolves.
|
|
441
|
-
MOCK_HARDCOPY_RESPONSE[WidgetTypeV3.PromptCarouselV3],
|
|
442
|
-
|
|
449
|
+
await expect(resultPromise).resolves.toEqual({
|
|
450
|
+
...MOCK_HARDCOPY_RESPONSE[WidgetTypeV3.PromptCarouselV3],
|
|
451
|
+
servedFrom: 'static',
|
|
452
|
+
fallbackReason: 'timeout',
|
|
453
|
+
});
|
|
443
454
|
} finally {
|
|
444
455
|
vi.useRealTimers();
|
|
445
456
|
}
|
|
@@ -49,6 +49,10 @@ export type HardcopyResponse = {
|
|
|
49
49
|
language: string;
|
|
50
50
|
rawValues?: Record<string, WidgetString | WidgetString[]>;
|
|
51
51
|
values: Record<string, string | string[]>;
|
|
52
|
+
// How the copy was served, for widget-load diagnostics: 'api' = live backend response,
|
|
53
|
+
// 'static' = fell back to the bundled MOCK_HARDCOPY_RESPONSE after a backend error or timeout.
|
|
54
|
+
servedFrom?: 'api' | 'static';
|
|
55
|
+
fallbackReason?: 'timeout' | 'error';
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
export interface IHardcopyService {
|
|
@@ -265,6 +269,8 @@ export class HardcopyService implements IHardcopyService {
|
|
|
265
269
|
},
|
|
266
270
|
});
|
|
267
271
|
|
|
272
|
+
// Reason the API path failed, surfaced on the static fallback for widget-load diagnostics.
|
|
273
|
+
let fallbackReason: 'timeout' | 'error' | undefined;
|
|
268
274
|
try {
|
|
269
275
|
const response = await withTimeout(
|
|
270
276
|
CommerceApiClient.getHardcopy(widgetTextRequest),
|
|
@@ -287,16 +293,18 @@ export class HardcopyService implements IHardcopyService {
|
|
|
287
293
|
: {}),
|
|
288
294
|
},
|
|
289
295
|
});
|
|
290
|
-
return convertedResponse;
|
|
296
|
+
return { ...convertedResponse, servedFrom: 'api' };
|
|
291
297
|
}
|
|
292
298
|
} catch (error) {
|
|
293
299
|
logger.logError('error getting hardcopy from backend', error);
|
|
300
|
+
fallbackReason =
|
|
301
|
+
error instanceof Error && error.message.includes('timed out') ? 'timeout' : 'error';
|
|
294
302
|
}
|
|
295
303
|
|
|
296
304
|
const mockResponse = MOCK_HARDCOPY_RESPONSE[request.widgetType];
|
|
297
305
|
if (mockResponse) {
|
|
298
306
|
logger.logDebug('no real response, using mock', mockResponse);
|
|
299
|
-
return mockResponse;
|
|
307
|
+
return { ...mockResponse, servedFrom: 'static', fallbackReason: fallbackReason ?? 'error' };
|
|
300
308
|
}
|
|
301
309
|
throw new Error(`No hardcopy response found for widget type: ${request.widgetType}`);
|
|
302
310
|
}
|