@envive-ai/react-hooks 0.3.3 → 0.3.4
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/_virtual/rolldown_runtime.cjs +2 -0
- package/dist/_virtual/rolldown_runtime.js +29 -0
- package/dist/application/commerce-api.cjs +11 -3
- package/dist/application/commerce-api.js +11 -3
- package/dist/application/models/api/userEvent.d.cts +4 -2
- package/dist/application/models/api/userEvent.d.ts +4 -2
- package/dist/application/models/chatElementDisplayLocationV3.cjs +18 -0
- package/dist/application/models/chatElementDisplayLocationV3.d.cts +15 -0
- package/dist/application/models/chatElementDisplayLocationV3.d.ts +15 -0
- package/dist/application/models/chatElementDisplayLocationV3.js +17 -0
- package/dist/application/models/colorsConfigV3.cjs +26 -0
- package/dist/application/models/colorsConfigV3.d.cts +22 -0
- package/dist/application/models/colorsConfigV3.d.ts +22 -0
- package/dist/application/models/colorsConfigV3.js +24 -0
- package/dist/application/models/featureGates.cjs +2 -1
- package/dist/application/models/featureGates.d.cts +2 -1
- package/dist/application/models/featureGates.d.ts +2 -1
- package/dist/application/models/featureGates.js +2 -1
- package/dist/application/models/frontendConfig.d.cts +4 -2
- package/dist/application/models/frontendConfig.d.ts +4 -2
- package/dist/application/models/frontendConfigV3.d.cts +14 -0
- package/dist/application/models/frontendConfigV3.d.ts +14 -0
- package/dist/application/models/index.cjs +3 -0
- package/dist/application/models/index.d.cts +4 -3
- package/dist/application/models/index.d.ts +4 -3
- package/dist/application/models/index.js +3 -2
- package/dist/application/models/utils/snakeToCamelTransformer.cjs +2 -1
- package/dist/application/models/utils/snakeToCamelTransformer.d.cts +7 -2
- package/dist/application/models/utils/snakeToCamelTransformer.d.ts +7 -2
- package/dist/application/models/utils/snakeToCamelTransformer.js +2 -2
- package/dist/application/utils/analyticsUtils.cjs +5 -4
- package/dist/application/utils/analyticsUtils.d.cts +1 -1
- package/dist/application/utils/analyticsUtils.d.ts +1 -1
- package/dist/application/utils/analyticsUtils.js +3 -2
- package/dist/application/utils/elementObserver.cjs +1 -1
- package/dist/application/utils/elementObserver.js +1 -1
- package/dist/application/utils/index.d.cts +1 -1
- package/dist/application/utils/index.d.ts +1 -1
- package/dist/application/utils/widgetTextFromApiWidgetTextResponse.cjs +14 -0
- package/dist/application/utils/widgetTextFromApiWidgetTextResponse.js +13 -0
- package/dist/application/utils/widgetTextRequestToApiRequest.cjs +30 -0
- package/dist/application/utils/widgetTextRequestToApiRequest.js +29 -0
- package/dist/atoms/amplitude/amplitudeTrackEventAtom.cjs +1 -1
- package/dist/atoms/amplitude/amplitudeTrackEventAtom.js +1 -1
- package/dist/atoms/app/index.cjs +4 -3
- package/dist/atoms/app/index.d.cts +3 -3
- package/dist/atoms/app/index.d.ts +9 -9
- package/dist/atoms/app/index.js +4 -5
- package/dist/atoms/app/variant.cjs +5 -1
- package/dist/atoms/app/variant.d.cts +11 -4
- package/dist/atoms/app/variant.d.ts +11 -4
- package/dist/atoms/app/variant.js +4 -2
- package/dist/atoms/chat/chatState.cjs +9 -4
- package/dist/atoms/chat/chatState.d.cts +25 -18
- package/dist/atoms/chat/chatState.d.ts +25 -18
- package/dist/atoms/chat/chatState.js +6 -3
- package/dist/atoms/chat/form.cjs +4 -4
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/form.d.ts +2 -2
- package/dist/atoms/chat/index.cjs +32 -30
- package/dist/atoms/chat/index.d.cts +4 -4
- package/dist/atoms/chat/index.d.ts +5 -5
- package/dist/atoms/chat/index.js +2 -2
- package/dist/atoms/chat/lastMessage.cjs +4 -4
- package/dist/atoms/chat/lastMessage.d.cts +2 -2
- package/dist/atoms/chat/lastMessage.d.ts +2 -2
- package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
- package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
- package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
- package/dist/atoms/chat/replies.cjs +9 -8
- package/dist/atoms/chat/replies.d.cts +3 -3
- package/dist/atoms/chat/replies.d.ts +3 -3
- package/dist/atoms/chat/replies.js +3 -2
- package/dist/atoms/chat/suggestions.cjs +6 -6
- package/dist/atoms/chat/suggestions.d.cts +2 -2
- package/dist/atoms/chat/suggestions.d.ts +2 -2
- package/dist/atoms/envive/enviveConfig.cjs +5 -2
- package/dist/atoms/envive/enviveConfig.js +5 -2
- package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
- package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
- package/dist/atoms/org/customerService.d.cts +6 -6
- package/dist/atoms/org/customerService.d.ts +6 -6
- package/dist/atoms/org/graphqlConfig.cjs +1 -3
- package/dist/atoms/org/graphqlConfig.d.cts +6 -9
- package/dist/atoms/org/graphqlConfig.d.ts +6 -9
- package/dist/atoms/org/graphqlConfig.js +2 -3
- package/dist/atoms/org/index.cjs +2 -3
- package/dist/atoms/org/index.d.cts +2 -2
- package/dist/atoms/org/index.d.ts +2 -2
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +5 -5
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +5 -5
- package/dist/atoms/search/chatSearch.cjs +7 -7
- package/dist/atoms/search/chatSearch.d.cts +20 -18
- package/dist/atoms/search/chatSearch.d.ts +20 -18
- package/dist/atoms/search/searchAPI.cjs +1 -1
- package/dist/atoms/search/searchAPI.d.cts +15 -14
- package/dist/atoms/search/searchAPI.d.ts +15 -14
- package/dist/atoms/search/searchAPI.js +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/widget/chatPreviewLoading.cjs +23 -0
- package/dist/atoms/widget/chatPreviewLoading.d.cts +26 -0
- package/dist/atoms/widget/chatPreviewLoading.d.ts +26 -0
- package/dist/atoms/widget/chatPreviewLoading.js +22 -0
- package/dist/atoms/widget/index.cjs +3 -0
- package/dist/atoms/widget/index.d.cts +2 -0
- package/dist/atoms/widget/index.d.ts +2 -0
- package/dist/atoms/widget/index.js +3 -0
- package/dist/contexts/amplitudeContext/amplitudeContext.cjs +40 -227
- package/dist/contexts/amplitudeContext/amplitudeContext.d.cts +4 -39
- package/dist/contexts/amplitudeContext/amplitudeContext.d.ts +4 -39
- package/dist/contexts/amplitudeContext/amplitudeContext.js +44 -230
- package/dist/contexts/amplitudeContext/index.cjs +2 -1
- package/dist/contexts/amplitudeContext/index.d.cts +2 -1
- package/dist/contexts/amplitudeContext/index.d.ts +2 -1
- package/dist/contexts/amplitudeContext/index.js +2 -1
- package/dist/contexts/enviveConfigContext/enviveConfigContext.cjs +3 -2
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.cts +2 -1
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.ts +2 -1
- package/dist/contexts/enviveConfigContext/enviveConfigContext.js +3 -2
- package/dist/contexts/enviveContext/enviveContext.cjs +67 -16
- package/dist/contexts/enviveContext/enviveContext.d.cts +9 -1
- package/dist/contexts/enviveContext/enviveContext.d.ts +9 -1
- package/dist/contexts/enviveContext/enviveContext.js +69 -18
- package/dist/contexts/enviveCssContext/enviveCssContext.cjs +96 -24
- package/dist/contexts/enviveCssContext/enviveCssContext.js +96 -24
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.cjs +5 -7
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.cts +2 -2
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +2 -2
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.js +5 -7
- package/dist/contexts/graphqlContext/graphqlContext.cjs +69 -7
- package/dist/contexts/graphqlContext/graphqlContext.d.cts +17 -5
- package/dist/contexts/graphqlContext/graphqlContext.d.ts +17 -5
- package/dist/contexts/graphqlContext/graphqlContext.js +69 -7
- package/dist/contexts/graphqlContext/index.d.cts +2 -2
- package/dist/contexts/graphqlContext/index.d.ts +2 -2
- package/dist/contexts/graphqlContext/mockV3Config.cjs +208 -0
- package/dist/contexts/graphqlContext/mockV3Config.js +207 -0
- package/dist/contexts/hardcopyContext/hardcopyContext.cjs +119 -12
- package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +3 -2
- package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +3 -2
- package/dist/contexts/hardcopyContext/hardcopyContext.js +120 -13
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +7 -8
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +8 -9
- package/dist/contexts/pageContext/mapping.cjs +5 -1
- package/dist/contexts/pageContext/mapping.d.cts +1 -1
- package/dist/contexts/pageContext/mapping.d.ts +1 -1
- package/dist/contexts/pageContext/mapping.js +5 -1
- package/dist/contexts/pageContext/pageContext.cjs +29 -9
- package/dist/contexts/pageContext/pageContext.d.cts +5 -2
- package/dist/contexts/pageContext/pageContext.d.ts +5 -2
- package/dist/contexts/pageContext/pageContext.js +30 -10
- package/dist/contexts/pageContext/types.d.cts +5 -1
- package/dist/contexts/pageContext/types.d.ts +5 -1
- package/dist/contexts/salesAgentContext/chatAPI.cjs +6 -3
- package/dist/contexts/salesAgentContext/chatAPI.js +6 -3
- package/dist/contexts/salesAgentContext/salesAgentContext.cjs +65 -25
- package/dist/contexts/salesAgentContext/salesAgentContext.js +64 -24
- package/dist/contexts/salesAgentContext/salesAgentService.cjs +43 -7
- package/dist/contexts/salesAgentContext/salesAgentService.js +42 -6
- package/dist/contexts/salesAgentContext/statusCodeError.cjs +14 -0
- package/dist/contexts/salesAgentContext/statusCodeError.js +13 -0
- package/dist/contexts/searchContext/searchContext.cjs +1 -1
- package/dist/contexts/searchContext/searchContext.js +1 -1
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
- package/dist/contexts/types.cjs +2 -13
- package/dist/contexts/types.d.cts +12 -16
- package/dist/contexts/types.d.ts +12 -16
- package/dist/contexts/types.js +3 -13
- package/dist/contexts/typesV3.cjs +125 -0
- package/dist/contexts/typesV3.d.cts +246 -0
- package/dist/contexts/typesV3.d.ts +246 -0
- package/dist/contexts/typesV3.js +113 -0
- package/dist/contexts/uiConfigContext/index.cjs +4 -0
- package/dist/contexts/uiConfigContext/index.d.cts +2 -0
- package/dist/contexts/uiConfigContext/index.d.ts +2 -0
- package/dist/contexts/uiConfigContext/index.js +3 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.cjs +44 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.d.cts +15 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.d.ts +15 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.js +42 -0
- package/dist/contexts/userIdentityContext/userIdentityContext.cjs +1 -1
- package/dist/contexts/userIdentityContext/userIdentityContext.js +1 -1
- package/dist/contexts/widgetConfigContext/index.cjs +4 -0
- package/dist/contexts/widgetConfigContext/index.d.cts +2 -0
- package/dist/contexts/widgetConfigContext/index.d.ts +2 -0
- package/dist/contexts/widgetConfigContext/index.js +3 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.cjs +67 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.d.cts +19 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.d.ts +19 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.js +65 -0
- package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.ts +1 -1
- package/dist/hooks/AppDetails/useAppDetails.cjs +2 -4
- package/dist/hooks/AppDetails/useAppDetails.js +3 -5
- package/dist/hooks/ChatToggle/useChatToggle.cjs +6 -5
- package/dist/hooks/ChatToggle/useChatToggle.js +3 -2
- package/dist/hooks/ChatToggleAnalytics/useChatToggleAnalytics.cjs +3 -3
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.ts +3 -3
- package/dist/hooks/GraphQLConfig/index.cjs +1 -1
- package/dist/hooks/GraphQLConfig/index.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.js +2 -2
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.cjs +27 -24
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.cts +5 -4
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.ts +5 -4
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.js +27 -24
- package/dist/hooks/Search/useSearch.cjs +10 -9
- package/dist/hooks/Search/useSearch.js +6 -5
- package/dist/hooks/Search/useSearchInput.cjs +4 -4
- package/dist/hooks/Search/useSearchInput.js +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.cjs +5 -4
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.cts +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.ts +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +3 -2
- package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.cjs +3 -2
- package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +3 -2
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/node_modules/classnames/index.cjs +52 -0
- package/dist/node_modules/classnames/index.js +49 -0
- package/dist/packages/components-v3/dist/Container/Container.cjs +11 -0
- package/dist/packages/components-v3/dist/Container/Container.js +12 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.js +3 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.js +3 -0
- package/dist/packages/components-v3/dist/Container/index.cjs +1 -0
- package/dist/packages/components-v3/dist/Container/index.js +3 -0
- package/dist/packages/components-v3/dist/Image/Image.cjs +16 -0
- package/dist/packages/components-v3/dist/Image/Image.js +17 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAccessibilityProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAccessibilityProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAspectRatioProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAspectRatioProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetObjectFitProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetObjectFitProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetRoundedProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetRoundedProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetSkeletonProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetSkeletonProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetWidthProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetWidthProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useHandleImageLoading.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useHandleImageLoading.js +3 -0
- package/dist/packages/components-v3/dist/ImageGallery/ImageGallery.cjs +2 -0
- package/dist/packages/components-v3/dist/ImageGallery/ImageGallery.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/ImageItem.cjs +2 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/ImageItem.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.cjs +15 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.js +16 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/NormalLayout.cjs +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/NormalLayout.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/OverlappedLayout.cjs +1 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/OverlappedLayout.js +3 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/index.cjs +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/index.js +6 -0
- package/dist/packages/components-v3/dist/ImageGallery/hooks/useGetContainerProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/ImageGallery/hooks/useGetContainerProperties.js +3 -0
- package/dist/packages/components-v3/dist/ImageGallery/index.cjs +2 -0
- package/dist/packages/components-v3/dist/ImageGallery/index.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/types/types.cjs +13 -0
- package/dist/packages/components-v3/dist/ImageGallery/types/types.js +12 -0
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.cjs +12 -0
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.js +13 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Icon.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Icon.js +3 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Label.cjs +3 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Label.js +5 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.cjs +12 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.js +13 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Loading.cjs +9 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Loading.js +10 -0
- package/dist/packages/components-v3/dist/PromptButton/components/index.cjs +4 -0
- package/dist/packages/components-v3/dist/PromptButton/components/index.js +6 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.js +3 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.cjs +8 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.js +9 -0
- package/dist/packages/components-v3/dist/PromptButton/index.cjs +2 -0
- package/dist/packages/components-v3/dist/PromptButton/index.js +4 -0
- package/dist/packages/components-v3/dist/PromptButton/types/index.cjs +13 -0
- package/dist/packages/components-v3/dist/PromptButton/types/index.js +12 -0
- package/dist/packages/components-v3/dist/PromptCarousel/PromptCarousel.cjs +12 -0
- package/dist/packages/components-v3/dist/PromptCarousel/PromptCarousel.js +14 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/BlockScrollContainer.cjs +9 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/BlockScrollContainer.js +10 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/ButtonContainerRow.cjs +11 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/ButtonContainerRow.js +12 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithBlockScroll.cjs +4 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithBlockScroll.js +6 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithRowScroll.cjs +4 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithRowScroll.js +6 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/index.cjs +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/index.js +5 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/index.cjs +5 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/index.js +7 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useButtonScrollPosition.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useButtonScrollPosition.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselAnimation.cjs +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselAnimation.js +5 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselButtons.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselButtons.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselRefs.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselRefs.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/index.cjs +2 -0
- package/dist/packages/components-v3/dist/PromptCarousel/index.js +4 -0
- package/dist/packages/components-v3/dist/PromptCarousel/types/types.cjs +19 -0
- package/dist/packages/components-v3/dist/PromptCarousel/types/types.js +17 -0
- package/dist/packages/components-v3/dist/Stack/Stack.cjs +36 -0
- package/dist/packages/components-v3/dist/Stack/Stack.js +36 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useFormatStackChildren.cjs +27 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useFormatStackChildren.js +26 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetAlignProperties.cjs +20 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetAlignProperties.js +19 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetDirectionProperties.cjs +19 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetDirectionProperties.js +18 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetGapProperties.cjs +16 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetGapProperties.js +15 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetJustifyProperties.cjs +21 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetJustifyProperties.js +20 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetStyleProperties.cjs +38 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetStyleProperties.js +38 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetWrapProperties.cjs +13 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetWrapProperties.js +12 -0
- package/dist/packages/components-v3/dist/Stack/index.cjs +1 -0
- package/dist/packages/components-v3/dist/Stack/index.js +3 -0
- package/dist/packages/components-v3/dist/Stack/utils/constants.cjs +42 -0
- package/dist/packages/components-v3/dist/Stack/utils/constants.js +41 -0
- package/dist/packages/components-v3/dist/Typography/Typography.cjs +15 -0
- package/dist/packages/components-v3/dist/Typography/Typography.js +16 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/index.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/index.js +3 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/WidgetWrapper.cjs +12 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/WidgetWrapper.js +13 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/hooks/useGetWrapperProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/hooks/useGetWrapperProperties.js +3 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/index.cjs +2 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/index.js +4 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/types/types.cjs +13 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/types/types.js +12 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.cjs +25 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.js +23 -0
- package/dist/packages/components-v3/dist/utils/useCheckIsMobile.cjs +1 -0
- package/dist/packages/components-v3/dist/utils/useCheckIsMobile.js +3 -0
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.cjs +57 -0
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.js +56 -0
- package/dist/packages/icons/dist/FourPointStar.cjs +8 -0
- package/dist/packages/icons/dist/FourPointStar.js +9 -0
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.cjs +28 -0
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.js +26 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +697 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.js +697 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs +44 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.js +44 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.cjs +1529 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.js +1529 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.cjs +330 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.js +330 -0
- package/dist/packages/icons/dist/node_modules/react/index.cjs +14 -0
- package/dist/packages/icons/dist/node_modules/react/index.js +14 -0
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.cjs +14 -0
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.js +14 -0
- package/dist/services/amplitudeService/amplitudeService.cjs +204 -0
- package/dist/services/amplitudeService/amplitudeService.d.cts +75 -0
- package/dist/services/amplitudeService/amplitudeService.d.ts +75 -0
- package/dist/services/amplitudeService/amplitudeService.js +202 -0
- package/dist/services/amplitudeService/index.cjs +4 -0
- package/dist/services/amplitudeService/index.d.cts +2 -0
- package/dist/services/amplitudeService/index.d.ts +2 -0
- package/dist/services/amplitudeService/index.js +3 -0
- package/dist/services/enviveConfigService/enviveConfigService.cjs +36 -0
- package/dist/services/enviveConfigService/enviveConfigService.d.cts +43 -0
- package/dist/services/enviveConfigService/enviveConfigService.d.ts +43 -0
- package/dist/services/enviveConfigService/enviveConfigService.js +36 -0
- package/dist/services/enviveConfigService/index.cjs +3 -0
- package/dist/services/enviveConfigService/index.d.cts +2 -0
- package/dist/services/enviveConfigService/index.d.ts +2 -0
- package/dist/services/enviveConfigService/index.js +3 -0
- package/dist/types/enviveConfig.d.cts +29 -0
- package/dist/types/enviveConfig.d.ts +29 -0
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +36 -4
- package/src/application/commerce-api.ts +14 -1
- package/src/application/models/api/userEvent.ts +3 -1
- package/src/application/models/api/widgetText.ts +9 -0
- package/src/application/models/api/widgetTextRequest.ts +10 -0
- package/src/application/models/chatElementDisplayLocationV3.ts +12 -0
- package/src/application/models/colorsConfigV3.ts +26 -0
- package/src/application/models/featureGates.ts +1 -0
- package/src/application/models/frontendConfig.ts +5 -0
- package/src/application/models/frontendConfigV3.ts +10 -0
- package/src/application/models/index.ts +1 -0
- package/src/application/models/utils/snakeToCamelTransformer.ts +1 -1
- package/src/application/utils/elementObserver.ts +2 -2
- package/src/application/utils/widgetTextFromApiWidgetTextResponse.ts +30 -0
- package/src/application/utils/widgetTextRequestToApiRequest.ts +45 -0
- package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -8
- package/src/atoms/app/index.ts +3 -3
- package/src/atoms/app/variant.ts +5 -0
- package/src/atoms/chat/chatState.ts +10 -2
- package/src/atoms/envive/enviveConfig.ts +5 -0
- package/src/atoms/org/graphqlConfig.ts +0 -1
- package/src/atoms/widget/chatPreviewLoading.ts +36 -0
- package/src/atoms/widget/index.ts +1 -0
- package/src/contexts/amplitudeContext/__tests__/amplitudeContext.test.tsx +197 -187
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +56 -334
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +3 -0
- package/src/contexts/enviveContext/enviveContext.tsx +101 -27
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +121 -22
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +12 -11
- package/src/contexts/graphqlContext/graphqlContext.tsx +131 -13
- package/src/contexts/graphqlContext/mockV3Config.ts +209 -0
- package/src/contexts/hardcopyContext/hardcopyContext.tsx +136 -14
- package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +6 -6
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +5 -13
- package/src/contexts/pageContext/__tests__/pageContext.test.tsx +24 -8
- package/src/contexts/pageContext/mapping.ts +4 -0
- package/src/contexts/pageContext/pageContext.tsx +41 -12
- package/src/contexts/pageContext/types.ts +4 -0
- package/src/contexts/salesAgentContext/chatAPI.ts +1 -0
- package/src/contexts/salesAgentContext/salesAgentContext.tsx +94 -42
- package/src/contexts/salesAgentContext/salesAgentService.ts +78 -3
- package/src/contexts/salesAgentContext/statusCodeError.ts +10 -0
- package/src/contexts/searchContext/__tests__/searchContext.test.tsx +8 -2
- package/src/contexts/types.ts +15 -19
- package/src/contexts/typesV3.ts +316 -0
- package/src/contexts/uiConfigContext/__tests__/uiConfigContext.test.tsx +321 -0
- package/src/contexts/uiConfigContext/index.ts +1 -0
- package/src/contexts/uiConfigContext/uiConfigContext.tsx +44 -0
- package/src/contexts/widgetConfigContext/__tests__/widgetConfigContext.test.tsx +512 -0
- package/src/contexts/widgetConfigContext/index.ts +1 -0
- package/src/contexts/widgetConfigContext/widgetConfigContext.tsx +84 -0
- package/src/hooks/AppDetails/useAppDetails.ts +2 -2
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +22 -21
- package/src/hooks/Search/__tests__/useSearch.test.tsx +15 -6
- package/src/hooks/Search/useSearch.tsx +6 -5
- package/src/services/amplitudeService/__tests__/amplitudeService.test.ts +558 -0
- package/src/services/amplitudeService/amplitudeService.ts +324 -0
- package/src/services/amplitudeService/index.ts +1 -0
- package/src/services/enviveConfigService/enviveConfigService.ts +72 -0
- package/src/services/enviveConfigService/index.ts +1 -0
- package/src/types/enviveConfig.ts +27 -0
- package/src/types/index.ts +1 -0
|
@@ -7,7 +7,10 @@ import { EnviveConfigProvider } from 'src/contexts/enviveConfigContext/enviveCon
|
|
|
7
7
|
import { LocalStorageProvider } from 'src/contexts/localStorageContext/localStorageContext';
|
|
8
8
|
import { GraphQLProvider } from 'src/contexts/graphqlContext/graphqlContext';
|
|
9
9
|
import { UserIdentityProvider } from 'src/contexts/userIdentityContext/userIdentityContext';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
FeatureFlagService,
|
|
12
|
+
FeatureFlagServiceProvider,
|
|
13
|
+
} from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
|
|
11
14
|
import { NewOrgConfigProvider } from 'src/contexts/newOrgConfigContext/newOrgConfigContext';
|
|
12
15
|
import { SearchProvider } from 'src/contexts/searchContext/searchContext';
|
|
13
16
|
import {
|
|
@@ -74,7 +77,7 @@ vi.mock('src/contexts/enviveConfigContext/enviveConfigContext', async () => {
|
|
|
74
77
|
|
|
75
78
|
// Mock useColorsAndFrontendConfig
|
|
76
79
|
vi.mock('src/hooks/GraphQLConfig/useGraphQLConfig', () => ({
|
|
77
|
-
|
|
80
|
+
useUIConfig: vi.fn(() => ({
|
|
78
81
|
data: {
|
|
79
82
|
colorsConfig: { accentPrimary: '#FF0000' },
|
|
80
83
|
frontendConfig: {
|
|
@@ -168,6 +171,9 @@ vi.mock('src/events', () => ({
|
|
|
168
171
|
},
|
|
169
172
|
}));
|
|
170
173
|
|
|
174
|
+
// FeatureFlagService
|
|
175
|
+
const testFeatureFlagService = new FeatureFlagService([]);
|
|
176
|
+
|
|
171
177
|
const mockSearchData: SearchResult = {
|
|
172
178
|
products: [
|
|
173
179
|
{
|
|
@@ -393,7 +399,7 @@ const TestWrapper: React.FC<{
|
|
|
393
399
|
<LocalStorageProvider>
|
|
394
400
|
<GraphQLProvider>
|
|
395
401
|
<UserIdentityProvider>
|
|
396
|
-
<FeatureFlagServiceProvider
|
|
402
|
+
<FeatureFlagServiceProvider featureFlagService={testFeatureFlagService}>
|
|
397
403
|
<AmplitudeProvider>
|
|
398
404
|
<NewOrgConfigProvider>
|
|
399
405
|
<SearchProvider>
|
|
@@ -405,9 +411,12 @@ const TestWrapper: React.FC<{
|
|
|
405
411
|
sorting={sorting}
|
|
406
412
|
isFilterOpen={isFilterOpen}
|
|
407
413
|
/>
|
|
408
|
-
{React.cloneElement(
|
|
409
|
-
allowRedirect
|
|
410
|
-
|
|
414
|
+
{React.cloneElement(
|
|
415
|
+
children as React.ReactElement<{ allowRedirect?: boolean }>,
|
|
416
|
+
{
|
|
417
|
+
allowRedirect,
|
|
418
|
+
},
|
|
419
|
+
)}
|
|
411
420
|
</SearchProvider>
|
|
412
421
|
</NewOrgConfigProvider>
|
|
413
422
|
</AmplitudeProvider>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { RefObject, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
SelectedFilterOption,
|
|
@@ -28,7 +28,7 @@ import { SearchResult } from 'src/application/models/api/search';
|
|
|
28
28
|
import { SearchResponseProduct } from '@spiffy-ai/commerce-api-client';
|
|
29
29
|
import { SearchFilterDatum, SelectFilterItem } from 'src/types/search-filter-types';
|
|
30
30
|
import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
|
|
31
|
-
import { SearchResponseProductAttributes } from 'src/application/models';
|
|
31
|
+
import { FrontendConfig, SearchResponseProductAttributes } from 'src/application/models';
|
|
32
32
|
import { SearchResultsState, getSearchResultsState } from '../utils';
|
|
33
33
|
import { useTrackComponentVisibleEvent } from '../TrackComponentVisibleEvent';
|
|
34
34
|
import { useSearchInput } from './useSearchInput';
|
|
@@ -147,7 +147,8 @@ export const useSearch = ({
|
|
|
147
147
|
const dynamicFilters = searchData?.filters || [];
|
|
148
148
|
|
|
149
149
|
// Provide fallback values when orgUIConfig is not yet available
|
|
150
|
-
const safeProductCardConfig = config?.frontendConfig?.uiConfigs
|
|
150
|
+
const safeProductCardConfig = (config?.frontendConfig as FrontendConfig)?.uiConfigs
|
|
151
|
+
?.productCardConfig || {
|
|
151
152
|
variant: 'minimal',
|
|
152
153
|
hoverVariant: 'none',
|
|
153
154
|
layoutVariant: 'square',
|
|
@@ -296,7 +297,7 @@ export const useSearch = ({
|
|
|
296
297
|
// Side Effects
|
|
297
298
|
useTrackComponentVisibleEvent(
|
|
298
299
|
SpiffyWidgets.SearchResults,
|
|
299
|
-
searchResultsRef
|
|
300
|
+
searchResultsRef as RefObject<HTMLElement>,
|
|
300
301
|
{},
|
|
301
302
|
SpiffyMetricsEventName.SearchComponentVisible,
|
|
302
303
|
);
|
|
@@ -360,6 +361,6 @@ export const useSearch = ({
|
|
|
360
361
|
onClearAllFilters: handleClearAllFilters,
|
|
361
362
|
setIsFilterOpen,
|
|
362
363
|
resetSearch,
|
|
363
|
-
searchResultsRef
|
|
364
|
+
searchResultsRef: searchResultsRef as RefObject<HTMLDivElement>,
|
|
364
365
|
};
|
|
365
366
|
};
|
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import { FeatureFlagService } from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
|
|
2
|
+
import { FeatureGates } from 'src/application/models/featureGates';
|
|
3
|
+
import { LocalStorageKeys } from 'src/contexts/localStorageContext';
|
|
4
|
+
import Logger from 'src/application/logging/logger';
|
|
5
|
+
import { SpiffyEvent } from 'src/events';
|
|
6
|
+
import {
|
|
7
|
+
AmplitudeService,
|
|
8
|
+
AmplitudeServiceConfig,
|
|
9
|
+
SpiffyMetricsEventName,
|
|
10
|
+
} from '../amplitudeService';
|
|
11
|
+
|
|
12
|
+
const { mockTrack, mockInit, mockAdd, mockDispatch } = vi.hoisted(() => {
|
|
13
|
+
return {
|
|
14
|
+
// Mock Amplitude
|
|
15
|
+
mockTrack: vi.fn(),
|
|
16
|
+
mockInit: vi.fn(),
|
|
17
|
+
mockAdd: vi.fn(),
|
|
18
|
+
// Mock EventsDispatcher
|
|
19
|
+
mockDispatch: vi.fn(),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
vi.mock('@amplitude/analytics-browser', () => ({
|
|
24
|
+
createInstance: vi.fn(() => ({
|
|
25
|
+
track: mockTrack,
|
|
26
|
+
init: mockInit,
|
|
27
|
+
add: mockAdd,
|
|
28
|
+
})),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
vi.mock('src/events', () => ({
|
|
32
|
+
EventsDispatcher: {
|
|
33
|
+
dispatch: mockDispatch,
|
|
34
|
+
},
|
|
35
|
+
SpiffyEvent: {
|
|
36
|
+
AMPLITUDE_EVENT: 'AMPLITUDE_EVENT',
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
// Mock crypto.subtle.digest for insert_id generation
|
|
41
|
+
const mockDigest = vi.fn().mockResolvedValue(new Uint8Array(32).fill(0));
|
|
42
|
+
Object.defineProperty(global, 'crypto', {
|
|
43
|
+
value: {
|
|
44
|
+
subtle: {
|
|
45
|
+
digest: mockDigest,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
writable: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('AmplitudeService', () => {
|
|
52
|
+
let featureFlagService: FeatureFlagService;
|
|
53
|
+
let mockGetLocalStorageItem: (key: string) => string | null;
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
vi.clearAllMocks();
|
|
57
|
+
mockGetLocalStorageItem = vi.fn((key: string) => {
|
|
58
|
+
if (key === LocalStorageKeys.ChatId) {
|
|
59
|
+
return 'test-chat-id';
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
});
|
|
63
|
+
featureFlagService = new FeatureFlagService([]);
|
|
64
|
+
mockTrack.mockClear();
|
|
65
|
+
mockInit.mockClear();
|
|
66
|
+
mockAdd.mockClear();
|
|
67
|
+
mockDigest.mockResolvedValue(new Uint8Array(32).fill(0));
|
|
68
|
+
mockDispatch.mockClear();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const createService = (overrides?: Partial<AmplitudeServiceConfig>) => {
|
|
72
|
+
return new AmplitudeService({
|
|
73
|
+
userId: 'test-user-id',
|
|
74
|
+
amplitudeApiKey: 'test-api-key',
|
|
75
|
+
dataResidency: 'US',
|
|
76
|
+
env: 'test',
|
|
77
|
+
contextSource: 'app',
|
|
78
|
+
orgShortName: 'test-org',
|
|
79
|
+
featureFlagService,
|
|
80
|
+
getLocalStorageItem: mockGetLocalStorageItem,
|
|
81
|
+
...overrides,
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
describe('Initialization', () => {
|
|
86
|
+
it('should initialize Amplitude client when all required config is provided', () => {
|
|
87
|
+
createService();
|
|
88
|
+
|
|
89
|
+
expect(mockInit).toHaveBeenCalledWith(
|
|
90
|
+
'test-api-key',
|
|
91
|
+
'test-user-id',
|
|
92
|
+
expect.objectContaining({
|
|
93
|
+
serverZone: 'US',
|
|
94
|
+
trackingOptions: {
|
|
95
|
+
ipAddress: true,
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should not be ready if userId is missing', () => {
|
|
102
|
+
const service = new AmplitudeService({
|
|
103
|
+
userId: '',
|
|
104
|
+
amplitudeApiKey: 'test-api-key',
|
|
105
|
+
dataResidency: 'US',
|
|
106
|
+
env: 'test',
|
|
107
|
+
contextSource: 'app',
|
|
108
|
+
orgShortName: 'test-org',
|
|
109
|
+
featureFlagService,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
expect(service.isReady).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should not be ready if amplitudeApiKey is missing', () => {
|
|
116
|
+
const service = new AmplitudeService({
|
|
117
|
+
userId: 'test-user-id',
|
|
118
|
+
amplitudeApiKey: '',
|
|
119
|
+
dataResidency: 'US',
|
|
120
|
+
env: 'test',
|
|
121
|
+
contextSource: 'app',
|
|
122
|
+
orgShortName: 'test-org',
|
|
123
|
+
featureFlagService,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(service.isReady).toBe(false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should not be ready if featureFlagService is missing', () => {
|
|
130
|
+
const service = new AmplitudeService({
|
|
131
|
+
userId: 'test-user-id',
|
|
132
|
+
amplitudeApiKey: 'test-api-key',
|
|
133
|
+
dataResidency: 'US',
|
|
134
|
+
env: 'test',
|
|
135
|
+
contextSource: 'app',
|
|
136
|
+
orgShortName: 'test-org',
|
|
137
|
+
featureFlagService: null as any,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
expect(service.isReady).toBe(false);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should be ready when all required config is provided', () => {
|
|
144
|
+
const service = createService();
|
|
145
|
+
|
|
146
|
+
expect(service.isReady).toBe(true);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('trackEvent', () => {
|
|
151
|
+
it('should track events with correct event name format', async () => {
|
|
152
|
+
const service = createService();
|
|
153
|
+
|
|
154
|
+
await service.trackEvent({
|
|
155
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
156
|
+
eventProps: { message: 'test' },
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(mockTrack).toHaveBeenCalledWith(
|
|
160
|
+
'[Spiffy] Chat User Message Input',
|
|
161
|
+
expect.objectContaining({
|
|
162
|
+
message: 'test',
|
|
163
|
+
}),
|
|
164
|
+
expect.objectContaining({
|
|
165
|
+
insert_id: expect.any(String),
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should include default tracking props in events', async () => {
|
|
171
|
+
const service = createService({
|
|
172
|
+
env: 'test',
|
|
173
|
+
contextSource: 'app',
|
|
174
|
+
orgShortName: 'test-org',
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
await service.trackEvent({
|
|
178
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
179
|
+
eventProps: { message: 'test' },
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
183
|
+
const eventProps = callArgs[1];
|
|
184
|
+
|
|
185
|
+
expect(eventProps).toHaveProperty('user.id', 'test-user-id');
|
|
186
|
+
expect(eventProps).toHaveProperty('env', 'test');
|
|
187
|
+
expect(eventProps).toHaveProperty('app_source', 'app');
|
|
188
|
+
expect(eventProps).toHaveProperty('org.short_name', 'test-org');
|
|
189
|
+
expect(eventProps).toHaveProperty('chat_id', 'test-chat-id');
|
|
190
|
+
expect(eventProps).toHaveProperty('app_id', 'commerce-chat-react-component');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('should prefix event props with event name', async () => {
|
|
194
|
+
const service = createService();
|
|
195
|
+
|
|
196
|
+
await service.trackEvent({
|
|
197
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
198
|
+
eventProps: { message: 'test', count: 5 },
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
202
|
+
const eventProps = callArgs[1];
|
|
203
|
+
|
|
204
|
+
expect(eventProps).toHaveProperty('chat_user_message_input.message', 'test');
|
|
205
|
+
expect(eventProps).toHaveProperty('chat_user_message_input.count', 5);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('should generate insert_id from event data', async () => {
|
|
209
|
+
const service = createService();
|
|
210
|
+
|
|
211
|
+
await service.trackEvent({
|
|
212
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
213
|
+
eventProps: { message: 'test' },
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
expect(mockDigest).toHaveBeenCalled();
|
|
217
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
218
|
+
expect(callArgs[2]).toHaveProperty('insert_id');
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('should include eventGroups in track call', async () => {
|
|
222
|
+
const service = createService();
|
|
223
|
+
|
|
224
|
+
await service.trackEvent({
|
|
225
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
226
|
+
eventProps: { message: 'test' },
|
|
227
|
+
eventGroups: { group1: 'value1', group2: 'value2' },
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
231
|
+
expect(callArgs[2]).toHaveProperty('group1', 'value1');
|
|
232
|
+
expect(callArgs[2]).toHaveProperty('group2', 'value2');
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('should not track if client is not initialized', async () => {
|
|
236
|
+
const service = new AmplitudeService({
|
|
237
|
+
userId: '',
|
|
238
|
+
amplitudeApiKey: 'test-api-key',
|
|
239
|
+
dataResidency: 'US',
|
|
240
|
+
env: 'test',
|
|
241
|
+
contextSource: 'app',
|
|
242
|
+
orgShortName: 'test-org',
|
|
243
|
+
featureFlagService,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const logWarnSpy = vi.spyOn(Logger, 'logWarn');
|
|
247
|
+
|
|
248
|
+
await service.trackEvent({
|
|
249
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
expect(mockTrack).not.toHaveBeenCalled();
|
|
253
|
+
expect(logWarnSpy).toHaveBeenCalledWith(
|
|
254
|
+
'amplitude client undefined',
|
|
255
|
+
undefined,
|
|
256
|
+
expect.objectContaining({
|
|
257
|
+
event_name: '[Spiffy] Chat User Message Input',
|
|
258
|
+
}),
|
|
259
|
+
);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should handle tracking errors gracefully', async () => {
|
|
263
|
+
const service = createService();
|
|
264
|
+
const error = new Error('Tracking error');
|
|
265
|
+
mockTrack.mockImplementationOnce(() => {
|
|
266
|
+
throw error;
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const logErrorSpy = vi.spyOn(Logger, 'logError');
|
|
270
|
+
|
|
271
|
+
await service.trackEvent({
|
|
272
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
273
|
+
eventProps: { message: 'test' },
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
expect(logErrorSpy).toHaveBeenCalledWith(
|
|
277
|
+
'[spiffy-ai] Error tracking event',
|
|
278
|
+
error,
|
|
279
|
+
expect.objectContaining({
|
|
280
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
281
|
+
}),
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('should send to Google Analytics when alsoSendToGoogleAnalytics is true', async () => {
|
|
286
|
+
const service = createService({
|
|
287
|
+
orgGaConfig: { enabled: true },
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const dataLayer: any[] = [];
|
|
291
|
+
Object.defineProperty(global, 'window', {
|
|
292
|
+
value: {
|
|
293
|
+
dataLayer,
|
|
294
|
+
},
|
|
295
|
+
writable: true,
|
|
296
|
+
configurable: true,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
await service.trackEvent({
|
|
300
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
301
|
+
eventProps: { message: 'test' },
|
|
302
|
+
alsoSendToGoogleAnalytics: true,
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
expect(dataLayer).toHaveLength(1);
|
|
306
|
+
expect(dataLayer[0]).toEqual({
|
|
307
|
+
event: '[Spiffy] Chat User Message Input',
|
|
308
|
+
eventProps: { message: 'test' },
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('should not send to Google Analytics when orgGaConfig is not provided', async () => {
|
|
313
|
+
const service = createService();
|
|
314
|
+
|
|
315
|
+
const dataLayer: any[] = [];
|
|
316
|
+
Object.defineProperty(global, 'window', {
|
|
317
|
+
value: {
|
|
318
|
+
dataLayer,
|
|
319
|
+
},
|
|
320
|
+
writable: true,
|
|
321
|
+
configurable: true,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
await service.trackEvent({
|
|
325
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
326
|
+
eventProps: { message: 'test' },
|
|
327
|
+
alsoSendToGoogleAnalytics: true,
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
expect(dataLayer).toHaveLength(0);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
describe('Default tracking props', () => {
|
|
335
|
+
it('should include feature gates in default props', async () => {
|
|
336
|
+
const featureGates = [
|
|
337
|
+
{ name: FeatureGates.IsNewFeatureEnabled, value: true },
|
|
338
|
+
{ name: FeatureGates.IsClientSessionEnabled, value: false },
|
|
339
|
+
];
|
|
340
|
+
const featureFlagServiceWithGates = new FeatureFlagService(featureGates);
|
|
341
|
+
const service = createService({ featureFlagService: featureFlagServiceWithGates });
|
|
342
|
+
|
|
343
|
+
await service.trackEvent({
|
|
344
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
348
|
+
const eventProps = callArgs[1];
|
|
349
|
+
|
|
350
|
+
expect(eventProps).toHaveProperty('feature_gate.is_new_feature_enabled', true);
|
|
351
|
+
expect(eventProps).toHaveProperty('feature_gate.is_client_session_enabled', false);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('should use localStorage getItem when provided', async () => {
|
|
355
|
+
const customGetItem = vi.fn((key: string) => {
|
|
356
|
+
if (key === LocalStorageKeys.ChatId) {
|
|
357
|
+
return 'custom-chat-id';
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
});
|
|
361
|
+
const service = createService({ getLocalStorageItem: customGetItem });
|
|
362
|
+
|
|
363
|
+
await service.trackEvent({
|
|
364
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
expect(customGetItem).toHaveBeenCalledWith(LocalStorageKeys.ChatId);
|
|
368
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
369
|
+
expect(callArgs[1]).toHaveProperty('chat_id', 'custom-chat-id');
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('should fall back to window.localStorage when getLocalStorageItem is not provided', async () => {
|
|
373
|
+
const service = new AmplitudeService({
|
|
374
|
+
userId: 'test-user-id',
|
|
375
|
+
amplitudeApiKey: 'test-api-key',
|
|
376
|
+
dataResidency: 'US',
|
|
377
|
+
env: 'test',
|
|
378
|
+
contextSource: 'app',
|
|
379
|
+
orgShortName: 'test-org',
|
|
380
|
+
featureFlagService,
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
// Mock window.localStorage
|
|
384
|
+
const mockLocalStorage = {
|
|
385
|
+
getItem: vi.fn((key: string) => {
|
|
386
|
+
if (key === LocalStorageKeys.ChatId) {
|
|
387
|
+
return 'window-chat-id';
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
}),
|
|
391
|
+
};
|
|
392
|
+
Object.defineProperty(global, 'window', {
|
|
393
|
+
value: {
|
|
394
|
+
localStorage: mockLocalStorage,
|
|
395
|
+
},
|
|
396
|
+
writable: true,
|
|
397
|
+
configurable: true,
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
await service.trackEvent({
|
|
401
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
expect(mockLocalStorage.getItem).toHaveBeenCalledWith(LocalStorageKeys.ChatId);
|
|
405
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
406
|
+
expect(callArgs[1]).toHaveProperty('chat_id', 'window-chat-id');
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('should include supplemental default props', async () => {
|
|
410
|
+
const service = createService();
|
|
411
|
+
service.setSupplementalDefaultProps({ customProp: 'customValue', anotherProp: 123 });
|
|
412
|
+
|
|
413
|
+
await service.trackEvent({
|
|
414
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
418
|
+
const eventProps = callArgs[1];
|
|
419
|
+
|
|
420
|
+
expect(eventProps).toHaveProperty('customProp', 'customValue');
|
|
421
|
+
expect(eventProps).toHaveProperty('anotherProp', 123);
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
describe('setSupplementalDefaultProps', () => {
|
|
426
|
+
it('should set supplemental default props', async () => {
|
|
427
|
+
const service = createService();
|
|
428
|
+
service.setSupplementalDefaultProps({ test: 'value' });
|
|
429
|
+
|
|
430
|
+
await service.trackEvent({
|
|
431
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
435
|
+
const eventProps = callArgs[1];
|
|
436
|
+
expect(eventProps).toHaveProperty('test', 'value');
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it('should replace existing supplemental props', async () => {
|
|
440
|
+
const service = createService();
|
|
441
|
+
service.setSupplementalDefaultProps({ prop1: 'value1' });
|
|
442
|
+
service.setSupplementalDefaultProps({ prop2: 'value2' });
|
|
443
|
+
|
|
444
|
+
await service.trackEvent({
|
|
445
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
const callArgs = mockTrack.mock.calls[0];
|
|
449
|
+
const eventProps = callArgs[1];
|
|
450
|
+
expect(eventProps).toHaveProperty('prop2', 'value2');
|
|
451
|
+
expect(eventProps).not.toHaveProperty('prop1');
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
describe('Event enrichment', () => {
|
|
456
|
+
it('should enrich Page Viewed events', async () => {
|
|
457
|
+
createService({
|
|
458
|
+
show: true,
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// Simulate a Page Viewed event by calling the enrichment plugin
|
|
462
|
+
// The enrichment is added during initialization
|
|
463
|
+
expect(mockAdd).toHaveBeenCalled();
|
|
464
|
+
|
|
465
|
+
// Get the enrichment plugin that was added
|
|
466
|
+
const enrichmentCall = mockAdd.mock.calls[0];
|
|
467
|
+
const enrichment = enrichmentCall[0];
|
|
468
|
+
|
|
469
|
+
const mockEvent = {
|
|
470
|
+
event_type: '[Amplitude] Page Viewed',
|
|
471
|
+
event_properties: {},
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
await enrichment.execute(mockEvent as any);
|
|
475
|
+
|
|
476
|
+
expect(mockDispatch).toHaveBeenCalledWith(
|
|
477
|
+
SpiffyEvent.AMPLITUDE_EVENT,
|
|
478
|
+
expect.objectContaining({
|
|
479
|
+
event_type: '[Amplitude] Page Viewed',
|
|
480
|
+
event_properties: expect.objectContaining({
|
|
481
|
+
'globalProperties.show': 'true',
|
|
482
|
+
}),
|
|
483
|
+
}),
|
|
484
|
+
);
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
it('should enrich Bundle Loaded events', async () => {
|
|
488
|
+
createService();
|
|
489
|
+
|
|
490
|
+
const enrichmentCall = mockAdd.mock.calls[0];
|
|
491
|
+
const enrichment = enrichmentCall[0];
|
|
492
|
+
|
|
493
|
+
const mockEvent = {
|
|
494
|
+
event_type: `[Spiffy] ${SpiffyMetricsEventName.BundleLoaded}`,
|
|
495
|
+
event_properties: {},
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
await enrichment.execute(mockEvent as any);
|
|
499
|
+
|
|
500
|
+
expect(mockDispatch).toHaveBeenCalled();
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
it('should not enrich non-specified events', async () => {
|
|
504
|
+
createService();
|
|
505
|
+
|
|
506
|
+
const enrichmentCall = mockAdd.mock.calls[0];
|
|
507
|
+
const enrichment = enrichmentCall[0];
|
|
508
|
+
|
|
509
|
+
const mockEvent = {
|
|
510
|
+
event_type: '[Spiffy] Some Other Event',
|
|
511
|
+
event_properties: {},
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
const result = await enrichment.execute(mockEvent as any);
|
|
515
|
+
|
|
516
|
+
expect(result).toEqual(mockEvent);
|
|
517
|
+
expect(mockDispatch).toHaveBeenCalledWith(SpiffyEvent.AMPLITUDE_EVENT, mockEvent);
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
describe('Session replay initialization', () => {
|
|
522
|
+
it('should disable session replay by default', () => {
|
|
523
|
+
createService();
|
|
524
|
+
|
|
525
|
+
// Session replay is always disabled in the current implementation
|
|
526
|
+
expect(mockInit).toHaveBeenCalledWith(
|
|
527
|
+
expect.any(String),
|
|
528
|
+
expect.any(String),
|
|
529
|
+
expect.objectContaining({
|
|
530
|
+
autocapture: expect.objectContaining({
|
|
531
|
+
sessions: false,
|
|
532
|
+
}),
|
|
533
|
+
}),
|
|
534
|
+
);
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
describe('Multiple events', () => {
|
|
539
|
+
it('should track multiple events with correct userId', async () => {
|
|
540
|
+
const service = createService();
|
|
541
|
+
|
|
542
|
+
await service.trackEvent({
|
|
543
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
544
|
+
eventProps: { event1: true },
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
await service.trackEvent({
|
|
548
|
+
eventName: SpiffyMetricsEventName.ChatSuggestionClicked,
|
|
549
|
+
eventProps: { event2: true },
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
expect(mockTrack).toHaveBeenCalledTimes(2);
|
|
553
|
+
mockTrack.mock.calls.forEach((call: any[]) => {
|
|
554
|
+
expect(call[1]).toHaveProperty('user.id', 'test-user-id');
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
});
|