@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
|
@@ -1,68 +1,23 @@
|
|
|
1
|
-
import React, { createContext,
|
|
1
|
+
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { useAtomValue } from 'jotai';
|
|
3
|
-
import { createInstance } from '@amplitude/analytics-browser';
|
|
4
|
-
import { FeatureGates } from 'src/application/models/featureGates';
|
|
5
|
-
import { OrgShortName } from 'src/application/models';
|
|
6
|
-
import { EventsDispatcher, SpiffyEvent } from 'src/events';
|
|
7
3
|
import {
|
|
8
4
|
amplitudeApiKeyAtom,
|
|
9
5
|
contextSourceAtom,
|
|
10
6
|
dataResidencyAtom,
|
|
11
7
|
envAtom,
|
|
12
|
-
identifyingPrefixAtom,
|
|
13
8
|
} from 'src/atoms/envive/enviveConfig';
|
|
14
|
-
import {
|
|
9
|
+
import { useLocalStorage } from 'src/contexts/localStorageContext';
|
|
15
10
|
import { orgAnalyticsGoogleAnalyticsConfigAtom } from 'src/atoms/org/orgAnalyticsConfig';
|
|
16
11
|
import { userIdAtom } from 'src/atoms/app';
|
|
17
|
-
import Logger from 'src/application/logging/logger';
|
|
18
|
-
import type {
|
|
19
|
-
BrowserClient,
|
|
20
|
-
EnrichmentPlugin,
|
|
21
|
-
Event,
|
|
22
|
-
ServerZoneType,
|
|
23
|
-
} from '@amplitude/analytics-types';
|
|
24
12
|
import { useEnviveConfig } from 'src/contexts/enviveConfigContext/enviveConfigContext';
|
|
25
13
|
import { useFeatureFlagService } from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
|
|
14
|
+
import {
|
|
15
|
+
AmplitudeService,
|
|
16
|
+
SpiffyMetricsEventName,
|
|
17
|
+
TrackEventParams,
|
|
18
|
+
} from 'src/services/amplitudeService/amplitudeService';
|
|
26
19
|
|
|
27
|
-
export
|
|
28
|
-
BundleLoaded = 'Bundle Loaded',
|
|
29
|
-
ChatLiveAgentBtnClick = 'Chat Live Agent Btn Click',
|
|
30
|
-
ChatFloatingButtonVisible = 'Chat Floating Button Visible',
|
|
31
|
-
ChatComponentVisible = 'Chat Component Visible',
|
|
32
|
-
ChatComponentExpanded = 'Chat Component Expanded',
|
|
33
|
-
ChatComponentCollapsed = 'Chat Component Collapsed',
|
|
34
|
-
ChatUserMessageInput = 'Chat User Message Input',
|
|
35
|
-
ChatSuggestionClicked = 'Chat Suggestion Clicked',
|
|
36
|
-
ChatAssistantResponse = 'Chat Assistant Response',
|
|
37
|
-
ProductCardClicked = 'Product Card Clicked',
|
|
38
|
-
ProductReviewCardClicked = 'Product Review Card Clicked',
|
|
39
|
-
AddToCartClicked = 'Add to Cart Clicked',
|
|
40
|
-
PromptCardClicked = 'Prompt Card Clicked',
|
|
41
|
-
SupportedEvent = 'Supported Event',
|
|
42
|
-
SearchBackToResponseClicked = 'Search Back to Response Clicked',
|
|
43
|
-
PerformanceMetrics = 'Performance Metrics',
|
|
44
|
-
SearchBarClicked = 'Search Bar Clicked',
|
|
45
|
-
OrderLookupStarted = 'Order Lookup Started',
|
|
46
|
-
OrderLookupFormSubmitted = 'Order Lookup Form Submitted',
|
|
47
|
-
SearchComponentVisible = 'Search Component Visible',
|
|
48
|
-
SearchZeroStateSuggestionClicked = 'Search Zero State Suggestion Clicked', // This is the scrolling list of suggestion buttons in global search
|
|
49
|
-
SearchInputStarted = 'Search Input Started',
|
|
50
|
-
SearchQuerySubmitted = 'Search Query Submitted',
|
|
51
|
-
// SearchAutocompleteViewed = 'Search Autocomplete Viewed', // TODO: add this when autocomplete is added
|
|
52
|
-
// SearchAutocompleteClicked = 'Search Autocomplete Clicked', // TODO: add this when autocomplete is added
|
|
53
|
-
SearchResultsViewed = 'Search Results Viewed',
|
|
54
|
-
SearchTimeToFirstClick = 'Search Time to First Click',
|
|
55
|
-
SearchZeroResultsRate = 'Search Zero Results Rate',
|
|
56
|
-
SearchFilterClicked = 'Search Filter Clicked',
|
|
57
|
-
SearchSortClicked = 'Search Sort Clicked',
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface TrackEventParams {
|
|
61
|
-
eventName: SpiffyMetricsEventName;
|
|
62
|
-
eventProps?: Record<string, unknown>;
|
|
63
|
-
eventGroups?: Record<string, unknown>;
|
|
64
|
-
alsoSendToGoogleAnalytics?: boolean;
|
|
65
|
-
}
|
|
20
|
+
export { SpiffyMetricsEventName };
|
|
66
21
|
|
|
67
22
|
interface AmplitudeContextType {
|
|
68
23
|
trackEvent: (params: TrackEventParams) => Promise<void>;
|
|
@@ -72,17 +27,18 @@ interface AmplitudeContextType {
|
|
|
72
27
|
|
|
73
28
|
const AmplitudeContext = createContext<AmplitudeContextType | null>(null);
|
|
74
29
|
|
|
75
|
-
export const AmplitudeProvider: React.FC<{
|
|
30
|
+
export const AmplitudeProvider: React.FC<{
|
|
31
|
+
externalAmplitudeService?: AmplitudeService;
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
}> = ({ externalAmplitudeService, children }) => {
|
|
76
34
|
const userId = useAtomValue(userIdAtom);
|
|
77
35
|
const amplitudeApiKey = useAtomValue(amplitudeApiKeyAtom);
|
|
78
36
|
const dataResidency = useAtomValue(dataResidencyAtom);
|
|
79
37
|
const orgGaConfig = useAtomValue(orgAnalyticsGoogleAnalyticsConfigAtom);
|
|
80
38
|
const env = useAtomValue(envAtom);
|
|
81
39
|
const contextSource = useAtomValue(contextSourceAtom);
|
|
82
|
-
const identifyingPrefix = useAtomValue(identifyingPrefixAtom);
|
|
83
40
|
const { getItem } = useLocalStorage();
|
|
84
41
|
const {
|
|
85
|
-
publicKey,
|
|
86
42
|
featureOverrides,
|
|
87
43
|
variantUrlOverride,
|
|
88
44
|
variantInfoOverride,
|
|
@@ -93,303 +49,69 @@ export const AmplitudeProvider: React.FC<{ children: React.ReactNode }> = ({ chi
|
|
|
93
49
|
|
|
94
50
|
const { featureFlagService } = useFeatureFlagService();
|
|
95
51
|
|
|
96
|
-
const [
|
|
97
|
-
undefined,
|
|
98
|
-
);
|
|
99
|
-
const [internalEventTrackingEnrichment, setInternalEventTrackingEnrichment] = React.useState<
|
|
100
|
-
EnrichmentPlugin | undefined
|
|
101
|
-
>(undefined);
|
|
102
|
-
const [supplementalDefaultProps, setSupplementalDefaultProps] = React.useState<
|
|
103
|
-
Record<string, unknown>
|
|
104
|
-
>({});
|
|
105
|
-
|
|
106
|
-
const isReady = Boolean(userId && featureFlagService && amplitudeApiKey);
|
|
107
|
-
|
|
108
|
-
const getDefaultTrackingProps = useCallback((): Record<string, unknown> => {
|
|
109
|
-
const gatesProps = featureGates
|
|
110
|
-
? featureGates.reduce<Record<string, boolean>>((acc, curr) => {
|
|
111
|
-
if (curr.name && curr.value != null) {
|
|
112
|
-
return { ...acc, [`feature_gate.${curr.name}`]: curr.value };
|
|
113
|
-
}
|
|
114
|
-
return acc;
|
|
115
|
-
}, {})
|
|
116
|
-
: {};
|
|
117
|
-
const experimentProps = {}; // No direct equivalent for experiments in EnviveConfig yet
|
|
118
|
-
|
|
119
|
-
const orgLevelAmplitudeTrackingProps = {
|
|
120
|
-
...gatesProps,
|
|
121
|
-
...experimentProps,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
...orgLevelAmplitudeTrackingProps,
|
|
126
|
-
...supplementalDefaultProps,
|
|
127
|
-
// TODO: org_id is not directly available in EnviveConfig. Need to find a new source or derive it.
|
|
128
|
-
// org_id: orgConfig?.org?.org?.id,
|
|
129
|
-
app_id: 'commerce-chat-react-component',
|
|
130
|
-
chat_id: getItem(LocalStorageKeys.ChatId),
|
|
131
|
-
env: env || 'unknown',
|
|
132
|
-
app_source: contextSource,
|
|
133
|
-
'org.short_name': orgShortName,
|
|
134
|
-
'user.id': userId,
|
|
135
|
-
'cdp.user_id': null,
|
|
136
|
-
'cdp.provider': null,
|
|
137
|
-
'event.source': 'web-browser',
|
|
138
|
-
'event.type': 'user-activity',
|
|
139
|
-
'event.id': null,
|
|
140
|
-
'event.channel': 'web',
|
|
141
|
-
'event.timestamp': null,
|
|
142
|
-
};
|
|
143
|
-
}, [featureGates, supplementalDefaultProps, env, contextSource, orgShortName, userId]);
|
|
144
|
-
|
|
145
|
-
const eventPropsToPrefixedEventProps = useCallback(
|
|
146
|
-
(
|
|
147
|
-
eventName: SpiffyMetricsEventName,
|
|
148
|
-
eventProps: Record<string, unknown>,
|
|
149
|
-
): Record<string, unknown> => {
|
|
150
|
-
const prefix = eventName.toLowerCase().replace(/\s+/g, '_');
|
|
151
|
-
return Object.entries(eventProps).reduce(
|
|
152
|
-
(acc, [key, value]) => {
|
|
153
|
-
acc[`${prefix}.${key}`] = value;
|
|
154
|
-
return acc;
|
|
155
|
-
},
|
|
156
|
-
{} as Record<string, unknown>,
|
|
157
|
-
);
|
|
158
|
-
},
|
|
159
|
-
[],
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
const amplitudeSessionReplayInit = useCallback((): boolean => {
|
|
163
|
-
const isEnabled = Boolean(
|
|
164
|
-
orgShortName === OrgShortName.UniqueVintage &&
|
|
165
|
-
featureFlagService?.isClientSessionEnabled() &&
|
|
166
|
-
featureFlagService?.isFeatureGateEnabled(FeatureGates.IsNewFeatureEnabled),
|
|
167
|
-
);
|
|
168
|
-
const sampleRate = 1;
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
Logger.logDebug(
|
|
172
|
-
`[spiffy-ai] amplitude session-replay initializing isEnabled=${isEnabled} sampleRate=${sampleRate}`,
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
if (!isEnabled) {
|
|
176
|
-
return isEnabled;
|
|
177
|
-
}
|
|
52
|
+
const [service, setService] = useState<AmplitudeService | null>(null);
|
|
178
53
|
|
|
179
|
-
|
|
54
|
+
const isReady = Boolean(userId && service && service.isReady);
|
|
180
55
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
56
|
+
// Create service instance when dependencies are ready
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (externalAmplitudeService !== undefined) {
|
|
59
|
+
setService(externalAmplitudeService);
|
|
60
|
+
return;
|
|
185
61
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
62
|
+
if (userId && amplitudeApiKey && dataResidency && featureFlagService) {
|
|
63
|
+
const amplitudeService = new AmplitudeService({
|
|
64
|
+
userId,
|
|
65
|
+
amplitudeApiKey,
|
|
66
|
+
dataResidency,
|
|
67
|
+
env: env || '',
|
|
68
|
+
contextSource: contextSource || '',
|
|
69
|
+
orgShortName: orgShortName || '',
|
|
70
|
+
featureFlagService,
|
|
71
|
+
orgGaConfig,
|
|
72
|
+
show,
|
|
73
|
+
getLocalStorageItem: getItem,
|
|
74
|
+
});
|
|
75
|
+
setService(amplitudeService);
|
|
76
|
+
} else {
|
|
77
|
+
setService(null);
|
|
191
78
|
}
|
|
192
|
-
|
|
193
|
-
const enrichment: EnrichmentPlugin = {
|
|
194
|
-
name: 'page-view-tracking-enrichment',
|
|
195
|
-
type: 'enrichment',
|
|
196
|
-
setup: async () => undefined,
|
|
197
|
-
execute: async (event: Event): Promise<Event> => {
|
|
198
|
-
let enrichedEvent: Event;
|
|
199
|
-
|
|
200
|
-
const eventsToEnrich = [
|
|
201
|
-
'[Amplitude] Page Viewed',
|
|
202
|
-
`[Spiffy] ${SpiffyMetricsEventName.BundleLoaded}`,
|
|
203
|
-
];
|
|
204
|
-
|
|
205
|
-
if (eventsToEnrich.includes(event.event_type)) {
|
|
206
|
-
const globalProperties: Record<string, string> = {};
|
|
207
|
-
|
|
208
|
-
if (publicKey) {
|
|
209
|
-
globalProperties['globalProperties.publicKey'] = publicKey;
|
|
210
|
-
}
|
|
211
|
-
if (featureOverrides) {
|
|
212
|
-
Object.entries(featureOverrides).forEach(([key, value]) => {
|
|
213
|
-
globalProperties[`globalProperties.featureOverrides.${key}`] = String(value);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
if (variantUrlOverride) {
|
|
217
|
-
globalProperties['globalProperties.variantUrlOverride'] = variantUrlOverride;
|
|
218
|
-
}
|
|
219
|
-
if (variantInfoOverride) {
|
|
220
|
-
globalProperties['globalProperties.variantInfoOverride'] =
|
|
221
|
-
JSON.stringify(variantInfoOverride);
|
|
222
|
-
}
|
|
223
|
-
if (show != null) {
|
|
224
|
-
globalProperties['globalProperties.show'] = String(show);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const enabledFeatures = featureFlagService!.getFeatureFlags();
|
|
228
|
-
const enabledFeaturesProperties = Object.entries(enabledFeatures).reduce<
|
|
229
|
-
Record<string, string>
|
|
230
|
-
>(
|
|
231
|
-
(acc, [key, value]) => ({
|
|
232
|
-
...acc,
|
|
233
|
-
[`enabledFeatures.${key}`]: `${value}`,
|
|
234
|
-
}),
|
|
235
|
-
{},
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
const timingProperties = {
|
|
239
|
-
'timing.enriched_at_ms': window.performance?.now(),
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
enrichedEvent = {
|
|
243
|
-
...event,
|
|
244
|
-
event_properties: {
|
|
245
|
-
...event.event_properties,
|
|
246
|
-
...getDefaultTrackingProps(),
|
|
247
|
-
...globalProperties,
|
|
248
|
-
...enabledFeaturesProperties,
|
|
249
|
-
...timingProperties,
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
} else {
|
|
253
|
-
enrichedEvent = event;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
EventsDispatcher.dispatch(SpiffyEvent.AMPLITUDE_EVENT, enrichedEvent);
|
|
257
|
-
|
|
258
|
-
return enrichedEvent;
|
|
259
|
-
},
|
|
260
|
-
};
|
|
261
|
-
setInternalEventTrackingEnrichment(enrichment);
|
|
262
|
-
return enrichment;
|
|
263
79
|
}, [
|
|
264
|
-
|
|
265
|
-
|
|
80
|
+
userId,
|
|
81
|
+
amplitudeApiKey,
|
|
82
|
+
dataResidency,
|
|
83
|
+
env,
|
|
84
|
+
contextSource,
|
|
85
|
+
orgShortName,
|
|
266
86
|
featureFlagService,
|
|
267
|
-
|
|
87
|
+
orgGaConfig,
|
|
268
88
|
featureOverrides,
|
|
269
89
|
variantUrlOverride,
|
|
270
90
|
variantInfoOverride,
|
|
271
91
|
show,
|
|
92
|
+
featureGates,
|
|
93
|
+
getItem,
|
|
94
|
+
externalAmplitudeService,
|
|
272
95
|
]);
|
|
273
96
|
|
|
274
|
-
useEffect(() => {
|
|
275
|
-
if (isReady && !amplitudeClient) {
|
|
276
|
-
const currentAmplitudeInstance: BrowserClient = createInstance();
|
|
277
|
-
const isSessionsEnabled = amplitudeSessionReplayInit();
|
|
278
|
-
currentAmplitudeInstance.add(getEventTrackingEnrichment());
|
|
279
|
-
currentAmplitudeInstance.init(amplitudeApiKey!, userId!, {
|
|
280
|
-
serverZone: dataResidency as ServerZoneType,
|
|
281
|
-
trackingOptions: {
|
|
282
|
-
ipAddress: true,
|
|
283
|
-
},
|
|
284
|
-
autocapture: {
|
|
285
|
-
attribution: true,
|
|
286
|
-
pageViews: {
|
|
287
|
-
trackHistoryChanges: 'pathOnly',
|
|
288
|
-
},
|
|
289
|
-
sessions: isSessionsEnabled,
|
|
290
|
-
formInteractions: false,
|
|
291
|
-
fileDownloads: false,
|
|
292
|
-
},
|
|
293
|
-
});
|
|
294
|
-
setAmplitudeClient(currentAmplitudeInstance);
|
|
295
|
-
}
|
|
296
|
-
}, [
|
|
297
|
-
isReady,
|
|
298
|
-
amplitudeClient,
|
|
299
|
-
amplitudeApiKey,
|
|
300
|
-
userId,
|
|
301
|
-
dataResidency,
|
|
302
|
-
amplitudeSessionReplayInit,
|
|
303
|
-
getEventTrackingEnrichment,
|
|
304
|
-
]);
|
|
305
|
-
|
|
306
|
-
const trackEvent = useCallback(
|
|
307
|
-
async ({
|
|
308
|
-
eventName,
|
|
309
|
-
eventProps,
|
|
310
|
-
eventGroups,
|
|
311
|
-
alsoSendToGoogleAnalytics = false,
|
|
312
|
-
}: TrackEventParams): Promise<void> => {
|
|
313
|
-
Logger.logDebug('Submitting event', eventName);
|
|
314
|
-
try {
|
|
315
|
-
const decoratedEventName = `[Spiffy] ${eventName}`;
|
|
316
|
-
|
|
317
|
-
if (!amplitudeClient) {
|
|
318
|
-
Logger.logWarn('amplitude client undefined', undefined, {
|
|
319
|
-
event_name: decoratedEventName,
|
|
320
|
-
});
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const eventData = JSON.stringify({
|
|
325
|
-
eventName,
|
|
326
|
-
eventProps,
|
|
327
|
-
created_at: new Date().toISOString(),
|
|
328
|
-
});
|
|
329
|
-
const encoder = new TextEncoder();
|
|
330
|
-
const data = encoder.encode(eventData);
|
|
331
|
-
// calculate a hash of the event properties to use as the insert_id so that duplicate events
|
|
332
|
-
// are automatically dropped by Amplitude
|
|
333
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
334
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
335
|
-
const currentInsertId = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
336
|
-
|
|
337
|
-
Logger.logDebug(`amplitude tracking ${decoratedEventName}`, null, {
|
|
338
|
-
event_name: decoratedEventName,
|
|
339
|
-
props: eventProps,
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
amplitudeClient.track(
|
|
343
|
-
decoratedEventName,
|
|
344
|
-
{
|
|
345
|
-
...getDefaultTrackingProps(),
|
|
346
|
-
...eventProps,
|
|
347
|
-
...(eventProps ? eventPropsToPrefixedEventProps(eventName, eventProps) : {}),
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
...eventGroups,
|
|
351
|
-
insert_id: currentInsertId,
|
|
352
|
-
},
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
if (alsoSendToGoogleAnalytics && orgGaConfig) {
|
|
356
|
-
// TODO: Add in windowDataLayerService or context alternative and hook it up here
|
|
357
|
-
Logger.logDebug('[spiffy-ai] GA tracking', decoratedEventName);
|
|
358
|
-
if (window.dataLayer) {
|
|
359
|
-
(window.dataLayer as any[]).push({
|
|
360
|
-
event: decoratedEventName,
|
|
361
|
-
eventProps,
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
} catch (err) {
|
|
366
|
-
Logger.logError('[spiffy-ai] Error tracking event', err, {
|
|
367
|
-
eventName,
|
|
368
|
-
eventProps,
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
[amplitudeClient, getDefaultTrackingProps, eventPropsToPrefixedEventProps, orgGaConfig],
|
|
373
|
-
);
|
|
374
|
-
|
|
375
97
|
const value = useMemo(
|
|
376
98
|
() => ({
|
|
377
|
-
trackEvent
|
|
99
|
+
trackEvent: async (params: TrackEventParams): Promise<void> => {
|
|
100
|
+
if (service) {
|
|
101
|
+
await service.trackEvent(params);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
378
104
|
isReady,
|
|
379
|
-
setSupplementalDefaultProps: (props: Record<string, unknown>) =>
|
|
380
|
-
|
|
105
|
+
setSupplementalDefaultProps: (props: Record<string, unknown>) => {
|
|
106
|
+
if (service) {
|
|
107
|
+
service.setSupplementalDefaultProps(props);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
381
110
|
}),
|
|
382
|
-
[
|
|
111
|
+
[service, isReady],
|
|
383
112
|
);
|
|
384
113
|
|
|
385
114
|
if (!isReady) {
|
|
386
|
-
console.log(
|
|
387
|
-
'AmplitudeProvider is not ready',
|
|
388
|
-
isReady,
|
|
389
|
-
userId,
|
|
390
|
-
featureFlagService,
|
|
391
|
-
amplitudeApiKey,
|
|
392
|
-
);
|
|
393
115
|
return null;
|
|
394
116
|
}
|
|
395
117
|
|
|
@@ -17,6 +17,7 @@ interface EnviveConfigProviderProps {
|
|
|
17
17
|
cdnUrl?: string;
|
|
18
18
|
contextSource?: string;
|
|
19
19
|
orgLevelApiKey?: string;
|
|
20
|
+
orgId?: string;
|
|
20
21
|
orgShortName?: string;
|
|
21
22
|
identifyingPrefix: string;
|
|
22
23
|
featureOverrides?: Record<string, boolean>;
|
|
@@ -38,6 +39,7 @@ export const EnviveConfigProvider: React.FC<EnviveConfigProviderProps> = ({
|
|
|
38
39
|
contextSource,
|
|
39
40
|
orgLevelApiKey,
|
|
40
41
|
orgShortName,
|
|
42
|
+
orgId,
|
|
41
43
|
identifyingPrefix,
|
|
42
44
|
featureOverrides,
|
|
43
45
|
variantUrlOverride,
|
|
@@ -58,6 +60,7 @@ export const EnviveConfigProvider: React.FC<EnviveConfigProviderProps> = ({
|
|
|
58
60
|
contextSource,
|
|
59
61
|
orgLevelApiKey,
|
|
60
62
|
orgShortName,
|
|
63
|
+
orgId,
|
|
61
64
|
identifyingPrefix,
|
|
62
65
|
featureOverrides,
|
|
63
66
|
variantUrlOverride,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { ReactNode, createContext } from 'react';
|
|
1
|
+
import { ReactNode, createContext, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { OrgConfigFeatureGate } from 'src/application/models/api/orgConfigResults';
|
|
4
|
+
import { EnviveConfigService, EnviveServiceConfig } from 'src/services/enviveConfigService';
|
|
5
|
+
import { AmplitudeService } from 'src/services/amplitudeService/amplitudeService';
|
|
6
|
+
import Logger from 'src/application/logging/logger';
|
|
4
7
|
import { AmplitudeProvider } from '../amplitudeContext';
|
|
5
8
|
import { EnviveConfigProvider } from '../enviveConfigContext';
|
|
6
9
|
import { EnviveCssProvider } from '../enviveCssContext';
|
|
7
|
-
import { FeatureFlagServiceProvider } from '../featureFlagServiceContext';
|
|
10
|
+
import { FeatureFlagService, FeatureFlagServiceProvider } from '../featureFlagServiceContext';
|
|
8
11
|
import { GraphQLProvider } from '../graphqlContext';
|
|
9
12
|
import { LocalStorageProvider } from '../localStorageContext';
|
|
10
13
|
import { NewOrgConfigProvider } from '../newOrgConfigContext';
|
|
@@ -13,6 +16,10 @@ import { EnviveAgent } from './types';
|
|
|
13
16
|
import { SearchProvider } from '../searchContext';
|
|
14
17
|
import { SalesAgentProvider } from '../salesAgentContext/salesAgentContext';
|
|
15
18
|
import { SystemSettingsContextProvider } from '../systemSettingsContext';
|
|
19
|
+
import { HardcopyProvider } from '../hardcopyContext';
|
|
20
|
+
import { WidgetConfigProvider } from '../widgetConfigContext';
|
|
21
|
+
import { PageProvider } from '../pageContext';
|
|
22
|
+
import { UiConfigProvider } from '../uiConfigContext';
|
|
16
23
|
|
|
17
24
|
const EnviveContext = createContext<null>(null);
|
|
18
25
|
|
|
@@ -38,6 +45,11 @@ interface EnviveProviderProps extends AgentWrapperProps {
|
|
|
38
45
|
show?: boolean;
|
|
39
46
|
publicKey?: string;
|
|
40
47
|
featureGates?: OrgConfigFeatureGate[]; // New prop for feature gates
|
|
48
|
+
featureFlagService?: FeatureFlagService;
|
|
49
|
+
enviveConfigService?: EnviveConfigService;
|
|
50
|
+
amplitudeService?: AmplitudeService;
|
|
51
|
+
mockV3ConfigToDeprecatedConfig?: boolean;
|
|
52
|
+
requestV3Config?: boolean;
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
const SearchAgentWrapper: React.FC<AgentWrapperProps> = ({ children, enabledAgents }) => {
|
|
@@ -61,29 +73,91 @@ const SalesAgentWrapper: React.FC<AgentWrapperProps> = ({ children, enabledAgent
|
|
|
61
73
|
export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
62
74
|
children,
|
|
63
75
|
enabledAgents,
|
|
76
|
+
enviveConfigService: inputEnviveConfigService,
|
|
77
|
+
featureFlagService: inputFeatureFlagService,
|
|
78
|
+
amplitudeService: inputAmplitudeService,
|
|
79
|
+
mockV3ConfigToDeprecatedConfig = false,
|
|
80
|
+
requestV3Config = false,
|
|
64
81
|
...config
|
|
65
|
-
}) =>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
}) => {
|
|
83
|
+
const userId = 'spiffy-user-id-0b64d781-e1c2-4b6d-9cf5-32b4f7c1e3f2'; // TODO: How should this be derived?
|
|
84
|
+
const namespace = 'spiffy-react-components'; // TODO: Should this be different from the current namespace?
|
|
85
|
+
const source = 'app'; // TODO: Make this dependent upon the "spiffy_on" query param
|
|
86
|
+
const [enviveServiceConfig, setEnviveServiceConfig] = useState<EnviveServiceConfig | null>(null);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
// Really not happy with this approach, but I'm seeing 429 errors in the tests
|
|
90
|
+
// because of the rate limiting on the API.
|
|
91
|
+
const enviveConfigService =
|
|
92
|
+
inputEnviveConfigService ??
|
|
93
|
+
new EnviveConfigService({
|
|
94
|
+
baseUrl: config?.baseUrl || '',
|
|
95
|
+
apiKey: config?.orgLevelApiKey || '',
|
|
96
|
+
userId: userId || '',
|
|
97
|
+
namespace: namespace || '',
|
|
98
|
+
source: source || '',
|
|
99
|
+
});
|
|
100
|
+
enviveConfigService.getEnviveConfig().then(newConfig => {
|
|
101
|
+
setEnviveServiceConfig(newConfig);
|
|
102
|
+
return newConfig;
|
|
103
|
+
});
|
|
104
|
+
}, [config, userId, namespace, source, inputEnviveConfigService]);
|
|
105
|
+
|
|
106
|
+
const enviveConfig = useMemo(
|
|
107
|
+
() => ({
|
|
108
|
+
...config,
|
|
109
|
+
featureGates: enviveServiceConfig?.gates || [],
|
|
110
|
+
orgShortName: enviveServiceConfig?.org.org.short_name || '',
|
|
111
|
+
orgId: enviveServiceConfig?.org.org.id || '',
|
|
112
|
+
}),
|
|
113
|
+
[config, enviveServiceConfig],
|
|
114
|
+
);
|
|
115
|
+
Logger.logDebug('enviveContext: enviveServiceConfig', enviveServiceConfig, config);
|
|
116
|
+
Logger.logDebug('enviveContext: enviveConfig', enviveConfig);
|
|
117
|
+
|
|
118
|
+
const featureFlagService = useMemo(
|
|
119
|
+
() => inputFeatureFlagService ?? new FeatureFlagService(enviveConfig.featureGates),
|
|
120
|
+
[enviveConfig.featureGates, inputFeatureFlagService],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (enviveServiceConfig === null || enviveConfig === null) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<EnviveContext.Provider value={null}>
|
|
129
|
+
<EnviveConfigProvider {...enviveConfig}>
|
|
130
|
+
<GraphQLProvider
|
|
131
|
+
mockV3ConfigToDeprecatedConfig={mockV3ConfigToDeprecatedConfig}
|
|
132
|
+
requestV3Config={requestV3Config}
|
|
133
|
+
>
|
|
134
|
+
<NewOrgConfigProvider>
|
|
135
|
+
<LocalStorageProvider>
|
|
136
|
+
<FeatureFlagServiceProvider featureFlagService={featureFlagService}>
|
|
137
|
+
<UserIdentityProvider>
|
|
138
|
+
<AmplitudeProvider externalAmplitudeService={inputAmplitudeService}>
|
|
139
|
+
<PageProvider>
|
|
140
|
+
<UiConfigProvider>
|
|
141
|
+
<WidgetConfigProvider>
|
|
142
|
+
<HardcopyProvider>
|
|
143
|
+
<EnviveCssProvider>
|
|
144
|
+
<SearchAgentWrapper enabledAgents={enabledAgents}>
|
|
145
|
+
<SalesAgentWrapper enabledAgents={enabledAgents}>
|
|
146
|
+
{children}
|
|
147
|
+
</SalesAgentWrapper>
|
|
148
|
+
</SearchAgentWrapper>
|
|
149
|
+
</EnviveCssProvider>
|
|
150
|
+
</HardcopyProvider>
|
|
151
|
+
</WidgetConfigProvider>
|
|
152
|
+
</UiConfigProvider>
|
|
153
|
+
</PageProvider>
|
|
154
|
+
</AmplitudeProvider>
|
|
155
|
+
</UserIdentityProvider>
|
|
156
|
+
</FeatureFlagServiceProvider>
|
|
157
|
+
</LocalStorageProvider>
|
|
158
|
+
</NewOrgConfigProvider>
|
|
159
|
+
</GraphQLProvider>
|
|
160
|
+
</EnviveConfigProvider>
|
|
161
|
+
</EnviveContext.Provider>
|
|
162
|
+
);
|
|
163
|
+
};
|