@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.
Files changed (91) hide show
  1. package/dist/debug/chatEmbed.cjs +1 -1
  2. package/dist/debug/chatEmbed.js +1 -1
  3. package/dist/debug/reportIssue.cjs +1 -1
  4. package/dist/debug/reportIssue.js +1 -1
  5. package/dist/hocs/withBaseWidget/types.d.cts +5 -6
  6. package/dist/hocs/withBaseWidget/types.d.ts +5 -6
  7. package/dist/hocs/withBaseWidget/withBaseWidget.cjs +37 -43
  8. package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
  9. package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
  10. package/dist/hocs/withBaseWidget/withBaseWidget.js +39 -45
  11. package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
  12. package/dist/packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
  13. package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
  14. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +34 -8
  15. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
  16. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
  17. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +35 -9
  18. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs +13 -5
  19. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
  20. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
  21. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +13 -5
  22. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +32 -15
  23. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
  24. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
  25. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +35 -18
  26. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +36 -32
  27. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
  28. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +37 -33
  29. package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.cjs +2 -2
  30. package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.js +2 -2
  31. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.cjs +7 -1
  32. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +7 -1
  33. package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +31 -15
  34. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
  35. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
  36. package/dist/widgets/ProductCardWidget/ProductCardWidget.js +33 -17
  37. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +33 -16
  38. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
  39. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
  40. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +36 -19
  41. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +3 -12
  42. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
  43. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
  44. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +5 -14
  45. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
  46. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
  47. package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +34 -17
  48. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
  49. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
  50. package/dist/widgets/SocialProofWidget/SocialProofWidget.js +37 -20
  51. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +2 -11
  52. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
  53. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
  54. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +4 -13
  55. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
  56. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
  57. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +31 -14
  58. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
  59. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
  60. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +34 -17
  61. package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
  62. package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
  63. package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
  64. package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
  65. package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
  66. package/dist/widgets/utils/functions.cjs +1 -1
  67. package/dist/widgets/utils/functions.js +1 -1
  68. package/package.json +1 -1
  69. package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +68 -302
  70. package/src/hocs/withBaseWidget/types.ts +6 -6
  71. package/src/hocs/withBaseWidget/withBaseWidget.tsx +46 -61
  72. package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +33 -0
  73. package/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.tsx +9 -1
  74. package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +34 -13
  75. package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +11 -5
  76. package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +56 -38
  77. package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +11 -5
  78. package/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.tsx +8 -0
  79. package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +37 -15
  80. package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +12 -8
  81. package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +35 -13
  82. package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +19 -8
  83. package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -12
  84. package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +21 -8
  85. package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +34 -12
  86. package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +19 -8
  87. package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +1 -12
  88. package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +19 -8
  89. package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +37 -14
  90. package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +19 -8
  91. package/src/widgets/__tests__/trackEventCanary.test.ts +1 -1
@@ -1,11 +1,14 @@
1
- import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
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, useEffect } from 'react';
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, widgetConfigId } = props;
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(mockTrackEvent).toHaveBeenCalledWith({
128
- eventName: SpiffyMetricsEventName.ChatComponentVisible,
129
- eventProps: {
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 = 15;
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 });