@envive-ai/react-hooks 0.3.6 → 0.3.8
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/application/commerce-api.cjs +2 -2
- package/dist/application/commerce-api.js +2 -2
- 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 +3 -1
- package/dist/application/models/chatElementDisplayLocationV3.d.cts +3 -1
- package/dist/application/models/chatElementDisplayLocationV3.d.ts +3 -1
- package/dist/application/models/chatElementDisplayLocationV3.js +3 -1
- package/dist/application/models/frontendConfigV3.d.cts +2 -2
- package/dist/application/models/frontendConfigV3.d.ts +2 -2
- package/dist/application/models/graphql/queries/getColorsAndFrontendQuery.cjs +18 -0
- package/dist/application/models/graphql/queries/getColorsAndFrontendQuery.js +18 -0
- package/dist/application/models/guards/api/isApiFormResponse.cjs +1 -1
- package/dist/application/models/guards/api/isApiFormResponse.js +1 -1
- package/dist/application/models/guards/api/isApiFormSubmittedResponseAttributes.cjs +1 -1
- package/dist/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +1 -1
- package/dist/application/models/guards/api/isApiOrderResponseAttributes.cjs +1 -1
- package/dist/application/models/guards/api/isApiOrderResponseAttributes.js +1 -1
- package/dist/application/models/guards/api/isApiProductResponseAttributes.cjs +1 -1
- package/dist/application/models/guards/api/isApiProductResponseAttributes.js +1 -1
- package/dist/application/models/guards/api/isApiQueryTypedEventAttributes.cjs +2 -2
- package/dist/application/models/guards/api/isApiQueryTypedEventAttributes.js +2 -2
- package/dist/application/models/guards/api/isApiResponse.cjs +1 -1
- package/dist/application/models/guards/api/isApiResponse.js +1 -1
- package/dist/application/utils/analyticsUtils.cjs +1 -1
- package/dist/application/utils/analyticsUtils.js +1 -1
- package/dist/application/utils/elementObserver.d.cts +2 -2
- package/dist/application/utils/elementObserver.d.ts +2 -2
- package/dist/application/utils/widgetTextRequestToApiRequest.cjs +5 -2
- package/dist/application/utils/widgetTextRequestToApiRequest.js +5 -2
- package/dist/atoms/app/index.cjs +4 -4
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/index.d.ts +7 -7
- package/dist/atoms/app/index.js +4 -4
- package/dist/atoms/chat/chatState.d.cts +18 -18
- package/dist/atoms/chat/chatState.d.ts +17 -17
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/form.d.ts +2 -2
- package/dist/atoms/chat/index.cjs +1 -3
- package/dist/atoms/chat/index.d.cts +4 -5
- package/dist/atoms/chat/index.d.ts +4 -5
- package/dist/atoms/chat/index.js +2 -3
- 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 +1 -1
- package/dist/atoms/chat/replies.d.cts +1 -1
- package/dist/atoms/chat/replies.d.ts +3 -3
- package/dist/atoms/chat/replies.js +1 -1
- package/dist/atoms/chat/suggestions.d.cts +2 -2
- package/dist/atoms/chat/suggestions.d.ts +2 -2
- package/dist/atoms/globalSearch/globalSearch.d.cts +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.d.cts +4 -4
- package/dist/atoms/org/graphqlConfig.d.ts +4 -4
- package/dist/atoms/org/index.cjs +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 +1 -1
- package/dist/atoms/search/chatSearch.d.cts +17 -17
- package/dist/atoms/search/chatSearch.d.ts +17 -17
- package/dist/atoms/search/chatSearch.js +1 -1
- package/dist/atoms/search/searchAPI.cjs +1 -1
- package/dist/atoms/search/searchAPI.d.cts +13 -13
- package/dist/atoms/search/searchAPI.d.ts +13 -13
- package/dist/atoms/search/searchAPI.js +1 -1
- package/dist/atoms/widget/chatPreviewLoading.d.cts +2 -2
- package/dist/contexts/amplitudeContext/amplitudeContext.cjs +6 -4
- package/dist/contexts/amplitudeContext/amplitudeContext.js +6 -4
- package/dist/contexts/enviveContext/enviveContext.cjs +38 -16
- package/dist/contexts/enviveContext/enviveContext.d.cts +4 -1
- package/dist/contexts/enviveContext/enviveContext.d.ts +4 -1
- package/dist/contexts/enviveContext/enviveContext.js +38 -16
- package/dist/contexts/enviveContext/types.d.cts +1 -1
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.cjs +57 -3
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.cts +6 -1
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +6 -1
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.js +57 -3
- package/dist/contexts/graphqlContext/graphqlContext.cjs +48 -28
- package/dist/contexts/graphqlContext/graphqlContext.js +49 -28
- package/dist/contexts/graphqlContext/mockV3Config.cjs +62 -49
- package/dist/contexts/graphqlContext/mockV3Config.js +21 -8
- package/dist/contexts/hardcopyContext/hardcopyContext.cjs +29 -1
- package/dist/contexts/hardcopyContext/hardcopyContext.js +29 -1
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +2 -3
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +2 -3
- package/dist/contexts/salesAgentContext/chatAPI.cjs +56 -7
- package/dist/contexts/salesAgentContext/chatAPI.d.cts +10 -6
- package/dist/contexts/salesAgentContext/chatAPI.d.ts +10 -6
- package/dist/contexts/salesAgentContext/chatAPI.js +56 -7
- package/dist/contexts/salesAgentContext/formSubmittedUtils.cjs +37 -0
- package/dist/contexts/salesAgentContext/formSubmittedUtils.js +36 -0
- package/dist/contexts/salesAgentContext/index.d.cts +2 -2
- package/dist/contexts/salesAgentContext/index.d.ts +2 -2
- package/dist/contexts/salesAgentContext/salesAgentContext.cjs +36 -10
- package/dist/contexts/salesAgentContext/salesAgentContext.d.cts +11 -4
- package/dist/contexts/salesAgentContext/salesAgentContext.d.ts +11 -4
- package/dist/contexts/salesAgentContext/salesAgentContext.js +36 -10
- package/dist/contexts/salesAgentContext/salesAgentService.cjs +50 -19
- package/dist/contexts/salesAgentContext/salesAgentService.js +50 -19
- 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/systemSettingsContext/systemSettingsContext.d.ts +2 -2
- package/dist/contexts/types.d.cts +1 -1
- package/dist/contexts/types.d.ts +1 -1
- package/dist/contexts/typesV3.cjs +2 -7
- package/dist/contexts/typesV3.d.cts +14 -11
- package/dist/contexts/typesV3.d.ts +14 -11
- package/dist/contexts/typesV3.js +3 -7
- package/dist/contexts/userIdentityContext/userIdentityContext.cjs +22 -30
- package/dist/contexts/userIdentityContext/userIdentityContext.d.cts +9 -8
- package/dist/contexts/userIdentityContext/userIdentityContext.d.ts +9 -8
- package/dist/contexts/userIdentityContext/userIdentityContext.js +22 -30
- package/dist/hooks/ElementObserver/useElementObserver.cjs +3 -2
- package/dist/hooks/ElementObserver/useElementObserver.js +3 -2
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.cjs +1 -2
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.js +1 -2
- package/dist/hooks/Search/useSearch.cjs +2 -2
- package/dist/hooks/Search/useSearch.js +2 -2
- package/dist/hooks/Search/useSearchInput.cjs +1 -1
- package/dist/hooks/Search/useSearchInput.js +1 -1
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/hooks/utils.d.ts +1 -1
- package/dist/mocks/index.cjs +5 -0
- package/dist/mocks/index.d.cts +2 -0
- package/dist/mocks/index.d.ts +2 -0
- package/dist/mocks/index.js +3 -0
- package/dist/mocks/salesAgentMockData.cjs +207 -0
- package/dist/mocks/salesAgentMockData.d.cts +11 -0
- package/dist/mocks/salesAgentMockData.d.ts +11 -0
- package/dist/mocks/salesAgentMockData.js +204 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/CloseButton.cjs +2 -2
- package/dist/packages/components-v3/dist/ChatHeader/components/CloseButton.js +2 -2
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetCloseButtonProperties.cjs +2 -2
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetCloseButtonProperties.js +2 -2
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetHandleProperties.cjs +18 -18
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetHandleProperties.js +18 -18
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetLayoutProperties.cjs +1 -1
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetLayoutProperties.js +1 -1
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetToggleProperties.cjs +4 -4
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetToggleProperties.js +4 -4
- package/dist/packages/components-v3/dist/ChatPreviewLoading/components/Skeleton.cjs +1 -0
- package/dist/packages/components-v3/dist/ChatPreviewLoading/components/Skeleton.js +3 -0
- package/dist/packages/components-v3/dist/Container/Container.cjs +19 -3
- package/dist/packages/components-v3/dist/Container/Container.js +19 -4
- package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.cjs +13 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.js +11 -1
- package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.cjs +13 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.js +11 -1
- package/dist/packages/components-v3/dist/Container/index.cjs +1 -1
- package/dist/packages/components-v3/dist/Container/index.js +1 -1
- package/dist/packages/components-v3/dist/DesignTokens/components/utils.cjs +16 -0
- package/dist/packages/components-v3/dist/DesignTokens/components/utils.js +15 -0
- package/dist/packages/components-v3/dist/FloatingButton/FloatingButton.cjs +2 -0
- package/dist/packages/components-v3/dist/FloatingButton/FloatingButton.js +4 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Button.cjs +9 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Button.js +10 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Container.cjs +9 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Container.js +10 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Icon.cjs +3 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Icon.js +5 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Wrapper.cjs +9 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/Wrapper.js +10 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/index.cjs +4 -0
- package/dist/packages/components-v3/dist/FloatingButton/components/index.js +6 -0
- package/dist/packages/components-v3/dist/FloatingButton/index.cjs +2 -0
- package/dist/packages/components-v3/dist/FloatingButton/index.js +4 -0
- package/dist/packages/components-v3/dist/FloatingButton/types/types.cjs +17 -0
- package/dist/packages/components-v3/dist/FloatingButton/types/types.js +16 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.cjs +3 -3
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.js +3 -3
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.cjs +40 -4
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.js +40 -5
- package/dist/packages/components-v3/dist/PromptButton/components/Icon.cjs +10 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Icon.js +8 -1
- package/dist/packages/components-v3/dist/PromptButton/components/Label.cjs +18 -1
- package/dist/packages/components-v3/dist/PromptButton/components/Label.js +16 -2
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.cjs +31 -3
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.js +31 -4
- package/dist/packages/components-v3/dist/PromptButton/components/Loading.cjs +5 -1
- package/dist/packages/components-v3/dist/PromptButton/components/Loading.js +5 -2
- package/dist/packages/components-v3/dist/PromptButton/components/index.cjs +16 -4
- package/dist/packages/components-v3/dist/PromptButton/components/index.js +15 -5
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBackgroundColorsProperties.cjs +18 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBackgroundColorsProperties.js +18 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.cjs +12 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.js +10 -1
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBorderColorsProperties.cjs +18 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBorderColorsProperties.js +18 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetIconColorsProperties.cjs +32 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetIconColorsProperties.js +32 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.cjs +9 -1
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.js +9 -2
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetTextColorsProperties.cjs +19 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetTextColorsProperties.js +19 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetVariantColorsProperties.cjs +29 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetVariantColorsProperties.js +29 -0
- package/dist/packages/components-v3/dist/PromptButton/index.cjs +1 -1
- package/dist/packages/components-v3/dist/PromptButton/index.js +1 -1
- package/dist/packages/components-v3/dist/PromptButton/utils/functions.cjs +10 -0
- package/dist/packages/components-v3/dist/PromptButton/utils/functions.js +10 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselRefs.js +1 -1
- package/dist/packages/components-v3/dist/SocialProof/SocialProof.cjs +10 -0
- package/dist/packages/components-v3/dist/SocialProof/SocialProof.js +12 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Headline.cjs +53 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Headline.js +54 -0
- package/dist/packages/components-v3/dist/SocialProof/components/ImageGallery.cjs +5 -0
- package/dist/packages/components-v3/dist/SocialProof/components/ImageGallery.js +7 -0
- package/dist/packages/components-v3/dist/SocialProof/components/LayoutFourGrid.cjs +6 -0
- package/dist/packages/components-v3/dist/SocialProof/components/LayoutFourGrid.js +8 -0
- package/dist/packages/components-v3/dist/SocialProof/components/LayoutFourHorizontal.cjs +16 -0
- package/dist/packages/components-v3/dist/SocialProof/components/LayoutFourHorizontal.js +17 -0
- package/dist/packages/components-v3/dist/SocialProof/components/LayoutSingle.cjs +8 -0
- package/dist/packages/components-v3/dist/SocialProof/components/LayoutSingle.js +10 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Skeleton.cjs +1 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Skeleton.js +3 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Subheadline.cjs +8 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Subheadline.js +10 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Textfield.cjs +3 -0
- package/dist/packages/components-v3/dist/SocialProof/components/Textfield.js +5 -0
- package/dist/packages/components-v3/dist/SocialProof/components/index.cjs +8 -0
- package/dist/packages/components-v3/dist/SocialProof/components/index.js +10 -0
- package/dist/packages/components-v3/dist/SocialProof/hooks/index.cjs +1 -0
- package/dist/packages/components-v3/dist/SocialProof/hooks/index.js +3 -0
- package/dist/packages/components-v3/dist/SocialProof/hooks/useSocialProofCount.cjs +1 -0
- package/dist/packages/components-v3/dist/SocialProof/hooks/useSocialProofCount.js +3 -0
- package/dist/packages/components-v3/dist/SocialProof/index.cjs +4 -0
- package/dist/packages/components-v3/dist/SocialProof/index.js +6 -0
- package/dist/packages/components-v3/dist/SocialProof/types/types.cjs +11 -0
- package/dist/packages/components-v3/dist/SocialProof/types/types.js +10 -0
- package/dist/packages/components-v3/dist/SocialProof/utils/functions.cjs +1 -0
- package/dist/packages/components-v3/dist/SocialProof/utils/functions.js +3 -0
- package/dist/packages/components-v3/dist/Title/Title.cjs +11 -0
- package/dist/packages/components-v3/dist/Title/Title.js +12 -0
- package/dist/packages/components-v3/dist/Title/components/Image.cjs +2 -0
- package/dist/packages/components-v3/dist/Title/components/Image.js +4 -0
- package/dist/packages/components-v3/dist/Title/components/Label.cjs +3 -0
- package/dist/packages/components-v3/dist/Title/components/Label.js +5 -0
- package/dist/packages/components-v3/dist/Title/components/Layout.cjs +11 -0
- package/dist/packages/components-v3/dist/Title/components/Layout.js +12 -0
- package/dist/packages/components-v3/dist/Title/components/index.cjs +3 -0
- package/dist/packages/components-v3/dist/Title/components/index.js +5 -0
- package/dist/packages/components-v3/dist/Title/index.cjs +1 -0
- package/dist/packages/components-v3/dist/Title/index.js +3 -0
- package/dist/packages/components-v3/dist/Tokens/index.cjs +11 -11
- package/dist/packages/components-v3/dist/Tokens/index.js +11 -11
- package/dist/packages/components-v3/dist/Typography/Typography.cjs +35 -7
- package/dist/packages/components-v3/dist/Typography/Typography.js +35 -8
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.cjs +30 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.js +28 -1
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.cjs +19 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.js +17 -1
- package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.cjs +20 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.js +18 -1
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.cjs +12 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.js +10 -1
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.cjs +21 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.js +19 -1
- package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.cjs +61 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.js +59 -1
- package/dist/packages/components-v3/dist/Typography/index.cjs +2 -1
- package/dist/packages/components-v3/dist/Typography/index.js +2 -1
- package/dist/packages/components-v3/dist/Typography/types/index.cjs +47 -0
- package/dist/packages/components-v3/dist/Typography/types/index.js +44 -0
- package/dist/packages/components-v3/dist/Typography/utils/utils.cjs +12 -0
- package/dist/packages/components-v3/dist/Typography/utils/utils.js +10 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Container.cjs +1 -1
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Container.js +1 -1
- package/dist/packages/components-v3/dist/WelcomeMessage/components/SparkleIcon.cjs +1 -1
- package/dist/packages/components-v3/dist/WelcomeMessage/components/SparkleIcon.js +1 -1
- package/dist/packages/components-v3/dist/WelcomeMessage/types/types.cjs +2 -2
- package/dist/packages/components-v3/dist/WelcomeMessage/types/types.js +2 -2
- package/dist/packages/components-v3/dist/WidgetTextField/WidgetTextField.cjs +2 -0
- package/dist/packages/components-v3/dist/WidgetTextField/WidgetTextField.js +4 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/Container.cjs +14 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/Container.js +15 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/FakeTextInput.cjs +3 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/FakeTextInput.js +5 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/Icon.cjs +7 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/Icon.js +9 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/Skeleton.cjs +10 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/Skeleton.js +11 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/index.cjs +4 -0
- package/dist/packages/components-v3/dist/WidgetTextField/components/index.js +6 -0
- package/dist/packages/components-v3/dist/WidgetTextField/hooks/useGetContainerProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/WidgetTextField/hooks/useGetContainerProperties.js +3 -0
- package/dist/packages/components-v3/dist/WidgetTextField/index.cjs +1 -0
- package/dist/packages/components-v3/dist/WidgetTextField/index.js +3 -0
- package/dist/packages/components-v3/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.cjs +8 -0
- package/dist/packages/components-v3/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.js +10 -0
- package/dist/packages/components-v3/dist/packages/components-v3/src/models/colorsConfig.cjs +26 -0
- package/dist/packages/components-v3/dist/packages/components-v3/src/models/colorsConfig.js +25 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/aspectRatio/aspectRatio.cjs +16 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/aspectRatio/aspectRatio.js +17 -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/packages/components-v3/tokens/colors/colors.cjs +51 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/colors/colors.js +51 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/radius/radius.cjs +64 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/radius/radius.js +65 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/theme/theme.cjs +18 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/theme/theme.js +16 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/fontFamily.cjs +25 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/fontFamily.js +25 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/fontSize.cjs +37 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/fontSize.js +38 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/fontWeight.cjs +17 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/fontWeight.js +18 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/letterSpacing.cjs +15 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/letterSpacing.js +16 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/lineHeight.cjs +31 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/typography/lineHeight.js +32 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/utils.cjs +7 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/utils.js +6 -0
- package/dist/packages/components-v3/dist/utils/CustomIcon.cjs +2 -0
- package/dist/packages/components-v3/dist/utils/CustomIcon.js +4 -0
- package/dist/packages/components-v3/dist/utils/resolveTheme.cjs +13 -0
- package/dist/packages/components-v3/dist/utils/resolveTheme.js +13 -0
- package/dist/packages/components-v3/dist/utils/useGetContentSize.cjs +1 -0
- package/dist/packages/components-v3/dist/utils/useGetContentSize.js +3 -0
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.cjs +2 -2
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.js +2 -2
- package/dist/packages/icons/dist/FourPointStar.cjs +16 -1
- package/dist/packages/icons/dist/FourPointStar.js +16 -2
- package/dist/packages/icons/dist/MagnifyingGlass.cjs +8 -0
- package/dist/packages/icons/dist/MagnifyingGlass.js +9 -0
- package/dist/packages/icons/dist/MagnifyingThin.cjs +8 -0
- package/dist/packages/icons/dist/MagnifyingThin.js +9 -0
- package/dist/packages/icons/dist/SendMinimalist.cjs +8 -0
- package/dist/packages/icons/dist/SendMinimalist.js +9 -0
- package/dist/packages/icons/dist/SendModern.cjs +8 -0
- package/dist/packages/icons/dist/SendModern.js +9 -0
- package/dist/packages/icons/dist/SendStandard.cjs +8 -0
- package/dist/packages/icons/dist/SendStandard.js +9 -0
- package/dist/services/amplitudeService/amplitudeService.cjs +36 -8
- package/dist/services/amplitudeService/amplitudeService.d.cts +11 -3
- package/dist/services/amplitudeService/amplitudeService.d.ts +11 -3
- package/dist/services/amplitudeService/amplitudeService.js +36 -8
- package/dist/services/userIdentityService/index.cjs +3 -0
- package/dist/services/userIdentityService/index.d.cts +2 -0
- package/dist/services/userIdentityService/index.d.ts +2 -0
- package/dist/services/userIdentityService/index.js +3 -0
- package/dist/services/userIdentityService/userIdentityService.cjs +49 -0
- package/dist/services/userIdentityService/userIdentityService.d.cts +19 -0
- package/dist/services/userIdentityService/userIdentityService.d.ts +19 -0
- package/dist/services/userIdentityService/userIdentityService.js +48 -0
- package/package.json +14 -5
- package/src/application/models/api/userEvent.ts +3 -1
- package/src/application/models/chatElementDisplayLocationV3.ts +2 -0
- package/src/application/models/frontendConfigV3.ts +1 -1
- package/src/application/models/graphql/queries/getColorsAndFrontendQuery.ts +13 -0
- package/src/application/models/guards/api/isApiQueryTypedEventAttributes.ts +6 -1
- package/src/application/utils/widgetTextRequestToApiRequest.ts +5 -5
- package/src/atoms/app/index.ts +9 -7
- package/src/atoms/chat/index.ts +0 -1
- package/src/contexts/amplitudeContext/__tests__/amplitudeContext.test.tsx +47 -66
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +4 -1
- package/src/contexts/enviveContext/enviveContext.tsx +47 -6
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +101 -2
- package/src/contexts/graphqlContext/graphqlContext.tsx +42 -42
- package/src/contexts/graphqlContext/mockV3Config.ts +18 -6
- package/src/contexts/hardcopyContext/hardcopyContext.tsx +29 -0
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +0 -1
- package/src/contexts/salesAgentContext/chatAPI.ts +56 -10
- package/src/contexts/salesAgentContext/formSubmittedUtils.ts +57 -0
- package/src/contexts/salesAgentContext/salesAgentContext.tsx +66 -9
- package/src/contexts/salesAgentContext/salesAgentService.ts +42 -11
- package/src/contexts/searchContext/__tests__/searchContext.test.tsx +3 -1
- package/src/contexts/typesV3.ts +16 -14
- package/src/contexts/uiConfigContext/__tests__/uiConfigContext.test.tsx +3 -2
- package/src/contexts/userIdentityContext/__tests__/userIdentityContext.test.tsx +18 -131
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +47 -42
- package/src/hooks/ElementObserver/useElementObserver.ts +2 -1
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +0 -1
- package/src/hooks/Search/__tests__/useSearch.test.tsx +11 -1
- package/src/mocks/index.ts +1 -0
- package/src/mocks/salesAgentMockData.ts +247 -0
- package/src/services/amplitudeService/__tests__/amplitudeService.test.ts +17 -15
- package/src/services/amplitudeService/amplitudeService.ts +50 -10
- package/src/services/userIdentityService/index.ts +1 -0
- package/src/services/userIdentityService/userIdentityService.ts +64 -0
- package/dist/contexts/featureFlagContext/featureFlagContext.cjs +0 -105
- package/dist/contexts/featureFlagContext/featureFlagContext.d.cts +0 -19
- package/dist/contexts/featureFlagContext/featureFlagContext.d.ts +0 -19
- package/dist/contexts/featureFlagContext/featureFlagContext.js +0 -102
- package/dist/contexts/featureFlagContext/index.cjs +0 -4
- package/dist/contexts/featureFlagContext/index.d.cts +0 -2
- package/dist/contexts/featureFlagContext/index.d.ts +0 -2
- package/dist/contexts/featureFlagContext/index.js +0 -3
- package/dist/packages/components-v3/dist/src/models/colorsConfig.cjs +0 -26
- package/dist/packages/components-v3/dist/src/models/colorsConfig.js +0 -25
- package/dist/packages/components-v3/dist/tokens/aspectRatio/aspectRatio.cjs +0 -16
- package/dist/packages/components-v3/dist/tokens/aspectRatio/aspectRatio.js +0 -17
- package/dist/packages/components-v3/dist/tokens/breakpoints/breakpoints.cjs +0 -25
- package/dist/packages/components-v3/dist/tokens/breakpoints/breakpoints.js +0 -23
- package/dist/packages/components-v3/dist/tokens/colors/colors.cjs +0 -51
- package/dist/packages/components-v3/dist/tokens/colors/colors.js +0 -51
- package/dist/packages/components-v3/dist/tokens/radius/radius.cjs +0 -64
- package/dist/packages/components-v3/dist/tokens/radius/radius.js +0 -65
- package/dist/packages/components-v3/dist/tokens/theme/theme.cjs +0 -13
- package/dist/packages/components-v3/dist/tokens/theme/theme.js +0 -12
- package/dist/packages/components-v3/dist/tokens/typography/fontFamily.cjs +0 -25
- package/dist/packages/components-v3/dist/tokens/typography/fontFamily.js +0 -25
- package/dist/packages/components-v3/dist/tokens/typography/fontSize.cjs +0 -37
- package/dist/packages/components-v3/dist/tokens/typography/fontSize.js +0 -38
- package/dist/packages/components-v3/dist/tokens/typography/fontWeight.cjs +0 -17
- package/dist/packages/components-v3/dist/tokens/typography/fontWeight.js +0 -18
- package/dist/packages/components-v3/dist/tokens/typography/letterSpacing.cjs +0 -15
- package/dist/packages/components-v3/dist/tokens/typography/letterSpacing.js +0 -16
- package/dist/packages/components-v3/dist/tokens/typography/lineHeight.cjs +0 -31
- package/dist/packages/components-v3/dist/tokens/typography/lineHeight.js +0 -32
- package/dist/packages/components-v3/dist/tokens/utils.cjs +0 -7
- package/dist/packages/components-v3/dist/tokens/utils.js +0 -6
- package/src/contexts/featureFlagContext/featureFlagContext.tsx +0 -180
- package/src/contexts/featureFlagContext/index.ts +0 -1
- /package/dist/packages/components-v3/dist/{tokens → packages/components-v3/tokens}/typography/typography.cjs +0 -0
- /package/dist/packages/components-v3/dist/{tokens → packages/components-v3/tokens}/typography/typography.js +0 -0
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ReactNode,
|
|
3
|
+
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
2
10
|
import UAParser from 'ua-parser-js';
|
|
3
11
|
import Logger from 'src/application/logging/logger';
|
|
4
12
|
import CommerceApiClient from 'src/application/commerce-api';
|
|
5
|
-
import { v4 as uuid } from 'uuid';
|
|
6
13
|
import { ClientDetails } from 'src/application/models/clientDetails';
|
|
7
14
|
import { useLocalStorage } from 'src/contexts/localStorageContext';
|
|
8
15
|
import { useSetAtom } from 'jotai';
|
|
9
16
|
import { userIdAtom } from 'src/atoms/app';
|
|
17
|
+
import { UserIdentityService } from 'src/services/userIdentityService';
|
|
10
18
|
|
|
11
19
|
// Helper function from the original service
|
|
12
20
|
const getUserAgentDetails = (): ClientDetails => {
|
|
@@ -27,10 +35,8 @@ const getUserAgentDetails = (): ClientDetails => {
|
|
|
27
35
|
|
|
28
36
|
export interface UserIdentityContextType {
|
|
29
37
|
identifyUser: () => Promise<void>;
|
|
30
|
-
getUserIdOrDefault: () => string
|
|
38
|
+
getUserIdOrDefault: () => Promise<string>;
|
|
31
39
|
getUserIdOverrideFromLocalStorage: () => string | undefined;
|
|
32
|
-
getUserIdDefaultFromLocalStorage: () => string | undefined;
|
|
33
|
-
setUserIdDefaultInLocalStorage: (userId: string) => string;
|
|
34
40
|
setUserIdOverrideInLocalStorage: (userId: string) => string;
|
|
35
41
|
clearUserIdOverrideInLocalStorage: () => void;
|
|
36
42
|
isReady: boolean;
|
|
@@ -38,7 +44,15 @@ export interface UserIdentityContextType {
|
|
|
38
44
|
|
|
39
45
|
const UserIdentityContext = createContext<UserIdentityContextType | undefined>(undefined);
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
interface UserIdentityProviderProps {
|
|
48
|
+
userIdService: UserIdentityService;
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const UserIdentityProvider: React.FC<UserIdentityProviderProps> = ({
|
|
53
|
+
userIdService: inputService,
|
|
54
|
+
children,
|
|
55
|
+
}) => {
|
|
42
56
|
const [localUserId, setLocalUserId] = useState<string | undefined>(undefined);
|
|
43
57
|
const setUserId = useSetAtom(userIdAtom);
|
|
44
58
|
const { getItem, setItem, isAvailable: localStorageIsReady } = useLocalStorage();
|
|
@@ -52,26 +66,12 @@ export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
52
66
|
}, [localStorageIsReady]);
|
|
53
67
|
|
|
54
68
|
const USER_ID_OVERRIDE_KEY = 'v1-spiffy-user-id-override';
|
|
55
|
-
const USER_ID_DEFAULT_KEY = 'v1-spiffy-user-id-default';
|
|
56
69
|
|
|
70
|
+
// @deprecated
|
|
57
71
|
const getUserIdOverrideFromLocalStorage = useCallback((): string | undefined => {
|
|
58
72
|
return getItem(USER_ID_OVERRIDE_KEY) ?? undefined;
|
|
59
73
|
}, [getItem]);
|
|
60
74
|
|
|
61
|
-
const getUserIdDefaultFromLocalStorage = useCallback((): string | undefined => {
|
|
62
|
-
return getItem(USER_ID_DEFAULT_KEY) ?? undefined;
|
|
63
|
-
}, [getItem]);
|
|
64
|
-
|
|
65
|
-
const setUserIdDefaultInLocalStorage = useCallback(
|
|
66
|
-
(userId: string): string => {
|
|
67
|
-
Logger.logInfo(`setUserIdDefaultInLocalStorage - Setting user_id=${userId}`);
|
|
68
|
-
setItem(USER_ID_DEFAULT_KEY, userId);
|
|
69
|
-
// window.dispatchEvent is handled by useLocalStorage now
|
|
70
|
-
return userId;
|
|
71
|
-
},
|
|
72
|
-
[setItem, USER_ID_DEFAULT_KEY],
|
|
73
|
-
);
|
|
74
|
-
|
|
75
75
|
const setUserIdOverrideInLocalStorage = useCallback(
|
|
76
76
|
(userId: string): string => {
|
|
77
77
|
Logger.logInfo(`setUserIdOverrideInLocalStorage - Setting user_id=${userId}`);
|
|
@@ -89,23 +89,29 @@ export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
89
89
|
setItem(USER_ID_OVERRIDE_KEY, ''); // Set to empty string to clear
|
|
90
90
|
}, [setItem, USER_ID_OVERRIDE_KEY]);
|
|
91
91
|
|
|
92
|
-
const getUserIdOrDefault = useCallback((): string => {
|
|
92
|
+
const getUserIdOrDefault = useCallback(async (): Promise<string> => {
|
|
93
93
|
const userIdOverride = getUserIdOverrideFromLocalStorage();
|
|
94
94
|
if (userIdOverride) {
|
|
95
95
|
return userIdOverride;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
98
|
+
try {
|
|
99
|
+
// NOTE: This uses EnviveAnalytics under the hood to determine the userID
|
|
100
|
+
const enviveUserId = await inputService.getUserIdOrDefault();
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
if (!enviveUserId) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
'[spiffy-ai] EnviveAnalytics.resolveEnviveUserId() returned null/undefined - this should never happen',
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return enviveUserId;
|
|
109
|
+
} catch (error: unknown) {
|
|
110
|
+
Logger.logError('[spiffy-ai] CRITICAL: Failed to get user ID from EnviveAnalytics', error);
|
|
111
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
112
|
+
throw new Error(`[spiffy-ai] CRITICAL: User ID resolution failed: ${errorMessage}`);
|
|
113
|
+
}
|
|
114
|
+
}, [getUserIdOverrideFromLocalStorage]);
|
|
109
115
|
|
|
110
116
|
const identifyUser = useCallback(async (): Promise<void> => {
|
|
111
117
|
if (!isReady) {
|
|
@@ -117,7 +123,7 @@ export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
117
123
|
// Temporarily commented out until WindowDataLayerService is resolved
|
|
118
124
|
// const cdpUserId = WindowDataLayerService.getGoogleAnalyticsClientId();
|
|
119
125
|
const cdpUserId = 'UNKNOWN_CDP_USER_ID'; // Placeholder
|
|
120
|
-
const userId = getUserIdOrDefault();
|
|
126
|
+
const userId = await getUserIdOrDefault();
|
|
121
127
|
const userAgentDetails = getUserAgentDetails();
|
|
122
128
|
|
|
123
129
|
if (!cdpUserId) {
|
|
@@ -136,8 +142,6 @@ export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
136
142
|
identifyUser,
|
|
137
143
|
getUserIdOrDefault,
|
|
138
144
|
getUserIdOverrideFromLocalStorage,
|
|
139
|
-
getUserIdDefaultFromLocalStorage,
|
|
140
|
-
setUserIdDefaultInLocalStorage,
|
|
141
145
|
setUserIdOverrideInLocalStorage,
|
|
142
146
|
clearUserIdOverrideInLocalStorage,
|
|
143
147
|
isReady,
|
|
@@ -146,8 +150,6 @@ export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
146
150
|
identifyUser,
|
|
147
151
|
getUserIdOrDefault,
|
|
148
152
|
getUserIdOverrideFromLocalStorage,
|
|
149
|
-
getUserIdDefaultFromLocalStorage,
|
|
150
|
-
setUserIdDefaultInLocalStorage,
|
|
151
153
|
setUserIdOverrideInLocalStorage,
|
|
152
154
|
clearUserIdOverrideInLocalStorage,
|
|
153
155
|
isReady,
|
|
@@ -155,12 +157,15 @@ export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
155
157
|
);
|
|
156
158
|
useEffect(() => {
|
|
157
159
|
if (isReady && !localUserId) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
const setUserIdStates = async () => {
|
|
161
|
+
const newUserId = await getUserIdOrDefault();
|
|
162
|
+
console.log('useUserIdentity useEffect - setting localUserId', newUserId);
|
|
163
|
+
setLocalUserId(newUserId);
|
|
164
|
+
setUserId(newUserId);
|
|
165
|
+
};
|
|
166
|
+
setUserIdStates();
|
|
162
167
|
}
|
|
163
|
-
}, [isReady, localUserId, setUserId]);
|
|
168
|
+
}, [getUserIdOrDefault, isReady, localUserId, setUserId]);
|
|
164
169
|
|
|
165
170
|
if (!localUserId) {
|
|
166
171
|
return null;
|
|
@@ -51,8 +51,9 @@ export interface ElementObserverUtility {
|
|
|
51
51
|
*/
|
|
52
52
|
export const useElementObserver = (selector: NodeSelector): ElementObserverUtility => {
|
|
53
53
|
const INITIAL_RENDER_STATE = true;
|
|
54
|
-
const eoRef = useRef<ElementObserver>(
|
|
54
|
+
const eoRef = useRef<ElementObserver | null>(null);
|
|
55
55
|
const [renderBlocked, setRenderBlocked] = useState(INITIAL_RENDER_STATE);
|
|
56
|
+
eoRef.current = DOMObserver.add(selector);
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
59
|
* Fired every time the HTML element changes.
|
|
@@ -25,6 +25,7 @@ import { ProductSorting } from 'src/atoms/search/types';
|
|
|
25
25
|
import { SearchResult } from 'src/application/models/api/search';
|
|
26
26
|
import { SearchResultsState } from 'src/hooks/utils';
|
|
27
27
|
import { SearchResponseProduct } from '@spiffy-ai/commerce-api-client';
|
|
28
|
+
import { UserIdentityService } from 'src/services/userIdentityService';
|
|
28
29
|
import { useSearch } from '../useSearch';
|
|
29
30
|
|
|
30
31
|
// Mock dependencies
|
|
@@ -171,6 +172,15 @@ vi.mock('src/events', () => ({
|
|
|
171
172
|
},
|
|
172
173
|
}));
|
|
173
174
|
|
|
175
|
+
const mockGetUserId = vi.fn().mockResolvedValue('test-user-id');
|
|
176
|
+
const mockInitializeUser = vi.fn().mockResolvedValue(undefined);
|
|
177
|
+
|
|
178
|
+
const testUserIdService = {
|
|
179
|
+
getUserIdOrDefault: mockGetUserId,
|
|
180
|
+
initializeUser: mockInitializeUser,
|
|
181
|
+
getUserIdOverrideFromLocalStorage: vi.fn().mockReturnValue(undefined),
|
|
182
|
+
} as unknown as UserIdentityService;
|
|
183
|
+
|
|
174
184
|
// FeatureFlagService
|
|
175
185
|
const testFeatureFlagService = new FeatureFlagService([]);
|
|
176
186
|
|
|
@@ -398,7 +408,7 @@ const TestWrapper: React.FC<{
|
|
|
398
408
|
>
|
|
399
409
|
<LocalStorageProvider>
|
|
400
410
|
<GraphQLProvider>
|
|
401
|
-
<UserIdentityProvider>
|
|
411
|
+
<UserIdentityProvider userIdService={testUserIdService}>
|
|
402
412
|
<FeatureFlagServiceProvider featureFlagService={testFeatureFlagService}>
|
|
403
413
|
<AmplitudeProvider>
|
|
404
414
|
<NewOrgConfigProvider>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './salesAgentMockData';
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { SuggestionCategory } from '@spiffy-ai/commerce-api-client';
|
|
2
|
+
import { Message, MessageRole, MessageType, Suggestion } from 'src/application/models';
|
|
3
|
+
import { MockSalesAgentData } from 'src/contexts/salesAgentContext/salesAgentContext';
|
|
4
|
+
|
|
5
|
+
export const mockMessages: Message[][] = [
|
|
6
|
+
// Welcome message
|
|
7
|
+
[
|
|
8
|
+
{
|
|
9
|
+
id: 'welcome-msg-1',
|
|
10
|
+
role: MessageRole.Assistant,
|
|
11
|
+
type: MessageType.Text,
|
|
12
|
+
createdAt: new Date(Date.now() - 310000).toISOString(),
|
|
13
|
+
metadata: {
|
|
14
|
+
content: 'Hello! How can I assist you today?',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
// User message
|
|
19
|
+
[
|
|
20
|
+
{
|
|
21
|
+
id: 'user-msg-1',
|
|
22
|
+
role: MessageRole.User,
|
|
23
|
+
type: MessageType.QueryTyped,
|
|
24
|
+
createdAt: new Date(Date.now() - 300000).toISOString(),
|
|
25
|
+
metadata: {
|
|
26
|
+
content: 'What are your best products?',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
// Assistant text response
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
id: 'agent-msg-1',
|
|
35
|
+
role: MessageRole.Assistant,
|
|
36
|
+
type: MessageType.Text,
|
|
37
|
+
createdAt: new Date(Date.now() - 290000).toISOString(),
|
|
38
|
+
metadata: {
|
|
39
|
+
content: 'Here are some of our best-selling products that customers love!',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
// Product carousel
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
id: 'product-1',
|
|
47
|
+
role: MessageRole.Assistant,
|
|
48
|
+
type: MessageType.Product,
|
|
49
|
+
createdAt: new Date(Date.now() - 280000).toISOString(),
|
|
50
|
+
metadata: {
|
|
51
|
+
id: 'product-1',
|
|
52
|
+
title: 'Leather Tote Bag',
|
|
53
|
+
salePrice: 89.99,
|
|
54
|
+
originalPrice: 129.99,
|
|
55
|
+
averageRating: 4.7,
|
|
56
|
+
numberReviews: 127,
|
|
57
|
+
url: 'https://example.com/product/leather-tote',
|
|
58
|
+
imageUrl: 'https://picsum.photos/400/400?random=1',
|
|
59
|
+
isForGrid: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'product-2',
|
|
64
|
+
role: MessageRole.Assistant,
|
|
65
|
+
type: MessageType.Product,
|
|
66
|
+
createdAt: new Date(Date.now() - 280000).toISOString(),
|
|
67
|
+
metadata: {
|
|
68
|
+
id: 'product-2',
|
|
69
|
+
title: 'Designer Handbag',
|
|
70
|
+
salePrice: 199.99,
|
|
71
|
+
originalPrice: 249.99,
|
|
72
|
+
averageRating: 4.5,
|
|
73
|
+
numberReviews: 89,
|
|
74
|
+
url: 'https://example.com/product/designer-handbag',
|
|
75
|
+
imageUrl: 'https://picsum.photos/400/400?random=2',
|
|
76
|
+
isForGrid: false,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'product-3',
|
|
81
|
+
role: MessageRole.Assistant,
|
|
82
|
+
type: MessageType.Product,
|
|
83
|
+
createdAt: new Date(Date.now() - 280000).toISOString(),
|
|
84
|
+
metadata: {
|
|
85
|
+
id: 'product-3',
|
|
86
|
+
title: 'Classic Shoulder Bag',
|
|
87
|
+
salePrice: 125.0,
|
|
88
|
+
originalPrice: 150.0,
|
|
89
|
+
averageRating: 4.8,
|
|
90
|
+
numberReviews: 203,
|
|
91
|
+
url: 'https://example.com/product/shoulder-bag',
|
|
92
|
+
imageUrl: 'https://picsum.photos/400/400?random=3',
|
|
93
|
+
isForGrid: false,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
// User message asking about reviews
|
|
98
|
+
[
|
|
99
|
+
{
|
|
100
|
+
id: 'user-msg-2',
|
|
101
|
+
role: MessageRole.User,
|
|
102
|
+
type: MessageType.QueryTyped,
|
|
103
|
+
createdAt: new Date(Date.now() - 200000).toISOString(),
|
|
104
|
+
metadata: {
|
|
105
|
+
content: 'What do customers say about these products?',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
// Assistant text response
|
|
110
|
+
[
|
|
111
|
+
{
|
|
112
|
+
id: 'agent-msg-2',
|
|
113
|
+
role: MessageRole.Assistant,
|
|
114
|
+
type: MessageType.Text,
|
|
115
|
+
createdAt: new Date(Date.now() - 190000).toISOString(),
|
|
116
|
+
metadata: {
|
|
117
|
+
content: 'Here are some recent customer reviews:',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
// Review carousel
|
|
122
|
+
[
|
|
123
|
+
{
|
|
124
|
+
id: 'review-1',
|
|
125
|
+
role: MessageRole.Assistant,
|
|
126
|
+
type: MessageType.Review,
|
|
127
|
+
createdAt: new Date(Date.now() - 180000).toISOString(),
|
|
128
|
+
metadata: {
|
|
129
|
+
id: 'review-1',
|
|
130
|
+
productId: 'product-1',
|
|
131
|
+
reviewer: 'Sarah M.',
|
|
132
|
+
review:
|
|
133
|
+
'Absolutely love this bag! The quality is outstanding and it fits everything I need. Highly recommend!',
|
|
134
|
+
stars: 5,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: 'review-2',
|
|
139
|
+
role: MessageRole.Assistant,
|
|
140
|
+
type: MessageType.Review,
|
|
141
|
+
createdAt: new Date(Date.now() - 180000).toISOString(),
|
|
142
|
+
metadata: {
|
|
143
|
+
id: 'review-2',
|
|
144
|
+
productId: 'product-2',
|
|
145
|
+
reviewer: 'Jessica K.',
|
|
146
|
+
review:
|
|
147
|
+
'Beautiful design and great craftsmanship. The leather feels premium and the bag is very spacious.',
|
|
148
|
+
stars: 5,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 'review-3',
|
|
153
|
+
role: MessageRole.Assistant,
|
|
154
|
+
type: MessageType.Review,
|
|
155
|
+
createdAt: new Date(Date.now() - 180000).toISOString(),
|
|
156
|
+
metadata: {
|
|
157
|
+
id: 'review-3',
|
|
158
|
+
productId: 'product-3',
|
|
159
|
+
reviewer: 'Emily R.',
|
|
160
|
+
review: 'Perfect size and style. I get compliments every time I use it. Worth every penny!',
|
|
161
|
+
stars: 5,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
// User message asking about help pages
|
|
166
|
+
[
|
|
167
|
+
{
|
|
168
|
+
id: 'user-msg-3',
|
|
169
|
+
role: MessageRole.User,
|
|
170
|
+
type: MessageType.QueryTyped,
|
|
171
|
+
createdAt: new Date(Date.now() - 100000).toISOString(),
|
|
172
|
+
metadata: {
|
|
173
|
+
content: 'How do I return an item?',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
// Assistant text response with link
|
|
178
|
+
[
|
|
179
|
+
{
|
|
180
|
+
id: 'agent-msg-3',
|
|
181
|
+
role: MessageRole.Assistant,
|
|
182
|
+
type: MessageType.Text,
|
|
183
|
+
createdAt: new Date(Date.now() - 90000).toISOString(),
|
|
184
|
+
metadata: {
|
|
185
|
+
content:
|
|
186
|
+
'You can return items within 30 days of purchase. Visit our returns page at [returns](https://example.com/returns) for more information.',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
// Page/document carousel
|
|
191
|
+
[
|
|
192
|
+
{
|
|
193
|
+
id: 'page-1',
|
|
194
|
+
role: MessageRole.Assistant,
|
|
195
|
+
type: MessageType.Page,
|
|
196
|
+
createdAt: new Date(Date.now() - 80000).toISOString(),
|
|
197
|
+
metadata: {
|
|
198
|
+
id: 'page-1',
|
|
199
|
+
title: 'Return Policy',
|
|
200
|
+
description:
|
|
201
|
+
'Learn about our return policy, including timeframes, conditions, and how to initiate a return.',
|
|
202
|
+
url: 'https://example.com/returns',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: 'page-2',
|
|
207
|
+
role: MessageRole.Assistant,
|
|
208
|
+
type: MessageType.Page,
|
|
209
|
+
createdAt: new Date(Date.now() - 80000).toISOString(),
|
|
210
|
+
metadata: {
|
|
211
|
+
id: 'page-2',
|
|
212
|
+
title: 'Shipping Information',
|
|
213
|
+
description: 'Find out about shipping options, delivery times, and tracking your order.',
|
|
214
|
+
url: 'https://example.com/shipping',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
];
|
|
219
|
+
|
|
220
|
+
export const mockSuggestions: Suggestion[] = [
|
|
221
|
+
{
|
|
222
|
+
id: 'suggestion-1',
|
|
223
|
+
category: SuggestionCategory.ProductBased,
|
|
224
|
+
content: 'What are the best products for gifting?',
|
|
225
|
+
createdAt: new Date().toISOString(),
|
|
226
|
+
isAnswer: false,
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: 'suggestion-2',
|
|
230
|
+
category: SuggestionCategory.ProductBased,
|
|
231
|
+
content: 'Show me summer dresses',
|
|
232
|
+
createdAt: new Date().toISOString(),
|
|
233
|
+
isAnswer: false,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
id: 'suggestion-3',
|
|
237
|
+
category: SuggestionCategory.ProductBased,
|
|
238
|
+
content: 'Do you have free shipping?',
|
|
239
|
+
createdAt: new Date().toISOString(),
|
|
240
|
+
isAnswer: false,
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
export const mockSalesAgentData: MockSalesAgentData = {
|
|
245
|
+
messages: mockMessages,
|
|
246
|
+
suggestions: mockSuggestions,
|
|
247
|
+
};
|
|
@@ -74,6 +74,8 @@ describe('AmplitudeService', () => {
|
|
|
74
74
|
amplitudeApiKey: 'test-api-key',
|
|
75
75
|
dataResidency: 'US',
|
|
76
76
|
env: 'test',
|
|
77
|
+
orgId: 'test-org-id',
|
|
78
|
+
show: true,
|
|
77
79
|
contextSource: 'app',
|
|
78
80
|
orgShortName: 'test-org',
|
|
79
81
|
featureFlagService,
|
|
@@ -104,6 +106,9 @@ describe('AmplitudeService', () => {
|
|
|
104
106
|
amplitudeApiKey: 'test-api-key',
|
|
105
107
|
dataResidency: 'US',
|
|
106
108
|
env: 'test',
|
|
109
|
+
orgId: 'test-org-id',
|
|
110
|
+
show: true,
|
|
111
|
+
getLocalStorageItem: mockGetLocalStorageItem,
|
|
107
112
|
contextSource: 'app',
|
|
108
113
|
orgShortName: 'test-org',
|
|
109
114
|
featureFlagService,
|
|
@@ -118,6 +123,9 @@ describe('AmplitudeService', () => {
|
|
|
118
123
|
amplitudeApiKey: '',
|
|
119
124
|
dataResidency: 'US',
|
|
120
125
|
env: 'test',
|
|
126
|
+
orgId: 'test-org-id',
|
|
127
|
+
show: true,
|
|
128
|
+
getLocalStorageItem: mockGetLocalStorageItem,
|
|
121
129
|
contextSource: 'app',
|
|
122
130
|
orgShortName: 'test-org',
|
|
123
131
|
featureFlagService,
|
|
@@ -132,6 +140,9 @@ describe('AmplitudeService', () => {
|
|
|
132
140
|
amplitudeApiKey: 'test-api-key',
|
|
133
141
|
dataResidency: 'US',
|
|
134
142
|
env: 'test',
|
|
143
|
+
orgId: 'test-org-id',
|
|
144
|
+
show: true,
|
|
145
|
+
getLocalStorageItem: mockGetLocalStorageItem,
|
|
135
146
|
contextSource: 'app',
|
|
136
147
|
orgShortName: 'test-org',
|
|
137
148
|
featureFlagService: null as any,
|
|
@@ -238,6 +249,9 @@ describe('AmplitudeService', () => {
|
|
|
238
249
|
amplitudeApiKey: 'test-api-key',
|
|
239
250
|
dataResidency: 'US',
|
|
240
251
|
env: 'test',
|
|
252
|
+
orgId: 'test-org-id',
|
|
253
|
+
show: true,
|
|
254
|
+
getLocalStorageItem: mockGetLocalStorageItem,
|
|
241
255
|
contextSource: 'app',
|
|
242
256
|
orgShortName: 'test-org',
|
|
243
257
|
featureFlagService,
|
|
@@ -375,6 +389,9 @@ describe('AmplitudeService', () => {
|
|
|
375
389
|
amplitudeApiKey: 'test-api-key',
|
|
376
390
|
dataResidency: 'US',
|
|
377
391
|
env: 'test',
|
|
392
|
+
orgId: 'test-org-id',
|
|
393
|
+
show: true,
|
|
394
|
+
getLocalStorageItem: null,
|
|
378
395
|
contextSource: 'app',
|
|
379
396
|
orgShortName: 'test-org',
|
|
380
397
|
featureFlagService,
|
|
@@ -435,21 +452,6 @@ describe('AmplitudeService', () => {
|
|
|
435
452
|
const eventProps = callArgs[1];
|
|
436
453
|
expect(eventProps).toHaveProperty('test', 'value');
|
|
437
454
|
});
|
|
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
455
|
});
|
|
454
456
|
|
|
455
457
|
describe('Event enrichment', () => {
|
|
@@ -9,9 +9,11 @@ import type {
|
|
|
9
9
|
ServerZoneType,
|
|
10
10
|
} from '@amplitude/analytics-types';
|
|
11
11
|
import { FeatureFlagService } from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
|
|
12
|
+
import { WidgetTypeV3 } from 'src/contexts/typesV3';
|
|
12
13
|
|
|
13
14
|
export enum SpiffyMetricsEventName {
|
|
14
15
|
BundleLoaded = 'Bundle Loaded',
|
|
16
|
+
EnvironmentInitialized = 'Environment Initialized',
|
|
15
17
|
ChatLiveAgentBtnClick = 'Chat Live Agent Btn Click',
|
|
16
18
|
ChatFloatingButtonVisible = 'Chat Floating Button Visible',
|
|
17
19
|
ChatComponentVisible = 'Chat Component Visible',
|
|
@@ -57,10 +59,12 @@ export interface AmplitudeServiceConfig {
|
|
|
57
59
|
env: string;
|
|
58
60
|
contextSource: string;
|
|
59
61
|
orgShortName: string;
|
|
62
|
+
orgId: string;
|
|
60
63
|
featureFlagService: FeatureFlagService;
|
|
61
64
|
orgGaConfig?: unknown;
|
|
62
|
-
show
|
|
63
|
-
|
|
65
|
+
show: boolean;
|
|
66
|
+
enabledFeatures?: Record<string, boolean>;
|
|
67
|
+
getLocalStorageItem: null | ((key: string) => string | null);
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
export class AmplitudeService {
|
|
@@ -123,6 +127,7 @@ export class AmplitudeService {
|
|
|
123
127
|
chat_id: this.getLocalStorageItem(LocalStorageKeys.ChatId),
|
|
124
128
|
env: this.config.env || 'unknown',
|
|
125
129
|
app_source: this.config.contextSource,
|
|
130
|
+
org_id: this.config.orgId,
|
|
126
131
|
'org.short_name': this.config.orgShortName,
|
|
127
132
|
'user.id': this.config.userId,
|
|
128
133
|
'cdp.user_id': null,
|
|
@@ -173,11 +178,11 @@ export class AmplitudeService {
|
|
|
173
178
|
if (this.config.show != null) {
|
|
174
179
|
globalProperties['globalProperties.show'] = String(this.config.show);
|
|
175
180
|
}
|
|
181
|
+
globalProperties['globalProperties.env'] = String(this.config.env);
|
|
176
182
|
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
>(
|
|
183
|
+
const enabledFeaturesProperties = Object.entries(
|
|
184
|
+
this.config?.enabledFeatures ?? ({} as Record<string, boolean>),
|
|
185
|
+
).reduce<Record<string, string>>(
|
|
181
186
|
(acc, [key, value]) => ({
|
|
182
187
|
...acc,
|
|
183
188
|
[`enabledFeatures.${key}`]: `${value}`,
|
|
@@ -251,6 +256,36 @@ export class AmplitudeService {
|
|
|
251
256
|
}
|
|
252
257
|
}
|
|
253
258
|
|
|
259
|
+
static mapWidgetTypeToChatComponent(widgetType: unknown): string {
|
|
260
|
+
switch (widgetType) {
|
|
261
|
+
case WidgetTypeV3.FloatingButtonV3:
|
|
262
|
+
return 'floating_button';
|
|
263
|
+
case WidgetTypeV3.ChatPreviewV3:
|
|
264
|
+
case WidgetTypeV3.SocialProofV3:
|
|
265
|
+
return 'embedded_widget';
|
|
266
|
+
case WidgetTypeV3.TitledPromptCarouselV3:
|
|
267
|
+
case WidgetTypeV3.PromptCarouselV3:
|
|
268
|
+
return 'suggestion_bar';
|
|
269
|
+
default:
|
|
270
|
+
return 'unknown';
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// This allows us to map the event props to the correct format for the legacy amplitude events
|
|
275
|
+
static mapEventProps({ eventName, eventProps }: TrackEventParams): Record<string, unknown> {
|
|
276
|
+
if (eventName === SpiffyMetricsEventName.ChatComponentVisible) {
|
|
277
|
+
const mappedWidgetType = AmplitudeService.mapWidgetTypeToChatComponent(
|
|
278
|
+
eventProps?.widget_type,
|
|
279
|
+
);
|
|
280
|
+
return {
|
|
281
|
+
...eventProps,
|
|
282
|
+
chat_component: mappedWidgetType,
|
|
283
|
+
'chat.component_visible': true,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return eventProps ?? {};
|
|
287
|
+
}
|
|
288
|
+
|
|
254
289
|
async trackEvent({
|
|
255
290
|
eventName,
|
|
256
291
|
eventProps,
|
|
@@ -268,9 +303,11 @@ export class AmplitudeService {
|
|
|
268
303
|
return;
|
|
269
304
|
}
|
|
270
305
|
|
|
306
|
+
const mappedEventProps = AmplitudeService.mapEventProps({ eventName, eventProps });
|
|
307
|
+
|
|
271
308
|
const eventData = JSON.stringify({
|
|
272
309
|
eventName,
|
|
273
|
-
eventProps,
|
|
310
|
+
eventProps: mappedEventProps,
|
|
274
311
|
created_at: new Date().toISOString(),
|
|
275
312
|
});
|
|
276
313
|
const encoder = new TextEncoder();
|
|
@@ -283,15 +320,17 @@ export class AmplitudeService {
|
|
|
283
320
|
|
|
284
321
|
Logger.logDebug(`amplitude tracking ${decoratedEventName}`, null, {
|
|
285
322
|
event_name: decoratedEventName,
|
|
286
|
-
props:
|
|
323
|
+
props: mappedEventProps,
|
|
287
324
|
});
|
|
288
325
|
|
|
289
326
|
this.amplitudeClient.track(
|
|
290
327
|
decoratedEventName,
|
|
291
328
|
{
|
|
292
329
|
...this.getDefaultTrackingProps(),
|
|
293
|
-
...
|
|
294
|
-
...(
|
|
330
|
+
...mappedEventProps,
|
|
331
|
+
...(mappedEventProps
|
|
332
|
+
? this.eventPropsToPrefixedEventProps(eventName, mappedEventProps)
|
|
333
|
+
: {}),
|
|
295
334
|
},
|
|
296
335
|
{
|
|
297
336
|
...eventGroups,
|
|
@@ -318,6 +357,7 @@ export class AmplitudeService {
|
|
|
318
357
|
}
|
|
319
358
|
}
|
|
320
359
|
|
|
360
|
+
// Ensure that supplemental default props are merged with the existing props
|
|
321
361
|
setSupplementalDefaultProps(props: Record<string, unknown>): void {
|
|
322
362
|
this.supplementalDefaultProps = props;
|
|
323
363
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './userIdentityService';
|