@envive-ai/react-widgets-v3 0.3.15-alpha.1 → 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/hocs/withBaseWidget/types.d.cts +5 -6
- package/dist/hocs/withBaseWidget/types.d.ts +5 -7
- 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/hooks/dist/application/models/api/orgConfigResults.d.ts +2 -1
- package/dist/packages/hooks/dist/application/models/api/userEvent.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/types.d.ts +3 -1
- package/dist/packages/hooks/dist/contexts/typesV3.d.ts +1 -1
- package/dist/packages/hooks/dist/types/custservice-types.d.ts +1 -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 -1
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/types.d.ts +1 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +2 -11
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +4 -13
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +44 -21
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +44 -21
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +34 -34
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +3 -1
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +35 -35
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +1 -11
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +3 -13
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +2 -11
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +4 -13
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +1 -10
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +3 -12
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +2 -11
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +4 -13
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +0 -9
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +2 -11
- 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 +1 -10
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +3 -12
- package/package.json +1 -1
- package/dist/hooks/dist/services/amplitudeService/eventNames.d.cts +0 -43
- package/dist/packages/hooks/dist/contexts/amplitudeContext/amplitudeContext.d.ts +0 -2
- package/dist/packages/hooks/dist/contexts/amplitudeContext/index.d.ts +0 -2
- package/dist/packages/hooks/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +0 -2
- package/dist/packages/hooks/dist/services/amplitudeService/amplitudeService.d.ts +0 -1
- package/dist/packages/hooks/dist/services/amplitudeService/eventNames.d.ts +0 -43
- package/dist/src/CXIntegration/hooks/useUnifiedCXButton.d.ts +0 -10
- package/dist/src/CXIntegration/hooks/useUnifiedCXButton.js +0 -29
- package/dist/src/CXIntegration/implementations/useDefaultUnifiedCXButton.d.ts +0 -2
- package/dist/src/CXIntegration/implementations/useDefaultUnifiedCXButton.js +0 -6
- package/dist/src/CXIntegration/implementations/useEightByEightUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useEightByEightUnifiedCXButton.js +0 -63
- package/dist/src/CXIntegration/implementations/useGladlyUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useGladlyUnifiedCXButton.js +0 -23
- package/dist/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.js +0 -54
- package/dist/src/CXIntegration/implementations/useGrooveUnifiedCXButton.d.ts +0 -18
- package/dist/src/CXIntegration/implementations/useGrooveUnifiedCXButton.js +0 -48
- package/dist/src/CXIntegration/implementations/useHelpScoutUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useHelpScoutUnifiedCXButton.js +0 -84
- package/dist/src/CXIntegration/implementations/useKustomerUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useKustomerUnifiedCXButton.js +0 -86
- package/dist/src/CXIntegration/implementations/useReDoUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useReDoUnifiedCXButton.js +0 -59
- package/dist/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.js +0 -62
- package/dist/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.js +0 -49
- package/dist/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.js +0 -77
- package/dist/src/CXIntegration/implementations/useTidioUnifiedCXButton.d.ts +0 -13
- package/dist/src/CXIntegration/implementations/useTidioUnifiedCXButton.js +0 -20
- package/dist/src/CXIntegration/implementations/useZendeskUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useZendeskUnifiedCXButton.js +0 -55
- package/dist/src/CXIntegration/implementations/useZowieUnifiedCXButton.d.ts +0 -13
- package/dist/src/CXIntegration/implementations/useZowieUnifiedCXButton.js +0 -20
- package/dist/src/CXIntegration/types.d.ts +0 -26
- package/dist/src/CXIntegration/types.js +0 -17
- package/dist/src/CXIntegration/utils/functions.d.ts +0 -2
- package/dist/src/CXIntegration/utils/functions.js +0 -57
- package/dist/src/debug/GenericSelect.d.ts +0 -11
- package/dist/src/debug/GenericSelect.js +0 -151
- package/dist/src/debug/MessageContent.d.ts +0 -4
- package/dist/src/debug/MessageContent.js +0 -87
- package/dist/src/debug/chatEmbed.d.ts +0 -2
- package/dist/src/debug/chatEmbed.js +0 -58
- package/dist/src/debug/debugBar.d.ts +0 -1
- package/dist/src/debug/debugBar.js +0 -9
- package/dist/src/debug/reportIssue.d.ts +0 -1
- package/dist/src/debug/reportIssue.js +0 -322
- package/dist/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.d.ts +0 -1
- package/dist/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.js +0 -452
- package/dist/src/hocs/withBaseWidget/index.d.ts +0 -2
- package/dist/src/hocs/withBaseWidget/index.js +0 -1
- package/dist/src/hocs/withBaseWidget/types.d.ts +0 -33
- package/dist/src/hocs/withBaseWidget/types.js +0 -0
- package/dist/src/hocs/withBaseWidget/withBaseWidget.d.ts +0 -5
- package/dist/src/hocs/withBaseWidget/withBaseWidget.js +0 -80
- package/dist/src/stories/FloatingChatWidget.stories.d.ts +0 -25
- package/dist/src/stories/FloatingChatWidget.stories.js +0 -44
- package/dist/src/stories/FullPageSalesAgentWidget.stories.d.ts +0 -31
- package/dist/src/stories/FullPageSalesAgentWidget.stories.js +0 -51
- package/dist/src/stories/ProductCardWidget.stories.d.ts +0 -31
- package/dist/src/stories/ProductCardWidget.stories.js +0 -44
- package/dist/src/stories/PromptButtonCarouselWithImageWidget.stories.d.ts +0 -31
- package/dist/src/stories/PromptButtonCarouselWithImageWidget.stories.js +0 -40
- package/dist/src/stories/PromptCarouselWidget.stories.d.ts +0 -31
- package/dist/src/stories/PromptCarouselWidget.stories.js +0 -40
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.d.ts +0 -1
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.js +0 -40
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.stories.d.ts +0 -12
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.stories.js +0 -12
- package/dist/src/stories/SalesAgentTest/index.d.ts +0 -0
- package/dist/src/stories/SalesAgentTest/index.js +0 -0
- package/dist/src/stories/SearchResults.stories.d.ts +0 -6
- package/dist/src/stories/SearchResults.stories.js +0 -23
- package/dist/src/stories/SearchZeroState.stories.d.ts +0 -38
- package/dist/src/stories/SearchZeroState.stories.js +0 -42
- package/dist/src/stories/SocialProofFlowWidget.stories.d.ts +0 -35
- package/dist/src/stories/SocialProofFlowWidget.stories.js +0 -60
- package/dist/src/stories/SuggestionBar.stories.d.ts +0 -7
- package/dist/src/stories/SuggestionBar.stories.js +0 -36
- package/dist/src/stories/TitledPromptCarouselWidget.stories.d.ts +0 -32
- package/dist/src/stories/TitledPromptCarouselWidget.stories.js +0 -55
- package/dist/src/stories/TypingAnimationFlowWidget.stories.d.ts +0 -34
- package/dist/src/stories/TypingAnimationFlowWidget.stories.js +0 -51
- package/dist/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +0 -12
- package/dist/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +0 -112
- package/dist/src/widgets/ChatPreviewComparisonWidget/index.d.ts +0 -3
- package/dist/src/widgets/ChatPreviewComparisonWidget/index.js +0 -2
- package/dist/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +0 -9
- package/dist/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +0 -34
- package/dist/src/widgets/ChatPreviewLoadingWidget/index.d.ts +0 -3
- package/dist/src/widgets/ChatPreviewLoadingWidget/index.js +0 -2
- package/dist/src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +0 -12
- package/dist/src/widgets/ChatPreviewWidget/ChatPreviewWidget.js +0 -111
- package/dist/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.d.ts +0 -1
- package/dist/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.js +0 -97
- package/dist/src/widgets/ChatPreviewWidget/index.d.ts +0 -3
- package/dist/src/widgets/ChatPreviewWidget/index.js +0 -2
- package/dist/src/widgets/FloatingChatWidget/FloatingChatOverlay.d.ts +0 -14
- package/dist/src/widgets/FloatingChatWidget/FloatingChatOverlay.js +0 -44
- package/dist/src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +0 -8
- package/dist/src/widgets/FloatingChatWidget/FloatingChatWidget.js +0 -134
- package/dist/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.d.ts +0 -1
- package/dist/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.js +0 -100
- package/dist/src/widgets/FloatingChatWidget/constants.d.ts +0 -1
- package/dist/src/widgets/FloatingChatWidget/constants.js +0 -1
- package/dist/src/widgets/FloatingChatWidget/hooks/useAutoPopup.d.ts +0 -4
- package/dist/src/widgets/FloatingChatWidget/hooks/useAutoPopup.js +0 -51
- package/dist/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.d.ts +0 -11
- package/dist/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.js +0 -21
- package/dist/src/widgets/FloatingChatWidget/index.d.ts +0 -4
- package/dist/src/widgets/FloatingChatWidget/index.js +0 -3
- package/dist/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +0 -12
- package/dist/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +0 -14
- package/dist/src/widgets/FullPageSalesAgentWidget/index.d.ts +0 -1
- package/dist/src/widgets/FullPageSalesAgentWidget/index.js +0 -1
- package/dist/src/widgets/ProductCardWidget/ProductCardWidget.d.ts +0 -7
- package/dist/src/widgets/ProductCardWidget/ProductCardWidget.js +0 -94
- package/dist/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.d.ts +0 -1
- package/dist/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.js +0 -106
- package/dist/src/widgets/ProductCardWidget/index.d.ts +0 -2
- package/dist/src/widgets/ProductCardWidget/index.js +0 -1
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +0 -12
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +0 -88
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.d.ts +0 -1
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.js +0 -132
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/index.d.ts +0 -2
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/index.js +0 -2
- package/dist/src/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +0 -7
- package/dist/src/widgets/PromptCarouselWidget/PromptCarouselWidget.js +0 -74
- package/dist/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.d.ts +0 -1
- package/dist/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.js +0 -106
- package/dist/src/widgets/PromptCarouselWidget/index.d.ts +0 -2
- package/dist/src/widgets/PromptCarouselWidget/index.js +0 -1
- package/dist/src/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +0 -7
- package/dist/src/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +0 -25
- package/dist/src/widgets/SocialProofFlowWidget/index.d.ts +0 -3
- package/dist/src/widgets/SocialProofFlowWidget/index.js +0 -2
- package/dist/src/widgets/SocialProofWidget/SocialProofWidget.d.ts +0 -12
- package/dist/src/widgets/SocialProofWidget/SocialProofWidget.js +0 -203
- package/dist/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.d.ts +0 -1
- package/dist/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.js +0 -135
- package/dist/src/widgets/SocialProofWidget/index.d.ts +0 -2
- package/dist/src/widgets/SocialProofWidget/index.js +0 -1
- package/dist/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +0 -7
- package/dist/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +0 -75
- package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.d.ts +0 -1
- package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.js +0 -106
- package/dist/src/widgets/TitledPromptCarouselWidget/index.d.ts +0 -2
- package/dist/src/widgets/TitledPromptCarouselWidget/index.js +0 -1
- package/dist/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +0 -7
- package/dist/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +0 -25
- package/dist/src/widgets/TypingAnimationFlowWidget/index.d.ts +0 -3
- package/dist/src/widgets/TypingAnimationFlowWidget/index.js +0 -2
- package/dist/src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +0 -12
- package/dist/src/widgets/TypingAnimationWidget/TypingAnimationWidget.js +0 -126
- package/dist/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.d.ts +0 -1
- package/dist/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.js +0 -118
- package/dist/src/widgets/TypingAnimationWidget/index.d.ts +0 -2
- package/dist/src/widgets/TypingAnimationWidget/index.js +0 -1
- package/dist/src/widgets/__tests__/testUtils.d.ts +0 -60
- package/dist/src/widgets/__tests__/testUtils.js +0 -46
- package/dist/src/widgets/__tests__/trackEventCanary.test.d.ts +0 -1
- package/dist/src/widgets/__tests__/trackEventCanary.test.js +0 -37
- package/dist/src/widgets/hooks/useGetWidgetStatus.d.ts +0 -7
- package/dist/src/widgets/hooks/useGetWidgetStatus.js +0 -17
- package/dist/src/widgets/utils/functions.d.ts +0 -16
- package/dist/src/widgets/utils/functions.js +0 -87
- package/dist/src/widgets-v2/SearchResults/index.d.ts +0 -2
- package/dist/src/widgets-v2/SearchResults/index.js +0 -2
- package/dist/src/widgets-v2/SearchZeroState/index.d.ts +0 -2
- package/dist/src/widgets-v2/SearchZeroState/index.js +0 -2
- package/dist/src/widgets-v2/SuggestionBar/index.d.ts +0 -2
- package/dist/src/widgets-v2/SuggestionBar/index.js +0 -2
- package/dist/src/widgets-v2/SuggestionButtonContainer/index.d.ts +0 -2
- package/dist/src/widgets-v2/SuggestionButtonContainer/index.js +0 -2
- package/dist/tsdown.config.d.ts +0 -2
- package/dist/tsdown.config.js +0 -12
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useMemo } from 'react';
|
|
3
|
-
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
4
|
-
import { useAtomValue, useSetAtom } from 'jotai';
|
|
5
|
-
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
6
|
-
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
7
|
-
import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
|
|
8
|
-
import { PageVariant, SocialProof, WidgetKind, } from '@envive-ai/react-toolkit-v3/SocialProof';
|
|
9
|
-
import { ChatElementDisplayLocationV3, VariantTypeEnum, } from '@envive-ai/react-hooks/application/models';
|
|
10
|
-
import { chatPreviewLoadingDataAtom } from '@envive-ai/react-hooks/atoms/widget';
|
|
11
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName, useAmplitude, } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
12
|
-
import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
|
|
13
|
-
import { WidgetInteractionComponent, WidgetInteractionType, } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
14
|
-
import { useProductImageUrl } from '@envive-ai/react-hooks/hooks/ProductImageUrl';
|
|
15
|
-
import { ChatPreviewLoading } from '@envive-ai/react-toolkit-v3/ChatPreviewLoading';
|
|
16
|
-
import { usePromptCarouselAnalytics } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
17
|
-
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
18
|
-
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
19
|
-
import { getStringIdForText } from '../utils/functions';
|
|
20
|
-
const SocialProofWidgetHandler = (props) => {
|
|
21
|
-
const setChatPreviewLoadingData = useSetAtom(chatPreviewLoadingDataAtom);
|
|
22
|
-
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
23
|
-
const { openChat } = useChatToggle();
|
|
24
|
-
const variantInfo = useAtomValue(variantInfoAtom);
|
|
25
|
-
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
26
|
-
const { onClick: onSuggestionClick, onHover, onDrag, onMouseDown, onMouseUp, onTouchStart, onTouchEnd, } = usePromptCarouselAnalytics(WidgetInteractionComponent.SOCIAL_PROOF, text => text);
|
|
27
|
-
const { hardcopyContent, widgetConfig, uiConfig, isLoading, widgetConfigId } = props;
|
|
28
|
-
const socialProofWidgetConfig = widgetConfig;
|
|
29
|
-
const id = widgetConfig?.contentId;
|
|
30
|
-
const { pageVariant, countKey } = useMemo(() => {
|
|
31
|
-
if (variantInfo.variant === VariantTypeEnum.Pdp) {
|
|
32
|
-
return {
|
|
33
|
-
pageVariant: PageVariant.PDP,
|
|
34
|
-
countKey: variantInfo.productId,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (variantInfo.variant === VariantTypeEnum.Plp) {
|
|
38
|
-
return {
|
|
39
|
-
pageVariant: PageVariant.PLP,
|
|
40
|
-
countKey: variantInfo.plpId,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
pageVariant: PageVariant.PageVisit,
|
|
45
|
-
countKey: variantInfo.url || variantInfo.pageVisitCategory,
|
|
46
|
-
};
|
|
47
|
-
}, [variantInfo]);
|
|
48
|
-
const hardCopyContent = {
|
|
49
|
-
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
50
|
-
customerQueryText: hardcopyContent?.values?.customerQueryText,
|
|
51
|
-
primaryButtonText: hardcopyContent?.values?.primaryButtonText,
|
|
52
|
-
secondaryButtonTitleText: hardcopyContent?.values?.secondaryButtonTitleText,
|
|
53
|
-
secondaryButtonTexts: hardcopyContent?.values?.secondaryButtonTexts,
|
|
54
|
-
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
55
|
-
};
|
|
56
|
-
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
57
|
-
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
58
|
-
const productId = variantInfo.variant === VariantTypeEnum.Pdp ? variantInfo.productId : undefined;
|
|
59
|
-
const dynamicImageUrl = useProductImageUrl(productId);
|
|
60
|
-
const images = socialProofWidgetConfig?.kind !== WidgetKind.DYNAMIC
|
|
61
|
-
? socialProofWidgetConfig?.images
|
|
62
|
-
: [{ src: dynamicImageUrl, alt: 'Product Image' }];
|
|
63
|
-
const { trackEvent } = useAmplitude();
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
trackEvent({
|
|
66
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
67
|
-
eventProps: {
|
|
68
|
-
widget_config_id: widgetConfigId,
|
|
69
|
-
widget_type: WidgetTypeV3.SocialProofV3,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
}, [trackEvent, widgetConfigId]);
|
|
73
|
-
const handlePrimaryButtonClick = useCallback((text) => {
|
|
74
|
-
const rawValues = hardcopyContent?.rawValues;
|
|
75
|
-
const stringId = getStringIdForText(rawValues, text);
|
|
76
|
-
trackEvent({
|
|
77
|
-
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
78
|
-
eventProps: {
|
|
79
|
-
response_id: hardcopyContent?.responseId,
|
|
80
|
-
string_id: stringId,
|
|
81
|
-
text,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
onTypedMessageSubmitted({
|
|
85
|
-
query: text,
|
|
86
|
-
userTyped: false,
|
|
87
|
-
displayLocation: ChatElementDisplayLocationV3.SOCIAL_PROOF_PRIMARY_BUTTON,
|
|
88
|
-
});
|
|
89
|
-
openChat(ChatElementDisplayLocationV3.SOCIAL_PROOF_PRIMARY_BUTTON);
|
|
90
|
-
trackWidgetInteraction({
|
|
91
|
-
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
92
|
-
trigger: {
|
|
93
|
-
widget: WidgetInteractionComponent.SOCIAL_PROOF,
|
|
94
|
-
widget_interaction: WidgetInteractionType.SUGGESTION_CLICKED,
|
|
95
|
-
widget_interaction_data: {
|
|
96
|
-
suggestion_clicked: {
|
|
97
|
-
suggestion_id: text,
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
}, [onTypedMessageSubmitted, openChat]);
|
|
103
|
-
const handlePrimaryButtonHover = useCallback((text) => {
|
|
104
|
-
trackWidgetInteraction({
|
|
105
|
-
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
106
|
-
trigger: {
|
|
107
|
-
widget: WidgetInteractionComponent.SOCIAL_PROOF,
|
|
108
|
-
widget_interaction: WidgetInteractionType.WIDGET_HOVERED,
|
|
109
|
-
widget_interaction_data: {
|
|
110
|
-
suggestion_hovered: {
|
|
111
|
-
suggestion_id: text,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
}, []);
|
|
117
|
-
const handleSecondaryButtonClick = useCallback((text) => {
|
|
118
|
-
const rawValues = hardcopyContent?.rawValues;
|
|
119
|
-
const stringId = getStringIdForText(rawValues, text);
|
|
120
|
-
trackEvent({
|
|
121
|
-
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
122
|
-
eventProps: {
|
|
123
|
-
response_id: hardcopyContent?.responseId,
|
|
124
|
-
string_id: stringId,
|
|
125
|
-
text,
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
onTypedMessageSubmitted({
|
|
129
|
-
query: text,
|
|
130
|
-
userTyped: false,
|
|
131
|
-
displayLocation: ChatElementDisplayLocationV3.SOCIAL_PROOF_SECONDARY_BUTTON,
|
|
132
|
-
});
|
|
133
|
-
openChat(ChatElementDisplayLocationV3.SOCIAL_PROOF_SECONDARY_BUTTON);
|
|
134
|
-
onSuggestionClick(text);
|
|
135
|
-
}, [onTypedMessageSubmitted, openChat]);
|
|
136
|
-
const handleTextFieldClick = useCallback(() => {
|
|
137
|
-
openChat(ChatElementDisplayLocationV3.SOCIAL_PROOF_TEXT_FIELD);
|
|
138
|
-
trackWidgetInteraction({
|
|
139
|
-
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
140
|
-
trigger: {
|
|
141
|
-
widget: WidgetInteractionComponent.SOCIAL_PROOF,
|
|
142
|
-
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
}, [openChat]);
|
|
146
|
-
if (isLoading) {
|
|
147
|
-
return _jsx(ChatPreviewLoading, { fullIsLoading: true });
|
|
148
|
-
}
|
|
149
|
-
setChatPreviewLoadingData({
|
|
150
|
-
widgetConfigId,
|
|
151
|
-
data: {
|
|
152
|
-
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
153
|
-
textFieldPlaceholder: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
154
|
-
logoSrc: logoSrc,
|
|
155
|
-
hideLogo: hideLogo ?? false,
|
|
156
|
-
variant: socialProofWidgetConfig?.variant,
|
|
157
|
-
hexCardColor: socialProofWidgetConfig?.hexCardColor,
|
|
158
|
-
hideTextField: socialProofWidgetConfig?.hideTextField ?? false,
|
|
159
|
-
},
|
|
160
|
-
});
|
|
161
|
-
const widgetStyleProps = {
|
|
162
|
-
theme: Theme.GLOBAL_CUSTOM,
|
|
163
|
-
variant: socialProofWidgetConfig?.variant,
|
|
164
|
-
kind: socialProofWidgetConfig?.kind,
|
|
165
|
-
primaryButtonVariant: socialProofWidgetConfig?.primaryButtonVariant,
|
|
166
|
-
secondaryButtonVariant: socialProofWidgetConfig?.secondaryButtonVariant,
|
|
167
|
-
promptCarouselRows: socialProofWidgetConfig?.promptCarouselRows,
|
|
168
|
-
imageGalleryLayout: socialProofWidgetConfig?.imageGalleryLayout,
|
|
169
|
-
hideImage: images?.length === 0 || images === undefined ? true : socialProofWidgetConfig?.hideImage,
|
|
170
|
-
hideTextField: socialProofWidgetConfig?.hideTextField,
|
|
171
|
-
hideLogo,
|
|
172
|
-
hexCardColor: socialProofWidgetConfig?.hexCardColor,
|
|
173
|
-
dynamicLayout: socialProofWidgetConfig?.dynamicLayout ?? undefined,
|
|
174
|
-
};
|
|
175
|
-
const widgetContentProps = {
|
|
176
|
-
titleLabel: hardCopyContent?.titleLabel,
|
|
177
|
-
customerQueryText: hardCopyContent?.customerQueryText,
|
|
178
|
-
primaryButtonText: hardCopyContent?.primaryButtonText,
|
|
179
|
-
secondaryButtonTitleText: hardCopyContent?.secondaryButtonTitleText,
|
|
180
|
-
secondaryButtonTexts: hardCopyContent?.secondaryButtonTexts,
|
|
181
|
-
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
182
|
-
images: images ?? [],
|
|
183
|
-
logoSrc: logoSrc ?? undefined,
|
|
184
|
-
};
|
|
185
|
-
const widgetEventProps = {
|
|
186
|
-
handlePrimaryButtonClick,
|
|
187
|
-
handlePrimaryButtonHover,
|
|
188
|
-
handleSecondaryButtonClick,
|
|
189
|
-
handleSecondaryButtonHover: onHover,
|
|
190
|
-
handleSecondaryButtonDrag: onDrag,
|
|
191
|
-
handleSecondaryButtonMouseDown: onMouseDown,
|
|
192
|
-
handleSecondaryButtonMouseUp: onMouseUp,
|
|
193
|
-
handleSecondaryButtonTouchStart: onTouchStart,
|
|
194
|
-
handleSecondaryButtonTouchEnd: onTouchEnd,
|
|
195
|
-
handleTextFieldClick,
|
|
196
|
-
};
|
|
197
|
-
return (_jsx(SocialProof, { baseProps: { id, pageVariant, countKey }, widgetStyleProps: widgetStyleProps, widgetContentProps: widgetContentProps, widgetEventProps: widgetEventProps }));
|
|
198
|
-
};
|
|
199
|
-
export const SocialProofWidgetWithBaseWidget = withBaseWidget(SocialProofWidgetHandler);
|
|
200
|
-
export const SocialProofWidget = ({ widgetConfigId }) => {
|
|
201
|
-
return (_jsx(SocialProofWidgetWithBaseWidget, { widgetConfigId: widgetConfigId, widgetType: WidgetTypeV3.SocialProofV3 }));
|
|
202
|
-
};
|
|
203
|
-
SocialProofWidget.displayName = 'SocialProofWidget';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName, } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
|
-
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
-
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
6
|
-
import { SocialProofWidget } from '../SocialProofWidget';
|
|
7
|
-
const mockTrackEvent = vi.fn();
|
|
8
|
-
const mockGetHardcopy = vi.fn();
|
|
9
|
-
vi.mock('@envive-ai/react-toolkit-v3/SocialProof', async (importOriginal) => {
|
|
10
|
-
const actual = await importOriginal();
|
|
11
|
-
const MockSocialProof = ({ widgetContentProps, widgetEventProps, }) => (_jsx("div", { "data-testid": "social-proof-mock", children: _jsx("button", { type: "button", onClick: () => widgetEventProps.handlePrimaryButtonClick(widgetContentProps.primaryButtonText || 'Primary'), children: widgetContentProps.primaryButtonText || 'Primary' }) }));
|
|
12
|
-
return {
|
|
13
|
-
...actual,
|
|
14
|
-
SocialProof: MockSocialProof,
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
18
|
-
useAmplitude: () => ({
|
|
19
|
-
trackEvent: mockTrackEvent,
|
|
20
|
-
isReady: true,
|
|
21
|
-
}),
|
|
22
|
-
SpiffyMetricsEventName: {
|
|
23
|
-
ChatComponentVisible: 'Chat Component Visible',
|
|
24
|
-
SearchComponentVisible: 'Search Component Visible',
|
|
25
|
-
},
|
|
26
|
-
EnviveMetricsEventName: {
|
|
27
|
-
WidgetTextClicked: 'Widget Text Clicked',
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
30
|
-
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
31
|
-
useHardcopy: () => ({
|
|
32
|
-
getHardcopy: mockGetHardcopy,
|
|
33
|
-
}),
|
|
34
|
-
}));
|
|
35
|
-
vi.mock('@envive-ai/react-hooks/contexts/pageContext', () => ({
|
|
36
|
-
usePage: () => ({
|
|
37
|
-
userEvent: {
|
|
38
|
-
id: 'test-user-event-id',
|
|
39
|
-
category: UserEventCategory.PageVisit,
|
|
40
|
-
created_at: '2025-01-01T00:00:00Z',
|
|
41
|
-
event_id: 'test-event-id',
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
}));
|
|
45
|
-
vi.mock('@envive-ai/react-hooks/contexts/widgetConfigContext', () => ({
|
|
46
|
-
useWidgetConfig: () => ({
|
|
47
|
-
getWidgetConfig: vi.fn().mockResolvedValue({}),
|
|
48
|
-
}),
|
|
49
|
-
}));
|
|
50
|
-
vi.mock('@envive-ai/react-hooks/contexts/uiConfigContext', () => ({
|
|
51
|
-
useUiConfig: () => ({
|
|
52
|
-
getUiConfig: vi.fn().mockResolvedValue({}),
|
|
53
|
-
}),
|
|
54
|
-
}));
|
|
55
|
-
vi.mock('@envive-ai/react-hooks/contexts/salesAgentContext', () => ({
|
|
56
|
-
useSalesAgent: () => ({
|
|
57
|
-
onTypedMessageSubmitted: vi.fn(),
|
|
58
|
-
}),
|
|
59
|
-
}));
|
|
60
|
-
vi.mock('@envive-ai/react-hooks/hooks/ChatToggle', () => ({
|
|
61
|
-
useChatToggle: () => ({
|
|
62
|
-
openChat: vi.fn(),
|
|
63
|
-
}),
|
|
64
|
-
}));
|
|
65
|
-
vi.mock('@envive-ai/react-hooks/atoms/chat', () => ({
|
|
66
|
-
lastAssistantMessageAtom: {},
|
|
67
|
-
}));
|
|
68
|
-
vi.mock('@envive-ai/react-hooks/atoms/app', () => ({
|
|
69
|
-
variantInfoAtom: {},
|
|
70
|
-
}));
|
|
71
|
-
vi.mock('@envive-ai/react-hooks/atoms/widget', () => ({
|
|
72
|
-
chatPreviewLoadingDataAtom: {},
|
|
73
|
-
}));
|
|
74
|
-
vi.mock('jotai', async (importOriginal) => {
|
|
75
|
-
const actual = await importOriginal();
|
|
76
|
-
const variantInfo = {
|
|
77
|
-
variant: 'PageVisit',
|
|
78
|
-
productId: undefined,
|
|
79
|
-
plpId: undefined,
|
|
80
|
-
url: '',
|
|
81
|
-
pageVisitCategory: '',
|
|
82
|
-
};
|
|
83
|
-
const useAtomValueMock = vi.fn();
|
|
84
|
-
useAtomValueMock.mockReturnValueOnce([]).mockReturnValueOnce(variantInfo).mockReturnValue([]);
|
|
85
|
-
return {
|
|
86
|
-
...actual,
|
|
87
|
-
useAtomValue: useAtomValueMock,
|
|
88
|
-
useSetAtom: vi.fn(() => vi.fn()),
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
describe('SocialProofWidget analytics', () => {
|
|
92
|
-
const defaultHardcopy = {
|
|
93
|
-
responseId: 'test-response-id',
|
|
94
|
-
language: 'en',
|
|
95
|
-
values: {
|
|
96
|
-
primaryButtonText: 'Primary Button',
|
|
97
|
-
titleLabel: 'Title',
|
|
98
|
-
},
|
|
99
|
-
rawValues: {
|
|
100
|
-
primaryButtonText: { id: 'id-1', value: 'Primary Button' },
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
beforeEach(() => {
|
|
104
|
-
vi.clearAllMocks();
|
|
105
|
-
mockGetHardcopy.mockResolvedValue(defaultHardcopy);
|
|
106
|
-
});
|
|
107
|
-
it('should track ChatComponentVisible when widget mounts', async () => {
|
|
108
|
-
render(_jsx(SocialProofWidget, { widgetConfigId: "test-config-1" }));
|
|
109
|
-
await waitFor(() => {
|
|
110
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
111
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
112
|
-
eventProps: {
|
|
113
|
-
widget_config_id: 'test-config-1',
|
|
114
|
-
widget_type: WidgetTypeV3.SocialProofV3,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
}, { timeout: 3000 });
|
|
118
|
-
}, 5000);
|
|
119
|
-
it('should track WidgetTextClicked when primary button is clicked', async () => {
|
|
120
|
-
render(_jsx(SocialProofWidget, { widgetConfigId: "test-config-2" }));
|
|
121
|
-
await waitFor(() => {
|
|
122
|
-
expect(screen.getByText('Primary Button')).toBeInTheDocument();
|
|
123
|
-
}, { timeout: 3000 });
|
|
124
|
-
mockTrackEvent.mockClear();
|
|
125
|
-
screen.getByText('Primary Button').click();
|
|
126
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
127
|
-
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
128
|
-
eventProps: {
|
|
129
|
-
response_id: 'test-response-id',
|
|
130
|
-
string_id: 'id-1',
|
|
131
|
-
text: 'Primary Button',
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
}, 5000);
|
|
135
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SocialProofWidget, SocialProofWidgetWithBaseWidget } from './SocialProofWidget';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
3
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName, useAmplitude, } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
|
-
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
5
|
-
import { WidgetTypeV3, } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
6
|
-
import { useCallback, useEffect } from 'react';
|
|
7
|
-
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
8
|
-
import { WidgetInteractionComponent } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
9
|
-
import { AnimationSpeed, usePromptCarouselAnalytics, } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
10
|
-
import { TitledPromptCarousel } from '@envive-ai/react-toolkit-v3/TitledPromptCarousel';
|
|
11
|
-
import { withBaseWidget } from '../../hocs/withBaseWidget';
|
|
12
|
-
import { getStringIdForText } from '../utils/functions';
|
|
13
|
-
const mockButtonTexts = [
|
|
14
|
-
'Loading button 1',
|
|
15
|
-
'Loading button 2',
|
|
16
|
-
'Loading button 3',
|
|
17
|
-
'Loading button 4',
|
|
18
|
-
'Loading button 5',
|
|
19
|
-
];
|
|
20
|
-
const mockTitleLabel = 'Loading...';
|
|
21
|
-
const TitledPromptCarouselWidgetHandler = (props) => {
|
|
22
|
-
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
23
|
-
const { openChat } = useChatToggle();
|
|
24
|
-
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
25
|
-
const { onClick, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } = usePromptCarouselAnalytics(WidgetInteractionComponent.EMBEDDED_WIDGET, text => text);
|
|
26
|
-
const hardCopyTitleLabel = hardcopyContent?.values?.titleLabel;
|
|
27
|
-
const titleLabel = isLoading ? mockTitleLabel : hardCopyTitleLabel;
|
|
28
|
-
const titleAriaLabel = hardcopyContent?.values?.titleAriaLabel;
|
|
29
|
-
const promptCarouselAriaLabel = hardcopyContent?.values?.promptCarouselAriaLabel;
|
|
30
|
-
const promptButtonTexts = hardcopyContent?.values?.promptButtonTexts || [];
|
|
31
|
-
const buttonTexts = isLoading ? mockButtonTexts : promptButtonTexts;
|
|
32
|
-
const titledPromptCarouselWidgetConfig = widgetConfig;
|
|
33
|
-
const id = titledPromptCarouselWidgetConfig?.contentId;
|
|
34
|
-
const boldFirstButton = titledPromptCarouselWidgetConfig?.boldFirstButton;
|
|
35
|
-
const promptButtonType = titledPromptCarouselWidgetConfig?.promptButtonType;
|
|
36
|
-
const promptCarouselRows = titledPromptCarouselWidgetConfig?.promptCarouselRows;
|
|
37
|
-
const animationSpeed = isLoading
|
|
38
|
-
? AnimationSpeed.NONE
|
|
39
|
-
: titledPromptCarouselWidgetConfig?.animationSpeed;
|
|
40
|
-
const { trackEvent } = useAmplitude();
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
trackEvent({
|
|
43
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
44
|
-
eventProps: {
|
|
45
|
-
widget_config_id: widgetConfigId,
|
|
46
|
-
widget_type: WidgetTypeV3.TitledPromptCarouselV3,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
}, [trackEvent, widgetConfigId]);
|
|
50
|
-
const handleButtonClick = useCallback((text) => {
|
|
51
|
-
const rawValues = hardcopyContent?.rawValues;
|
|
52
|
-
const stringId = getStringIdForText(rawValues, text);
|
|
53
|
-
trackEvent({
|
|
54
|
-
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
55
|
-
eventProps: {
|
|
56
|
-
response_id: hardcopyContent?.responseId,
|
|
57
|
-
string_id: stringId,
|
|
58
|
-
text,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
onTypedMessageSubmitted({
|
|
62
|
-
query: text,
|
|
63
|
-
userTyped: false,
|
|
64
|
-
displayLocation: ChatElementDisplayLocationV3.TITLED_PROMPT_CAROUSEL,
|
|
65
|
-
});
|
|
66
|
-
openChat(ChatElementDisplayLocationV3.TITLED_PROMPT_CAROUSEL);
|
|
67
|
-
onClick(text);
|
|
68
|
-
}, [onTypedMessageSubmitted, openChat]);
|
|
69
|
-
return (_jsx(TitledPromptCarousel, { id: id, titleLabel: titleLabel, titleAriaLabel: titleAriaLabel, isLoading: isLoading, boldFirstButton: boldFirstButton, promptButtonType: promptButtonType, promptCarouselRows: promptCarouselRows, animationSpeed: animationSpeed, handleButtonClick: handleButtonClick, handleButtonDrag: onDrag, handleButtonHover: onHover, handleButtonMouseDown: onMouseDown, handleButtonMouseUp: onMouseUp, handleButtonTouchStart: onTouchStart, handleButtonTouchEnd: onTouchEnd, promptButtonTexts: buttonTexts, promptCarouselAriaLabel: promptCarouselAriaLabel }));
|
|
70
|
-
};
|
|
71
|
-
const TitledPromptCarouselWidgetWithBaseWidget = withBaseWidget(TitledPromptCarouselWidgetHandler);
|
|
72
|
-
export const TitledPromptCarouselWidget = ({ widgetConfigId }) => {
|
|
73
|
-
return (_jsx(TitledPromptCarouselWidgetWithBaseWidget, { widgetConfigId: widgetConfigId, widgetType: WidgetTypeV3.TitledPromptCarouselV3 }));
|
|
74
|
-
};
|
|
75
|
-
TitledPromptCarouselWidget.displayName = 'TitledPromptCarouselWidget';
|
package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName, } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
|
-
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
-
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
6
|
-
import { TitledPromptCarouselWidget } from '../TitledPromptCarouselWidget';
|
|
7
|
-
const mockTrackEvent = vi.fn();
|
|
8
|
-
const mockGetHardcopy = vi.fn();
|
|
9
|
-
vi.mock('@envive-ai/react-toolkit-v3/TitledPromptCarousel', () => ({
|
|
10
|
-
TitledPromptCarousel: ({ promptButtonTexts, handleButtonClick, }) => (_jsx("div", { "data-testid": "titled-prompt-carousel-mock", children: promptButtonTexts.map(text => (_jsx("button", { type: "button", onClick: () => handleButtonClick(text), children: text }, text))) })),
|
|
11
|
-
}));
|
|
12
|
-
vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
13
|
-
useAmplitude: () => ({
|
|
14
|
-
trackEvent: mockTrackEvent,
|
|
15
|
-
isReady: true,
|
|
16
|
-
}),
|
|
17
|
-
SpiffyMetricsEventName: {
|
|
18
|
-
ChatComponentVisible: 'Chat Component Visible',
|
|
19
|
-
SearchComponentVisible: 'Search Component Visible',
|
|
20
|
-
},
|
|
21
|
-
EnviveMetricsEventName: {
|
|
22
|
-
WidgetTextClicked: 'Widget Text Clicked',
|
|
23
|
-
},
|
|
24
|
-
}));
|
|
25
|
-
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
26
|
-
useHardcopy: () => ({
|
|
27
|
-
getHardcopy: mockGetHardcopy,
|
|
28
|
-
}),
|
|
29
|
-
}));
|
|
30
|
-
vi.mock('@envive-ai/react-hooks/contexts/pageContext', () => ({
|
|
31
|
-
usePage: () => ({
|
|
32
|
-
userEvent: {
|
|
33
|
-
id: 'test-user-event-id',
|
|
34
|
-
category: UserEventCategory.PageVisit,
|
|
35
|
-
created_at: '2025-01-01T00:00:00Z',
|
|
36
|
-
event_id: 'test-event-id',
|
|
37
|
-
},
|
|
38
|
-
}),
|
|
39
|
-
}));
|
|
40
|
-
vi.mock('@envive-ai/react-hooks/contexts/widgetConfigContext', () => ({
|
|
41
|
-
useWidgetConfig: () => ({
|
|
42
|
-
getWidgetConfig: vi.fn().mockResolvedValue({}),
|
|
43
|
-
}),
|
|
44
|
-
}));
|
|
45
|
-
vi.mock('@envive-ai/react-hooks/contexts/uiConfigContext', () => ({
|
|
46
|
-
useUiConfig: () => ({
|
|
47
|
-
getUiConfig: vi.fn().mockResolvedValue({}),
|
|
48
|
-
}),
|
|
49
|
-
}));
|
|
50
|
-
vi.mock('@envive-ai/react-hooks/contexts/salesAgentContext', () => ({
|
|
51
|
-
useSalesAgent: () => ({
|
|
52
|
-
onTypedMessageSubmitted: vi.fn(),
|
|
53
|
-
}),
|
|
54
|
-
}));
|
|
55
|
-
vi.mock('@envive-ai/react-hooks/hooks/ChatToggle', () => ({
|
|
56
|
-
useChatToggle: () => ({
|
|
57
|
-
openChat: vi.fn(),
|
|
58
|
-
}),
|
|
59
|
-
}));
|
|
60
|
-
describe('TitledPromptCarouselWidget analytics', () => {
|
|
61
|
-
const defaultHardcopy = {
|
|
62
|
-
responseId: 'test-response-id',
|
|
63
|
-
language: 'en',
|
|
64
|
-
values: {
|
|
65
|
-
promptButtonTexts: ['Button 1', 'Button 2', 'Button 3'],
|
|
66
|
-
},
|
|
67
|
-
rawValues: {
|
|
68
|
-
promptButtonTexts: [
|
|
69
|
-
{ id: 'id-1', value: 'Button 1' },
|
|
70
|
-
{ id: 'id-2', value: 'Button 2' },
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
vi.clearAllMocks();
|
|
76
|
-
mockGetHardcopy.mockResolvedValue(defaultHardcopy);
|
|
77
|
-
});
|
|
78
|
-
it('should track ChatComponentVisible when widget mounts', async () => {
|
|
79
|
-
render(_jsx(TitledPromptCarouselWidget, { widgetConfigId: "test-config-1" }));
|
|
80
|
-
await waitFor(() => {
|
|
81
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
82
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
83
|
-
eventProps: {
|
|
84
|
-
widget_config_id: 'test-config-1',
|
|
85
|
-
widget_type: WidgetTypeV3.TitledPromptCarouselV3,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
}, { timeout: 3000 });
|
|
89
|
-
}, 5000);
|
|
90
|
-
it('should track WidgetTextClicked when button is clicked', async () => {
|
|
91
|
-
render(_jsx(TitledPromptCarouselWidget, { widgetConfigId: "test-config-2" }));
|
|
92
|
-
await waitFor(() => {
|
|
93
|
-
expect(screen.getByText('Button 1')).toBeInTheDocument();
|
|
94
|
-
}, { timeout: 3000 });
|
|
95
|
-
mockTrackEvent.mockClear();
|
|
96
|
-
screen.getByText('Button 1').click();
|
|
97
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
98
|
-
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
99
|
-
eventProps: {
|
|
100
|
-
response_id: 'test-response-id',
|
|
101
|
-
string_id: 'id-1',
|
|
102
|
-
text: 'Button 1',
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
}, 5000);
|
|
106
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TitledPromptCarouselWidget } from './TitledPromptCarouselWidget';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
3
|
-
import { ChatPreviewLoading } from '@envive-ai/react-toolkit-v3/ChatPreviewLoading';
|
|
4
|
-
import useGetWidgetStatus from '../hooks/useGetWidgetStatus';
|
|
5
|
-
import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
|
|
6
|
-
import { TypingAnimationWithBaseWidget } from '../TypingAnimationWidget/TypingAnimationWidget';
|
|
7
|
-
import { ChatPreviewComparisonWidgetWithBaseWidget } from '../ChatPreviewComparisonWidget/ChatPreviewComparisonWidget';
|
|
8
|
-
import { ChatPreviewWidgetWithBaseWidget } from '../ChatPreviewWidget/ChatPreviewWidget';
|
|
9
|
-
export const TypingAnimationFlowWidget = ({ widgetConfigId }) => {
|
|
10
|
-
const { userHasInteractedValue, userHasNotInteractedValue, isLoadingValue, isProductComparisonValue, } = useGetWidgetStatus();
|
|
11
|
-
if (userHasInteractedValue && isLoadingValue) {
|
|
12
|
-
return (_jsx(ChatPreviewLoadingWidgetWithBaseWidget, { widgetConfigId: widgetConfigId, widgetType: WidgetTypeV3.ChatPreviewLoadingV3 }));
|
|
13
|
-
}
|
|
14
|
-
if (userHasInteractedValue && isProductComparisonValue) {
|
|
15
|
-
return (_jsx(ChatPreviewComparisonWidgetWithBaseWidget, { widgetConfigId: widgetConfigId, widgetType: WidgetTypeV3.ChatPreviewComparisonV3 }));
|
|
16
|
-
}
|
|
17
|
-
if (userHasInteractedValue) {
|
|
18
|
-
return (_jsx(ChatPreviewWidgetWithBaseWidget, { widgetConfigId: widgetConfigId, widgetType: WidgetTypeV3.ChatPreviewV3 }));
|
|
19
|
-
}
|
|
20
|
-
if (userHasNotInteractedValue) {
|
|
21
|
-
return (_jsx(TypingAnimationWithBaseWidget, { widgetConfigId: widgetConfigId, widgetType: WidgetTypeV3.TypingAnimationV3 }));
|
|
22
|
-
}
|
|
23
|
-
return _jsx(ChatPreviewLoading, { fullIsLoading: true });
|
|
24
|
-
};
|
|
25
|
-
TypingAnimationFlowWidget.displayName = 'TypingAnimationFlowWidget';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseWidgetProps } from '../../hocs/withBaseWidget';
|
|
2
|
-
export declare const TypingAnimationWithBaseWidget: {
|
|
3
|
-
(props: BaseWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
displayName: string;
|
|
5
|
-
};
|
|
6
|
-
export interface TypingAnimationWidgetProps {
|
|
7
|
-
widgetConfigId: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const TypingAnimationWidget: {
|
|
10
|
-
({ widgetConfigId }: TypingAnimationWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
displayName: string;
|
|
12
|
-
};
|