@envive-ai/react-widgets-v3 0.3.21 → 0.3.23
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/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/types.d.cts +5 -6
- package/dist/hocs/withBaseWidget/types.d.ts +5 -6
- package/dist/hocs/withBaseWidget/withBaseWidget.cjs +37 -43
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.js +39 -45
- package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +34 -8
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +35 -9
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs +13 -5
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +13 -5
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +32 -15
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +35 -18
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +36 -32
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +37 -33
- package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.cjs +2 -2
- package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.js +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.cjs +7 -1
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +7 -1
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +31 -15
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +33 -17
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +33 -16
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +36 -19
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +3 -12
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +5 -14
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +34 -17
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +37 -20
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +2 -11
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +4 -13
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +31 -14
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +34 -17
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
- package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
- 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 +68 -302
- package/src/hocs/withBaseWidget/types.ts +6 -6
- package/src/hocs/withBaseWidget/withBaseWidget.tsx +46 -61
- package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +33 -0
- package/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.tsx +9 -1
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +34 -13
- package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +11 -5
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +56 -38
- package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +11 -5
- package/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.tsx +8 -0
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +37 -15
- package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +12 -8
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +35 -13
- package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +19 -8
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -12
- package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +21 -8
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +34 -12
- package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +19 -8
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +1 -12
- package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +19 -8
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +37 -14
- package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +19 -8
- package/src/widgets/__tests__/trackEventCanary.test.ts +1 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ChatElementDisplayLocationV3,
|
|
3
|
+
FeatureGates,
|
|
4
|
+
} from '@envive-ai/react-hooks/application/models';
|
|
2
5
|
import { chatOnToggleAtom } from '@envive-ai/react-hooks/atoms/chat/chatState';
|
|
3
6
|
import {
|
|
4
7
|
EnviveMetricsEventName,
|
|
5
|
-
SpiffyMetricsEventName,
|
|
6
8
|
useAmplitude,
|
|
7
9
|
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
8
10
|
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
11
|
+
import { useFeatureFlagService } from '@envive-ai/react-hooks/contexts/featureFlagServiceContext';
|
|
9
12
|
import {
|
|
10
13
|
TypingAnimationWidgetV3Config,
|
|
11
14
|
WidgetTypeV3,
|
|
@@ -23,7 +26,7 @@ import {
|
|
|
23
26
|
import { TypingAnimation } from '@envive-ai/react-toolkit-v3/TypingAnimation';
|
|
24
27
|
import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
|
|
25
28
|
import { useSetAtom } from 'jotai';
|
|
26
|
-
import { useCallback
|
|
29
|
+
import { useCallback } from 'react';
|
|
27
30
|
import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
|
|
28
31
|
import { RawValues, getStringIdForText } from '../utils/functions';
|
|
29
32
|
|
|
@@ -43,7 +46,7 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
43
46
|
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
44
47
|
const onToggle = useSetAtom(chatOnToggleAtom);
|
|
45
48
|
|
|
46
|
-
const { hardcopyContent, widgetConfig, uiConfig, isLoading
|
|
49
|
+
const { hardcopyContent, widgetConfig, uiConfig, isLoading } = props;
|
|
47
50
|
|
|
48
51
|
const titleLabel = (hardcopyContent?.values?.titleLabel as string | undefined) || '';
|
|
49
52
|
const headlineText = (hardcopyContent?.values?.headlineText as string | undefined) || '';
|
|
@@ -70,6 +73,10 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
70
73
|
|
|
71
74
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
72
75
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
76
|
+
const voiceInputEnabled = uiConfig?.lookAndFeel?.voiceInputEnabled;
|
|
77
|
+
const { featureFlagService } = useFeatureFlagService();
|
|
78
|
+
const isVoiceInputEnabled =
|
|
79
|
+
featureFlagService?.isFeatureGateEnabled(FeatureGates.IsVoiceInputEnabled) || voiceInputEnabled;
|
|
73
80
|
|
|
74
81
|
const { trackEvent } = useAmplitude();
|
|
75
82
|
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
@@ -86,16 +93,6 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
86
93
|
return getStringIdForText(rawValues, text);
|
|
87
94
|
});
|
|
88
95
|
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
trackEvent({
|
|
91
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
92
|
-
eventProps: {
|
|
93
|
-
widget_config_id: widgetConfigId,
|
|
94
|
-
widget_type: WidgetTypeV3.TypingAnimationV3,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
}, [trackEvent, widgetConfigId]);
|
|
98
|
-
|
|
99
96
|
const handleButtonClick = useCallback(
|
|
100
97
|
(text: string) => {
|
|
101
98
|
const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
|
|
@@ -130,6 +127,29 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
130
127
|
});
|
|
131
128
|
}, [onToggle]);
|
|
132
129
|
|
|
130
|
+
const handleTranscriptionStarted = useCallback(() => {
|
|
131
|
+
trackWidgetInteraction({
|
|
132
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
133
|
+
trigger: {
|
|
134
|
+
widget: WidgetInteractionComponent.EMBEDDED_WIDGET,
|
|
135
|
+
widget_interaction: WidgetInteractionType.VOICE_TRANSCRIPTION_STARTED,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
const handleTranscriptionCompleted = useCallback((transcript: string) => {
|
|
141
|
+
trackWidgetInteraction({
|
|
142
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
143
|
+
trigger: {
|
|
144
|
+
widget: WidgetInteractionComponent.EMBEDDED_WIDGET,
|
|
145
|
+
widget_interaction: WidgetInteractionType.VOICE_TRANSCRIPTION_COMPLETED,
|
|
146
|
+
widget_interaction_data: {
|
|
147
|
+
transcription: transcript,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}, []);
|
|
152
|
+
|
|
133
153
|
return (
|
|
134
154
|
<TypingAnimation
|
|
135
155
|
baseProps={{
|
|
@@ -144,6 +164,7 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
144
164
|
textFieldAriaLabel,
|
|
145
165
|
logoSrc: logoSrc ?? undefined,
|
|
146
166
|
hideLogo: hideLogo ?? false,
|
|
167
|
+
voiceInputEnabled: isVoiceInputEnabled,
|
|
147
168
|
}}
|
|
148
169
|
widgetStyleProps={{
|
|
149
170
|
widgetVariant,
|
|
@@ -162,6 +183,8 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
162
183
|
handleButtonTouchStart: onTouchStart,
|
|
163
184
|
handleButtonTouchEnd: onTouchEnd,
|
|
164
185
|
handleTextFieldClick,
|
|
186
|
+
onTranscriptionStarted: handleTranscriptionStarted,
|
|
187
|
+
onTranscriptionCompleted: handleTranscriptionCompleted,
|
|
165
188
|
}}
|
|
166
189
|
/>
|
|
167
190
|
);
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import { atom } from 'jotai';
|
|
3
|
-
import {
|
|
4
|
-
EnviveMetricsEventName,
|
|
5
|
-
SpiffyMetricsEventName,
|
|
6
|
-
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
3
|
+
import { EnviveMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
7
4
|
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
8
5
|
import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
9
6
|
import { TypingAnimationWidget } from '../TypingAnimationWidget';
|
|
10
7
|
|
|
11
8
|
const mockTrackEvent = vi.fn();
|
|
9
|
+
const mockUseTrackComponentVisibleEvent = vi.fn();
|
|
12
10
|
|
|
13
11
|
vi.mock('@envive-ai/react-toolkit-v3/TypingAnimation', () => ({
|
|
14
12
|
TypingAnimation: ({
|
|
@@ -50,6 +48,17 @@ vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
|
50
48
|
},
|
|
51
49
|
}));
|
|
52
50
|
|
|
51
|
+
vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
|
|
52
|
+
useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
vi.mock('@envive-ai/react-hooks/hooks/WidgetInteraction', () => ({
|
|
56
|
+
useWidgetInteraction: () => ({
|
|
57
|
+
trackWidgetInteraction: vi.fn(),
|
|
58
|
+
getInteractionId: vi.fn(),
|
|
59
|
+
}),
|
|
60
|
+
}));
|
|
61
|
+
|
|
53
62
|
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
54
63
|
useHardcopy: () => ({
|
|
55
64
|
getHardcopy: mockGetHardcopy,
|
|
@@ -124,13 +133,15 @@ describe('TypingAnimationWidget analytics', () => {
|
|
|
124
133
|
|
|
125
134
|
await waitFor(
|
|
126
135
|
() => {
|
|
127
|
-
expect(
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
137
|
+
expect.any(Object),
|
|
138
|
+
{
|
|
130
139
|
widget_config_id: 'test-config-1',
|
|
131
140
|
widget_type: WidgetTypeV3.TypingAnimationV3,
|
|
132
141
|
},
|
|
133
|
-
|
|
142
|
+
'0px',
|
|
143
|
+
true,
|
|
144
|
+
);
|
|
134
145
|
},
|
|
135
146
|
{ timeout: 3000 },
|
|
136
147
|
);
|
|
@@ -7,7 +7,7 @@ const WIDGETS_SRC_DIR = join(process.cwd(), 'src');
|
|
|
7
7
|
* Known count of trackEvent({ invocations in widget source files (excluding tests and stories).
|
|
8
8
|
* Update this when adding new trackEvent calls - and add a test for the new event!
|
|
9
9
|
*/
|
|
10
|
-
const EXPECTED_TRACK_EVENT_CALL_COUNT =
|
|
10
|
+
const EXPECTED_TRACK_EVENT_CALL_COUNT = 7;
|
|
11
11
|
|
|
12
12
|
function getAllSourceFiles(dir: string, files: string[] = []): string[] {
|
|
13
13
|
const entries = readdirSync(dir, { withFileTypes: true });
|