@envive-ai/react-widgets-v3 0.3.14 → 0.3.15-alpha.2
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 +7 -8
- package/dist/hocs/withBaseWidget/types.d.ts +8 -8
- 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/hooks/dist/application/models/api/widgetText.d.cts +8 -0
- package/dist/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.cts +12 -0
- package/dist/hooks/dist/contexts/types.d.cts +38 -0
- package/dist/hooks/dist/contexts/typesV3.d.cts +230 -0
- package/dist/hooks/dist/types/customerService.d.cts +21 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetType.cjs +1 -0
- package/dist/packages/hooks/dist/application/models/api/orgConfigResults.d.ts +2 -0
- package/dist/packages/hooks/dist/application/models/api/userEvent.d.ts +1 -0
- package/dist/packages/hooks/dist/application/models/api/widgetText.d.ts +8 -0
- package/dist/packages/hooks/dist/application/models/frontendConfig.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +15 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/index.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/types.d.ts +44 -0
- package/dist/packages/hooks/dist/contexts/typesV3.d.ts +230 -0
- package/dist/packages/hooks/dist/types/customerService.d.ts +21 -0
- package/dist/packages/hooks/dist/types/custservice-types.d.ts +1 -0
- package/dist/packages/icons/dist/IconCloseVariant.cjs +5 -6
- package/dist/packages/icons/dist/IconCloseVariant.js +4 -6
- package/dist/packages/widgets/dist/SearchResults/SearchResults.d.ts +4 -3
- 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/SearchZeroState/index.d.ts +2 -1
- package/dist/packages/widgets/dist/SearchZeroState/types.d.ts +2 -2
- package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +3 -3
- package/dist/packages/widgets/dist/SuggestionButtonContainer/index.d.ts +2 -0
- package/dist/packages/widgets/dist/SuggestionButtonContainer/types.d.ts +3 -2
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/response.d.ts +14 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/search.d.ts +15 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.ts +73 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.ts +61 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.ts +25 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.ts +35 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.ts +32 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.ts +32 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/pageVisitInfo.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/variantInfo.d.ts +2 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.ts +15 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/types.d.ts +64 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.ts +60 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/utils.d.ts +13 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/OrgInfo.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/index.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/search-filter-types.d.ts +28 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/test-types.d.ts +10 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +35 -4
- 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 -4
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +33 -12
- 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 -14
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +44 -23
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +44 -23
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +62 -38
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +63 -39
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +24 -12
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +26 -14
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +22 -12
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +24 -14
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +14 -11
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +18 -15
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +53 -15
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +56 -18
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +10 -10
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +13 -13
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +23 -11
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +26 -14
- package/dist/widgets/dist/SearchResults/SearchResults.d.cts +4 -3
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/types.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +3 -3
- package/dist/widgets/dist/SuggestionButtonContainer/types.d.cts +3 -2
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/response.d.cts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/search.d.cts +15 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.cts +73 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.cts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.cts +25 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.cts +35 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.cts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.cts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.cts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/contexts/types.d.cts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.cts +60 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/utils.d.cts +12 -0
- package/dist/widgets/dist/packages/hooks/dist/types/search-filter-types.d.cts +28 -0
- package/dist/widgets/dist/packages/hooks/dist/types/test-types.d.cts +10 -0
- package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
- package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
- package/dist/widgets/utils/functions.cjs +0 -14
- package/dist/widgets/utils/functions.js +1 -14
- package/dist/widgets-v2/SearchZeroState/index.d.cts +2 -1
- package/dist/widgets-v2/SearchZeroState/index.d.ts +2 -1
- package/dist/widgets-v2/SuggestionButtonContainer/index.d.ts +1 -0
- package/package.json +4 -4
- 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 +59 -8
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +54 -18
- package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +11 -5
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +48 -19
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +100 -52
- package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +11 -5
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +37 -16
- package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +12 -8
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +38 -19
- package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +19 -8
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +32 -19
- package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +21 -8
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +77 -18
- package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +19 -8
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +23 -19
- package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +19 -8
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +45 -21
- package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +19 -8
- package/src/widgets/__tests__/trackEventCanary.test.ts +1 -1
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.cjs +0 -27
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.js +0 -25
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +0 -696
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.js +0 -696
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs +0 -43
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.js +0 -43
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.cjs +0 -1528
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.js +0 -1528
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.cjs +0 -329
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.js +0 -329
- package/dist/packages/icons/dist/node_modules/react/index.cjs +0 -13
- package/dist/packages/icons/dist/node_modules/react/index.js +0 -13
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.cjs +0 -13
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.js +0 -13
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
-
import {
|
|
3
|
-
EnviveMetricsEventName,
|
|
4
|
-
SpiffyMetricsEventName,
|
|
5
|
-
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
2
|
+
import { EnviveMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
6
3
|
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
7
4
|
import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
8
5
|
import { SocialProofWidget } from '../SocialProofWidget';
|
|
9
6
|
|
|
10
7
|
const mockTrackEvent = vi.fn();
|
|
11
8
|
const mockGetHardcopy = vi.fn();
|
|
9
|
+
const mockUseTrackComponentVisibleEvent = vi.fn();
|
|
12
10
|
|
|
13
11
|
vi.mock('@envive-ai/react-toolkit-v3/SocialProof', async importOriginal => {
|
|
14
12
|
const actual = await importOriginal();
|
|
@@ -52,6 +50,17 @@ vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
|
52
50
|
},
|
|
53
51
|
}));
|
|
54
52
|
|
|
53
|
+
vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
|
|
54
|
+
useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
vi.mock('@envive-ai/react-hooks/hooks/WidgetInteraction', () => ({
|
|
58
|
+
useWidgetInteraction: () => ({
|
|
59
|
+
trackWidgetInteraction: vi.fn(),
|
|
60
|
+
getInteractionId: vi.fn(),
|
|
61
|
+
}),
|
|
62
|
+
}));
|
|
63
|
+
|
|
55
64
|
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
56
65
|
useHardcopy: () => ({
|
|
57
66
|
getHardcopy: mockGetHardcopy,
|
|
@@ -146,13 +155,15 @@ describe('SocialProofWidget analytics', () => {
|
|
|
146
155
|
|
|
147
156
|
await waitFor(
|
|
148
157
|
() => {
|
|
149
|
-
expect(
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
159
|
+
expect.any(Object),
|
|
160
|
+
{
|
|
152
161
|
widget_config_id: 'test-config-1',
|
|
153
162
|
widget_type: WidgetTypeV3.SocialProofV3,
|
|
154
163
|
},
|
|
155
|
-
|
|
164
|
+
'0px',
|
|
165
|
+
true,
|
|
166
|
+
);
|
|
156
167
|
},
|
|
157
168
|
{ timeout: 3000 },
|
|
158
169
|
);
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TitledPromptCarouselWidgetV3Config,
|
|
3
|
-
WidgetTypeV3,
|
|
4
|
-
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
-
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
|
|
6
1
|
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
7
|
-
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
8
|
-
import { useCallback, useEffect } from 'react';
|
|
9
2
|
import {
|
|
10
3
|
EnviveMetricsEventName,
|
|
11
|
-
SpiffyMetricsEventName,
|
|
12
4
|
useAmplitude,
|
|
13
5
|
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
6
|
+
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
7
|
+
import {
|
|
8
|
+
TitledPromptCarouselWidgetV3Config,
|
|
9
|
+
WidgetTypeV3,
|
|
10
|
+
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
11
|
+
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
|
|
12
|
+
import { useCallback } from 'react';
|
|
14
13
|
|
|
15
14
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
15
|
+
import { WidgetInteractionComponent } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
16
|
+
import {
|
|
17
|
+
AnimationSpeed,
|
|
18
|
+
PromptCarouselRows,
|
|
19
|
+
usePromptCarouselAnalytics,
|
|
20
|
+
} from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
16
21
|
import { TitledPromptCarousel } from '@envive-ai/react-toolkit-v3/TitledPromptCarousel';
|
|
17
|
-
import { AnimationSpeed, PromptCarouselRows } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
18
22
|
import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
|
|
19
23
|
import { RawValues, getStringIdForText } from '../utils/functions';
|
|
20
24
|
|
|
@@ -33,6 +37,9 @@ const TitledPromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
33
37
|
const { openChat } = useChatToggle();
|
|
34
38
|
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
35
39
|
|
|
40
|
+
const { onClick, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } =
|
|
41
|
+
usePromptCarouselAnalytics(WidgetInteractionComponent.EMBEDDED_WIDGET, text => text);
|
|
42
|
+
|
|
36
43
|
const hardCopyTitleLabel = hardcopyContent?.values?.titleLabel as string | undefined;
|
|
37
44
|
const titleLabel = isLoading ? mockTitleLabel : hardCopyTitleLabel;
|
|
38
45
|
|
|
@@ -57,16 +64,6 @@ const TitledPromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
57
64
|
|
|
58
65
|
const { trackEvent } = useAmplitude();
|
|
59
66
|
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
trackEvent({
|
|
62
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
63
|
-
eventProps: {
|
|
64
|
-
widget_config_id: widgetConfigId,
|
|
65
|
-
widget_type: WidgetTypeV3.TitledPromptCarouselV3,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}, [trackEvent, widgetConfigId]);
|
|
69
|
-
|
|
70
67
|
const handleButtonClick = useCallback(
|
|
71
68
|
(text: string) => {
|
|
72
69
|
const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
|
|
@@ -85,6 +82,7 @@ const TitledPromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
85
82
|
displayLocation: ChatElementDisplayLocationV3.TITLED_PROMPT_CAROUSEL,
|
|
86
83
|
});
|
|
87
84
|
openChat(ChatElementDisplayLocationV3.TITLED_PROMPT_CAROUSEL);
|
|
85
|
+
onClick(text);
|
|
88
86
|
},
|
|
89
87
|
[onTypedMessageSubmitted, openChat],
|
|
90
88
|
);
|
|
@@ -100,6 +98,12 @@ const TitledPromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
100
98
|
promptCarouselRows={promptCarouselRows as PromptCarouselRows}
|
|
101
99
|
animationSpeed={animationSpeed as AnimationSpeed}
|
|
102
100
|
handleButtonClick={handleButtonClick}
|
|
101
|
+
handleButtonDrag={onDrag}
|
|
102
|
+
handleButtonHover={onHover}
|
|
103
|
+
handleButtonMouseDown={onMouseDown}
|
|
104
|
+
handleButtonMouseUp={onMouseUp}
|
|
105
|
+
handleButtonTouchStart={onTouchStart}
|
|
106
|
+
handleButtonTouchEnd={onTouchEnd}
|
|
103
107
|
promptButtonTexts={buttonTexts}
|
|
104
108
|
promptCarouselAriaLabel={promptCarouselAriaLabel}
|
|
105
109
|
/>
|
package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
-
import {
|
|
3
|
-
EnviveMetricsEventName,
|
|
4
|
-
SpiffyMetricsEventName,
|
|
5
|
-
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
2
|
+
import { EnviveMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
6
3
|
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
7
4
|
import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
8
5
|
import { TitledPromptCarouselWidget } from '../TitledPromptCarouselWidget';
|
|
9
6
|
|
|
10
7
|
const mockTrackEvent = vi.fn();
|
|
11
8
|
const mockGetHardcopy = vi.fn();
|
|
9
|
+
const mockUseTrackComponentVisibleEvent = vi.fn();
|
|
12
10
|
|
|
13
11
|
vi.mock('@envive-ai/react-toolkit-v3/TitledPromptCarousel', () => ({
|
|
14
12
|
TitledPromptCarousel: ({
|
|
@@ -46,6 +44,17 @@ vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
|
46
44
|
},
|
|
47
45
|
}));
|
|
48
46
|
|
|
47
|
+
vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
|
|
48
|
+
useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
vi.mock('@envive-ai/react-hooks/hooks/WidgetInteraction', () => ({
|
|
52
|
+
useWidgetInteraction: () => ({
|
|
53
|
+
trackWidgetInteraction: vi.fn(),
|
|
54
|
+
getInteractionId: vi.fn(),
|
|
55
|
+
}),
|
|
56
|
+
}));
|
|
57
|
+
|
|
49
58
|
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
50
59
|
useHardcopy: () => ({
|
|
51
60
|
getHardcopy: mockGetHardcopy,
|
|
@@ -112,13 +121,15 @@ describe('TitledPromptCarouselWidget analytics', () => {
|
|
|
112
121
|
|
|
113
122
|
await waitFor(
|
|
114
123
|
() => {
|
|
115
|
-
expect(
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
125
|
+
expect.any(Object),
|
|
126
|
+
{
|
|
118
127
|
widget_config_id: 'test-config-1',
|
|
119
128
|
widget_type: WidgetTypeV3.TitledPromptCarouselV3,
|
|
120
129
|
},
|
|
121
|
-
|
|
130
|
+
'0px',
|
|
131
|
+
true,
|
|
132
|
+
);
|
|
122
133
|
},
|
|
123
134
|
{ timeout: 3000 },
|
|
124
135
|
);
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TypingAnimationWidgetV3Config,
|
|
3
|
-
WidgetTypeV3,
|
|
4
|
-
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
-
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
|
|
6
|
-
import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
|
|
7
|
-
import { useCallback, useEffect } from 'react';
|
|
8
1
|
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
2
|
+
import { chatOnToggleAtom } from '@envive-ai/react-hooks/atoms/chat/chatState';
|
|
9
3
|
import {
|
|
10
4
|
EnviveMetricsEventName,
|
|
11
|
-
SpiffyMetricsEventName,
|
|
12
5
|
useAmplitude,
|
|
13
6
|
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
14
|
-
import { useSetAtom } from 'jotai';
|
|
15
7
|
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
16
|
-
import {
|
|
17
|
-
|
|
8
|
+
import {
|
|
9
|
+
TypingAnimationWidgetV3Config,
|
|
10
|
+
WidgetTypeV3,
|
|
11
|
+
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
12
|
+
import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
|
|
13
|
+
import {
|
|
14
|
+
WidgetInteractionComponent,
|
|
15
|
+
WidgetInteractionType,
|
|
16
|
+
} from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
17
|
+
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
|
|
18
|
+
import {
|
|
19
|
+
PromptCarouselRows,
|
|
20
|
+
usePromptCarouselAnalytics,
|
|
21
|
+
} from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
18
22
|
import { TypingAnimation } from '@envive-ai/react-toolkit-v3/TypingAnimation';
|
|
23
|
+
import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
|
|
24
|
+
import { useSetAtom } from 'jotai';
|
|
25
|
+
import { useCallback } from 'react';
|
|
19
26
|
import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
|
|
20
27
|
import { RawValues, getStringIdForText } from '../utils/functions';
|
|
21
28
|
|
|
@@ -64,16 +71,19 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
64
71
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
65
72
|
|
|
66
73
|
const { trackEvent } = useAmplitude();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
74
|
+
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
75
|
+
const {
|
|
76
|
+
onClick: onPromptClicked,
|
|
77
|
+
onDrag,
|
|
78
|
+
onHover,
|
|
79
|
+
onMouseDown,
|
|
80
|
+
onMouseUp,
|
|
81
|
+
onTouchStart,
|
|
82
|
+
onTouchEnd,
|
|
83
|
+
} = usePromptCarouselAnalytics(WidgetInteractionComponent.EMBEDDED_WIDGET, text => {
|
|
84
|
+
const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
|
|
85
|
+
return getStringIdForText(rawValues, text);
|
|
86
|
+
});
|
|
77
87
|
|
|
78
88
|
const handleButtonClick = useCallback(
|
|
79
89
|
(text: string) => {
|
|
@@ -93,12 +103,20 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
93
103
|
displayLocation: ChatElementDisplayLocationV3.TYPING_ANIMATION,
|
|
94
104
|
});
|
|
95
105
|
onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
|
|
106
|
+
onPromptClicked(text);
|
|
96
107
|
},
|
|
97
108
|
[hardcopyContent, trackEvent, onTypedMessageSubmitted, onToggle],
|
|
98
109
|
);
|
|
99
110
|
|
|
100
111
|
const handleTextFieldClick = useCallback(() => {
|
|
101
112
|
onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
|
|
113
|
+
trackWidgetInteraction({
|
|
114
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
115
|
+
trigger: {
|
|
116
|
+
widget: WidgetInteractionComponent.EMBEDDED_WIDGET,
|
|
117
|
+
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
102
120
|
}, [onToggle]);
|
|
103
121
|
|
|
104
122
|
return (
|
|
@@ -126,6 +144,12 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
126
144
|
}}
|
|
127
145
|
widgetEventProps={{
|
|
128
146
|
handleButtonClick,
|
|
147
|
+
handleButtonDrag: onDrag,
|
|
148
|
+
handleButtonHover: onHover,
|
|
149
|
+
handleButtonMouseDown: onMouseDown,
|
|
150
|
+
handleButtonMouseUp: onMouseUp,
|
|
151
|
+
handleButtonTouchStart: onTouchStart,
|
|
152
|
+
handleButtonTouchEnd: onTouchEnd,
|
|
129
153
|
handleTextFieldClick,
|
|
130
154
|
}}
|
|
131
155
|
/>
|
|
@@ -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 });
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../icons/dist/_virtual/rolldown_runtime.js
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
-
key = keys[i];
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
value: mod,
|
|
22
|
-
enumerable: true
|
|
23
|
-
}) : target, mod));
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
exports.__commonJSMin = __commonJSMin;
|
|
27
|
-
exports.__toESM = __toESM;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region ../icons/dist/_virtual/rolldown_runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { __commonJSMin, __toESM };
|