@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,6 +1,7 @@
|
|
|
1
1
|
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
|
|
2
2
|
import { ReactNode, createContext, useCallback, useEffect, useMemo } from 'react';
|
|
3
3
|
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
4
|
+
import Logger from 'src/application/logging/logger';
|
|
4
5
|
import { Message, MessageRole, MessageType } from 'src/application/models/message';
|
|
5
6
|
import { NextMessageRequest, Suggestion, UserEvent } from 'src/application/models';
|
|
6
7
|
import {
|
|
@@ -16,6 +17,10 @@ import {
|
|
|
16
17
|
userQueueEventCountAtom,
|
|
17
18
|
} from 'src/atoms/chat/messageQueue';
|
|
18
19
|
import { useSystemSettingsContext } from 'src/hooks/SystemSettingsContext';
|
|
20
|
+
import {
|
|
21
|
+
buildFormSubmittedDisplayContent,
|
|
22
|
+
createFormSubmittedUserMessage,
|
|
23
|
+
} from './formSubmittedUtils';
|
|
19
24
|
import { SalesAgentChatAPI, useSalesAgentChatAPI } from './chatAPI';
|
|
20
25
|
import { useSalesAgentService } from './salesAgentService';
|
|
21
26
|
|
|
@@ -34,19 +39,48 @@ export interface SalesAgent extends SalesAgentChatAPI {
|
|
|
34
39
|
isInitialized: boolean;
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
export interface MockSalesAgentData {
|
|
43
|
+
messages?: Message[][];
|
|
44
|
+
suggestions?: Suggestion[];
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
const SalesAgentContext = createContext<SalesAgent | undefined>(undefined);
|
|
38
48
|
|
|
39
|
-
export
|
|
49
|
+
export interface SalesAgentProviderProps {
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
previewMode?: boolean;
|
|
52
|
+
mockData?: MockSalesAgentData;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const SalesAgentProvider: React.FC<SalesAgentProviderProps> = ({
|
|
56
|
+
children,
|
|
57
|
+
previewMode = false,
|
|
58
|
+
mockData,
|
|
59
|
+
}) => {
|
|
40
60
|
const userEvents = useAtomValue(userEventQueueAtom);
|
|
41
61
|
const userQueueEventCount = useAtomValue(userQueueEventCountAtom);
|
|
42
62
|
const markUserEventsProcessed = useSetAtom(processUserEventAtom);
|
|
43
63
|
const [isInitialized, setIsInitialized] = useAtom(initializedAtom);
|
|
44
64
|
const settingsContext = useSystemSettingsContext();
|
|
45
65
|
const setMessages = useSetAtom(messagesAtom);
|
|
66
|
+
const setSuggestions = useSetAtom(suggestionsAtom);
|
|
46
67
|
|
|
47
68
|
const { getStreamingResponses, createResponsePayload, getSuggestions, hydrateMessages } =
|
|
48
69
|
useSalesAgentService();
|
|
49
70
|
|
|
71
|
+
// Initialize with mock data in preview mode
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (previewMode && mockData) {
|
|
74
|
+
if (mockData.messages) {
|
|
75
|
+
setMessages(mockData.messages);
|
|
76
|
+
}
|
|
77
|
+
if (mockData.suggestions) {
|
|
78
|
+
setSuggestions(mockData.suggestions);
|
|
79
|
+
}
|
|
80
|
+
setIsInitialized(true);
|
|
81
|
+
}
|
|
82
|
+
}, [previewMode, mockData, setMessages, setSuggestions, setIsInitialized]);
|
|
83
|
+
|
|
50
84
|
// TODO: Ensure that amplitude events are being emitted
|
|
51
85
|
|
|
52
86
|
// TODO: Add support for the streaming responses to function
|
|
@@ -55,27 +89,27 @@ export const SalesAgentProvider: React.FC<{ children: ReactNode }> = ({ children
|
|
|
55
89
|
const sendMessagesToBackend = useCallback(
|
|
56
90
|
async (requestPayload: NextMessageRequest) => {
|
|
57
91
|
try {
|
|
58
|
-
|
|
92
|
+
await getStreamingResponses(requestPayload);
|
|
59
93
|
setIsInitialized(true);
|
|
60
94
|
|
|
61
|
-
console.log('response', response);
|
|
62
95
|
// Remove the pending message from the user events
|
|
63
96
|
requestPayload.userEvents?.map(userEvent => markUserEventsProcessed([userEvent.eventId]));
|
|
64
97
|
} catch (error) {
|
|
65
|
-
|
|
98
|
+
Logger.logError('[envive-ai] error sending message', error);
|
|
66
99
|
}
|
|
67
100
|
},
|
|
68
101
|
[getStreamingResponses, setIsInitialized, markUserEventsProcessed],
|
|
69
102
|
);
|
|
70
103
|
|
|
71
|
-
console.log('userQueueEventCount', userQueueEventCount);
|
|
72
|
-
console.log('userEvents', userEvents);
|
|
73
|
-
|
|
74
104
|
// This is the primary event loop for communicating with the backend API
|
|
75
105
|
// It will be triggered when there are pending messages to be sent to the backend
|
|
76
106
|
// It will be responsible for sending the messages to the backend and receiving the responses
|
|
77
107
|
useEffect(() => {
|
|
78
|
-
|
|
108
|
+
// Skip backend communication in preview mode
|
|
109
|
+
if (previewMode) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
79
113
|
if (userQueueEventCount > 0) {
|
|
80
114
|
const payloadEvents = userEvents.slice(0, userQueueEventCount);
|
|
81
115
|
|
|
@@ -104,6 +138,23 @@ export const SalesAgentProvider: React.FC<{ children: ReactNode }> = ({ children
|
|
|
104
138
|
};
|
|
105
139
|
setMessages(current => [...current, [newMessage]]);
|
|
106
140
|
}
|
|
141
|
+
if (userEvent && userEvent.category === UserEventCategory.FormSubmitted) {
|
|
142
|
+
const { formResponseId, filledSchema } = userEvent.attributes;
|
|
143
|
+
setMessages(prevMessagesState => {
|
|
144
|
+
const formSubmittedContent = buildFormSubmittedDisplayContent(
|
|
145
|
+
prevMessagesState,
|
|
146
|
+
formResponseId,
|
|
147
|
+
filledSchema,
|
|
148
|
+
);
|
|
149
|
+
const newUserMessage = createFormSubmittedUserMessage(userEvent, formSubmittedContent);
|
|
150
|
+
const turnsWithoutForm = prevMessagesState
|
|
151
|
+
.map(turn =>
|
|
152
|
+
turn.filter(msg => !(msg.type === MessageType.Form && msg.id === formResponseId)),
|
|
153
|
+
)
|
|
154
|
+
.filter(turn => turn.length > 0);
|
|
155
|
+
return [...turnsWithoutForm, [newUserMessage]];
|
|
156
|
+
});
|
|
157
|
+
}
|
|
107
158
|
});
|
|
108
159
|
|
|
109
160
|
sendMessagesToBackend(
|
|
@@ -129,14 +180,20 @@ export const SalesAgentProvider: React.FC<{ children: ReactNode }> = ({ children
|
|
|
129
180
|
settingsContext.generationParams,
|
|
130
181
|
userEvents,
|
|
131
182
|
userQueueEventCount,
|
|
183
|
+
previewMode,
|
|
132
184
|
]);
|
|
133
185
|
|
|
134
186
|
useEffect(() => {
|
|
187
|
+
// Skip hydration in preview mode
|
|
188
|
+
if (previewMode) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
135
192
|
if (isInitialized) {
|
|
136
193
|
// Rehydrate any messages from the backend
|
|
137
194
|
hydrateMessages();
|
|
138
195
|
}
|
|
139
|
-
}, [isInitialized, hydrateMessages]);
|
|
196
|
+
}, [isInitialized, hydrateMessages, previewMode]);
|
|
140
197
|
|
|
141
198
|
return <SalesAgentContext.Provider value={undefined}>{children}</SalesAgentContext.Provider>;
|
|
142
199
|
};
|
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
suggestionsAtom,
|
|
23
23
|
} from 'src/atoms/chat/chatState';
|
|
24
24
|
import { useMessageInterceptor } from 'src/interceptors/useMessageInterceptor';
|
|
25
|
-
import {
|
|
25
|
+
import { SpiffyMetricsEventName, useAmplitude } from 'src/contexts/amplitudeContext';
|
|
26
|
+
import { useFeatureFlagService } from 'src/contexts/featureFlagServiceContext';
|
|
27
|
+
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
28
|
+
|
|
26
29
|
import { StatusCodeError } from './statusCodeError';
|
|
27
30
|
|
|
28
31
|
interface SalesAgentService {
|
|
@@ -35,6 +38,27 @@ interface SalesAgentService {
|
|
|
35
38
|
hydrateMessages: () => Promise<void>;
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
const inputPropsToTrackingProps = (
|
|
42
|
+
payload: NextMessageRequest,
|
|
43
|
+
): Record<string, unknown> | undefined => {
|
|
44
|
+
const [userEvent] = payload.userEvents || [];
|
|
45
|
+
if (userEvent.category === UserEventCategory.SuggestionClicked) {
|
|
46
|
+
return {
|
|
47
|
+
message_id: userEvent.eventId,
|
|
48
|
+
user_event_type: 'suggestion_clicked',
|
|
49
|
+
user_query: userEvent.attributes.content,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (userEvent.category === UserEventCategory.QueryTyped) {
|
|
53
|
+
return {
|
|
54
|
+
message_id: userEvent.eventId,
|
|
55
|
+
user_event_type: 'query_typed',
|
|
56
|
+
user_query: userEvent.attributes.query,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {};
|
|
60
|
+
};
|
|
61
|
+
|
|
38
62
|
export const getQueryParam = (key: string): string | null => {
|
|
39
63
|
const urlObj = new URL(window.location.href);
|
|
40
64
|
return urlObj.searchParams.get(key);
|
|
@@ -115,6 +139,7 @@ const processStreamingResponse = async (
|
|
|
115
139
|
setResponseStreaming: (responseStreaming: boolean) => void,
|
|
116
140
|
): Promise<void> => {
|
|
117
141
|
let lastMessage: Message | undefined;
|
|
142
|
+
setResponseStreaming(true);
|
|
118
143
|
|
|
119
144
|
for await (const response of stream) {
|
|
120
145
|
try {
|
|
@@ -126,8 +151,6 @@ const processStreamingResponse = async (
|
|
|
126
151
|
throw new Error('No response from stream');
|
|
127
152
|
}
|
|
128
153
|
|
|
129
|
-
setResponseStreaming(true);
|
|
130
|
-
|
|
131
154
|
const message = messageFromResponse(response);
|
|
132
155
|
if (!message) {
|
|
133
156
|
throw new Error('Failed to transform API response to client message');
|
|
@@ -148,6 +171,7 @@ const processStreamingResponse = async (
|
|
|
148
171
|
response,
|
|
149
172
|
});
|
|
150
173
|
}
|
|
174
|
+
setResponseStreaming(false);
|
|
151
175
|
}
|
|
152
176
|
};
|
|
153
177
|
|
|
@@ -158,6 +182,7 @@ export const useSalesAgentService: () => SalesAgentService = () => {
|
|
|
158
182
|
const setPendingResponse = useSetAtom(pendingResponseAtom);
|
|
159
183
|
const setResponseStreaming = useSetAtom(responseStreamingAtom);
|
|
160
184
|
const messageInterceptor = useMessageInterceptor();
|
|
185
|
+
const { trackEvent } = useAmplitude();
|
|
161
186
|
|
|
162
187
|
const featureFlagService = useFeatureFlagService();
|
|
163
188
|
const context = useAtomValue(appDetailsAtom);
|
|
@@ -192,10 +217,9 @@ export const useSalesAgentService: () => SalesAgentService = () => {
|
|
|
192
217
|
|
|
193
218
|
const getStreamingResponses = useCallback(
|
|
194
219
|
async (payload: NextMessageRequest): Promise<void> => {
|
|
195
|
-
|
|
196
|
-
|
|
220
|
+
const startTime = Date.now();
|
|
221
|
+
let successfulResponse: boolean | undefined;
|
|
197
222
|
setPendingResponse(true);
|
|
198
|
-
console.log('getStreamingResponses payload', JSON.stringify(payload, null, 2));
|
|
199
223
|
const stream = CommerceApiClient.getNextResponseStreaming(payload);
|
|
200
224
|
|
|
201
225
|
try {
|
|
@@ -207,10 +231,9 @@ export const useSalesAgentService: () => SalesAgentService = () => {
|
|
|
207
231
|
setMessages,
|
|
208
232
|
setResponseStreaming,
|
|
209
233
|
);
|
|
234
|
+
successfulResponse = true;
|
|
210
235
|
|
|
211
236
|
// TODO: Add support for the Chrome Extension communication
|
|
212
|
-
// Log successful next_responses call
|
|
213
|
-
// const responseTime = Date.now() - startTime;
|
|
214
237
|
// await logBundleEvent({
|
|
215
238
|
// level: 'info',
|
|
216
239
|
// event: 'NEXT_RESPONSE_SUCCESS',
|
|
@@ -223,6 +246,7 @@ export const useSalesAgentService: () => SalesAgentService = () => {
|
|
|
223
246
|
// });
|
|
224
247
|
} catch (e) {
|
|
225
248
|
console.error('error getting streaming responses', e);
|
|
249
|
+
successfulResponse = false;
|
|
226
250
|
// Log failed next_responses call
|
|
227
251
|
// const responseTime = Date.now() - startTime;
|
|
228
252
|
// await logBundleEvent({
|
|
@@ -240,6 +264,16 @@ export const useSalesAgentService: () => SalesAgentService = () => {
|
|
|
240
264
|
handleStreamingError(e, setRequestFailure, setMessages);
|
|
241
265
|
throw e;
|
|
242
266
|
} finally {
|
|
267
|
+
// Log next_responses call
|
|
268
|
+
const responseTime = Date.now() - startTime;
|
|
269
|
+
trackEvent({
|
|
270
|
+
eventName: SpiffyMetricsEventName.ChatAssistantResponse,
|
|
271
|
+
eventProps: {
|
|
272
|
+
responseTimeMs: responseTime.toString(),
|
|
273
|
+
successful_response: successfulResponse,
|
|
274
|
+
...inputPropsToTrackingProps(payload),
|
|
275
|
+
},
|
|
276
|
+
});
|
|
243
277
|
setPendingResponse(false);
|
|
244
278
|
setResponseStreaming(false);
|
|
245
279
|
// logPerfMetric(PerfMetricsEvents.FirstResponseCompleted);
|
|
@@ -264,14 +298,11 @@ export const useSalesAgentService: () => SalesAgentService = () => {
|
|
|
264
298
|
|
|
265
299
|
const hydrateMessages = useCallback(async () => {
|
|
266
300
|
const { orgId, chatId, userId } = context;
|
|
267
|
-
console.log('hydrateMessages', orgId, chatId, userId, context);
|
|
268
301
|
const { messages: existingMessages, userEvents } = await CommerceApiClient.getResponses(
|
|
269
302
|
orgId,
|
|
270
303
|
chatId,
|
|
271
304
|
userId,
|
|
272
305
|
);
|
|
273
|
-
console.log('existingMessages', existingMessages);
|
|
274
|
-
console.log('userEvents', userEvents);
|
|
275
306
|
setMessages([...existingMessages]);
|
|
276
307
|
}, [context, setMessages]);
|
|
277
308
|
|
|
@@ -21,6 +21,7 @@ import { SearchResult } from 'src/application/models/api/search';
|
|
|
21
21
|
|
|
22
22
|
import { useAppDetails } from 'src/hooks/AppDetails/useAppDetails';
|
|
23
23
|
import * as commerceApiClient from '@spiffy-ai/commerce-api-client';
|
|
24
|
+
import { UserIdentityService } from 'src/services/userIdentityService';
|
|
24
25
|
import { SearchProvider, useSearchService } from '../searchContext';
|
|
25
26
|
|
|
26
27
|
// Mock the commerce-api-client
|
|
@@ -61,6 +62,7 @@ vi.mock('@spiffy-ai/commerce-api-client', () => {
|
|
|
61
62
|
|
|
62
63
|
// FeatureFlagService
|
|
63
64
|
const testFeatureFlagService = new FeatureFlagService([]);
|
|
65
|
+
const testUserIdService = new UserIdentityService({ apiKey: '' });
|
|
64
66
|
|
|
65
67
|
// Mock useAppDetails
|
|
66
68
|
vi.mock('src/hooks/AppDetails/useAppDetails', () => ({
|
|
@@ -197,7 +199,7 @@ const TestWrapper: React.FC<{
|
|
|
197
199
|
>
|
|
198
200
|
<LocalStorageProvider>
|
|
199
201
|
<GraphQLProvider>
|
|
200
|
-
<UserIdentityProvider>
|
|
202
|
+
<UserIdentityProvider userIdService={testUserIdService}>
|
|
201
203
|
<FeatureFlagServiceProvider featureFlagService={testFeatureFlagService}>
|
|
202
204
|
<SearchProvider>{children}</SearchProvider>
|
|
203
205
|
</FeatureFlagServiceProvider>
|
package/src/contexts/typesV3.ts
CHANGED
|
@@ -3,8 +3,9 @@ import { ImageGalleryImage, ImageGalleryLayout } from '@envive-ai/react-toolkit-
|
|
|
3
3
|
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton';
|
|
4
4
|
import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
|
|
5
5
|
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
6
|
-
import { DynamicLayout } from '@envive-ai/react-toolkit-v3/SocialProof';
|
|
6
|
+
import { DynamicLayout, WidgetKind } from '@envive-ai/react-toolkit-v3/SocialProof';
|
|
7
7
|
import { SparkleIconColor } from '@envive-ai/react-toolkit-v3/WelcomeMessage';
|
|
8
|
+
import { FloatingButtonLocation } from '@envive-ai/react-toolkit-v3/FloatingButton';
|
|
8
9
|
import { ColorNames } from '../application/models/colorsConfigV3';
|
|
9
10
|
import { CustomerServiceType } from '../types/customerService';
|
|
10
11
|
import type { MerchantVariantSettings, SearchConfig } from './types';
|
|
@@ -170,14 +171,12 @@ type ConfigVersion = ConfigVersionEnum.V3 | ConfigVersionEnum.Deprecated | undef
|
|
|
170
171
|
|
|
171
172
|
type Mode = 'dark' | 'light';
|
|
172
173
|
|
|
173
|
-
type Position = 'bottomLeft' | 'middleLeft' | 'middleRight' | 'bottomRight';
|
|
174
|
-
|
|
175
174
|
type ShowOptions = 'always' | 'postInteraction' | 'none';
|
|
176
175
|
|
|
177
176
|
type Style = 'attached' | 'detached';
|
|
178
177
|
|
|
179
178
|
type FloatingButtonConfig = {
|
|
180
|
-
position:
|
|
179
|
+
position: FloatingButtonLocation;
|
|
181
180
|
backgroundColor?: string;
|
|
182
181
|
mode: Mode;
|
|
183
182
|
showOption: ShowOptions;
|
|
@@ -241,6 +240,7 @@ export enum WidgetTypeV3 {
|
|
|
241
240
|
SingleImagePromptV3 = 'SingleImagePromptV3',
|
|
242
241
|
FloatingChatV3 = 'FloatingChatV3',
|
|
243
242
|
FloatingButtonV3 = 'FloatingButtonV3',
|
|
243
|
+
ProductCardV3 = 'ProductCardV3',
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
interface BaseWidgetConfig<T extends WidgetTypeV3> {
|
|
@@ -262,13 +262,8 @@ interface TitledPromptCarouselWidgetV3Config extends BaseWidgetConfig<WidgetType
|
|
|
262
262
|
promptCarouselRows?: PromptCarouselRows;
|
|
263
263
|
animationSpeed?: AnimationSpeed;
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
enum SocialProofWidgetKind {
|
|
267
|
-
STATIC = 'static',
|
|
268
|
-
DYNAMIC = 'dynamic',
|
|
269
|
-
}
|
|
270
265
|
interface SocialProofWidgetV3Config extends BaseWidgetConfig<WidgetTypeV3.SocialProofV3> {
|
|
271
|
-
kind:
|
|
266
|
+
kind: WidgetKind;
|
|
272
267
|
variant: WidgetWrapperVariant;
|
|
273
268
|
hexCardColor?: string;
|
|
274
269
|
promptCarouselRows: PromptCarouselRows;
|
|
@@ -316,6 +311,13 @@ interface PromptButtonCarouselWithImageWidgetV3Config extends BaseWidgetConfig<W
|
|
|
316
311
|
|
|
317
312
|
interface FloatingChatWidgetV3Config extends BaseWidgetConfig<WidgetTypeV3.FloatingChatV3> {}
|
|
318
313
|
|
|
314
|
+
interface ProductCardWidgetV3Config extends BaseWidgetConfig<WidgetTypeV3.ProductCardV3> {
|
|
315
|
+
promptButtonType?: PromptButtonVariant;
|
|
316
|
+
italicizeHeadline?: boolean;
|
|
317
|
+
fallbackColor?: string;
|
|
318
|
+
imageSrc?: string;
|
|
319
|
+
}
|
|
320
|
+
|
|
319
321
|
type WidgetConfigV3 =
|
|
320
322
|
| PromptCarouselWidgetV3Config
|
|
321
323
|
| SocialProofWidgetV3Config
|
|
@@ -325,7 +327,8 @@ type WidgetConfigV3 =
|
|
|
325
327
|
| TypingAnimationWidgetV3Config
|
|
326
328
|
| ChatPreviewWidgetV3Config
|
|
327
329
|
| PromptButtonCarouselWithImageWidgetV3Config
|
|
328
|
-
| FloatingChatWidgetV3Config
|
|
330
|
+
| FloatingChatWidgetV3Config
|
|
331
|
+
| ProductCardWidgetV3Config;
|
|
329
332
|
|
|
330
333
|
export type {
|
|
331
334
|
OrgUIConfigV3,
|
|
@@ -340,9 +343,8 @@ export type {
|
|
|
340
343
|
TypingAnimationWidgetV3Config,
|
|
341
344
|
PromptButtonCarouselWithImageWidgetV3Config,
|
|
342
345
|
FloatingChatWidgetV3Config,
|
|
346
|
+
ProductCardWidgetV3Config,
|
|
343
347
|
FloatingChatConfig,
|
|
348
|
+
FloatingButtonConfig,
|
|
344
349
|
CustomerServiceIntegration,
|
|
345
|
-
Position,
|
|
346
350
|
};
|
|
347
|
-
|
|
348
|
-
export { SocialProofWidgetKind };
|
|
@@ -4,9 +4,10 @@ import Logger from 'src/application/logging/logger';
|
|
|
4
4
|
import { useNewOrgConfig } from 'src/hooks/NewOrgConfig';
|
|
5
5
|
import { SparkleIconColor } from '@envive-ai/react-toolkit-v3/WelcomeMessage';
|
|
6
6
|
import { ChatHeaderVariant } from '@envive-ai/react-toolkit-v3/ChatHeader';
|
|
7
|
+
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
8
|
+
import { FloatingButtonLocation } from '@envive-ai/react-toolkit-v3/FloatingButton';
|
|
7
9
|
import { UiConfigProvider, useUiConfig } from '../uiConfigContext';
|
|
8
10
|
import { ConfigVersionEnum, OrgUIConfigV3 } from '../../typesV3';
|
|
9
|
-
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
10
11
|
|
|
11
12
|
// Mock the Logger to avoid console output in tests
|
|
12
13
|
vi.spyOn(Logger, 'logInfo').mockImplementation(() => {});
|
|
@@ -107,7 +108,7 @@ describe('UiConfigProvider', () => {
|
|
|
107
108
|
},
|
|
108
109
|
},
|
|
109
110
|
floatingButton: {
|
|
110
|
-
position:
|
|
111
|
+
position: FloatingButtonLocation.BOTTOM_RIGHT,
|
|
111
112
|
backgroundColor: '#000000',
|
|
112
113
|
mode: 'light',
|
|
113
114
|
showOption: 'always',
|
|
@@ -5,6 +5,7 @@ import { userIdAtom } from 'src/atoms/app';
|
|
|
5
5
|
import { LocalStorageProvider } from 'src/contexts/localStorageContext';
|
|
6
6
|
import Logger from 'src/application/logging/logger';
|
|
7
7
|
import CommerceApiClient from 'src/application/commerce-api';
|
|
8
|
+
import { UserIdentityService } from 'src/services/userIdentityService';
|
|
8
9
|
import { UserIdentityProvider, useUserIdentity } from '../userIdentityContext';
|
|
9
10
|
|
|
10
11
|
// Mock the Logger to avoid console output in tests
|
|
@@ -24,20 +25,32 @@ vi.mock('uuid', () => ({
|
|
|
24
25
|
v4: vi.fn(() => 'test-uuid-12345'),
|
|
25
26
|
}));
|
|
26
27
|
|
|
28
|
+
// Mock userIdService
|
|
29
|
+
const mockGetUserId = vi.fn().mockResolvedValue('spiffy-user-id-test-user-id');
|
|
30
|
+
const mockInitializeUser = vi.fn().mockResolvedValue(undefined);
|
|
31
|
+
|
|
32
|
+
const testUserIdService = {
|
|
33
|
+
getUserIdOrDefault: mockGetUserId,
|
|
34
|
+
initializeUser: mockInitializeUser,
|
|
35
|
+
getUserIdOverrideFromLocalStorage: vi.fn().mockReturnValue(undefined),
|
|
36
|
+
} as unknown as UserIdentityService;
|
|
37
|
+
|
|
27
38
|
// Component that uses the useUserIdentity hook
|
|
28
39
|
const MockComponent: React.FC = () => {
|
|
29
40
|
const context = useUserIdentity();
|
|
41
|
+
const [userId, setUserId] = React.useState<string>('');
|
|
42
|
+
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
context.getUserIdOrDefault().then(setUserId);
|
|
45
|
+
}, [context]);
|
|
30
46
|
|
|
31
47
|
return (
|
|
32
48
|
<div data-testid="mock-component">
|
|
33
|
-
<div data-testid="user-id">{
|
|
49
|
+
<div data-testid="user-id">{userId}</div>
|
|
34
50
|
<div data-testid="is-ready">{context.isReady.toString()}</div>
|
|
35
51
|
<div data-testid="user-id-override">
|
|
36
52
|
{context.getUserIdOverrideFromLocalStorage() || 'none'}
|
|
37
53
|
</div>
|
|
38
|
-
<div data-testid="user-id-default">
|
|
39
|
-
{context.getUserIdDefaultFromLocalStorage() || 'none'}
|
|
40
|
-
</div>
|
|
41
54
|
</div>
|
|
42
55
|
);
|
|
43
56
|
};
|
|
@@ -122,7 +135,7 @@ describe('UserIdentityProvider', () => {
|
|
|
122
135
|
return render(
|
|
123
136
|
<Provider>
|
|
124
137
|
<LocalStorageProvider>
|
|
125
|
-
<UserIdentityProvider>{children}</UserIdentityProvider>
|
|
138
|
+
<UserIdentityProvider userIdService={testUserIdService}>{children}</UserIdentityProvider>
|
|
126
139
|
</LocalStorageProvider>
|
|
127
140
|
</Provider>,
|
|
128
141
|
);
|
|
@@ -220,50 +233,6 @@ describe('UserIdentityProvider', () => {
|
|
|
220
233
|
|
|
221
234
|
consoleSpy.mockRestore();
|
|
222
235
|
});
|
|
223
|
-
|
|
224
|
-
it('should set userIdAtom correctly when multiple components use useUserIdentity', async () => {
|
|
225
|
-
// Component that sets override - the atom will be set by useUserIdentity
|
|
226
|
-
const ComponentWithActions: React.FC = () => {
|
|
227
|
-
const context = useUserIdentity();
|
|
228
|
-
|
|
229
|
-
React.useEffect(() => {
|
|
230
|
-
// Set override on mount
|
|
231
|
-
context.setUserIdOverrideInLocalStorage('multi-component-override');
|
|
232
|
-
}, [context]);
|
|
233
|
-
|
|
234
|
-
// Get userId from context instead of atom directly
|
|
235
|
-
const userId = context.getUserIdOrDefault();
|
|
236
|
-
|
|
237
|
-
return (
|
|
238
|
-
<div>
|
|
239
|
-
<div data-testid="current-user-id">{userId}</div>
|
|
240
|
-
</div>
|
|
241
|
-
);
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
renderWithProviders(
|
|
245
|
-
<>
|
|
246
|
-
<ComponentWithActions />
|
|
247
|
-
<AtomReaderComponent />
|
|
248
|
-
</>,
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
// Wait for the atom to be set
|
|
252
|
-
await waitFor(() => {
|
|
253
|
-
const atomValue = screen.getByTestId('atom-reader').textContent;
|
|
254
|
-
expect(atomValue).not.toBe('not-set');
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Both components should see the same atom value
|
|
258
|
-
// Note: The atom is set by useUserIdentity's useEffect, which runs after
|
|
259
|
-
// the override is set in localStorage, so it should reflect the override
|
|
260
|
-
await waitFor(() => {
|
|
261
|
-
const atomValue = screen.getByTestId('atom-reader').textContent;
|
|
262
|
-
// The atom should be set to the override value since it was set before
|
|
263
|
-
// the component mounted, or it will be the generated default
|
|
264
|
-
expect(atomValue).toBeTruthy();
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
236
|
});
|
|
268
237
|
|
|
269
238
|
describe('getUserIdOrDefault', () => {
|
|
@@ -276,40 +245,6 @@ describe('UserIdentityProvider', () => {
|
|
|
276
245
|
expect(screen.getByTestId('user-id').textContent).toBe('override-123');
|
|
277
246
|
});
|
|
278
247
|
});
|
|
279
|
-
|
|
280
|
-
it('should return default userId if override does not exist', async () => {
|
|
281
|
-
localStorage.setItem('v1-spiffy-user-id-default', 'default-456');
|
|
282
|
-
|
|
283
|
-
renderWithProviders(<MockComponent />);
|
|
284
|
-
|
|
285
|
-
await waitFor(() => {
|
|
286
|
-
expect(screen.getByTestId('user-id').textContent).toBe('default-456');
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('should generate and store new userId if neither exists', async () => {
|
|
291
|
-
renderWithProviders(<MockComponent />);
|
|
292
|
-
|
|
293
|
-
await waitFor(() => {
|
|
294
|
-
const userId = screen.getByTestId('user-id').textContent;
|
|
295
|
-
expect(userId).toContain('spiffy-user-id-');
|
|
296
|
-
expect(userId).toContain('test-uuid-12345');
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
// Verify it was stored in localStorage
|
|
300
|
-
expect(localStorage.getItem('v1-spiffy-user-id-default')).toContain('spiffy-user-id-');
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it('should prioritize override over default', async () => {
|
|
304
|
-
localStorage.setItem('v1-spiffy-user-id-override', 'override-789');
|
|
305
|
-
localStorage.setItem('v1-spiffy-user-id-default', 'default-012');
|
|
306
|
-
|
|
307
|
-
renderWithProviders(<MockComponent />);
|
|
308
|
-
|
|
309
|
-
await waitFor(() => {
|
|
310
|
-
expect(screen.getByTestId('user-id').textContent).toBe('override-789');
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
248
|
});
|
|
314
249
|
|
|
315
250
|
describe('LocalStorage Operations', () => {
|
|
@@ -323,33 +258,6 @@ describe('UserIdentityProvider', () => {
|
|
|
323
258
|
});
|
|
324
259
|
});
|
|
325
260
|
|
|
326
|
-
it('should get userId default from localStorage', async () => {
|
|
327
|
-
localStorage.setItem('v1-spiffy-user-id-default', 'test-default');
|
|
328
|
-
|
|
329
|
-
renderWithProviders(<MockComponent />);
|
|
330
|
-
|
|
331
|
-
await waitFor(() => {
|
|
332
|
-
expect(screen.getByTestId('user-id-default').textContent).toBe('test-default');
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
it('should set userId default in localStorage', async () => {
|
|
337
|
-
const ComponentWithSet: React.FC = () => {
|
|
338
|
-
const context = useUserIdentity();
|
|
339
|
-
React.useEffect(() => {
|
|
340
|
-
context.setUserIdDefaultInLocalStorage('new-default-id');
|
|
341
|
-
}, [context]);
|
|
342
|
-
|
|
343
|
-
return <div data-testid="set-component">Set</div>;
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
renderWithProviders(<ComponentWithSet />);
|
|
347
|
-
|
|
348
|
-
await waitFor(() => {
|
|
349
|
-
expect(localStorage.getItem('v1-spiffy-user-id-default')).toBe('new-default-id');
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
|
|
353
261
|
it('should set userId override in localStorage', async () => {
|
|
354
262
|
const ComponentWithSet: React.FC = () => {
|
|
355
263
|
const context = useUserIdentity();
|
|
@@ -386,27 +294,6 @@ describe('UserIdentityProvider', () => {
|
|
|
386
294
|
});
|
|
387
295
|
});
|
|
388
296
|
|
|
389
|
-
it('should log info when setting userId default', async () => {
|
|
390
|
-
const logSpy = vi.spyOn(Logger, 'logInfo');
|
|
391
|
-
|
|
392
|
-
const ComponentWithSet: React.FC = () => {
|
|
393
|
-
const context = useUserIdentity();
|
|
394
|
-
React.useEffect(() => {
|
|
395
|
-
context.setUserIdDefaultInLocalStorage('logged-default-id');
|
|
396
|
-
}, [context]);
|
|
397
|
-
|
|
398
|
-
return <div>Set</div>;
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
renderWithProviders(<ComponentWithSet />);
|
|
402
|
-
|
|
403
|
-
await waitFor(() => {
|
|
404
|
-
expect(logSpy).toHaveBeenCalledWith(
|
|
405
|
-
'setUserIdDefaultInLocalStorage - Setting user_id=logged-default-id',
|
|
406
|
-
);
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
|
|
410
297
|
it('should log info when setting userId override', async () => {
|
|
411
298
|
const logSpy = vi.spyOn(Logger, 'logInfo');
|
|
412
299
|
|