@envive-ai/react-widgets-v3 0.3.15-alpha.1 → 0.3.15-alpha.2
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/hocs/withBaseWidget/types.d.cts +5 -6
- package/dist/hocs/withBaseWidget/types.d.ts +5 -7
- package/dist/hocs/withBaseWidget/withBaseWidget.cjs +37 -43
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.js +39 -45
- package/dist/packages/hooks/dist/application/models/api/orgConfigResults.d.ts +2 -1
- package/dist/packages/hooks/dist/application/models/api/userEvent.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/types.d.ts +3 -1
- package/dist/packages/hooks/dist/contexts/typesV3.d.ts +1 -1
- package/dist/packages/hooks/dist/types/custservice-types.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/pageVisitInfo.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/variantInfo.d.ts +2 -1
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/types.d.ts +1 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +2 -11
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +4 -13
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +44 -21
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +44 -21
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +34 -34
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +3 -1
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +35 -35
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +1 -11
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +3 -13
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +2 -11
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +4 -13
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +1 -10
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +3 -12
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +2 -11
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +4 -13
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +0 -9
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +2 -11
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +1 -10
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +3 -12
- package/package.json +1 -1
- package/dist/hooks/dist/services/amplitudeService/eventNames.d.cts +0 -43
- package/dist/packages/hooks/dist/contexts/amplitudeContext/amplitudeContext.d.ts +0 -2
- package/dist/packages/hooks/dist/contexts/amplitudeContext/index.d.ts +0 -2
- package/dist/packages/hooks/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +0 -2
- package/dist/packages/hooks/dist/services/amplitudeService/amplitudeService.d.ts +0 -1
- package/dist/packages/hooks/dist/services/amplitudeService/eventNames.d.ts +0 -43
- package/dist/src/CXIntegration/hooks/useUnifiedCXButton.d.ts +0 -10
- package/dist/src/CXIntegration/hooks/useUnifiedCXButton.js +0 -29
- package/dist/src/CXIntegration/implementations/useDefaultUnifiedCXButton.d.ts +0 -2
- package/dist/src/CXIntegration/implementations/useDefaultUnifiedCXButton.js +0 -6
- package/dist/src/CXIntegration/implementations/useEightByEightUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useEightByEightUnifiedCXButton.js +0 -63
- package/dist/src/CXIntegration/implementations/useGladlyUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useGladlyUnifiedCXButton.js +0 -23
- package/dist/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.js +0 -54
- package/dist/src/CXIntegration/implementations/useGrooveUnifiedCXButton.d.ts +0 -18
- package/dist/src/CXIntegration/implementations/useGrooveUnifiedCXButton.js +0 -48
- package/dist/src/CXIntegration/implementations/useHelpScoutUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useHelpScoutUnifiedCXButton.js +0 -84
- package/dist/src/CXIntegration/implementations/useKustomerUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useKustomerUnifiedCXButton.js +0 -86
- package/dist/src/CXIntegration/implementations/useReDoUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useReDoUnifiedCXButton.js +0 -59
- package/dist/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.js +0 -62
- package/dist/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.js +0 -49
- package/dist/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useTalkdeskUnifiedCXButton.js +0 -77
- package/dist/src/CXIntegration/implementations/useTidioUnifiedCXButton.d.ts +0 -13
- package/dist/src/CXIntegration/implementations/useTidioUnifiedCXButton.js +0 -20
- package/dist/src/CXIntegration/implementations/useZendeskUnifiedCXButton.d.ts +0 -5
- package/dist/src/CXIntegration/implementations/useZendeskUnifiedCXButton.js +0 -55
- package/dist/src/CXIntegration/implementations/useZowieUnifiedCXButton.d.ts +0 -13
- package/dist/src/CXIntegration/implementations/useZowieUnifiedCXButton.js +0 -20
- package/dist/src/CXIntegration/types.d.ts +0 -26
- package/dist/src/CXIntegration/types.js +0 -17
- package/dist/src/CXIntegration/utils/functions.d.ts +0 -2
- package/dist/src/CXIntegration/utils/functions.js +0 -57
- package/dist/src/debug/GenericSelect.d.ts +0 -11
- package/dist/src/debug/GenericSelect.js +0 -151
- package/dist/src/debug/MessageContent.d.ts +0 -4
- package/dist/src/debug/MessageContent.js +0 -87
- package/dist/src/debug/chatEmbed.d.ts +0 -2
- package/dist/src/debug/chatEmbed.js +0 -58
- package/dist/src/debug/debugBar.d.ts +0 -1
- package/dist/src/debug/debugBar.js +0 -9
- package/dist/src/debug/reportIssue.d.ts +0 -1
- package/dist/src/debug/reportIssue.js +0 -322
- package/dist/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.d.ts +0 -1
- package/dist/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.js +0 -452
- package/dist/src/hocs/withBaseWidget/index.d.ts +0 -2
- package/dist/src/hocs/withBaseWidget/index.js +0 -1
- package/dist/src/hocs/withBaseWidget/types.d.ts +0 -33
- package/dist/src/hocs/withBaseWidget/types.js +0 -0
- package/dist/src/hocs/withBaseWidget/withBaseWidget.d.ts +0 -5
- package/dist/src/hocs/withBaseWidget/withBaseWidget.js +0 -80
- package/dist/src/stories/FloatingChatWidget.stories.d.ts +0 -25
- package/dist/src/stories/FloatingChatWidget.stories.js +0 -44
- package/dist/src/stories/FullPageSalesAgentWidget.stories.d.ts +0 -31
- package/dist/src/stories/FullPageSalesAgentWidget.stories.js +0 -51
- package/dist/src/stories/ProductCardWidget.stories.d.ts +0 -31
- package/dist/src/stories/ProductCardWidget.stories.js +0 -44
- package/dist/src/stories/PromptButtonCarouselWithImageWidget.stories.d.ts +0 -31
- package/dist/src/stories/PromptButtonCarouselWithImageWidget.stories.js +0 -40
- package/dist/src/stories/PromptCarouselWidget.stories.d.ts +0 -31
- package/dist/src/stories/PromptCarouselWidget.stories.js +0 -40
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.d.ts +0 -1
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.js +0 -40
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.stories.d.ts +0 -12
- package/dist/src/stories/SalesAgentTest/SalesAgentTest.stories.js +0 -12
- package/dist/src/stories/SalesAgentTest/index.d.ts +0 -0
- package/dist/src/stories/SalesAgentTest/index.js +0 -0
- package/dist/src/stories/SearchResults.stories.d.ts +0 -6
- package/dist/src/stories/SearchResults.stories.js +0 -23
- package/dist/src/stories/SearchZeroState.stories.d.ts +0 -38
- package/dist/src/stories/SearchZeroState.stories.js +0 -42
- package/dist/src/stories/SocialProofFlowWidget.stories.d.ts +0 -35
- package/dist/src/stories/SocialProofFlowWidget.stories.js +0 -60
- package/dist/src/stories/SuggestionBar.stories.d.ts +0 -7
- package/dist/src/stories/SuggestionBar.stories.js +0 -36
- package/dist/src/stories/TitledPromptCarouselWidget.stories.d.ts +0 -32
- package/dist/src/stories/TitledPromptCarouselWidget.stories.js +0 -55
- package/dist/src/stories/TypingAnimationFlowWidget.stories.d.ts +0 -34
- package/dist/src/stories/TypingAnimationFlowWidget.stories.js +0 -51
- package/dist/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +0 -12
- package/dist/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +0 -112
- package/dist/src/widgets/ChatPreviewComparisonWidget/index.d.ts +0 -3
- package/dist/src/widgets/ChatPreviewComparisonWidget/index.js +0 -2
- package/dist/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +0 -9
- package/dist/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +0 -34
- package/dist/src/widgets/ChatPreviewLoadingWidget/index.d.ts +0 -3
- package/dist/src/widgets/ChatPreviewLoadingWidget/index.js +0 -2
- package/dist/src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +0 -12
- package/dist/src/widgets/ChatPreviewWidget/ChatPreviewWidget.js +0 -111
- package/dist/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.d.ts +0 -1
- package/dist/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.js +0 -97
- package/dist/src/widgets/ChatPreviewWidget/index.d.ts +0 -3
- package/dist/src/widgets/ChatPreviewWidget/index.js +0 -2
- package/dist/src/widgets/FloatingChatWidget/FloatingChatOverlay.d.ts +0 -14
- package/dist/src/widgets/FloatingChatWidget/FloatingChatOverlay.js +0 -44
- package/dist/src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +0 -8
- package/dist/src/widgets/FloatingChatWidget/FloatingChatWidget.js +0 -134
- package/dist/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.d.ts +0 -1
- package/dist/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.js +0 -100
- package/dist/src/widgets/FloatingChatWidget/constants.d.ts +0 -1
- package/dist/src/widgets/FloatingChatWidget/constants.js +0 -1
- package/dist/src/widgets/FloatingChatWidget/hooks/useAutoPopup.d.ts +0 -4
- package/dist/src/widgets/FloatingChatWidget/hooks/useAutoPopup.js +0 -51
- package/dist/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.d.ts +0 -11
- package/dist/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.js +0 -21
- package/dist/src/widgets/FloatingChatWidget/index.d.ts +0 -4
- package/dist/src/widgets/FloatingChatWidget/index.js +0 -3
- package/dist/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +0 -12
- package/dist/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +0 -14
- package/dist/src/widgets/FullPageSalesAgentWidget/index.d.ts +0 -1
- package/dist/src/widgets/FullPageSalesAgentWidget/index.js +0 -1
- package/dist/src/widgets/ProductCardWidget/ProductCardWidget.d.ts +0 -7
- package/dist/src/widgets/ProductCardWidget/ProductCardWidget.js +0 -94
- package/dist/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.d.ts +0 -1
- package/dist/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.js +0 -106
- package/dist/src/widgets/ProductCardWidget/index.d.ts +0 -2
- package/dist/src/widgets/ProductCardWidget/index.js +0 -1
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +0 -12
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +0 -88
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.d.ts +0 -1
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.js +0 -132
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/index.d.ts +0 -2
- package/dist/src/widgets/PromptButtonCarouselWithImageWidget/index.js +0 -2
- package/dist/src/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +0 -7
- package/dist/src/widgets/PromptCarouselWidget/PromptCarouselWidget.js +0 -74
- package/dist/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.d.ts +0 -1
- package/dist/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.js +0 -106
- package/dist/src/widgets/PromptCarouselWidget/index.d.ts +0 -2
- package/dist/src/widgets/PromptCarouselWidget/index.js +0 -1
- package/dist/src/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +0 -7
- package/dist/src/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +0 -25
- package/dist/src/widgets/SocialProofFlowWidget/index.d.ts +0 -3
- package/dist/src/widgets/SocialProofFlowWidget/index.js +0 -2
- package/dist/src/widgets/SocialProofWidget/SocialProofWidget.d.ts +0 -12
- package/dist/src/widgets/SocialProofWidget/SocialProofWidget.js +0 -203
- package/dist/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.d.ts +0 -1
- package/dist/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.js +0 -135
- package/dist/src/widgets/SocialProofWidget/index.d.ts +0 -2
- package/dist/src/widgets/SocialProofWidget/index.js +0 -1
- package/dist/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +0 -7
- package/dist/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +0 -75
- package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.d.ts +0 -1
- package/dist/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.js +0 -106
- package/dist/src/widgets/TitledPromptCarouselWidget/index.d.ts +0 -2
- package/dist/src/widgets/TitledPromptCarouselWidget/index.js +0 -1
- package/dist/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +0 -7
- package/dist/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +0 -25
- package/dist/src/widgets/TypingAnimationFlowWidget/index.d.ts +0 -3
- package/dist/src/widgets/TypingAnimationFlowWidget/index.js +0 -2
- package/dist/src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +0 -12
- package/dist/src/widgets/TypingAnimationWidget/TypingAnimationWidget.js +0 -126
- package/dist/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.d.ts +0 -1
- package/dist/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.js +0 -118
- package/dist/src/widgets/TypingAnimationWidget/index.d.ts +0 -2
- package/dist/src/widgets/TypingAnimationWidget/index.js +0 -1
- package/dist/src/widgets/__tests__/testUtils.d.ts +0 -60
- package/dist/src/widgets/__tests__/testUtils.js +0 -46
- package/dist/src/widgets/__tests__/trackEventCanary.test.d.ts +0 -1
- package/dist/src/widgets/__tests__/trackEventCanary.test.js +0 -37
- package/dist/src/widgets/hooks/useGetWidgetStatus.d.ts +0 -7
- package/dist/src/widgets/hooks/useGetWidgetStatus.js +0 -17
- package/dist/src/widgets/utils/functions.d.ts +0 -16
- package/dist/src/widgets/utils/functions.js +0 -87
- package/dist/src/widgets-v2/SearchResults/index.d.ts +0 -2
- package/dist/src/widgets-v2/SearchResults/index.js +0 -2
- package/dist/src/widgets-v2/SearchZeroState/index.d.ts +0 -2
- package/dist/src/widgets-v2/SearchZeroState/index.js +0 -2
- package/dist/src/widgets-v2/SuggestionBar/index.d.ts +0 -2
- package/dist/src/widgets-v2/SuggestionBar/index.js +0 -2
- package/dist/src/widgets-v2/SuggestionButtonContainer/index.d.ts +0 -2
- package/dist/src/widgets-v2/SuggestionButtonContainer/index.js +0 -2
- package/dist/tsdown.config.d.ts +0 -2
- package/dist/tsdown.config.js +0 -12
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
3
|
-
import { chatOnToggleAtom } from '@envive-ai/react-hooks/atoms/chat/chatState';
|
|
4
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName, useAmplitude, } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
5
|
-
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
6
|
-
import { WidgetTypeV3, } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
7
|
-
import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
|
|
8
|
-
import { WidgetInteractionComponent, WidgetInteractionType, } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
9
|
-
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
|
|
10
|
-
import { PromptCarouselRows, usePromptCarouselAnalytics, } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
11
|
-
import { TypingAnimation } from '@envive-ai/react-toolkit-v3/TypingAnimation';
|
|
12
|
-
import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
|
|
13
|
-
import { useSetAtom } from 'jotai';
|
|
14
|
-
import { useCallback, useEffect } from 'react';
|
|
15
|
-
import { withBaseWidget } from '../../hocs/withBaseWidget';
|
|
16
|
-
import { getStringIdForText } from '../utils/functions';
|
|
17
|
-
const mockButtonTexts = [
|
|
18
|
-
'Loading button 1',
|
|
19
|
-
'Loading button 2',
|
|
20
|
-
'Loading button 3',
|
|
21
|
-
'Loading button 4',
|
|
22
|
-
];
|
|
23
|
-
const mockTitleLabel = 'Loading...';
|
|
24
|
-
const mockHeadlineText = 'Loading';
|
|
25
|
-
const mockAnimatedTextSequence = ['...'];
|
|
26
|
-
const mockHintText = 'Ask me anything';
|
|
27
|
-
const TypingAnimationWidgetHandler = (props) => {
|
|
28
|
-
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
29
|
-
const onToggle = useSetAtom(chatOnToggleAtom);
|
|
30
|
-
const { hardcopyContent, widgetConfig, uiConfig, isLoading, widgetConfigId } = props;
|
|
31
|
-
const titleLabel = hardcopyContent?.values?.titleLabel || '';
|
|
32
|
-
const headlineText = hardcopyContent?.values?.headlineText || '';
|
|
33
|
-
const animatedTextSequence = hardcopyContent?.values?.animatedTextSequence || [];
|
|
34
|
-
const hintText = hardcopyContent?.values?.hintText;
|
|
35
|
-
const textFieldAriaLabel = hardcopyContent?.values?.textFieldAriaLabel;
|
|
36
|
-
const promptButtonTexts = hardcopyContent?.values?.promptButtonTexts || [];
|
|
37
|
-
const buttonTexts = isLoading ? mockButtonTexts : promptButtonTexts;
|
|
38
|
-
const typingAnimationWidgetConfig = widgetConfig;
|
|
39
|
-
const id = typingAnimationWidgetConfig?.contentId;
|
|
40
|
-
const widgetVariant = typingAnimationWidgetConfig?.widgetVariant ||
|
|
41
|
-
WidgetWrapperVariant.CARD_WITH_BORDER;
|
|
42
|
-
const cardColor = typingAnimationWidgetConfig?.cardColor;
|
|
43
|
-
const promptButtonType = typingAnimationWidgetConfig?.promptButtonType ||
|
|
44
|
-
PromptButtonVariant.LIGHT;
|
|
45
|
-
const promptCarouselRows = typingAnimationWidgetConfig?.promptCarouselRows || PromptCarouselRows.ALWAYS_ONE;
|
|
46
|
-
const showTextField = typingAnimationWidgetConfig?.showTextField !== false; // Default: true
|
|
47
|
-
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
48
|
-
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
49
|
-
const { trackEvent } = useAmplitude();
|
|
50
|
-
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
51
|
-
const { onClick: onPromptClicked, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd, } = usePromptCarouselAnalytics(WidgetInteractionComponent.EMBEDDED_WIDGET, text => {
|
|
52
|
-
const rawValues = hardcopyContent?.rawValues;
|
|
53
|
-
return getStringIdForText(rawValues, text);
|
|
54
|
-
});
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
trackEvent({
|
|
57
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
58
|
-
eventProps: {
|
|
59
|
-
widget_config_id: widgetConfigId,
|
|
60
|
-
widget_type: WidgetTypeV3.TypingAnimationV3,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}, [trackEvent, widgetConfigId]);
|
|
64
|
-
const handleButtonClick = useCallback((text) => {
|
|
65
|
-
const rawValues = hardcopyContent?.rawValues;
|
|
66
|
-
const stringId = getStringIdForText(rawValues, text);
|
|
67
|
-
trackEvent({
|
|
68
|
-
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
69
|
-
eventProps: {
|
|
70
|
-
response_id: hardcopyContent?.responseId,
|
|
71
|
-
string_id: stringId,
|
|
72
|
-
text,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
onTypedMessageSubmitted({
|
|
76
|
-
query: text,
|
|
77
|
-
userTyped: false,
|
|
78
|
-
displayLocation: ChatElementDisplayLocationV3.TYPING_ANIMATION,
|
|
79
|
-
});
|
|
80
|
-
onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
|
|
81
|
-
onPromptClicked(text);
|
|
82
|
-
}, [hardcopyContent, trackEvent, onTypedMessageSubmitted, onToggle]);
|
|
83
|
-
const handleTextFieldClick = useCallback(() => {
|
|
84
|
-
onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
|
|
85
|
-
trackWidgetInteraction({
|
|
86
|
-
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
87
|
-
trigger: {
|
|
88
|
-
widget: WidgetInteractionComponent.EMBEDDED_WIDGET,
|
|
89
|
-
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}, [onToggle]);
|
|
93
|
-
return (_jsx(TypingAnimation, { baseProps: {
|
|
94
|
-
id,
|
|
95
|
-
}, widgetContentProps: {
|
|
96
|
-
titleLabel: isLoading ? mockTitleLabel : titleLabel,
|
|
97
|
-
headlineText: isLoading ? mockHeadlineText : headlineText,
|
|
98
|
-
animatedTextSequence: isLoading ? mockAnimatedTextSequence : animatedTextSequence,
|
|
99
|
-
promptButtonTexts: buttonTexts,
|
|
100
|
-
hintText: isLoading ? mockHintText : hintText,
|
|
101
|
-
textFieldAriaLabel,
|
|
102
|
-
logoSrc: logoSrc ?? undefined,
|
|
103
|
-
hideLogo: hideLogo ?? false,
|
|
104
|
-
}, widgetStyleProps: {
|
|
105
|
-
widgetVariant,
|
|
106
|
-
cardColor,
|
|
107
|
-
promptButtonType,
|
|
108
|
-
promptCarouselRows,
|
|
109
|
-
showTextField,
|
|
110
|
-
isLoading,
|
|
111
|
-
}, widgetEventProps: {
|
|
112
|
-
handleButtonClick,
|
|
113
|
-
handleButtonDrag: onDrag,
|
|
114
|
-
handleButtonHover: onHover,
|
|
115
|
-
handleButtonMouseDown: onMouseDown,
|
|
116
|
-
handleButtonMouseUp: onMouseUp,
|
|
117
|
-
handleButtonTouchStart: onTouchStart,
|
|
118
|
-
handleButtonTouchEnd: onTouchEnd,
|
|
119
|
-
handleTextFieldClick,
|
|
120
|
-
} }));
|
|
121
|
-
};
|
|
122
|
-
export const TypingAnimationWithBaseWidget = withBaseWidget(TypingAnimationWidgetHandler);
|
|
123
|
-
export const TypingAnimationWidget = ({ widgetConfigId }) => {
|
|
124
|
-
return (_jsx(TypingAnimationWithBaseWidget, { widgetConfigId: widgetConfigId, widgetType: WidgetTypeV3.TypingAnimationV3 }));
|
|
125
|
-
};
|
|
126
|
-
TypingAnimationWidget.displayName = 'TypingAnimationWidget';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { atom } from 'jotai';
|
|
4
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName, } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
5
|
-
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
6
|
-
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
7
|
-
import { TypingAnimationWidget } from '../TypingAnimationWidget';
|
|
8
|
-
const mockTrackEvent = vi.fn();
|
|
9
|
-
vi.mock('@envive-ai/react-toolkit-v3/TypingAnimation', () => ({
|
|
10
|
-
TypingAnimation: ({ widgetContentProps, widgetEventProps, }) => (_jsx("div", { "data-testid": "typing-animation-mock", children: widgetContentProps.promptButtonTexts.map(text => (_jsx("button", { type: "button", onClick: () => widgetEventProps.handleButtonClick(text), children: text }, text))) })),
|
|
11
|
-
}));
|
|
12
|
-
const mockGetHardcopy = vi.fn();
|
|
13
|
-
const mockOnTypedMessageSubmitted = vi.fn();
|
|
14
|
-
const mockOpenChat = vi.fn();
|
|
15
|
-
const mockSetAtom = vi.fn();
|
|
16
|
-
vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
17
|
-
useAmplitude: () => ({
|
|
18
|
-
trackEvent: mockTrackEvent,
|
|
19
|
-
isReady: true,
|
|
20
|
-
}),
|
|
21
|
-
SpiffyMetricsEventName: {
|
|
22
|
-
ChatComponentVisible: 'Chat Component Visible',
|
|
23
|
-
SearchComponentVisible: 'Search Component Visible',
|
|
24
|
-
},
|
|
25
|
-
EnviveMetricsEventName: {
|
|
26
|
-
WidgetTextClicked: 'Widget Text Clicked',
|
|
27
|
-
},
|
|
28
|
-
}));
|
|
29
|
-
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
30
|
-
useHardcopy: () => ({
|
|
31
|
-
getHardcopy: mockGetHardcopy,
|
|
32
|
-
}),
|
|
33
|
-
}));
|
|
34
|
-
vi.mock('@envive-ai/react-hooks/contexts/pageContext', () => ({
|
|
35
|
-
usePage: () => ({
|
|
36
|
-
userEvent: {
|
|
37
|
-
id: 'test-user-event-id',
|
|
38
|
-
category: UserEventCategory.PageVisit,
|
|
39
|
-
created_at: '2025-01-01T00:00:00Z',
|
|
40
|
-
event_id: 'test-event-id',
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
}));
|
|
44
|
-
vi.mock('@envive-ai/react-hooks/contexts/widgetConfigContext', () => ({
|
|
45
|
-
useWidgetConfig: () => ({
|
|
46
|
-
getWidgetConfig: vi.fn().mockResolvedValue({}),
|
|
47
|
-
}),
|
|
48
|
-
}));
|
|
49
|
-
vi.mock('@envive-ai/react-hooks/contexts/uiConfigContext', () => ({
|
|
50
|
-
useUiConfig: () => ({
|
|
51
|
-
getUiConfig: vi.fn().mockResolvedValue({}),
|
|
52
|
-
}),
|
|
53
|
-
}));
|
|
54
|
-
vi.mock('@envive-ai/react-hooks/contexts/salesAgentContext', () => ({
|
|
55
|
-
useSalesAgent: () => ({
|
|
56
|
-
onTypedMessageSubmitted: mockOnTypedMessageSubmitted,
|
|
57
|
-
}),
|
|
58
|
-
}));
|
|
59
|
-
vi.mock('@envive-ai/react-hooks/hooks/ChatToggle', () => ({
|
|
60
|
-
useChatToggle: () => ({
|
|
61
|
-
openChat: mockOpenChat,
|
|
62
|
-
}),
|
|
63
|
-
}));
|
|
64
|
-
vi.mock('@envive-ai/react-hooks/atoms/chat/chatState', () => ({
|
|
65
|
-
chatOnToggleAtom: atom(null),
|
|
66
|
-
}));
|
|
67
|
-
describe('TypingAnimationWidget analytics', () => {
|
|
68
|
-
const defaultHardcopy = {
|
|
69
|
-
responseId: 'test-response-id',
|
|
70
|
-
language: 'en',
|
|
71
|
-
values: {
|
|
72
|
-
promptButtonTexts: ['Button 1', 'Button 2', 'Button 3'],
|
|
73
|
-
titleLabel: 'Test Title',
|
|
74
|
-
headlineText: 'Headline',
|
|
75
|
-
animatedTextSequence: ['...'],
|
|
76
|
-
hintText: 'Ask me anything',
|
|
77
|
-
},
|
|
78
|
-
rawValues: {
|
|
79
|
-
promptButtonTexts: [
|
|
80
|
-
{ id: 'id-1', value: 'Button 1' },
|
|
81
|
-
{ id: 'id-2', value: 'Button 2' },
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
vi.clearAllMocks();
|
|
87
|
-
mockGetHardcopy.mockResolvedValue(defaultHardcopy);
|
|
88
|
-
});
|
|
89
|
-
it('should track ChatComponentVisible when widget mounts', async () => {
|
|
90
|
-
render(_jsx(TypingAnimationWidget, { widgetConfigId: "test-config-1" }));
|
|
91
|
-
await waitFor(() => {
|
|
92
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
93
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
94
|
-
eventProps: {
|
|
95
|
-
widget_config_id: 'test-config-1',
|
|
96
|
-
widget_type: WidgetTypeV3.TypingAnimationV3,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}, { timeout: 3000 });
|
|
100
|
-
}, 5000);
|
|
101
|
-
it('should track WidgetTextClicked when button is clicked', async () => {
|
|
102
|
-
render(_jsx(TypingAnimationWidget, { widgetConfigId: "test-config-2" }));
|
|
103
|
-
await waitFor(() => {
|
|
104
|
-
expect(screen.getByText('Button 1')).toBeInTheDocument();
|
|
105
|
-
}, { timeout: 3000 });
|
|
106
|
-
mockTrackEvent.mockClear();
|
|
107
|
-
const button = screen.getByText('Button 1');
|
|
108
|
-
button.click();
|
|
109
|
-
expect(mockTrackEvent).toHaveBeenCalledWith({
|
|
110
|
-
eventName: EnviveMetricsEventName.WidgetTextClicked,
|
|
111
|
-
eventProps: {
|
|
112
|
-
response_id: 'test-response-id',
|
|
113
|
-
string_id: 'id-1',
|
|
114
|
-
text: 'Button 1',
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
}, 5000);
|
|
118
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TypingAnimationWidget, TypingAnimationWithBaseWidget } from './TypingAnimationWidget';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { RenderOptions } from '@testing-library/react';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { UserEvent } from '@spiffy-ai/commerce-api-client';
|
|
4
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
5
|
-
export declare const mockTrackEvent: any;
|
|
6
|
-
export declare const defaultHardcopyResponse: {
|
|
7
|
-
responseId: string;
|
|
8
|
-
language: string;
|
|
9
|
-
values: {
|
|
10
|
-
promptButtonTexts: string[];
|
|
11
|
-
titleLabel: string;
|
|
12
|
-
headlineText: string;
|
|
13
|
-
headline: string;
|
|
14
|
-
animatedTextSequence: string[];
|
|
15
|
-
hintText: string;
|
|
16
|
-
prompts: string[];
|
|
17
|
-
primaryButtonText: string;
|
|
18
|
-
secondaryButtonTexts: string[];
|
|
19
|
-
promptButtonsTexts: string[];
|
|
20
|
-
};
|
|
21
|
-
rawValues: {
|
|
22
|
-
promptButtonTexts: {
|
|
23
|
-
id: string;
|
|
24
|
-
value: string;
|
|
25
|
-
}[];
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export declare const defaultUserEvent: UserEvent;
|
|
29
|
-
export declare function createWidgetTestMocks(overrides?: {
|
|
30
|
-
trackEvent?: ReturnType<typeof vi.fn>;
|
|
31
|
-
hardcopy?: Partial<typeof defaultHardcopyResponse>;
|
|
32
|
-
}): {
|
|
33
|
-
trackEvent: any;
|
|
34
|
-
hardcopy: {
|
|
35
|
-
responseId: string;
|
|
36
|
-
language: string;
|
|
37
|
-
values: {
|
|
38
|
-
promptButtonTexts: string[];
|
|
39
|
-
titleLabel: string;
|
|
40
|
-
headlineText: string;
|
|
41
|
-
headline: string;
|
|
42
|
-
animatedTextSequence: string[];
|
|
43
|
-
hintText: string;
|
|
44
|
-
prompts: string[];
|
|
45
|
-
primaryButtonText: string;
|
|
46
|
-
secondaryButtonTexts: string[];
|
|
47
|
-
promptButtonsTexts: string[];
|
|
48
|
-
};
|
|
49
|
-
rawValues: {
|
|
50
|
-
promptButtonTexts: {
|
|
51
|
-
id: string;
|
|
52
|
-
value: string;
|
|
53
|
-
}[];
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
getHardcopy: any;
|
|
57
|
-
userEvent: UserEvent;
|
|
58
|
-
};
|
|
59
|
-
export declare function renderWithWidgetProviders(ui: ReactElement, options?: Omit<RenderOptions, 'wrapper'>): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
|
|
60
|
-
export { EnviveMetricsEventName, SpiffyMetricsEventName };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
3
|
-
import { EnviveMetricsEventName, SpiffyMetricsEventName, } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
|
-
export const mockTrackEvent = vi.fn();
|
|
5
|
-
export const defaultHardcopyResponse = {
|
|
6
|
-
responseId: 'test-response-id',
|
|
7
|
-
language: 'en',
|
|
8
|
-
values: {
|
|
9
|
-
promptButtonTexts: ['Button 1', 'Button 2', 'Button 3'],
|
|
10
|
-
titleLabel: 'Test Title',
|
|
11
|
-
headlineText: 'Headline',
|
|
12
|
-
headline: 'Product Headline',
|
|
13
|
-
animatedTextSequence: ['...'],
|
|
14
|
-
hintText: 'Ask me anything',
|
|
15
|
-
prompts: ['Prompt 1', 'Prompt 2'],
|
|
16
|
-
primaryButtonText: 'Primary',
|
|
17
|
-
secondaryButtonTexts: ['Secondary 1'],
|
|
18
|
-
promptButtonsTexts: ['Prompt A', 'Prompt B'],
|
|
19
|
-
},
|
|
20
|
-
rawValues: {
|
|
21
|
-
promptButtonTexts: [
|
|
22
|
-
{ id: 'id-1', value: 'Button 1' },
|
|
23
|
-
{ id: 'id-2', value: 'Button 2' },
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
export const defaultUserEvent = {
|
|
28
|
-
id: 'test-user-event-id',
|
|
29
|
-
category: UserEventCategory.PageVisit,
|
|
30
|
-
created_at: '2025-01-01T00:00:00Z',
|
|
31
|
-
event_id: 'test-event-id',
|
|
32
|
-
};
|
|
33
|
-
export function createWidgetTestMocks(overrides) {
|
|
34
|
-
const trackEvent = overrides?.trackEvent ?? mockTrackEvent;
|
|
35
|
-
const hardcopy = { ...defaultHardcopyResponse, ...overrides?.hardcopy };
|
|
36
|
-
return {
|
|
37
|
-
trackEvent,
|
|
38
|
-
hardcopy,
|
|
39
|
-
getHardcopy: vi.fn().mockResolvedValue(hardcopy),
|
|
40
|
-
userEvent: defaultUserEvent,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export function renderWithWidgetProviders(ui, options) {
|
|
44
|
-
return render(ui, options);
|
|
45
|
-
}
|
|
46
|
-
export { EnviveMetricsEventName, SpiffyMetricsEventName };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { readFileSync, readdirSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
const WIDGETS_SRC_DIR = join(process.cwd(), 'src');
|
|
4
|
-
/**
|
|
5
|
-
* Known count of trackEvent({ invocations in widget source files (excluding tests and stories).
|
|
6
|
-
* Update this when adding new trackEvent calls - and add a test for the new event!
|
|
7
|
-
*/
|
|
8
|
-
const EXPECTED_TRACK_EVENT_CALL_COUNT = 15;
|
|
9
|
-
function getAllSourceFiles(dir, files = []) {
|
|
10
|
-
const entries = readdirSync(dir, { withFileTypes: true });
|
|
11
|
-
for (const entry of entries) {
|
|
12
|
-
const fullPath = join(dir, entry.name);
|
|
13
|
-
if (entry.isDirectory()) {
|
|
14
|
-
if (!entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
15
|
-
getAllSourceFiles(fullPath, files);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
else if (entry.isFile() && /\.(ts|tsx)$/.test(entry.name)) {
|
|
19
|
-
files.push(fullPath);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return files;
|
|
23
|
-
}
|
|
24
|
-
describe('trackEvent canary', () => {
|
|
25
|
-
it('should not add new trackEvent calls without updating this test', () => {
|
|
26
|
-
const files = getAllSourceFiles(WIDGETS_SRC_DIR).filter(file => !file.includes('__tests__') && !file.includes('.test.') && !file.includes('.stories.'));
|
|
27
|
-
let count = 0;
|
|
28
|
-
for (const file of files) {
|
|
29
|
-
const content = readFileSync(file, 'utf-8');
|
|
30
|
-
const matches = content.match(/trackEvent\s*\(\s*\{/g);
|
|
31
|
-
if (matches) {
|
|
32
|
-
count += matches.length;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
expect(count).toBe(EXPECTED_TRACK_EVENT_CALL_COUNT);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useAtomValue } from 'jotai';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { responseStreamingAtom } from '@envive-ai/react-hooks/atoms/chat/chatState';
|
|
4
|
-
import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
5
|
-
import { isLoading, isProductComparison, userHasInteracted, userHasNotInteracted, } from '../utils/functions';
|
|
6
|
-
const useGetWidgetStatus = () => {
|
|
7
|
-
const { messages } = useAtomValue(chatAtom);
|
|
8
|
-
const responseStreaming = useAtomValue(responseStreamingAtom);
|
|
9
|
-
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
10
|
-
return useMemo(() => ({
|
|
11
|
-
userHasInteractedValue: userHasInteracted(messages),
|
|
12
|
-
userHasNotInteractedValue: userHasNotInteracted(messages),
|
|
13
|
-
isLoadingValue: isLoading(messages, responseStreaming),
|
|
14
|
-
isProductComparisonValue: isProductComparison(lastAssistantMessage),
|
|
15
|
-
}), [messages, responseStreaming, lastAssistantMessage]);
|
|
16
|
-
};
|
|
17
|
-
export default useGetWidgetStatus;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Message } from '@envive-ai/react-hooks/application/models';
|
|
2
|
-
export declare const getProductImageUrl: (lastAssistantMessage: Message[]) => string;
|
|
3
|
-
export declare const getRecentProductImageUrls: (lastMessages: Message[], currentProductId: string | undefined) => string[];
|
|
4
|
-
export declare const getMessageText: (lastAssistantMessage: Message[]) => string;
|
|
5
|
-
export declare const userHasInteracted: (msgs?: Message[][]) => boolean;
|
|
6
|
-
export declare const userHasNotInteracted: (msgs?: Message[][]) => boolean;
|
|
7
|
-
export declare const isLoading: (msgs?: Message[][], responseStream?: boolean) => boolean;
|
|
8
|
-
export declare const isProductComparison: (lastMsg?: Message[] | null | undefined) => boolean;
|
|
9
|
-
type RawWidgetString = {
|
|
10
|
-
id: string;
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
13
|
-
export type RawValues = Record<string, RawWidgetString | RawWidgetString[]>;
|
|
14
|
-
/** Finds the string_id (id) from raw widget text values for the given display text */
|
|
15
|
-
export declare const getStringIdForText: (rawValues: RawValues | undefined, text: string) => string | undefined;
|
|
16
|
-
export {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { MessageRole, MessageType, } from '@envive-ai/react-hooks/application/models';
|
|
2
|
-
import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
3
|
-
import { getAtomStore } from '@envive-ai/react-hooks/atoms/atomStore';
|
|
4
|
-
export const getProductImageUrl = (lastAssistantMessage) => {
|
|
5
|
-
const productImageUrls = lastAssistantMessage != null
|
|
6
|
-
? lastAssistantMessage.reduce((acc, msg) => {
|
|
7
|
-
if (msg.type === MessageType.Product && msg.metadata) {
|
|
8
|
-
if (msg.metadata.imageUrls?.length) {
|
|
9
|
-
return [...acc, ...msg.metadata.imageUrls];
|
|
10
|
-
}
|
|
11
|
-
// imageUrl is being deprecated so only use it if imageUrls is not present
|
|
12
|
-
if (msg.metadata.imageUrl) {
|
|
13
|
-
return [...acc, msg.metadata.imageUrl];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return acc;
|
|
17
|
-
}, [])
|
|
18
|
-
: [];
|
|
19
|
-
const productImageUrl = (() => {
|
|
20
|
-
const productImageUrlIndex = 1;
|
|
21
|
-
return productImageUrls.length > 0 && productImageUrlIndex > productImageUrls.length - 1
|
|
22
|
-
? productImageUrls[productImageUrls.length - 1]
|
|
23
|
-
: productImageUrls[productImageUrlIndex];
|
|
24
|
-
})();
|
|
25
|
-
return productImageUrl;
|
|
26
|
-
};
|
|
27
|
-
export const getRecentProductImageUrls = (lastMessages, currentProductId) => {
|
|
28
|
-
const productMessages = lastMessages
|
|
29
|
-
.filter(message => message.type === MessageType.Product && message.metadata?.imageUrl)
|
|
30
|
-
.map(m => m);
|
|
31
|
-
// put added product image at the top of the list
|
|
32
|
-
return [
|
|
33
|
-
...productMessages.filter(m => m.metadata?.id === currentProductId),
|
|
34
|
-
...productMessages.filter(m => m.metadata?.id !== currentProductId),
|
|
35
|
-
].map(m => m.metadata.imageUrl);
|
|
36
|
-
};
|
|
37
|
-
export const getMessageText = (lastAssistantMessage) => {
|
|
38
|
-
if (!lastAssistantMessage) {
|
|
39
|
-
return '';
|
|
40
|
-
}
|
|
41
|
-
const textMessage = lastAssistantMessage.find(msg => msg.role === MessageRole.Assistant && msg.type === MessageType.Text);
|
|
42
|
-
return textMessage && textMessage.type === MessageType.Text ? textMessage.metadata.content : '';
|
|
43
|
-
};
|
|
44
|
-
export const userHasInteracted = (msgs) => {
|
|
45
|
-
if (msgs) {
|
|
46
|
-
return msgs.some(m => m.some(msg => msg.role === MessageRole.User));
|
|
47
|
-
}
|
|
48
|
-
const atomStore = getAtomStore();
|
|
49
|
-
const { messages } = atomStore.get(chatAtom);
|
|
50
|
-
return messages.some(m => m.some(msg => msg.role === MessageRole.User));
|
|
51
|
-
};
|
|
52
|
-
export const userHasNotInteracted = (msgs) => {
|
|
53
|
-
if (msgs) {
|
|
54
|
-
return !msgs.some(m => m.some(msg => msg.role === MessageRole.User));
|
|
55
|
-
}
|
|
56
|
-
const atomStore = getAtomStore();
|
|
57
|
-
const chat = atomStore.get(chatAtom);
|
|
58
|
-
return !chat.messages.some(m => m.some(msg => msg.role === MessageRole.User));
|
|
59
|
-
};
|
|
60
|
-
export const isLoading = (msgs, responseStream) => {
|
|
61
|
-
if (msgs) {
|
|
62
|
-
return responseStream || (!responseStream && msgs.length === 0);
|
|
63
|
-
}
|
|
64
|
-
const atomStore = getAtomStore();
|
|
65
|
-
const { responseStreaming, messages } = atomStore.get(chatAtom);
|
|
66
|
-
return responseStreaming || (!responseStreaming && messages.length === 0);
|
|
67
|
-
};
|
|
68
|
-
export const isProductComparison = (lastMsg) => {
|
|
69
|
-
if (lastMsg) {
|
|
70
|
-
return lastMsg?.filter(msg => msg.type === MessageType.Product).length === 2;
|
|
71
|
-
}
|
|
72
|
-
const atomStore = getAtomStore();
|
|
73
|
-
const lastAssistantMessage = atomStore.get(lastAssistantMessageAtom);
|
|
74
|
-
return lastAssistantMessage?.filter(msg => msg.type === MessageType.Product).length === 2;
|
|
75
|
-
};
|
|
76
|
-
/** Finds the string_id (id) from raw widget text values for the given display text */
|
|
77
|
-
export const getStringIdForText = (rawValues, text) => {
|
|
78
|
-
if (!rawValues)
|
|
79
|
-
return undefined;
|
|
80
|
-
for (const raw of Object.values(rawValues)) {
|
|
81
|
-
const list = Array.isArray(raw) ? raw : [raw];
|
|
82
|
-
const found = list.find((s) => s.value === text);
|
|
83
|
-
if (found)
|
|
84
|
-
return found.id;
|
|
85
|
-
}
|
|
86
|
-
return undefined;
|
|
87
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { SearchEntryPointWidgetConfig, SearchInputVariant, SearchZeroState, SearchZeroStateProps, SearchZeroStateWidget } from '@envive-ai/react-widgets/SearchZeroState';
|
|
2
|
-
export { SearchZeroStateProps, SearchEntryPointWidgetConfig, SearchInputVariant, SearchZeroState, SearchZeroStateWidget, };
|
package/dist/tsdown.config.d.ts
DELETED
package/dist/tsdown.config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsdown';
|
|
2
|
-
export default defineConfig({
|
|
3
|
-
entry: ['src/**/index.ts'],
|
|
4
|
-
format: ['esm', 'cjs'],
|
|
5
|
-
platform: 'neutral',
|
|
6
|
-
target: 'esnext',
|
|
7
|
-
dts: true,
|
|
8
|
-
clean: true,
|
|
9
|
-
outDir: 'dist',
|
|
10
|
-
unbundle: true,
|
|
11
|
-
exports: true,
|
|
12
|
-
});
|