@envive-ai/react-widgets-v3 0.3.55 → 0.3.57

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 (54) hide show
  1. package/dist/debug/GenericSelect.cjs +4 -1
  2. package/dist/debug/GenericSelect.js +3 -1
  3. package/dist/debug/reportIssue.cjs +6 -3
  4. package/dist/debug/reportIssue.js +5 -3
  5. package/dist/hocs/withBaseWidget/withBaseWidget.cjs +13 -4
  6. package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
  7. package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
  8. package/dist/hocs/withBaseWidget/withBaseWidget.js +13 -4
  9. package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AISuggestionsServedMethodAttribution.cjs +10 -2
  10. package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
  11. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
  12. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
  13. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
  14. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
  15. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
  16. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +3 -25
  17. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
  18. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
  19. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +4 -26
  20. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
  21. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
  22. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
  23. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
  24. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
  25. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
  26. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +1 -1
  27. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
  28. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
  29. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +1 -1
  30. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
  31. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
  32. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
  33. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
  34. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
  35. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
  36. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
  37. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
  38. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
  39. package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
  40. package/package.json +1 -1
  41. package/src/debug/GenericSelect.tsx +4 -1
  42. package/src/debug/reportIssue.tsx +6 -3
  43. package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +159 -2
  44. package/src/hocs/withBaseWidget/withBaseWidget.tsx +29 -1
  45. package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +5 -1
  46. package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +19 -42
  47. package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +1 -1
  48. package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +6 -1
  49. package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +5 -1
  50. package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +3 -1
  51. package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +1 -1
  52. package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +5 -1
  53. package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +1 -1
  54. package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +5 -1
@@ -2,10 +2,7 @@ import {
2
2
  ChatElementDisplayLocationV3,
3
3
  FeatureGates,
4
4
  } from '@envive-ai/react-hooks/application/models';
5
- import {
6
- EnviveMetricsEventName,
7
- useAmplitude,
8
- } from '@envive-ai/react-hooks/contexts/amplitudeContext';
5
+ import { useAmplitude } from '@envive-ai/react-hooks/contexts/amplitudeContext';
9
6
  import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
10
7
  import {
11
8
  FloatingChatConfig,
@@ -14,13 +11,7 @@ import {
14
11
  } from '@envive-ai/react-hooks/contexts/typesV3';
15
12
  import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
16
13
  import { useTrackComponentVisibleEvent } from '@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent';
17
- import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
18
14
  import { useFeatureFlagService } from '@envive-ai/react-hooks/contexts/featureFlagServiceContext';
19
- import {
20
- Collapse,
21
- WidgetInteractionComponent,
22
- WidgetInteractionType,
23
- } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
24
15
  import {
25
16
  FloatingButton,
26
17
  FloatingButtonBackgroundColor,
@@ -88,7 +79,6 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
88
79
  const { previewButtonOnly, previewChatAlwaysOpen, previewCXButtonsEnabled, previewDisclaimer } =
89
80
  props;
90
81
  const salesAgentData = useSalesAgent();
91
- const { trackWidgetInteraction } = useWidgetInteraction();
92
82
  const { userHasInteractedValue } = useGetWidgetStatus();
93
83
 
94
84
  // TODO: Get hardcopy
@@ -124,19 +114,6 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
124
114
  if (isOpen) setIsCXOpen(false);
125
115
  }, [isOpen]);
126
116
 
127
- const handleClose = (type: Collapse) => {
128
- trackWidgetInteraction({
129
- eventName: EnviveMetricsEventName.WidgetInteraction,
130
- trigger: {
131
- widget: WidgetInteractionComponent.FLOATING_CHAT,
132
- widget_interaction: WidgetInteractionType.WIDGET_COLLAPSED,
133
- widget_interaction_data: {
134
- widget_collapsed: type,
135
- },
136
- },
137
- });
138
- };
139
-
140
117
  const { shouldShowFloatingButton } = useFloatingButtonVisibility({
141
118
  floatingButtonShowConfig: floatingButton?.showOption as FloatingButtonShow,
142
119
  isChatOpen: isOpen,
@@ -191,12 +168,12 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
191
168
  onClose={
192
169
  previewChatAlwaysOpen
193
170
  ? () => {}
194
- : () => {
195
- closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_OVERLAY);
196
- handleClose({
197
- collapse_source: 'body_click',
198
- });
199
- }
171
+ : () =>
172
+ closeChat(
173
+ ChatElementDisplayLocationV3.FLOATING_CHAT_OVERLAY,
174
+ undefined,
175
+ 'body_click',
176
+ )
200
177
  }
201
178
  previewMode={!!previewChatAlwaysOpen}
202
179
  >
@@ -215,22 +192,22 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
215
192
  onSwipeClose={
216
193
  previewChatAlwaysOpen
217
194
  ? () => {}
218
- : () => {
219
- closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON);
220
- handleClose({
221
- collapse_source: 'swipe',
222
- });
223
- }
195
+ : () =>
196
+ closeChat(
197
+ ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON,
198
+ undefined,
199
+ 'swipe',
200
+ )
224
201
  }
225
202
  onClose={
226
203
  previewChatAlwaysOpen
227
204
  ? () => {}
228
- : () => {
229
- closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON);
230
- handleClose({
231
- collapse_source: 'close_button',
232
- });
233
- }
205
+ : () =>
206
+ closeChat(
207
+ ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON,
208
+ undefined,
209
+ 'close_button',
210
+ )
234
211
  }
235
212
  />
236
213
  </Suspense>
@@ -5,7 +5,7 @@ import { FloatingChatWidget } from '../FloatingChatWidget';
5
5
 
6
6
  const mockTrackEvent = vi.fn();
7
7
  const mockGetHardcopy = vi.fn();
8
- const mockUseTrackComponentVisibleEvent = vi.fn();
8
+ const mockUseTrackComponentVisibleEvent = vi.fn(() => ({ isVisible: true }));
9
9
 
10
10
  vi.mock('@envive-ai/react-toolkit-v3/FloatingButton', () => ({
11
11
  FloatingButton: () => <div data-testid="floating-button">Floating Button</div>,
@@ -6,9 +6,10 @@ import { ProductCardWidget } from '../ProductCardWidget';
6
6
 
7
7
  const mockTrackEvent = vi.fn();
8
8
  const mockGetHardcopy = vi.fn();
9
- const mockUseTrackComponentVisibleEvent = vi.fn();
9
+ const mockUseTrackComponentVisibleEvent = vi.fn(() => ({ isVisible: true }));
10
10
 
11
11
  vi.mock('@envive-ai/react-toolkit-v3/ProductCard', () => ({
12
+ ProductCardVariant: { DARK: 'dark', LIGHT: 'light' },
12
13
  ProductCard: ({ prompts, onSelect }: { prompts: string[]; onSelect: (text: string) => void }) => (
13
14
  <div data-testid="product-card-mock">
14
15
  {prompts.map(text => (
@@ -42,6 +43,10 @@ vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
42
43
  useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
43
44
  }));
44
45
 
46
+ vi.mock('@envive-ai/react-hooks/contexts/featureFlagServiceContext', () => ({
47
+ useFeatureFlagService: () => ({ featureFlagService: undefined }),
48
+ }));
49
+
45
50
  vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
46
51
  useHardcopy: () => ({
47
52
  getHardcopy: mockGetHardcopy,
@@ -6,7 +6,7 @@ import { PromptButtonCarouselWithImageWidget } from '../PromptButtonCarouselWith
6
6
 
7
7
  const mockTrackEvent = vi.fn();
8
8
  const mockGetHardcopy = vi.fn();
9
- const mockUseTrackComponentVisibleEvent = vi.fn();
9
+ const mockUseTrackComponentVisibleEvent = vi.fn(() => ({ isVisible: true }));
10
10
 
11
11
  vi.mock('@envive-ai/react-toolkit-v3/PromptButtonCarouselWithImage', () => ({
12
12
  PromptButtonCarouselWithImage: ({
@@ -48,6 +48,10 @@ vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
48
48
  useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
49
49
  }));
50
50
 
51
+ vi.mock('@envive-ai/react-hooks/contexts/featureFlagServiceContext', () => ({
52
+ useFeatureFlagService: () => ({ featureFlagService: undefined }),
53
+ }));
54
+
51
55
  vi.mock('@envive-ai/react-hooks/hooks/WidgetInteraction', () => ({
52
56
  useWidgetInteraction: () => ({
53
57
  trackWidgetInteraction: vi.fn(),
@@ -74,7 +74,9 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
74
74
  (text: string) => {
75
75
  const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
76
76
  const stringId = getStringIdForText(rawValues, text);
77
- onSuggestionClick(stringId);
77
+ // Pass the raw text — onSuggestionClick runs its own idExtractor. Passing stringId here
78
+ // double-extracted it, the lookup missed, and suggestion_id landed empty on the event.
79
+ onSuggestionClick(text);
78
80
  trackEvent({
79
81
  eventName: EnviveMetricsEventName.WidgetTextClicked,
80
82
  eventProps: {
@@ -6,7 +6,7 @@ import { PromptCarouselWidget } from '../PromptCarouselWidget';
6
6
 
7
7
  const mockTrackEvent = vi.fn();
8
8
  const mockGetHardcopy = vi.fn();
9
- const mockUseTrackComponentVisibleEvent = vi.fn();
9
+ const mockUseTrackComponentVisibleEvent = vi.fn(() => ({ isVisible: true }));
10
10
 
11
11
  vi.mock('@envive-ai/react-toolkit-v3/PromptCarousel', () => ({
12
12
  PromptCarousel: ({
@@ -6,7 +6,7 @@ import { SocialProofWidget } from '../SocialProofWidget';
6
6
 
7
7
  const mockTrackEvent = vi.fn();
8
8
  const mockGetHardcopy = vi.fn();
9
- const mockUseTrackComponentVisibleEvent = vi.fn();
9
+ const mockUseTrackComponentVisibleEvent = vi.fn(() => ({ isVisible: true }));
10
10
 
11
11
  vi.mock('@envive-ai/react-toolkit-v3/SocialProof', async importOriginal => {
12
12
  const actual = await importOriginal();
@@ -54,6 +54,10 @@ vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
54
54
  useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
55
55
  }));
56
56
 
57
+ vi.mock('@envive-ai/react-hooks/contexts/featureFlagServiceContext', () => ({
58
+ useFeatureFlagService: () => ({ featureFlagService: undefined }),
59
+ }));
60
+
57
61
  vi.mock('@envive-ai/react-hooks/hooks/WidgetInteraction', () => ({
58
62
  useWidgetInteraction: () => ({
59
63
  trackWidgetInteraction: vi.fn(),
@@ -6,7 +6,7 @@ import { TitledPromptCarouselWidget } from '../TitledPromptCarouselWidget';
6
6
 
7
7
  const mockTrackEvent = vi.fn();
8
8
  const mockGetHardcopy = vi.fn();
9
- const mockUseTrackComponentVisibleEvent = vi.fn();
9
+ const mockUseTrackComponentVisibleEvent = vi.fn(() => ({ isVisible: true }));
10
10
 
11
11
  vi.mock('@envive-ai/react-toolkit-v3/TitledPromptCarousel', () => ({
12
12
  TitledPromptCarousel: ({
@@ -6,7 +6,7 @@ import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
6
6
  import { TypingAnimationWidget } from '../TypingAnimationWidget';
7
7
 
8
8
  const mockTrackEvent = vi.fn();
9
- const mockUseTrackComponentVisibleEvent = vi.fn();
9
+ const mockUseTrackComponentVisibleEvent = vi.fn(() => ({ isVisible: true }));
10
10
 
11
11
  vi.mock('@envive-ai/react-toolkit-v3/TypingAnimation', () => ({
12
12
  TypingAnimation: ({
@@ -52,6 +52,10 @@ vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
52
52
  useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
53
53
  }));
54
54
 
55
+ vi.mock('@envive-ai/react-hooks/contexts/featureFlagServiceContext', () => ({
56
+ useFeatureFlagService: () => ({ featureFlagService: undefined }),
57
+ }));
58
+
55
59
  vi.mock('@envive-ai/react-hooks/hooks/WidgetInteraction', () => ({
56
60
  useWidgetInteraction: () => ({
57
61
  trackWidgetInteraction: vi.fn(),