@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
|
@@ -1,72 +1,17 @@
|
|
|
1
1
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
|
-
import { SpiffyMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
3
|
import { HardcopyResponse } from '@envive-ai/react-hooks/contexts/hardcopyContext';
|
|
5
4
|
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
6
5
|
import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
7
6
|
import { BaseWidgetProps } from '../types';
|
|
8
7
|
import { withBaseWidget } from '../withBaseWidget';
|
|
9
8
|
|
|
10
|
-
// Mock IntersectionObserver
|
|
11
|
-
class MockIntersectionObserver implements IntersectionObserver {
|
|
12
|
-
observe = vi.fn();
|
|
13
|
-
|
|
14
|
-
disconnect = vi.fn();
|
|
15
|
-
|
|
16
|
-
unobserve = vi.fn();
|
|
17
|
-
|
|
18
|
-
root: Element | null = null;
|
|
19
|
-
|
|
20
|
-
rootMargin: string = '';
|
|
21
|
-
|
|
22
|
-
thresholds: ReadonlyArray<number> = [];
|
|
23
|
-
|
|
24
|
-
private callback: (entries: IntersectionObserverEntry[]) => void;
|
|
25
|
-
|
|
26
|
-
private options?: IntersectionObserverInit;
|
|
27
|
-
|
|
28
|
-
constructor(
|
|
29
|
-
callback: (entries: IntersectionObserverEntry[]) => void,
|
|
30
|
-
options?: IntersectionObserverInit,
|
|
31
|
-
) {
|
|
32
|
-
this.callback = callback;
|
|
33
|
-
this.options = options;
|
|
34
|
-
if (options) {
|
|
35
|
-
this.rootMargin = options.rootMargin || '';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Helper method to trigger intersection
|
|
40
|
-
triggerIntersection(isIntersecting: boolean, target?: Element) {
|
|
41
|
-
const entry = {
|
|
42
|
-
isIntersecting,
|
|
43
|
-
intersectionRatio: isIntersecting ? 1 : 0,
|
|
44
|
-
boundingClientRect: {} as DOMRectReadOnly,
|
|
45
|
-
rootBounds: {} as DOMRectReadOnly,
|
|
46
|
-
target: target || ({} as Element),
|
|
47
|
-
time: Date.now(),
|
|
48
|
-
} as IntersectionObserverEntry;
|
|
49
|
-
|
|
50
|
-
this.callback([entry]);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Helper method to get options
|
|
54
|
-
getOptions() {
|
|
55
|
-
return this.options;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Required by IntersectionObserver interface but not used in tests
|
|
59
|
-
// eslint-disable-next-line class-methods-use-this
|
|
60
|
-
takeRecords(): IntersectionObserverEntry[] {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
9
|
// Mock the contexts
|
|
66
10
|
const mockTrackEvent = vi.fn();
|
|
67
11
|
const mockGetHardcopy = vi.fn();
|
|
12
|
+
const mockUseTrackComponentVisibleEvent = vi.fn();
|
|
68
13
|
|
|
69
|
-
vi.mock('
|
|
14
|
+
vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
70
15
|
useAmplitude: () => ({
|
|
71
16
|
trackEvent: mockTrackEvent,
|
|
72
17
|
isReady: true,
|
|
@@ -77,13 +22,13 @@ vi.mock('src/contexts/amplitudeContext/amplitudeContext', () => ({
|
|
|
77
22
|
},
|
|
78
23
|
}));
|
|
79
24
|
|
|
80
|
-
vi.mock('
|
|
25
|
+
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
81
26
|
useHardcopy: () => ({
|
|
82
27
|
getHardcopy: mockGetHardcopy,
|
|
83
28
|
}),
|
|
84
29
|
}));
|
|
85
30
|
|
|
86
|
-
vi.mock('
|
|
31
|
+
vi.mock('@envive-ai/react-hooks/contexts/pageContext', () => ({
|
|
87
32
|
usePage: () => ({
|
|
88
33
|
userEvent: {
|
|
89
34
|
id: 'test-user-event-id',
|
|
@@ -94,6 +39,22 @@ vi.mock('src/contexts/pageContext', () => ({
|
|
|
94
39
|
}),
|
|
95
40
|
}));
|
|
96
41
|
|
|
42
|
+
vi.mock('@envive-ai/react-hooks/contexts/widgetConfigContext', () => ({
|
|
43
|
+
useWidgetConfig: () => ({
|
|
44
|
+
getWidgetConfig: vi.fn().mockResolvedValue({}),
|
|
45
|
+
}),
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
vi.mock('@envive-ai/react-hooks/contexts/uiConfigContext', () => ({
|
|
49
|
+
useUiConfig: () => ({
|
|
50
|
+
getUiConfig: vi.fn().mockResolvedValue({}),
|
|
51
|
+
}),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
|
|
55
|
+
useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
|
|
56
|
+
}));
|
|
57
|
+
|
|
97
58
|
// Test widget component
|
|
98
59
|
interface TestWidgetProps extends BaseWidgetProps {
|
|
99
60
|
testId?: string;
|
|
@@ -133,44 +94,18 @@ const TestWidget: React.FC<TestWidgetProps> = ({
|
|
|
133
94
|
};
|
|
134
95
|
|
|
135
96
|
describe('withBaseWidget', () => {
|
|
136
|
-
let mockObserver: MockIntersectionObserver;
|
|
137
|
-
let mockObservers: MockIntersectionObserver[];
|
|
138
|
-
let originalIntersectionObserver: typeof IntersectionObserver;
|
|
139
|
-
|
|
140
97
|
beforeEach(() => {
|
|
141
98
|
vi.clearAllMocks();
|
|
142
|
-
mockObservers = [];
|
|
143
99
|
|
|
144
100
|
// Set default mock for getHardcopy to return a resolved promise
|
|
145
101
|
mockGetHardcopy.mockResolvedValue({
|
|
146
102
|
language: 'en',
|
|
147
103
|
values: {},
|
|
148
104
|
});
|
|
149
|
-
|
|
150
|
-
// Store original IntersectionObserver
|
|
151
|
-
originalIntersectionObserver = global.IntersectionObserver;
|
|
152
|
-
|
|
153
|
-
// Replace IntersectionObserver with mock class
|
|
154
|
-
global.IntersectionObserver = class extends MockIntersectionObserver {
|
|
155
|
-
constructor(
|
|
156
|
-
callback: (entries: IntersectionObserverEntry[]) => void,
|
|
157
|
-
options?: IntersectionObserverInit,
|
|
158
|
-
) {
|
|
159
|
-
super(callback, options);
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
161
|
-
mockObserver = this;
|
|
162
|
-
mockObservers.push(this);
|
|
163
|
-
}
|
|
164
|
-
} as unknown as typeof IntersectionObserver;
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
afterEach(() => {
|
|
168
|
-
// Restore original IntersectionObserver
|
|
169
|
-
global.IntersectionObserver = originalIntersectionObserver;
|
|
170
105
|
});
|
|
171
106
|
|
|
172
|
-
describe('
|
|
173
|
-
it('should
|
|
107
|
+
describe('Visibility tracking', () => {
|
|
108
|
+
it('should call useTrackComponentVisibleEvent with default event', () => {
|
|
174
109
|
const WrappedWidget = withBaseWidget(TestWidget);
|
|
175
110
|
render(
|
|
176
111
|
<WrappedWidget
|
|
@@ -179,14 +114,19 @@ describe('withBaseWidget', () => {
|
|
|
179
114
|
/>,
|
|
180
115
|
);
|
|
181
116
|
|
|
182
|
-
expect(
|
|
183
|
-
|
|
117
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
118
|
+
expect.any(Object),
|
|
119
|
+
{
|
|
120
|
+
widget_config_id: 'test-config-1',
|
|
121
|
+
widget_type: WidgetTypeV3.PromptCarouselV3,
|
|
122
|
+
},
|
|
123
|
+
'0px',
|
|
124
|
+
true,
|
|
125
|
+
);
|
|
184
126
|
});
|
|
185
127
|
|
|
186
|
-
it('should
|
|
187
|
-
const WrappedWidget = withBaseWidget(TestWidget, {
|
|
188
|
-
rootMargin: '100px',
|
|
189
|
-
});
|
|
128
|
+
it('should pass custom rootMargin to useTrackComponentVisibleEvent', () => {
|
|
129
|
+
const WrappedWidget = withBaseWidget(TestWidget, { rootMargin: '100px' });
|
|
190
130
|
render(
|
|
191
131
|
<WrappedWidget
|
|
192
132
|
widgetConfigId="test-config-2"
|
|
@@ -194,168 +134,42 @@ describe('withBaseWidget', () => {
|
|
|
194
134
|
/>,
|
|
195
135
|
);
|
|
196
136
|
|
|
197
|
-
expect(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
widgetConfigId="test-config-3"
|
|
206
|
-
widgetType={WidgetTypeV3.PromptCarouselV3}
|
|
207
|
-
/>,
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
expect(mockObserver.observe).toHaveBeenCalled();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('Amplitude event tracking', () => {
|
|
215
|
-
it('should track default event when widget becomes visible', async () => {
|
|
216
|
-
const WrappedWidget = withBaseWidget(TestWidget);
|
|
217
|
-
const { container } = render(
|
|
218
|
-
<WrappedWidget
|
|
219
|
-
widgetConfigId="test-config-4"
|
|
220
|
-
widgetType={WidgetTypeV3.PromptCarouselV3}
|
|
221
|
-
/>,
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
const widgetElement = container.querySelector('[data-testid="test-widget"]');
|
|
225
|
-
|
|
226
|
-
// Trigger intersection with the actual element
|
|
227
|
-
mockObserver.triggerIntersection(true, widgetElement as Element);
|
|
228
|
-
|
|
229
|
-
await waitFor(() => {
|
|
230
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
231
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
232
|
-
eventProps: {
|
|
233
|
-
widget_config_id: 'test-config-4',
|
|
234
|
-
widget_type: WidgetTypeV3.PromptCarouselV3,
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it('should track custom event when widget becomes visible', async () => {
|
|
241
|
-
const WrappedWidget = withBaseWidget(TestWidget, {
|
|
242
|
-
visibilityEventName: SpiffyMetricsEventName.SearchComponentVisible,
|
|
243
|
-
});
|
|
244
|
-
const { container } = render(
|
|
245
|
-
<WrappedWidget
|
|
246
|
-
widgetConfigId="test-config-5"
|
|
247
|
-
widgetType={WidgetTypeV3.ChatPreviewV3}
|
|
248
|
-
/>,
|
|
137
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
138
|
+
expect.any(Object),
|
|
139
|
+
{
|
|
140
|
+
widget_config_id: 'test-config-2',
|
|
141
|
+
widget_type: WidgetTypeV3.ChatPreviewV3,
|
|
142
|
+
},
|
|
143
|
+
'100px',
|
|
144
|
+
true,
|
|
249
145
|
);
|
|
250
|
-
|
|
251
|
-
const widgetElement = container.querySelector('[data-testid="test-widget"]');
|
|
252
|
-
|
|
253
|
-
// Trigger intersection
|
|
254
|
-
mockObserver.triggerIntersection(true, widgetElement as Element);
|
|
255
|
-
|
|
256
|
-
await waitFor(() => {
|
|
257
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
258
|
-
eventName: SpiffyMetricsEventName.SearchComponentVisible,
|
|
259
|
-
eventProps: {
|
|
260
|
-
widget_config_id: 'test-config-5',
|
|
261
|
-
widget_type: WidgetTypeV3.ChatPreviewV3,
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
146
|
});
|
|
266
147
|
|
|
267
|
-
it('should include custom event props
|
|
148
|
+
it('should include custom event props', () => {
|
|
268
149
|
const WrappedWidget = withBaseWidget(TestWidget, {
|
|
269
150
|
visibilityEventProps: {
|
|
270
151
|
custom_prop: 'custom_value',
|
|
271
152
|
another_prop: 123,
|
|
272
153
|
},
|
|
273
154
|
});
|
|
274
|
-
|
|
155
|
+
render(
|
|
275
156
|
<WrappedWidget
|
|
276
|
-
widgetConfigId="test-config-
|
|
157
|
+
widgetConfigId="test-config-4"
|
|
277
158
|
widgetType={WidgetTypeV3.SocialProofV3}
|
|
278
159
|
/>,
|
|
279
160
|
);
|
|
280
161
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
widget_type: WidgetTypeV3.SocialProofV3,
|
|
292
|
-
custom_prop: 'custom_value',
|
|
293
|
-
another_prop: 123,
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('should only track event once even if intersection happens multiple times', async () => {
|
|
300
|
-
const WrappedWidget = withBaseWidget(TestWidget);
|
|
301
|
-
const { container } = render(
|
|
302
|
-
<WrappedWidget
|
|
303
|
-
widgetConfigId="test-config-7"
|
|
304
|
-
widgetType={WidgetTypeV3.PromptCarouselV3}
|
|
305
|
-
/>,
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
const widgetElement = container.querySelector('[data-testid="test-widget"]');
|
|
309
|
-
|
|
310
|
-
// Trigger intersection multiple times
|
|
311
|
-
mockObserver.triggerIntersection(true, widgetElement as Element);
|
|
312
|
-
mockObserver.triggerIntersection(false, widgetElement as Element);
|
|
313
|
-
mockObserver.triggerIntersection(true, widgetElement as Element);
|
|
314
|
-
|
|
315
|
-
await waitFor(() => {
|
|
316
|
-
expect(mockTrackEvent).toHaveBeenCalledTimes(1);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('should disconnect observer after tracking event', async () => {
|
|
321
|
-
const WrappedWidget = withBaseWidget(TestWidget);
|
|
322
|
-
const { container } = render(
|
|
323
|
-
<WrappedWidget
|
|
324
|
-
widgetConfigId="test-config-8"
|
|
325
|
-
widgetType={WidgetTypeV3.PromptCarouselV3}
|
|
326
|
-
/>,
|
|
327
|
-
);
|
|
328
|
-
|
|
329
|
-
const widgetElement = container.querySelector('[data-testid="test-widget"]');
|
|
330
|
-
|
|
331
|
-
// Trigger intersection
|
|
332
|
-
mockObserver.triggerIntersection(true, widgetElement as Element);
|
|
333
|
-
|
|
334
|
-
await waitFor(() => {
|
|
335
|
-
expect(mockObserver.disconnect).toHaveBeenCalled();
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it('should not track event if widget is not intersecting', async () => {
|
|
340
|
-
const WrappedWidget = withBaseWidget(TestWidget);
|
|
341
|
-
const { container } = render(
|
|
342
|
-
<WrappedWidget
|
|
343
|
-
widgetConfigId="test-config-9"
|
|
344
|
-
widgetType={WidgetTypeV3.PromptCarouselV3}
|
|
345
|
-
/>,
|
|
162
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
163
|
+
expect.any(Object),
|
|
164
|
+
{
|
|
165
|
+
widget_config_id: 'test-config-4',
|
|
166
|
+
widget_type: WidgetTypeV3.SocialProofV3,
|
|
167
|
+
custom_prop: 'custom_value',
|
|
168
|
+
another_prop: 123,
|
|
169
|
+
},
|
|
170
|
+
'0px',
|
|
171
|
+
true,
|
|
346
172
|
);
|
|
347
|
-
|
|
348
|
-
const widgetElement = container.querySelector('[data-testid="test-widget"]');
|
|
349
|
-
|
|
350
|
-
// Trigger non-intersection
|
|
351
|
-
mockObserver.triggerIntersection(false, widgetElement as Element);
|
|
352
|
-
|
|
353
|
-
// Wait a bit to ensure no event is tracked
|
|
354
|
-
await new Promise(resolve => {
|
|
355
|
-
setTimeout(resolve, 100);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
expect(mockTrackEvent).not.toHaveBeenCalled();
|
|
359
173
|
});
|
|
360
174
|
});
|
|
361
175
|
|
|
@@ -541,7 +355,6 @@ describe('withBaseWidget', () => {
|
|
|
541
355
|
mockGetHardcopy.mockResolvedValue(mockHardcopy);
|
|
542
356
|
|
|
543
357
|
const WrappedWidget = withBaseWidget(TestWidget, {
|
|
544
|
-
visibilityEventName: SpiffyMetricsEventName.SearchComponentVisible,
|
|
545
358
|
visibilityEventProps: {
|
|
546
359
|
test_integration: true,
|
|
547
360
|
},
|
|
@@ -561,20 +374,17 @@ describe('withBaseWidget', () => {
|
|
|
561
374
|
|
|
562
375
|
const widgetElement = screen.getByTestId('test-widget');
|
|
563
376
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
},
|
|
576
|
-
});
|
|
577
|
-
});
|
|
377
|
+
expect(widgetElement).toBeInTheDocument();
|
|
378
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
379
|
+
expect.any(Object),
|
|
380
|
+
{
|
|
381
|
+
widget_config_id: 'test-config-integration',
|
|
382
|
+
widget_type: WidgetTypeV3.PromptCarouselV3,
|
|
383
|
+
test_integration: true,
|
|
384
|
+
},
|
|
385
|
+
'0px',
|
|
386
|
+
true,
|
|
387
|
+
);
|
|
578
388
|
|
|
579
389
|
expect(screen.getByTestId('hardcopy-language')).toHaveTextContent('en');
|
|
580
390
|
expect(screen.getByTestId('hardcopy-values')).toHaveTextContent(
|
|
@@ -640,56 +450,24 @@ describe('withBaseWidget', () => {
|
|
|
640
450
|
userEvent: expect.any(Object),
|
|
641
451
|
});
|
|
642
452
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
// Trigger intersection for widget-1 using its observer
|
|
662
|
-
widget1Observer.triggerIntersection(true, widget1Element);
|
|
663
|
-
|
|
664
|
-
await waitFor(() => {
|
|
665
|
-
// Verify that an event was tracked for widget-1
|
|
666
|
-
expect(mockTrackEvent).toHaveBeenCalled();
|
|
667
|
-
const { calls } = mockTrackEvent.mock;
|
|
668
|
-
// Find any call that matches widget-1's properties
|
|
669
|
-
const widget1Call = calls.find(
|
|
670
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
671
|
-
(call: any) =>
|
|
672
|
-
call[0]?.eventProps?.widget_config_id === 'widget-1' &&
|
|
673
|
-
call[0]?.eventProps?.widget_type === WidgetTypeV3.PromptCarouselV3,
|
|
674
|
-
);
|
|
675
|
-
expect(widget1Call).toBeDefined();
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
// Verify widget-2 can also track independently
|
|
679
|
-
mockTrackEvent.mockClear();
|
|
680
|
-
widget2Observer.triggerIntersection(true, widget2Element);
|
|
681
|
-
|
|
682
|
-
await waitFor(() => {
|
|
683
|
-
expect(mockTrackEvent).toHaveBeenCalled();
|
|
684
|
-
const { calls } = mockTrackEvent.mock;
|
|
685
|
-
const widget2Call = calls.find(
|
|
686
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
687
|
-
(call: any) =>
|
|
688
|
-
call[0]?.eventProps?.widget_config_id === 'widget-2' &&
|
|
689
|
-
call[0]?.eventProps?.widget_type === WidgetTypeV3.ChatPreviewV3,
|
|
690
|
-
);
|
|
691
|
-
expect(widget2Call).toBeDefined();
|
|
692
|
-
});
|
|
453
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
454
|
+
expect.any(Object),
|
|
455
|
+
{
|
|
456
|
+
widget_config_id: 'widget-1',
|
|
457
|
+
widget_type: WidgetTypeV3.PromptCarouselV3,
|
|
458
|
+
},
|
|
459
|
+
'0px',
|
|
460
|
+
true,
|
|
461
|
+
);
|
|
462
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
463
|
+
expect.any(Object),
|
|
464
|
+
{
|
|
465
|
+
widget_config_id: 'widget-2',
|
|
466
|
+
widget_type: WidgetTypeV3.ChatPreviewV3,
|
|
467
|
+
},
|
|
468
|
+
'0px',
|
|
469
|
+
true,
|
|
470
|
+
);
|
|
693
471
|
});
|
|
694
472
|
});
|
|
695
473
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
import { SpiffyMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
3
2
|
import { HardcopyResponse } from '@envive-ai/react-hooks/contexts/hardcopyContext';
|
|
4
3
|
import {
|
|
5
4
|
OrgUIConfigV3,
|
|
@@ -22,11 +21,6 @@ export interface BaseWidgetProps {
|
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export interface WithBaseWidgetOptions {
|
|
25
|
-
/**
|
|
26
|
-
* The Amplitude event name to track when the widget becomes visible.
|
|
27
|
-
* Defaults to a generic component visible event if not provided.
|
|
28
|
-
*/
|
|
29
|
-
visibilityEventName?: SpiffyMetricsEventName;
|
|
30
24
|
/**
|
|
31
25
|
* Additional properties to include with the visibility event.
|
|
32
26
|
*/
|
|
@@ -36,4 +30,10 @@ export interface WithBaseWidgetOptions {
|
|
|
36
30
|
* Defaults to '0px'.
|
|
37
31
|
*/
|
|
38
32
|
rootMargin?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether to defer loading of the widget until it is visible.
|
|
36
|
+
* Defaults to true
|
|
37
|
+
*/
|
|
38
|
+
deferLoading?: boolean;
|
|
39
39
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
useAmplitude,
|
|
6
|
-
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
3
|
+
import { useAmplitude } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
|
+
import { useTrackComponentVisibleEvent } from '@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent';
|
|
7
5
|
import { HardcopyResponse, useHardcopy } from '@envive-ai/react-hooks/contexts/hardcopyContext';
|
|
8
6
|
import { usePage } from '@envive-ai/react-hooks/contexts/pageContext';
|
|
9
7
|
import { useWidgetConfig } from '@envive-ai/react-hooks/contexts/widgetConfigContext';
|
|
10
8
|
import { OrgUIConfigV3, WidgetConfigV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
11
9
|
import { useUiConfig } from '@envive-ai/react-hooks/contexts/uiConfigContext';
|
|
12
|
-
|
|
13
10
|
import { BaseWidgetProps, WithBaseWidgetOptions } from './types';
|
|
14
11
|
|
|
15
12
|
export function withBaseWidget<P extends BaseWidgetProps>(
|
|
@@ -19,10 +16,10 @@ export function withBaseWidget<P extends BaseWidgetProps>(
|
|
|
19
16
|
const WrappedWidget = (props: P) => {
|
|
20
17
|
const { widgetConfigId, widgetType } = props;
|
|
21
18
|
const widgetRef = useRef<HTMLDivElement>(null);
|
|
22
|
-
const
|
|
23
|
-
const { trackEvent, isReady } = useAmplitude();
|
|
19
|
+
const { isReady } = useAmplitude();
|
|
24
20
|
|
|
25
21
|
const [hardcopyContent, setHardcopyContent] = useState<HardcopyResponse | undefined>(undefined);
|
|
22
|
+
const hardcopyFetchedRef = useRef(false);
|
|
26
23
|
const { getHardcopy, isLoading: isHardcopyLoading } = useHardcopy();
|
|
27
24
|
|
|
28
25
|
const { userEvent, isLoading: isPageLoading } = usePage();
|
|
@@ -36,87 +33,75 @@ export function withBaseWidget<P extends BaseWidgetProps>(
|
|
|
36
33
|
const isLoading =
|
|
37
34
|
isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading;
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const visibilityEventProps = {
|
|
37
|
+
widget_config_id: widgetConfigId,
|
|
38
|
+
widget_type: widgetType,
|
|
39
|
+
...options?.visibilityEventProps,
|
|
40
|
+
};
|
|
41
|
+
const { isVisible } = useTrackComponentVisibleEvent(
|
|
42
|
+
widgetRef,
|
|
43
|
+
visibilityEventProps,
|
|
44
|
+
options?.rootMargin || '0px',
|
|
45
|
+
isReady,
|
|
46
|
+
);
|
|
47
|
+
const startLoading: boolean = useMemo(() => {
|
|
48
|
+
if (options?.deferLoading === false) {
|
|
49
|
+
return true;
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (entry.isIntersecting && !hasTrackedEvent.current) {
|
|
47
|
-
const eventName =
|
|
48
|
-
options?.visibilityEventName || SpiffyMetricsEventName.ChatComponentVisible;
|
|
49
|
-
|
|
50
|
-
trackEvent({
|
|
51
|
-
eventName,
|
|
52
|
-
eventProps: {
|
|
53
|
-
widget_config_id: widgetConfigId,
|
|
54
|
-
widget_type: widgetType,
|
|
55
|
-
...options?.visibilityEventProps,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
hasTrackedEvent.current = true;
|
|
60
|
-
observer.disconnect();
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
rootMargin: options?.rootMargin || '0px',
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
observer.observe(widgetRef.current);
|
|
69
|
-
|
|
70
|
-
return () => {
|
|
71
|
-
observer.disconnect();
|
|
72
|
-
};
|
|
73
|
-
}, [isReady, widgetConfigId, widgetType, trackEvent]);
|
|
51
|
+
// Defer loading by default until the widget is visible
|
|
52
|
+
return isVisible && !!widgetConfigId && !!widgetType;
|
|
53
|
+
}, [isVisible, widgetConfigId, widgetType]);
|
|
74
54
|
|
|
75
55
|
useEffect(() => {
|
|
76
|
-
if (!
|
|
56
|
+
if (!startLoading || hardcopyFetchedRef.current) {
|
|
77
57
|
return;
|
|
78
58
|
}
|
|
59
|
+
hardcopyFetchedRef.current = true;
|
|
79
60
|
getHardcopy({ widgetType, userEvent })
|
|
80
61
|
.then(setHardcopyContent)
|
|
81
62
|
.catch(() => {
|
|
82
63
|
// Silently handle errors - widget will render without hardcopy content
|
|
83
64
|
});
|
|
84
|
-
}, [
|
|
65
|
+
}, [startLoading, widgetType, getHardcopy, userEvent, widgetConfigId]);
|
|
85
66
|
|
|
86
67
|
useEffect(() => {
|
|
68
|
+
if (!startLoading) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
87
71
|
getUiConfig()
|
|
88
72
|
.then(setUiConfig)
|
|
89
73
|
.catch(() => {
|
|
90
74
|
// Silently handle errors - widget will render without ui config
|
|
91
75
|
});
|
|
92
|
-
}, [getUiConfig, widgetConfigId, widgetType]);
|
|
76
|
+
}, [startLoading, getUiConfig, widgetConfigId, widgetType]);
|
|
93
77
|
|
|
94
78
|
useEffect(() => {
|
|
95
|
-
if (!
|
|
79
|
+
if (!startLoading) {
|
|
96
80
|
return;
|
|
97
81
|
}
|
|
98
82
|
|
|
99
83
|
getWidgetConfig({ widgetConfigId, widgetType })
|
|
100
84
|
.then(setWidgetConfig)
|
|
101
|
-
.catch(
|
|
102
|
-
console.error('Error getting widget config', widgetConfigId, widgetType, e);
|
|
85
|
+
.catch(() => {
|
|
103
86
|
// Silently handle errors - widget will render without widget config
|
|
104
87
|
});
|
|
105
|
-
}, [widgetConfigId, widgetType, getWidgetConfig]);
|
|
88
|
+
}, [startLoading, widgetConfigId, widgetType, getWidgetConfig]);
|
|
106
89
|
|
|
107
90
|
return (
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
91
|
+
<span ref={widgetRef}>
|
|
92
|
+
<Widget
|
|
93
|
+
{...props}
|
|
94
|
+
isLoading={isLoading}
|
|
95
|
+
isHardcopyLoading={isHardcopyLoading}
|
|
96
|
+
isPageLoading={isPageLoading}
|
|
97
|
+
isWidgetConfigLoading={isWidgetConfigLoading}
|
|
98
|
+
isUiConfigLoading={isUiConfigLoading}
|
|
99
|
+
uiConfig={uiConfig}
|
|
100
|
+
widgetConfig={widgetConfig}
|
|
101
|
+
hardcopyContent={hardcopyContent}
|
|
102
|
+
observedWidget={widgetRef}
|
|
103
|
+
/>
|
|
104
|
+
</span>
|
|
120
105
|
);
|
|
121
106
|
};
|
|
122
107
|
|