@envive-ai/react-widgets-v3 0.3.13 → 0.3.15-alpha.1
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/CXIntegration/implementations/useHelpScoutUnifiedCXButton.cjs +65 -0
- package/dist/CXIntegration/implementations/useHelpScoutUnifiedCXButton.js +64 -0
- package/dist/CXIntegration/implementations/useTalkdeskUnifiedCXButton.cjs +64 -0
- package/dist/CXIntegration/implementations/useTalkdeskUnifiedCXButton.js +63 -0
- package/dist/CXIntegration/types.cjs +2 -0
- package/dist/CXIntegration/types.js +2 -0
- package/dist/CXIntegration/utils/functions.cjs +4 -0
- package/dist/CXIntegration/utils/functions.js +4 -0
- 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 +3 -3
- package/dist/hocs/withBaseWidget/types.d.ts +5 -3
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- 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/services/amplitudeService/eventNames.d.cts +43 -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 +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/amplitudeContext/amplitudeContext.d.ts +2 -0
- package/dist/packages/hooks/dist/contexts/amplitudeContext/index.d.ts +2 -0
- package/dist/packages/hooks/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +2 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +14 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/index.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/types.d.ts +42 -0
- package/dist/packages/hooks/dist/contexts/typesV3.d.ts +230 -0
- package/dist/packages/hooks/dist/services/amplitudeService/amplitudeService.d.ts +1 -0
- package/dist/packages/hooks/dist/services/amplitudeService/eventNames.d.ts +43 -0
- package/dist/packages/hooks/dist/types/customerService.d.ts +21 -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 +3 -2
- package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.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 +1 -1
- 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/variantInfo.d.ts +1 -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 +63 -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/src/CXIntegration/hooks/useUnifiedCXButton.d.ts +10 -0
- package/dist/src/CXIntegration/hooks/useUnifiedCXButton.js +29 -0
- package/dist/src/CXIntegration/implementations/useDefaultUnifiedCXButton.d.ts +2 -0
- package/dist/src/CXIntegration/implementations/useDefaultUnifiedCXButton.js +6 -0
- package/dist/src/CXIntegration/implementations/useEightByEightUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useEightByEightUnifiedCXButton.js +63 -0
- package/dist/src/CXIntegration/implementations/useGladlyUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useGladlyUnifiedCXButton.js +23 -0
- package/dist/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.js +54 -0
- package/dist/src/CXIntegration/implementations/useGrooveUnifiedCXButton.d.ts +18 -0
- package/dist/src/CXIntegration/implementations/useGrooveUnifiedCXButton.js +48 -0
- package/dist/src/CXIntegration/implementations/useHelpScoutUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useHelpScoutUnifiedCXButton.js +84 -0
- package/dist/src/CXIntegration/implementations/useKustomerUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useKustomerUnifiedCXButton.js +86 -0
- package/dist/src/CXIntegration/implementations/useReDoUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useReDoUnifiedCXButton.js +59 -0
- package/dist/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.js +62 -0
- package/dist/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.js +49 -0
- package/dist/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.js +77 -0
- package/dist/src/CXIntegration/implementations/useTidioUnifiedCXButton.d.ts +13 -0
- package/dist/src/CXIntegration/implementations/useTidioUnifiedCXButton.js +20 -0
- package/dist/src/CXIntegration/implementations/useZendeskUnifiedCXButton.d.ts +5 -0
- package/dist/src/CXIntegration/implementations/useZendeskUnifiedCXButton.js +55 -0
- package/dist/src/CXIntegration/implementations/useZowieUnifiedCXButton.d.ts +13 -0
- package/dist/src/CXIntegration/implementations/useZowieUnifiedCXButton.js +20 -0
- package/dist/src/CXIntegration/types.d.ts +26 -0
- package/dist/src/CXIntegration/types.js +17 -0
- package/dist/src/CXIntegration/utils/functions.d.ts +2 -0
- package/dist/src/CXIntegration/utils/functions.js +57 -0
- package/dist/src/debug/GenericSelect.d.ts +11 -0
- package/dist/src/debug/GenericSelect.js +151 -0
- package/dist/src/debug/MessageContent.d.ts +4 -0
- package/dist/src/debug/MessageContent.js +87 -0
- package/dist/src/debug/chatEmbed.d.ts +2 -0
- package/dist/src/debug/chatEmbed.js +58 -0
- package/dist/src/debug/debugBar.d.ts +1 -0
- package/dist/src/debug/debugBar.js +9 -0
- package/dist/src/debug/reportIssue.d.ts +1 -0
- package/dist/src/debug/reportIssue.js +322 -0
- package/dist/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.d.ts +1 -0
- package/dist/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.js +452 -0
- package/dist/src/hocs/withBaseWidget/index.d.ts +2 -0
- package/dist/src/hocs/withBaseWidget/index.js +1 -0
- package/dist/src/hocs/withBaseWidget/types.d.ts +33 -0
- package/dist/src/hocs/withBaseWidget/types.js +0 -0
- package/dist/src/hocs/withBaseWidget/withBaseWidget.d.ts +5 -0
- package/dist/src/hocs/withBaseWidget/withBaseWidget.js +80 -0
- package/dist/src/stories/FloatingChatWidget.stories.d.ts +25 -0
- package/dist/src/stories/FloatingChatWidget.stories.js +44 -0
- package/dist/src/stories/FullPageSalesAgentWidget.stories.d.ts +31 -0
- package/dist/src/stories/FullPageSalesAgentWidget.stories.js +51 -0
- package/dist/src/stories/ProductCardWidget.stories.d.ts +31 -0
- package/dist/src/stories/ProductCardWidget.stories.js +44 -0
- package/dist/src/stories/PromptButtonCarouselWithImageWidget.stories.d.ts +31 -0
- package/dist/src/stories/PromptButtonCarouselWithImageWidget.stories.js +40 -0
- package/dist/src/stories/PromptCarouselWidget.stories.d.ts +31 -0
- package/dist/src/stories/PromptCarouselWidget.stories.js +40 -0
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.d.ts +1 -0
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.js +40 -0
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.stories.d.ts +12 -0
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.stories.js +12 -0
- 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 +6 -0
- package/dist/src/stories/SearchResults.stories.js +23 -0
- package/dist/src/stories/SearchZeroState.stories.d.ts +38 -0
- package/dist/src/stories/SearchZeroState.stories.js +42 -0
- package/dist/src/stories/SocialProofFlowWidget.stories.d.ts +35 -0
- package/dist/src/stories/SocialProofFlowWidget.stories.js +60 -0
- package/dist/src/stories/SuggestionBar.stories.d.ts +7 -0
- package/dist/src/stories/SuggestionBar.stories.js +36 -0
- package/dist/src/stories/TitledPromptCarouselWidget.stories.d.ts +32 -0
- package/dist/src/stories/TitledPromptCarouselWidget.stories.js +55 -0
- package/dist/src/stories/TypingAnimationFlowWidget.stories.d.ts +34 -0
- package/dist/src/stories/TypingAnimationFlowWidget.stories.js +51 -0
- package/dist/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +12 -0
- package/dist/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +112 -0
- package/dist/src/widgets/ChatPreviewComparisonWidget/index.d.ts +3 -0
- package/dist/src/widgets/ChatPreviewComparisonWidget/index.js +2 -0
- package/dist/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +9 -0
- package/dist/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +34 -0
- package/dist/src/widgets/ChatPreviewLoadingWidget/index.d.ts +3 -0
- package/dist/src/widgets/ChatPreviewLoadingWidget/index.js +2 -0
- package/dist/src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +12 -0
- package/dist/src/widgets/ChatPreviewWidget/ChatPreviewWidget.js +111 -0
- package/dist/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.d.ts +1 -0
- package/dist/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.js +97 -0
- package/dist/src/widgets/ChatPreviewWidget/index.d.ts +3 -0
- package/dist/src/widgets/ChatPreviewWidget/index.js +2 -0
- package/dist/src/widgets/FloatingChatWidget/FloatingChatOverlay.d.ts +14 -0
- package/dist/src/widgets/FloatingChatWidget/FloatingChatOverlay.js +44 -0
- package/dist/src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +8 -0
- package/dist/src/widgets/FloatingChatWidget/FloatingChatWidget.js +134 -0
- package/dist/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.d.ts +1 -0
- package/dist/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.js +100 -0
- package/dist/src/widgets/FloatingChatWidget/constants.d.ts +1 -0
- package/dist/src/widgets/FloatingChatWidget/constants.js +1 -0
- package/dist/src/widgets/FloatingChatWidget/hooks/useAutoPopup.d.ts +4 -0
- package/dist/src/widgets/FloatingChatWidget/hooks/useAutoPopup.js +51 -0
- package/dist/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.d.ts +11 -0
- package/dist/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.js +21 -0
- package/dist/src/widgets/FloatingChatWidget/index.d.ts +4 -0
- package/dist/src/widgets/FloatingChatWidget/index.js +3 -0
- package/dist/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +12 -0
- package/dist/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +14 -0
- package/dist/src/widgets/FullPageSalesAgentWidget/index.d.ts +1 -0
- package/dist/src/widgets/FullPageSalesAgentWidget/index.js +1 -0
- package/dist/src/widgets/ProductCardWidget/ProductCardWidget.d.ts +7 -0
- package/dist/src/widgets/ProductCardWidget/ProductCardWidget.js +94 -0
- package/dist/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.d.ts +1 -0
- package/dist/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.js +106 -0
- package/dist/src/widgets/ProductCardWidget/index.d.ts +2 -0
- package/dist/src/widgets/ProductCardWidget/index.js +1 -0
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +12 -0
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +88 -0
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.d.ts +1 -0
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.js +132 -0
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/index.d.ts +2 -0
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/index.js +2 -0
- package/dist/src/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +7 -0
- package/dist/src/widgets/PromptCarouselWidget/PromptCarouselWidget.js +74 -0
- package/dist/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.d.ts +1 -0
- package/dist/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.js +106 -0
- package/dist/src/widgets/PromptCarouselWidget/index.d.ts +2 -0
- package/dist/src/widgets/PromptCarouselWidget/index.js +1 -0
- package/dist/src/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +7 -0
- package/dist/src/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +25 -0
- package/dist/src/widgets/SocialProofFlowWidget/index.d.ts +3 -0
- package/dist/src/widgets/SocialProofFlowWidget/index.js +2 -0
- package/dist/src/widgets/SocialProofWidget/SocialProofWidget.d.ts +12 -0
- package/dist/src/widgets/SocialProofWidget/SocialProofWidget.js +203 -0
- package/dist/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.d.ts +1 -0
- package/dist/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.js +135 -0
- package/dist/src/widgets/SocialProofWidget/index.d.ts +2 -0
- package/dist/src/widgets/SocialProofWidget/index.js +1 -0
- package/dist/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +7 -0
- package/dist/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +75 -0
- package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.d.ts +1 -0
- package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.js +106 -0
- package/dist/src/widgets/TitledPromptCarouselWidget/index.d.ts +2 -0
- package/dist/src/widgets/TitledPromptCarouselWidget/index.js +1 -0
- package/dist/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +7 -0
- package/dist/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +25 -0
- package/dist/src/widgets/TypingAnimationFlowWidget/index.d.ts +3 -0
- package/dist/src/widgets/TypingAnimationFlowWidget/index.js +2 -0
- package/dist/src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +12 -0
- package/dist/src/widgets/TypingAnimationWidget/TypingAnimationWidget.js +126 -0
- package/dist/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.d.ts +1 -0
- package/dist/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.js +118 -0
- package/dist/src/widgets/TypingAnimationWidget/index.d.ts +2 -0
- package/dist/src/widgets/TypingAnimationWidget/index.js +1 -0
- package/dist/src/widgets/__tests__/testUtils.d.ts +60 -0
- package/dist/src/widgets/__tests__/testUtils.js +46 -0
- package/dist/src/widgets/__tests__/trackEventCanary.test.d.ts +1 -0
- package/dist/src/widgets/__tests__/trackEventCanary.test.js +37 -0
- package/dist/src/widgets/hooks/useGetWidgetStatus.d.ts +7 -0
- package/dist/src/widgets/hooks/useGetWidgetStatus.js +17 -0
- package/dist/src/widgets/utils/functions.d.ts +16 -0
- package/dist/src/widgets/utils/functions.js +87 -0
- package/dist/src/widgets-v2/SearchResults/index.d.ts +2 -0
- package/dist/src/widgets-v2/SearchResults/index.js +2 -0
- package/dist/src/widgets-v2/SearchZeroState/index.d.ts +2 -0
- package/dist/src/widgets-v2/SearchZeroState/index.js +2 -0
- package/dist/src/widgets-v2/SuggestionBar/index.d.ts +2 -0
- package/dist/src/widgets-v2/SuggestionBar/index.js +2 -0
- package/dist/src/widgets-v2/SuggestionButtonContainer/index.d.ts +2 -0
- package/dist/src/widgets-v2/SuggestionButtonContainer/index.js +2 -0
- package/dist/tsdown.config.d.ts +2 -0
- package/dist/tsdown.config.js +12 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +36 -5
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +36 -5
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +34 -4
- 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 -5
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +0 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +0 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +31 -7
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +32 -8
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +44 -6
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +45 -7
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +33 -4
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +35 -6
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +17 -12
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +18 -13
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +63 -6
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +65 -8
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +21 -1
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +23 -3
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +47 -6
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +49 -8
- package/dist/widgets/dist/SearchResults/SearchResults.d.cts +3 -2
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/types.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +1 -1
- 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 +9 -14
- package/dist/widgets/utils/functions.js +9 -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/CXIntegration/implementations/useHelpScoutUnifiedCXButton.ts +108 -0
- package/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.ts +94 -0
- package/src/CXIntegration/types.ts +2 -0
- package/src/CXIntegration/utils/functions.ts +8 -0
- package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +83 -305
- 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 +120 -0
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +48 -19
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +100 -52
- package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +125 -0
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +52 -19
- package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +148 -0
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +50 -20
- package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +190 -0
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +33 -33
- package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +163 -0
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +88 -18
- package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +195 -0
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +34 -18
- package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +161 -0
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +63 -22
- package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +174 -0
- package/src/widgets/__tests__/testUtils.tsx +63 -0
- package/src/widgets/__tests__/trackEventCanary.test.ts +45 -0
- package/src/widgets/utils/functions.ts +16 -0
- 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
package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx
CHANGED
|
@@ -1,34 +1,50 @@
|
|
|
1
|
+
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
1
2
|
import {
|
|
2
3
|
PromptButtonCarouselWithImageWidgetV3Config,
|
|
3
4
|
WidgetTypeV3,
|
|
4
5
|
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
-
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
6
6
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
7
7
|
|
|
8
|
-
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
9
|
-
import { useCallback, useEffect, useMemo } from 'react';
|
|
10
|
-
import {
|
|
11
|
-
SpiffyMetricsEventName,
|
|
12
|
-
useAmplitude,
|
|
13
|
-
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
14
8
|
import {
|
|
15
9
|
ChatElementDisplayLocationV3,
|
|
16
10
|
VariantTypeEnum,
|
|
17
11
|
} from '@envive-ai/react-hooks/application/models';
|
|
12
|
+
import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
|
|
13
|
+
import { lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
14
|
+
import {
|
|
15
|
+
EnviveMetricsEventName,
|
|
16
|
+
useAmplitude,
|
|
17
|
+
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
18
|
+
import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
|
|
19
|
+
import {
|
|
20
|
+
WidgetInteractionComponent,
|
|
21
|
+
WidgetInteractionType,
|
|
22
|
+
} from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
18
23
|
import {
|
|
19
24
|
PromptButtonCarouselWithImage,
|
|
20
25
|
PromptButtonCarouselWithImageProps,
|
|
21
26
|
} from '@envive-ai/react-toolkit-v3/PromptButtonCarouselWithImage';
|
|
22
|
-
import {
|
|
27
|
+
import { usePromptCarouselAnalytics } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
28
|
+
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
23
29
|
import { useAtomValue } from 'jotai';
|
|
24
|
-
import {
|
|
30
|
+
import { useCallback, useMemo } from 'react';
|
|
25
31
|
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
26
32
|
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
27
|
-
import { getRecentProductImageUrls } from '../utils/functions';
|
|
33
|
+
import { RawValues, getRecentProductImageUrls, getStringIdForText } from '../utils/functions';
|
|
28
34
|
|
|
29
35
|
const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
30
36
|
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
31
37
|
const { openChat } = useChatToggle();
|
|
38
|
+
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
39
|
+
const {
|
|
40
|
+
onClick: onSuggestionClick,
|
|
41
|
+
onDrag,
|
|
42
|
+
onHover,
|
|
43
|
+
onMouseDown,
|
|
44
|
+
onMouseUp,
|
|
45
|
+
onTouchStart,
|
|
46
|
+
onTouchEnd,
|
|
47
|
+
} = usePromptCarouselAnalytics(WidgetInteractionComponent.SINGLE_IMAGE_PROMPT, text => text);
|
|
32
48
|
|
|
33
49
|
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
34
50
|
|
|
@@ -48,18 +64,18 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
48
64
|
|
|
49
65
|
const { trackEvent } = useAmplitude();
|
|
50
66
|
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
trackEvent({
|
|
53
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
54
|
-
eventProps: {
|
|
55
|
-
widget_config_id: widgetConfigId,
|
|
56
|
-
widget_type: WidgetTypeV3.PromptButtonCarouselWithImageV3,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}, [trackEvent, widgetConfigId]);
|
|
60
|
-
|
|
61
67
|
const handlePromptButtonClick = useCallback(
|
|
62
68
|
(text: string) => {
|
|
69
|
+
const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
|
|
70
|
+
const stringId = getStringIdForText(rawValues, text);
|
|
71
|
+
trackEvent({
|
|
72
|
+
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
73
|
+
eventProps: {
|
|
74
|
+
response_id: hardcopyContent?.responseId,
|
|
75
|
+
string_id: stringId,
|
|
76
|
+
text,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
63
79
|
onTypedMessageSubmitted({
|
|
64
80
|
query: text,
|
|
65
81
|
userTyped: false,
|
|
@@ -67,12 +83,20 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
67
83
|
ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_PROMPT_BUTTON,
|
|
68
84
|
});
|
|
69
85
|
openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_PROMPT_BUTTON);
|
|
86
|
+
onSuggestionClick(text);
|
|
70
87
|
},
|
|
71
88
|
[onTypedMessageSubmitted, openChat],
|
|
72
89
|
);
|
|
73
90
|
|
|
74
91
|
const handleTextFieldClick = useCallback(() => {
|
|
75
92
|
openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_TEXT_FIELD);
|
|
93
|
+
trackWidgetInteraction({
|
|
94
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
95
|
+
trigger: {
|
|
96
|
+
widget: WidgetInteractionComponent.SINGLE_IMAGE_PROMPT,
|
|
97
|
+
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
76
100
|
}, [openChat]);
|
|
77
101
|
|
|
78
102
|
const variantInfo = useAtomValue(variantInfoAtom);
|
|
@@ -109,6 +133,12 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
109
133
|
textFieldPlaceholder={hardCopyContent?.textFieldPlaceholder}
|
|
110
134
|
hideTextField={promptButtonCarouselWithImageWidgetConfig?.hideTextField}
|
|
111
135
|
handlePromptButtonClick={handlePromptButtonClick}
|
|
136
|
+
handlePromptButtonDrag={onDrag}
|
|
137
|
+
handlePromptButtonHover={onHover}
|
|
138
|
+
handlePromptButtonMouseDown={onMouseDown}
|
|
139
|
+
handlePromptButtonMouseUp={onMouseUp}
|
|
140
|
+
handlePromptButtonTouchStart={onTouchStart}
|
|
141
|
+
handlePromptButtonTouchEnd={onTouchEnd}
|
|
112
142
|
handleTextFieldClick={handleTextFieldClick}
|
|
113
143
|
/>
|
|
114
144
|
);
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import { EnviveMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
3
|
+
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
4
|
+
import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
5
|
+
import { PromptButtonCarouselWithImageWidget } from '../PromptButtonCarouselWithImageWidget';
|
|
6
|
+
|
|
7
|
+
const mockTrackEvent = vi.fn();
|
|
8
|
+
const mockGetHardcopy = vi.fn();
|
|
9
|
+
const mockUseTrackComponentVisibleEvent = vi.fn();
|
|
10
|
+
|
|
11
|
+
vi.mock('@envive-ai/react-toolkit-v3/PromptButtonCarouselWithImage', () => ({
|
|
12
|
+
PromptButtonCarouselWithImage: ({
|
|
13
|
+
promptButtonsTexts = [],
|
|
14
|
+
handlePromptButtonClick,
|
|
15
|
+
}: {
|
|
16
|
+
promptButtonsTexts?: string[];
|
|
17
|
+
handlePromptButtonClick: (text: string) => void;
|
|
18
|
+
}) => (
|
|
19
|
+
<div data-testid="prompt-button-carousel-mock">
|
|
20
|
+
{(promptButtonsTexts ?? []).map(text => (
|
|
21
|
+
<button
|
|
22
|
+
key={text}
|
|
23
|
+
type="button"
|
|
24
|
+
onClick={() => handlePromptButtonClick(text)}
|
|
25
|
+
>
|
|
26
|
+
{text}
|
|
27
|
+
</button>
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
34
|
+
useAmplitude: () => ({
|
|
35
|
+
trackEvent: mockTrackEvent,
|
|
36
|
+
isReady: true,
|
|
37
|
+
}),
|
|
38
|
+
SpiffyMetricsEventName: {
|
|
39
|
+
ChatComponentVisible: 'Chat Component Visible',
|
|
40
|
+
SearchComponentVisible: 'Search Component Visible',
|
|
41
|
+
},
|
|
42
|
+
EnviveMetricsEventName: {
|
|
43
|
+
WidgetTextClicked: 'Widget Text Clicked',
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
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
|
+
|
|
58
|
+
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
59
|
+
useHardcopy: () => ({
|
|
60
|
+
getHardcopy: mockGetHardcopy,
|
|
61
|
+
}),
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
vi.mock('@envive-ai/react-hooks/contexts/pageContext', () => ({
|
|
65
|
+
usePage: () => ({
|
|
66
|
+
userEvent: {
|
|
67
|
+
id: 'test-user-event-id',
|
|
68
|
+
category: UserEventCategory.PageVisit,
|
|
69
|
+
created_at: '2025-01-01T00:00:00Z',
|
|
70
|
+
event_id: 'test-event-id',
|
|
71
|
+
} as UserEvent,
|
|
72
|
+
}),
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
vi.mock('@envive-ai/react-hooks/contexts/widgetConfigContext', () => ({
|
|
76
|
+
useWidgetConfig: () => ({
|
|
77
|
+
getWidgetConfig: vi.fn().mockResolvedValue({}),
|
|
78
|
+
}),
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
vi.mock('@envive-ai/react-hooks/contexts/uiConfigContext', () => ({
|
|
82
|
+
useUiConfig: () => ({
|
|
83
|
+
getUiConfig: vi.fn().mockResolvedValue({}),
|
|
84
|
+
}),
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
vi.mock('@envive-ai/react-hooks/contexts/salesAgentContext', () => ({
|
|
88
|
+
useSalesAgent: () => ({
|
|
89
|
+
onTypedMessageSubmitted: vi.fn(),
|
|
90
|
+
}),
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
vi.mock('@envive-ai/react-hooks/hooks/ChatToggle', () => ({
|
|
94
|
+
useChatToggle: () => ({
|
|
95
|
+
openChat: vi.fn(),
|
|
96
|
+
}),
|
|
97
|
+
}));
|
|
98
|
+
|
|
99
|
+
vi.mock('@envive-ai/react-hooks/atoms/chat', () => ({
|
|
100
|
+
lastAssistantMessageAtom: {},
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
vi.mock('@envive-ai/react-hooks/atoms/app', () => ({
|
|
104
|
+
variantInfoAtom: {},
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
vi.mock('jotai', async importOriginal => {
|
|
108
|
+
const actual = await importOriginal();
|
|
109
|
+
const variantInfo = {
|
|
110
|
+
variant: 'PageVisit',
|
|
111
|
+
productId: undefined,
|
|
112
|
+
plpId: undefined,
|
|
113
|
+
url: '',
|
|
114
|
+
pageVisitCategory: '',
|
|
115
|
+
};
|
|
116
|
+
const useAtomValueMock = vi.fn();
|
|
117
|
+
let callCount = 0;
|
|
118
|
+
useAtomValueMock.mockImplementation(() => {
|
|
119
|
+
callCount += 1;
|
|
120
|
+
return callCount % 2 === 0 ? [] : variantInfo;
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
...actual,
|
|
124
|
+
useAtomValue: useAtomValueMock,
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('PromptButtonCarouselWithImageWidget analytics', () => {
|
|
129
|
+
const defaultHardcopy = {
|
|
130
|
+
responseId: 'test-response-id',
|
|
131
|
+
language: 'en',
|
|
132
|
+
values: {
|
|
133
|
+
promptButtonsTexts: ['Button 1', 'Button 2', 'Button 3'],
|
|
134
|
+
},
|
|
135
|
+
rawValues: {
|
|
136
|
+
promptButtonsTexts: [
|
|
137
|
+
{ id: 'id-1', value: 'Button 1' },
|
|
138
|
+
{ id: 'id-2', value: 'Button 2' },
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
beforeEach(() => {
|
|
144
|
+
vi.clearAllMocks();
|
|
145
|
+
mockGetHardcopy.mockResolvedValue(defaultHardcopy);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should track ChatComponentVisible when widget mounts', async () => {
|
|
149
|
+
render(<PromptButtonCarouselWithImageWidget widgetConfigId="test-config-1" />);
|
|
150
|
+
|
|
151
|
+
await waitFor(
|
|
152
|
+
() => {
|
|
153
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
154
|
+
expect.any(Object),
|
|
155
|
+
{
|
|
156
|
+
widget_config_id: 'test-config-1',
|
|
157
|
+
widget_type: WidgetTypeV3.PromptButtonCarouselWithImageV3,
|
|
158
|
+
},
|
|
159
|
+
'0px',
|
|
160
|
+
true,
|
|
161
|
+
);
|
|
162
|
+
},
|
|
163
|
+
{ timeout: 3000 },
|
|
164
|
+
);
|
|
165
|
+
}, 5000);
|
|
166
|
+
|
|
167
|
+
it('should track WidgetTextClicked when button is clicked', async () => {
|
|
168
|
+
render(<PromptButtonCarouselWithImageWidget widgetConfigId="test-config-2" />);
|
|
169
|
+
|
|
170
|
+
await waitFor(
|
|
171
|
+
() => {
|
|
172
|
+
expect(screen.getByText('Button 1')).toBeInTheDocument();
|
|
173
|
+
},
|
|
174
|
+
{ timeout: 3000 },
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
mockTrackEvent.mockClear();
|
|
178
|
+
|
|
179
|
+
screen.getByText('Button 1').click();
|
|
180
|
+
|
|
181
|
+
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
182
|
+
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
183
|
+
eventProps: {
|
|
184
|
+
response_id: 'test-response-id',
|
|
185
|
+
string_id: 'id-1',
|
|
186
|
+
text: 'Button 1',
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}, 5000);
|
|
190
|
+
});
|
|
@@ -1,36 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PromptCarouselWidgetV3Config,
|
|
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
|
+
PromptCarouselWidgetV3Config,
|
|
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
|
+
PromptCarousel,
|
|
18
|
+
usePromptCarouselAnalytics,
|
|
19
|
+
} from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
16
20
|
import { AnimationSpeed } from '@envive-ai/react-toolkit-v3/PromptCarousel/types/types';
|
|
17
21
|
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
18
|
-
import { PromptCarousel } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
19
22
|
import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
|
|
20
|
-
|
|
21
|
-
type RawWidgetString = { id: string; value: string };
|
|
22
|
-
type RawValues = Record<string, RawWidgetString | RawWidgetString[]>;
|
|
23
|
-
|
|
24
|
-
/** Finds the string_id (id) from raw widget text values for the given display text */
|
|
25
|
-
function getStringIdForText(rawValues: RawValues | undefined, text: string): string | undefined {
|
|
26
|
-
if (!rawValues) return undefined;
|
|
27
|
-
for (const raw of Object.values(rawValues)) {
|
|
28
|
-
const list = Array.isArray(raw) ? raw : [raw];
|
|
29
|
-
const found = list.find((s: RawWidgetString) => s.value === text);
|
|
30
|
-
if (found) return found.id;
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
23
|
+
import { RawValues, getStringIdForText } from '../utils/functions';
|
|
34
24
|
|
|
35
25
|
const mockButtonTexts = [
|
|
36
26
|
'Loading button 1',
|
|
@@ -46,6 +36,19 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
46
36
|
|
|
47
37
|
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
48
38
|
|
|
39
|
+
const {
|
|
40
|
+
onClick: onSuggestionClick,
|
|
41
|
+
onDrag,
|
|
42
|
+
onHover,
|
|
43
|
+
onMouseDown,
|
|
44
|
+
onMouseUp,
|
|
45
|
+
onTouchStart,
|
|
46
|
+
onTouchEnd,
|
|
47
|
+
} = usePromptCarouselAnalytics(WidgetInteractionComponent.SUGGESTION_BAR, text => {
|
|
48
|
+
const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
|
|
49
|
+
return getStringIdForText(rawValues, text);
|
|
50
|
+
});
|
|
51
|
+
|
|
49
52
|
const promptButtonTexts = (hardcopyContent?.values?.promptButtonTexts as string[]) || [];
|
|
50
53
|
const buttonTexts = isLoading ? mockButtonTexts : promptButtonTexts;
|
|
51
54
|
|
|
@@ -61,20 +64,11 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
61
64
|
|
|
62
65
|
const { trackEvent } = useAmplitude();
|
|
63
66
|
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
trackEvent({
|
|
66
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
67
|
-
eventProps: {
|
|
68
|
-
widget_config_id: widgetConfigId,
|
|
69
|
-
widget_type: WidgetTypeV3.PromptCarouselV3,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
}, [trackEvent, widgetConfigId]);
|
|
73
|
-
|
|
74
67
|
const handleButtonClick = useCallback(
|
|
75
68
|
(text: string) => {
|
|
76
69
|
const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
|
|
77
70
|
const stringId = getStringIdForText(rawValues, text);
|
|
71
|
+
onSuggestionClick(stringId);
|
|
78
72
|
trackEvent({
|
|
79
73
|
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
80
74
|
eventProps: {
|
|
@@ -104,6 +98,12 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
104
98
|
promptCarouselRows={promptCarouselRows}
|
|
105
99
|
animationSpeed={animationSpeed}
|
|
106
100
|
handleButtonClick={handleButtonClick}
|
|
101
|
+
handleButtonHover={onHover}
|
|
102
|
+
handleButtonDrag={onDrag}
|
|
103
|
+
handleButtonMouseUp={onMouseUp}
|
|
104
|
+
handleButtonMouseDown={onMouseDown}
|
|
105
|
+
handleButtonTouchStart={onTouchStart}
|
|
106
|
+
handleButtonTouchEnd={onTouchEnd}
|
|
107
107
|
promptButtonTexts={buttonTexts}
|
|
108
108
|
/>
|
|
109
109
|
);
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import { EnviveMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
3
|
+
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
4
|
+
import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
5
|
+
import { PromptCarouselWidget } from '../PromptCarouselWidget';
|
|
6
|
+
|
|
7
|
+
const mockTrackEvent = vi.fn();
|
|
8
|
+
const mockGetHardcopy = vi.fn();
|
|
9
|
+
const mockUseTrackComponentVisibleEvent = vi.fn();
|
|
10
|
+
|
|
11
|
+
vi.mock('@envive-ai/react-toolkit-v3/PromptCarousel', () => ({
|
|
12
|
+
PromptCarousel: ({
|
|
13
|
+
promptButtonTexts,
|
|
14
|
+
handleButtonClick,
|
|
15
|
+
}: {
|
|
16
|
+
promptButtonTexts: string[];
|
|
17
|
+
handleButtonClick: (text: string) => void;
|
|
18
|
+
}) => (
|
|
19
|
+
<div data-testid="prompt-carousel-mock">
|
|
20
|
+
{promptButtonTexts.map(text => (
|
|
21
|
+
<button
|
|
22
|
+
key={text}
|
|
23
|
+
type="button"
|
|
24
|
+
onClick={() => handleButtonClick(text)}
|
|
25
|
+
>
|
|
26
|
+
{text}
|
|
27
|
+
</button>
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
),
|
|
31
|
+
usePromptCarouselAnalytics: () => ({
|
|
32
|
+
onClick: vi.fn(),
|
|
33
|
+
onDrag: vi.fn(),
|
|
34
|
+
onHover: vi.fn(),
|
|
35
|
+
onMouseDown: vi.fn(),
|
|
36
|
+
onMouseUp: vi.fn(),
|
|
37
|
+
onTouchStart: vi.fn(),
|
|
38
|
+
onTouchEnd: vi.fn(),
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
43
|
+
useAmplitude: () => ({
|
|
44
|
+
trackEvent: mockTrackEvent,
|
|
45
|
+
isReady: true,
|
|
46
|
+
}),
|
|
47
|
+
SpiffyMetricsEventName: {
|
|
48
|
+
ChatComponentVisible: 'Chat Component Visible',
|
|
49
|
+
SearchComponentVisible: 'Search Component Visible',
|
|
50
|
+
},
|
|
51
|
+
EnviveMetricsEventName: {
|
|
52
|
+
WidgetTextClicked: 'Widget Text Clicked',
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
|
|
57
|
+
useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
61
|
+
useHardcopy: () => ({
|
|
62
|
+
getHardcopy: mockGetHardcopy,
|
|
63
|
+
}),
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
vi.mock('@envive-ai/react-hooks/contexts/pageContext', () => ({
|
|
67
|
+
usePage: () => ({
|
|
68
|
+
userEvent: {
|
|
69
|
+
id: 'test-user-event-id',
|
|
70
|
+
category: UserEventCategory.PageVisit,
|
|
71
|
+
created_at: '2025-01-01T00:00:00Z',
|
|
72
|
+
event_id: 'test-event-id',
|
|
73
|
+
} as UserEvent,
|
|
74
|
+
}),
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
vi.mock('@envive-ai/react-hooks/contexts/widgetConfigContext', () => ({
|
|
78
|
+
useWidgetConfig: () => ({
|
|
79
|
+
getWidgetConfig: vi.fn().mockResolvedValue({}),
|
|
80
|
+
}),
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
vi.mock('@envive-ai/react-hooks/contexts/uiConfigContext', () => ({
|
|
84
|
+
useUiConfig: () => ({
|
|
85
|
+
getUiConfig: vi.fn().mockResolvedValue({}),
|
|
86
|
+
}),
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
vi.mock('@envive-ai/react-hooks/contexts/salesAgentContext', () => ({
|
|
90
|
+
useSalesAgent: () => ({
|
|
91
|
+
onTypedMessageSubmitted: vi.fn(),
|
|
92
|
+
}),
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
vi.mock('@envive-ai/react-hooks/hooks/ChatToggle', () => ({
|
|
96
|
+
useChatToggle: () => ({
|
|
97
|
+
openChat: vi.fn(),
|
|
98
|
+
}),
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
describe('PromptCarouselWidget analytics', () => {
|
|
102
|
+
const defaultHardcopy = {
|
|
103
|
+
responseId: 'test-response-id',
|
|
104
|
+
language: 'en',
|
|
105
|
+
values: {
|
|
106
|
+
promptButtonTexts: ['Button 1', 'Button 2', 'Button 3'],
|
|
107
|
+
},
|
|
108
|
+
rawValues: {
|
|
109
|
+
promptButtonTexts: [
|
|
110
|
+
{ id: 'id-1', value: 'Button 1' },
|
|
111
|
+
{ id: 'id-2', value: 'Button 2' },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
beforeEach(() => {
|
|
117
|
+
vi.clearAllMocks();
|
|
118
|
+
mockGetHardcopy.mockResolvedValue(defaultHardcopy);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should track ChatComponentVisible when widget mounts', async () => {
|
|
122
|
+
render(<PromptCarouselWidget widgetConfigId="test-config-1" />);
|
|
123
|
+
|
|
124
|
+
await waitFor(
|
|
125
|
+
() => {
|
|
126
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
127
|
+
expect.any(Object),
|
|
128
|
+
{
|
|
129
|
+
widget_config_id: 'test-config-1',
|
|
130
|
+
widget_type: WidgetTypeV3.PromptCarouselV3,
|
|
131
|
+
},
|
|
132
|
+
'0px',
|
|
133
|
+
true,
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
{ timeout: 3000 },
|
|
137
|
+
);
|
|
138
|
+
}, 5000);
|
|
139
|
+
|
|
140
|
+
it('should track WidgetTextClicked when button is clicked', async () => {
|
|
141
|
+
render(<PromptCarouselWidget widgetConfigId="test-config-2" />);
|
|
142
|
+
|
|
143
|
+
await waitFor(
|
|
144
|
+
() => {
|
|
145
|
+
expect(screen.getByText('Button 1')).toBeInTheDocument();
|
|
146
|
+
},
|
|
147
|
+
{ timeout: 3000 },
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
mockTrackEvent.mockClear();
|
|
151
|
+
|
|
152
|
+
screen.getByText('Button 1').click();
|
|
153
|
+
|
|
154
|
+
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
155
|
+
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
156
|
+
eventProps: {
|
|
157
|
+
response_id: 'test-response-id',
|
|
158
|
+
string_id: 'id-1',
|
|
159
|
+
text: 'Button 1',
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
}, 5000);
|
|
163
|
+
});
|