@envive-ai/react-widgets-v3 0.3.63 → 0.3.65
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/debug/MessageContent.cjs +1 -1
- package/dist/debug/MessageContent.js +1 -1
- package/dist/debug/chatEmbed.cjs +1 -1
- package/dist/debug/chatEmbed.js +1 -1
- package/dist/debug/reportIssue.cjs +1 -1
- package/dist/debug/reportIssue.js +1 -1
- package/dist/hocs/withBaseWidget/withBaseWidget.cjs +28 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.js +28 -2
- package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +2 -2
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs +2 -2
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +2 -2
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +2 -2
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +2 -2
- package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.cjs +2 -2
- package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.js +2 -2
- package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.cjs +1 -1
- package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.js +1 -1
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.cjs +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +2 -2
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +2 -2
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +1 -1
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +1 -1
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +2 -2
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/dist/widgets/utils/functions.cjs +1 -1
- package/dist/widgets/utils/functions.js +1 -1
- package/package.json +1 -1
- package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +15 -0
- package/src/hocs/withBaseWidget/withBaseWidget.tsx +47 -3
- package/src/stories/FullPageSalesAgentWidget.stories.tsx +5 -3
- package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +6 -0
|
@@ -8,6 +8,9 @@ import { usePage } from '@envive-ai/react-hooks/contexts/pageContext';
|
|
|
8
8
|
import { useWidgetConfig } from '@envive-ai/react-hooks/contexts/widgetConfigContext';
|
|
9
9
|
import { OrgUIConfigV3, WidgetConfigV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
10
10
|
import { useUiConfig } from '@envive-ai/react-hooks/contexts/uiConfigContext';
|
|
11
|
+
import { FeatureGates } from '@envive-ai/react-hooks/application/models';
|
|
12
|
+
import { useFeatureFlagService } from '@envive-ai/react-hooks/contexts/featureFlagServiceContext';
|
|
13
|
+
import { useWidgetLoadDiagnostics } from '@envive-ai/react-hooks/hooks/WidgetLoadDiagnostics';
|
|
11
14
|
import { BaseWidgetProps, WithBaseWidgetOptions } from './types';
|
|
12
15
|
|
|
13
16
|
const logger = new Logger('withBaseWidget');
|
|
@@ -51,12 +54,28 @@ export function withBaseWidget<P extends BaseWidgetProps>(
|
|
|
51
54
|
const [uiConfigSettled, setUiConfigSettled] = useState(false);
|
|
52
55
|
const ownRequestsSettled = hardcopySettled && widgetConfigSettled && uiConfigSettled;
|
|
53
56
|
|
|
57
|
+
// --- Widget load diagnostics (see useWidgetLoadDiagnostics) ---
|
|
58
|
+
// load_id correlates this widget's mount / rendered / outcome / stall events for one load.
|
|
59
|
+
const loadId = useRef(
|
|
60
|
+
`${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`,
|
|
61
|
+
).current;
|
|
62
|
+
const { featureFlagService } = useFeatureFlagService();
|
|
63
|
+
// Diagnostics are ON by default; the gate is a kill switch (default false → enabled) so we
|
|
64
|
+
// can gather a cross-merchant baseline. Flip it true (globally or per-org) via Statsig to stop.
|
|
65
|
+
const diagnosticsEnabled = !featureFlagService?.isFeatureGateEnabled(
|
|
66
|
+
FeatureGates.IsWidgetDiagnosticsDisabled,
|
|
67
|
+
);
|
|
68
|
+
// Reason this widget's own hardcopy request rejected (distinct from a served static fallback).
|
|
69
|
+
const hardcopyErrorRef = useRef<string | undefined>(undefined);
|
|
70
|
+
|
|
54
71
|
const visibilityEventProps = {
|
|
55
72
|
widget_config_id: widgetConfigId,
|
|
56
73
|
widget_type: widgetType,
|
|
74
|
+
// Threaded onto [Envive] Widget Rendered so it can be joined to the diagnostics events.
|
|
75
|
+
load_id: loadId,
|
|
57
76
|
...options?.visibilityEventProps,
|
|
58
77
|
};
|
|
59
|
-
const { isVisible } = useTrackComponentVisibleEvent(
|
|
78
|
+
const { isVisible, visibilitySource } = useTrackComponentVisibleEvent(
|
|
60
79
|
widgetRef,
|
|
61
80
|
visibilityEventProps,
|
|
62
81
|
options?.rootMargin || '0px',
|
|
@@ -125,8 +144,14 @@ export function withBaseWidget<P extends BaseWidgetProps>(
|
|
|
125
144
|
hardcopyFetchedRef.current = true;
|
|
126
145
|
getHardcopy({ widgetType, userEvent })
|
|
127
146
|
.then(setHardcopyContent)
|
|
128
|
-
.catch(
|
|
129
|
-
// Silently handle errors - widget will render without hardcopy content
|
|
147
|
+
.catch(error => {
|
|
148
|
+
// Silently handle errors - widget will render without hardcopy content. Record the
|
|
149
|
+
// reason for the load-outcome diagnostic (the served static-fallback path resolves
|
|
150
|
+
// rather than rejects, so reaching here means no content at all).
|
|
151
|
+
hardcopyErrorRef.current =
|
|
152
|
+
error instanceof Error && error.message.includes('timed out')
|
|
153
|
+
? 'hardcopy_timeout'
|
|
154
|
+
: 'hardcopy_error';
|
|
130
155
|
})
|
|
131
156
|
.finally(() => {
|
|
132
157
|
setHardcopySettled(true);
|
|
@@ -162,6 +187,25 @@ export function withBaseWidget<P extends BaseWidgetProps>(
|
|
|
162
187
|
});
|
|
163
188
|
}, [startLoading, widgetConfigId, widgetType, getWidgetConfig]);
|
|
164
189
|
|
|
190
|
+
const pendingRequests = [
|
|
191
|
+
hardcopySettled ? null : 'hardcopy',
|
|
192
|
+
widgetConfigSettled ? null : 'widgetConfig',
|
|
193
|
+
uiConfigSettled ? null : 'uiConfig',
|
|
194
|
+
].filter((name): name is string => name !== null);
|
|
195
|
+
|
|
196
|
+
useWidgetLoadDiagnostics({
|
|
197
|
+
enabled: diagnosticsEnabled,
|
|
198
|
+
loadId,
|
|
199
|
+
widgetType,
|
|
200
|
+
widgetConfigId,
|
|
201
|
+
startLoading,
|
|
202
|
+
ownRequestsSettled,
|
|
203
|
+
hardcopyContent,
|
|
204
|
+
visibilitySource,
|
|
205
|
+
pendingRequests,
|
|
206
|
+
hardcopyErrorReason: hardcopyErrorRef.current,
|
|
207
|
+
});
|
|
208
|
+
|
|
165
209
|
return (
|
|
166
210
|
<span ref={widgetRef}>
|
|
167
211
|
<Widget
|
|
@@ -101,9 +101,11 @@ export const PartialView: Story = {
|
|
|
101
101
|
name: 'Partial View (default)',
|
|
102
102
|
// 'fake-widget-config-id' short-circuits withBaseWidget's real widget-config
|
|
103
103
|
// fetch (see WidgetConfigProvider.getWidgetConfig) and resolves to `{}` —
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
104
|
+
// both `partialViewMode` and the deprecated `partialViewEnabled` then come
|
|
105
|
+
// out `undefined`, which resolvePartialViewEnabled (see
|
|
106
|
+
// FullPageSalesAgent/hooks/resolvePartialViewMode.ts) correctly defaults
|
|
107
|
+
// to enabled, regardless of which merchant is selected in the toolbar or
|
|
108
|
+
// what that merchant's own backend config has configured.
|
|
107
109
|
args: {
|
|
108
110
|
widgetConfigId: 'fake-widget-config-id',
|
|
109
111
|
},
|
|
@@ -60,6 +60,11 @@ vi.mock('@envive-ai/react-hooks/contexts/featureFlagServiceContext', () => ({
|
|
|
60
60
|
useFeatureFlagService: () => ({ featureFlagService: undefined }),
|
|
61
61
|
}));
|
|
62
62
|
|
|
63
|
+
// Diagnostics pulls its own amplitude context internally; stub it like the other sub-hooks.
|
|
64
|
+
vi.mock('@envive-ai/react-hooks/hooks/WidgetLoadDiagnostics', () => ({
|
|
65
|
+
useWidgetLoadDiagnostics: vi.fn(),
|
|
66
|
+
}));
|
|
67
|
+
|
|
63
68
|
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
64
69
|
useHardcopy: () => ({
|
|
65
70
|
getHardcopy: mockGetHardcopy,
|
|
@@ -131,6 +136,7 @@ describe('ProductCardWidget analytics', () => {
|
|
|
131
136
|
{
|
|
132
137
|
widget_config_id: 'test-config-1',
|
|
133
138
|
widget_type: WidgetTypeV3.ProductCardV3,
|
|
139
|
+
load_id: expect.any(String),
|
|
134
140
|
},
|
|
135
141
|
'0px',
|
|
136
142
|
true,
|