@envive-ai/react-widgets-v3 0.3.15 → 0.3.16

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.
Files changed (49) hide show
  1. package/dist/debug/chatEmbed.cjs +1 -1
  2. package/dist/debug/chatEmbed.js +1 -1
  3. package/dist/debug/reportIssue.cjs +1 -1
  4. package/dist/debug/reportIssue.js +1 -1
  5. package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
  6. package/dist/packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
  7. package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
  8. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +36 -5
  9. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
  10. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +36 -5
  11. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
  12. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
  13. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +34 -4
  14. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
  15. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +35 -5
  16. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +3 -3
  17. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
  18. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
  19. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +3 -3
  20. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
  21. package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +25 -3
  22. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
  23. package/dist/widgets/ProductCardWidget/ProductCardWidget.js +25 -3
  24. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +5 -5
  25. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
  26. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
  27. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +5 -5
  28. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +2 -2
  29. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
  30. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +2 -2
  31. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
  32. package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +6 -6
  33. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
  34. package/dist/widgets/SocialProofWidget/SocialProofWidget.js +6 -6
  35. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +1 -1
  36. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +1 -1
  37. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
  38. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +23 -2
  39. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
  40. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +24 -3
  41. package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
  42. package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
  43. package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
  44. package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
  45. package/package.json +1 -1
  46. package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +59 -8
  47. package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +55 -7
  48. package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +37 -4
  49. package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +45 -10
@@ -1,31 +1,52 @@
1
+ import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
2
+ import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
1
3
  import {
2
4
  ChatPreviewComparisonWidgetV3Config,
3
5
  WidgetTypeV3,
4
6
  } from '@envive-ai/react-hooks/contexts/typesV3';
5
- import { useAtomValue } from 'jotai';
6
- import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
7
7
  import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
8
- import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
8
+ import { useAtomValue } from 'jotai';
9
9
 
10
- import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
11
- import { useCallback, useMemo } from 'react';
12
10
  import {
13
11
  ChatElementDisplayLocationV3,
14
12
  Suggestion,
15
13
  VariantTypeEnum,
16
14
  } from '@envive-ai/react-hooks/application/models';
15
+ import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
16
+ import { EnviveMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
17
+ import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
18
+ import {
19
+ WidgetInteractionComponent,
20
+ WidgetInteractionType,
21
+ } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
17
22
  import { ChatPreviewComparison } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison';
18
23
  import { ChatPreviewComparisonProps } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison/types/types';
19
- import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
20
- import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
24
+ import { usePromptCarouselAnalytics } from '@envive-ai/react-toolkit-v3/PromptCarousel';
25
+ import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
26
+ import { useCallback, useMemo } from 'react';
21
27
  import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
22
- import { getMessageText, getRecentProductImageUrls } from '../utils/functions';
28
+ import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
23
29
  import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
30
+ import { getMessageText, getRecentProductImageUrls } from '../utils/functions';
24
31
 
25
32
  const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
26
33
  const { onSuggestionClicked } = useSalesAgent();
27
34
  const { openChat } = useChatToggle();
28
35
 
36
+ const { trackWidgetInteraction } = useWidgetInteraction();
37
+ const {
38
+ onClick: onPromptClicked,
39
+ onDrag,
40
+ onHover,
41
+ onMouseDown,
42
+ onMouseUp,
43
+ onTouchStart,
44
+ onTouchEnd,
45
+ } = usePromptCarouselAnalytics(
46
+ WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
47
+ text => text,
48
+ );
49
+
29
50
  const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
30
51
 
31
52
  const variantInfo = useAtomValue(variantInfoAtom);
@@ -75,14 +96,37 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
75
96
  ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON,
76
97
  );
77
98
  openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
99
+ onPromptClicked(suggestion.id);
78
100
  },
79
101
  [onSuggestionClicked, openChat],
80
102
  );
81
103
 
82
104
  const handleTextFieldClick = useCallback(() => {
83
105
  openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
106
+ trackWidgetInteraction({
107
+ eventName: EnviveMetricsEventName.WidgetInteraction,
108
+ trigger: {
109
+ widget: WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
110
+ widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
111
+ },
112
+ });
84
113
  }, [openChat]);
85
114
 
115
+ const handleLinkClick = (url: string) => {
116
+ trackWidgetInteraction({
117
+ eventName: EnviveMetricsEventName.WidgetInteraction,
118
+ trigger: {
119
+ widget: WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
120
+ widget_interaction: WidgetInteractionType.LINK_CLICKED,
121
+ widget_interaction_data: {
122
+ link_clicked: {
123
+ url,
124
+ },
125
+ },
126
+ },
127
+ });
128
+ };
129
+
86
130
  if (isLoading) {
87
131
  return (
88
132
  <ChatPreviewLoadingWidgetWithBaseWidget
@@ -116,6 +160,13 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
116
160
 
117
161
  const widgetEventProps: ChatPreviewComparisonProps['widgetEventProps'] = {
118
162
  handlePromptButtonClick,
163
+ handlePromptButtonDrag: onDrag,
164
+ handlePromptButtonHover: onHover,
165
+ handlePromptButtonMouseDown: onMouseDown,
166
+ handlePromptButtonMouseUp: onMouseUp,
167
+ handlePromptButtonTouchStart: onTouchStart,
168
+ handlePromptButtonTouchEnd: onTouchEnd,
169
+ handleLinkClick,
119
170
  handleTextFieldClick,
120
171
  };
121
172
 
@@ -1,8 +1,8 @@
1
- import { ChatPreviewWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
2
- import { useAtomValue } from 'jotai';
1
+ import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
3
2
  import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
3
+ import { ChatPreviewWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
4
4
  import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
5
- import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
5
+ import { useAtomValue } from 'jotai';
6
6
 
7
7
  import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
8
8
 
@@ -10,17 +10,24 @@ import {
10
10
  ChatElementDisplayLocationV3,
11
11
  Suggestion,
12
12
  } from '@envive-ai/react-hooks/application/models';
13
- import { useCallback, useEffect, useMemo } from 'react';
14
13
  import {
14
+ EnviveMetricsEventName,
15
15
  SpiffyMetricsEventName,
16
16
  useAmplitude,
17
17
  } from '@envive-ai/react-hooks/contexts/amplitudeContext';
18
- import { ChatPreviewProps } from '@envive-ai/react-toolkit-v3/ChatPreview/types/types';
18
+ import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
19
+ import {
20
+ WidgetInteractionComponent,
21
+ WidgetInteractionType,
22
+ } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
19
23
  import { ChatPreview } from '@envive-ai/react-toolkit-v3/ChatPreview';
20
- import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
24
+ import { ChatPreviewProps } from '@envive-ai/react-toolkit-v3/ChatPreview/types/types';
25
+ import { usePromptCarouselAnalytics } from '@envive-ai/react-toolkit-v3/PromptCarousel';
26
+ import { useCallback, useEffect, useMemo } from 'react';
21
27
  import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
22
- import { getMessageText } from '../utils/functions';
28
+ import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
23
29
  import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
30
+ import { getMessageText } from '../utils/functions';
24
31
 
25
32
  const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
26
33
  const { onSuggestionClicked } = useSalesAgent();
@@ -49,8 +56,19 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
49
56
  >;
50
57
 
51
58
  const { trackEvent } = useAmplitude();
59
+ const { trackWidgetInteraction } = useWidgetInteraction();
60
+ const {
61
+ onClick: onPromptClicked,
62
+ onDrag,
63
+ onHover,
64
+ onMouseDown,
65
+ onMouseUp,
66
+ onTouchStart,
67
+ onTouchEnd,
68
+ } = usePromptCarouselAnalytics(WidgetInteractionComponent.CHAT_PREVIEW, text => text);
52
69
 
53
70
  useEffect(() => {
71
+ // TODO: -Add Widget Interaction here
54
72
  trackEvent({
55
73
  eventName: SpiffyMetricsEventName.ChatComponentVisible,
56
74
  eventProps: {
@@ -68,14 +86,37 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
68
86
  (suggestion: Suggestion) => {
69
87
  onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
70
88
  openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
89
+ onPromptClicked(suggestion.id);
71
90
  },
72
91
  [onSuggestionClicked, openChat],
73
92
  );
74
93
 
75
94
  const handleTextFieldClick = useCallback(() => {
76
95
  openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
96
+ trackWidgetInteraction({
97
+ eventName: EnviveMetricsEventName.WidgetInteraction,
98
+ trigger: {
99
+ widget: WidgetInteractionComponent.CHAT_PREVIEW,
100
+ widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
101
+ },
102
+ });
77
103
  }, [openChat]);
78
104
 
105
+ const handleLinkClick = (url: string) => {
106
+ trackWidgetInteraction({
107
+ eventName: EnviveMetricsEventName.WidgetInteraction,
108
+ trigger: {
109
+ widget: WidgetInteractionComponent.CHAT_PREVIEW,
110
+ widget_interaction: WidgetInteractionType.LINK_CLICKED,
111
+ widget_interaction_data: {
112
+ link_clicked: {
113
+ url,
114
+ },
115
+ },
116
+ },
117
+ });
118
+ };
119
+
79
120
  if (isLoading) {
80
121
  return (
81
122
  <ChatPreviewLoadingWidgetWithBaseWidget
@@ -103,6 +144,13 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
103
144
 
104
145
  const widgetEventProps: ChatPreviewProps['widgetEventProps'] = {
105
146
  handlePromptButtonClick,
147
+ handlePromptButtonDrag: onDrag,
148
+ handlePromptButtonHover: onHover,
149
+ handlePromptButtonMouseDown: onMouseDown,
150
+ handlePromptButtonMouseUp: onMouseUp,
151
+ handlePromptButtonTouchStart: onTouchStart,
152
+ handlePromptButtonTouchEnd: onTouchEnd,
153
+ handleLinkClick,
106
154
  handleTextFieldClick,
107
155
  };
108
156
 
@@ -1,16 +1,22 @@
1
- import { ProductCardWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
2
- import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
3
- import { useCallback, useEffect } from 'react';
1
+ import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
4
2
  import {
5
3
  EnviveMetricsEventName,
6
4
  SpiffyMetricsEventName,
7
5
  useAmplitude,
8
6
  } from '@envive-ai/react-hooks/contexts/amplitudeContext';
9
- import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
10
7
  import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
8
+ import { ProductCardWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
11
9
  import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
10
+ import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
11
+ import {
12
+ WidgetInteractionComponent,
13
+ WidgetInteractionType,
14
+ } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
12
15
  import { ProductCard } from '@envive-ai/react-toolkit-v3/ProductCard';
16
+ import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
17
+ import { usePromptCarouselAnalytics } from '@envive-ai/react-toolkit-v3/PromptCarousel';
13
18
  import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
19
+ import { useCallback, useEffect } from 'react';
14
20
  import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
15
21
  import { RawValues, getStringIdForText } from '../utils/functions';
16
22
 
@@ -52,6 +58,19 @@ const ProductCardWidgetHandler = (props: BaseWidgetProps) => {
52
58
  const imageSrc = productCardWidgetConfig?.imageSrc || '';
53
59
 
54
60
  const { trackEvent } = useAmplitude();
61
+ const { trackWidgetInteraction } = useWidgetInteraction();
62
+ const {
63
+ onClick: onSuggestionClick,
64
+ onDrag,
65
+ onHover,
66
+ onMouseDown,
67
+ onMouseUp,
68
+ onTouchStart,
69
+ onTouchEnd,
70
+ } = usePromptCarouselAnalytics(WidgetInteractionComponent.IMAGE_PROMPT_CARD, text => {
71
+ const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
72
+ return getStringIdForText(rawValues, text);
73
+ });
55
74
 
56
75
  const { widgetConfigId } = props;
57
76
  useEffect(() => {
@@ -82,12 +101,20 @@ const ProductCardWidgetHandler = (props: BaseWidgetProps) => {
82
101
  displayLocation: ChatElementDisplayLocationV3.PRODUCT_CARD_PROMPT_BUTTON,
83
102
  });
84
103
  openChat(ChatElementDisplayLocationV3.PRODUCT_CARD_PROMPT_BUTTON);
104
+ onSuggestionClick(text);
85
105
  },
86
106
  [hardcopyContent, onTypedMessageSubmitted, openChat, trackEvent],
87
107
  );
88
108
 
89
109
  const handleInputClick = useCallback(() => {
90
110
  openChat(ChatElementDisplayLocationV3.PRODUCT_CARD_TEXT_FIELD);
111
+ trackWidgetInteraction({
112
+ eventName: EnviveMetricsEventName.WidgetInteraction,
113
+ trigger: {
114
+ widget: WidgetInteractionComponent.IMAGE_PROMPT_CARD,
115
+ widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
116
+ },
117
+ });
91
118
  }, [openChat]);
92
119
 
93
120
  return (
@@ -105,6 +132,12 @@ const ProductCardWidgetHandler = (props: BaseWidgetProps) => {
105
132
  textTypingDuration={800}
106
133
  textTransition={2000}
107
134
  onSelect={handleSelect}
135
+ onDrag={onDrag}
136
+ onHover={onHover}
137
+ onMouseDown={onMouseDown}
138
+ onMouseUp={onMouseUp}
139
+ onTouchStart={onTouchStart}
140
+ onTouchEnd={onTouchEnd}
108
141
  onInputClick={handleInputClick}
109
142
  />
110
143
  );
@@ -1,21 +1,29 @@
1
- import {
2
- TypingAnimationWidgetV3Config,
3
- WidgetTypeV3,
4
- } from '@envive-ai/react-hooks/contexts/typesV3';
5
- import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
6
- import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
7
- import { useCallback, useEffect } from 'react';
8
1
  import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
2
+ import { chatOnToggleAtom } from '@envive-ai/react-hooks/atoms/chat/chatState';
9
3
  import {
10
4
  EnviveMetricsEventName,
11
5
  SpiffyMetricsEventName,
12
6
  useAmplitude,
13
7
  } from '@envive-ai/react-hooks/contexts/amplitudeContext';
14
- import { useSetAtom } from 'jotai';
15
8
  import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
16
- import { chatOnToggleAtom } from '@envive-ai/react-hooks/atoms/chat/chatState';
17
- import { PromptCarouselRows } from '@envive-ai/react-toolkit-v3/PromptCarousel';
9
+ import {
10
+ TypingAnimationWidgetV3Config,
11
+ WidgetTypeV3,
12
+ } from '@envive-ai/react-hooks/contexts/typesV3';
13
+ import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
14
+ import {
15
+ WidgetInteractionComponent,
16
+ WidgetInteractionType,
17
+ } from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
18
+ import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
19
+ import {
20
+ PromptCarouselRows,
21
+ usePromptCarouselAnalytics,
22
+ } from '@envive-ai/react-toolkit-v3/PromptCarousel';
18
23
  import { TypingAnimation } from '@envive-ai/react-toolkit-v3/TypingAnimation';
24
+ import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
25
+ import { useSetAtom } from 'jotai';
26
+ import { useCallback, useEffect } from 'react';
19
27
  import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
20
28
  import { RawValues, getStringIdForText } from '../utils/functions';
21
29
 
@@ -64,6 +72,19 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
64
72
  const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
65
73
 
66
74
  const { trackEvent } = useAmplitude();
75
+ const { trackWidgetInteraction } = useWidgetInteraction();
76
+ const {
77
+ onClick: onPromptClicked,
78
+ onDrag,
79
+ onHover,
80
+ onMouseDown,
81
+ onMouseUp,
82
+ onTouchStart,
83
+ onTouchEnd,
84
+ } = usePromptCarouselAnalytics(WidgetInteractionComponent.EMBEDDED_WIDGET, text => {
85
+ const rawValues = (hardcopyContent as { rawValues?: RawValues } | undefined)?.rawValues;
86
+ return getStringIdForText(rawValues, text);
87
+ });
67
88
 
68
89
  useEffect(() => {
69
90
  trackEvent({
@@ -93,12 +114,20 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
93
114
  displayLocation: ChatElementDisplayLocationV3.TYPING_ANIMATION,
94
115
  });
95
116
  onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
117
+ onPromptClicked(text);
96
118
  },
97
119
  [hardcopyContent, trackEvent, onTypedMessageSubmitted, onToggle],
98
120
  );
99
121
 
100
122
  const handleTextFieldClick = useCallback(() => {
101
123
  onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
124
+ trackWidgetInteraction({
125
+ eventName: EnviveMetricsEventName.WidgetInteraction,
126
+ trigger: {
127
+ widget: WidgetInteractionComponent.EMBEDDED_WIDGET,
128
+ widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
129
+ },
130
+ });
102
131
  }, [onToggle]);
103
132
 
104
133
  return (
@@ -126,6 +155,12 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
126
155
  }}
127
156
  widgetEventProps={{
128
157
  handleButtonClick,
158
+ handleButtonDrag: onDrag,
159
+ handleButtonHover: onHover,
160
+ handleButtonMouseDown: onMouseDown,
161
+ handleButtonMouseUp: onMouseUp,
162
+ handleButtonTouchStart: onTouchStart,
163
+ handleButtonTouchEnd: onTouchEnd,
129
164
  handleTextFieldClick,
130
165
  }}
131
166
  />