@envive-ai/react-widgets-v3 0.3.21 → 0.3.22

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 (69) hide show
  1. package/dist/hocs/withBaseWidget/types.d.cts +5 -6
  2. package/dist/hocs/withBaseWidget/types.d.ts +5 -6
  3. package/dist/hocs/withBaseWidget/withBaseWidget.cjs +37 -43
  4. package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
  5. package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
  6. package/dist/hocs/withBaseWidget/withBaseWidget.js +39 -45
  7. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
  8. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
  9. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
  10. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
  11. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +0 -9
  12. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
  13. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
  14. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +2 -11
  15. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +24 -28
  16. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
  17. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
  18. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +25 -29
  19. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
  20. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
  21. package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +0 -10
  22. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
  23. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
  24. package/dist/widgets/ProductCardWidget/ProductCardWidget.js +2 -12
  25. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +0 -9
  26. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
  27. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
  28. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +2 -11
  29. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +0 -9
  30. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
  31. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
  32. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +2 -11
  33. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
  34. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
  35. package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +0 -9
  36. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
  37. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
  38. package/dist/widgets/SocialProofWidget/SocialProofWidget.js +2 -11
  39. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +0 -9
  40. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
  41. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
  42. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +2 -11
  43. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
  44. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
  45. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +0 -9
  46. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
  47. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
  48. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +2 -11
  49. package/package.json +1 -1
  50. package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +68 -302
  51. package/src/hocs/withBaseWidget/types.ts +6 -6
  52. package/src/hocs/withBaseWidget/withBaseWidget.tsx +46 -61
  53. package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +1 -13
  54. package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +11 -5
  55. package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +36 -36
  56. package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +11 -5
  57. package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +1 -13
  58. package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +12 -8
  59. package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +1 -12
  60. package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +19 -8
  61. package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -12
  62. package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +21 -8
  63. package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +1 -12
  64. package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +19 -8
  65. package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +1 -12
  66. package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +19 -8
  67. package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +1 -12
  68. package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +19 -8
  69. package/src/widgets/__tests__/trackEventCanary.test.ts +1 -1
@@ -1,5 +1,4 @@
1
1
  import { RefObject } from "react";
2
- import { SpiffyMetricsEventName } from "@envive-ai/react-hooks/contexts/amplitudeContext";
3
2
  import { HardcopyResponse } from "@envive-ai/react-hooks/contexts/hardcopyContext";
4
3
  import { OrgUIConfigV3, WidgetConfigV3, WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
5
4
 
@@ -18,11 +17,6 @@ interface BaseWidgetProps {
18
17
  isUiConfigLoading?: boolean;
19
18
  }
20
19
  interface WithBaseWidgetOptions {
21
- /**
22
- * The Amplitude event name to track when the widget becomes visible.
23
- * Defaults to a generic component visible event if not provided.
24
- */
25
- visibilityEventName?: SpiffyMetricsEventName;
26
20
  /**
27
21
  * Additional properties to include with the visibility event.
28
22
  */
@@ -32,6 +26,11 @@ interface WithBaseWidgetOptions {
32
26
  * Defaults to '0px'.
33
27
  */
34
28
  rootMargin?: string;
29
+ /**
30
+ * Whether to defer loading of the widget until it is visible.
31
+ * Defaults to true
32
+ */
33
+ deferLoading?: boolean;
35
34
  }
36
35
  //#endregion
37
36
  export { BaseWidgetProps, WithBaseWidgetOptions };
@@ -1,5 +1,4 @@
1
1
  import { RefObject } from "react";
2
- import { SpiffyMetricsEventName } from "@envive-ai/react-hooks/contexts/amplitudeContext";
3
2
  import { HardcopyResponse } from "@envive-ai/react-hooks/contexts/hardcopyContext";
4
3
  import { OrgUIConfigV3, WidgetConfigV3, WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
5
4
 
@@ -18,11 +17,6 @@ interface BaseWidgetProps {
18
17
  isUiConfigLoading?: boolean;
19
18
  }
20
19
  interface WithBaseWidgetOptions {
21
- /**
22
- * The Amplitude event name to track when the widget becomes visible.
23
- * Defaults to a generic component visible event if not provided.
24
- */
25
- visibilityEventName?: SpiffyMetricsEventName;
26
20
  /**
27
21
  * Additional properties to include with the visibility event.
28
22
  */
@@ -32,6 +26,11 @@ interface WithBaseWidgetOptions {
32
26
  * Defaults to '0px'.
33
27
  */
34
28
  rootMargin?: string;
29
+ /**
30
+ * Whether to defer loading of the widget until it is visible.
31
+ * Defaults to true
32
+ */
33
+ deferLoading?: boolean;
35
34
  }
36
35
  //#endregion
37
36
  export { BaseWidgetProps, WithBaseWidgetOptions };
@@ -1,6 +1,7 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  let react = require("react");
3
3
  let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
4
+ let __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent = require("@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent");
4
5
  let __envive_ai_react_hooks_contexts_hardcopyContext = require("@envive-ai/react-hooks/contexts/hardcopyContext");
5
6
  let __envive_ai_react_hooks_contexts_pageContext = require("@envive-ai/react-hooks/contexts/pageContext");
6
7
  let __envive_ai_react_hooks_contexts_widgetConfigContext = require("@envive-ai/react-hooks/contexts/widgetConfigContext");
@@ -12,9 +13,9 @@ function withBaseWidget(Widget, options) {
12
13
  const WrappedWidget = (props) => {
13
14
  const { widgetConfigId, widgetType } = props;
14
15
  const widgetRef = (0, react.useRef)(null);
15
- const hasTrackedEvent = (0, react.useRef)(false);
16
- const { trackEvent, isReady } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
16
+ const { isReady } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
17
17
  const [hardcopyContent, setHardcopyContent] = (0, react.useState)(void 0);
18
+ const hardcopyFetchedRef = (0, react.useRef)(false);
18
19
  const { getHardcopy, isLoading: isHardcopyLoading } = (0, __envive_ai_react_hooks_contexts_hardcopyContext.useHardcopy)();
19
20
  const { userEvent, isLoading: isPageLoading } = (0, __envive_ai_react_hooks_contexts_pageContext.usePage)();
20
21
  const [widgetConfig, setWidgetConfig] = (0, react.useState)(void 0);
@@ -22,75 +23,68 @@ function withBaseWidget(Widget, options) {
22
23
  const [uiConfig, setUiConfig] = (0, react.useState)(void 0);
23
24
  const { getUiConfig, isLoading: isUiConfigLoading } = (0, __envive_ai_react_hooks_contexts_uiConfigContext.useUiConfig)();
24
25
  const isLoading = isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading;
25
- (0, react.useEffect)(() => {
26
- if (!isReady || hasTrackedEvent.current || !widgetRef.current) return;
27
- const observer = new IntersectionObserver(([entry]) => {
28
- if (entry.isIntersecting && !hasTrackedEvent.current) {
29
- trackEvent({
30
- eventName: options?.visibilityEventName || __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
31
- eventProps: {
32
- widget_config_id: widgetConfigId,
33
- widget_type: widgetType,
34
- ...options?.visibilityEventProps
35
- }
36
- });
37
- hasTrackedEvent.current = true;
38
- observer.disconnect();
39
- }
40
- }, { rootMargin: options?.rootMargin || "0px" });
41
- observer.observe(widgetRef.current);
42
- return () => {
43
- observer.disconnect();
44
- };
26
+ const { isVisible } = (0, __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent.useTrackComponentVisibleEvent)(widgetRef, {
27
+ widget_config_id: widgetConfigId,
28
+ widget_type: widgetType,
29
+ ...options?.visibilityEventProps
30
+ }, options?.rootMargin || "0px", isReady);
31
+ const startLoading = (0, react.useMemo)(() => {
32
+ if (options?.deferLoading === false) return true;
33
+ return isVisible && !!widgetConfigId && !!widgetType;
45
34
  }, [
46
- isReady,
35
+ isVisible,
47
36
  widgetConfigId,
48
- widgetType,
49
- trackEvent
37
+ widgetType
50
38
  ]);
51
39
  (0, react.useEffect)(() => {
52
- if (!widgetType || !userEvent) return;
40
+ if (!startLoading || hardcopyFetchedRef.current) return;
41
+ hardcopyFetchedRef.current = true;
53
42
  getHardcopy({
54
43
  widgetType,
55
44
  userEvent
56
45
  }).then(setHardcopyContent).catch(() => {});
57
46
  }, [
58
- widgetConfigId,
47
+ startLoading,
59
48
  widgetType,
60
49
  getHardcopy,
61
- userEvent
50
+ userEvent,
51
+ widgetConfigId
62
52
  ]);
63
53
  (0, react.useEffect)(() => {
54
+ if (!startLoading) return;
64
55
  getUiConfig().then(setUiConfig).catch(() => {});
65
56
  }, [
57
+ startLoading,
66
58
  getUiConfig,
67
59
  widgetConfigId,
68
60
  widgetType
69
61
  ]);
70
62
  (0, react.useEffect)(() => {
71
- if (!widgetConfigId || !widgetType) return;
63
+ if (!startLoading) return;
72
64
  getWidgetConfig({
73
65
  widgetConfigId,
74
66
  widgetType
75
- }).then(setWidgetConfig).catch((e) => {
76
- console.error("Error getting widget config", widgetConfigId, widgetType, e);
77
- });
67
+ }).then(setWidgetConfig).catch(() => {});
78
68
  }, [
69
+ startLoading,
79
70
  widgetConfigId,
80
71
  widgetType,
81
72
  getWidgetConfig
82
73
  ]);
83
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Widget, {
84
- ...props,
85
- isLoading,
86
- isHardcopyLoading,
87
- isPageLoading,
88
- isWidgetConfigLoading,
89
- isUiConfigLoading,
90
- uiConfig,
91
- widgetConfig,
92
- hardcopyContent,
93
- observedWidget: widgetRef
74
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
75
+ ref: widgetRef,
76
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Widget, {
77
+ ...props,
78
+ isLoading,
79
+ isHardcopyLoading,
80
+ isPageLoading,
81
+ isWidgetConfigLoading,
82
+ isUiConfigLoading,
83
+ uiConfig,
84
+ widgetConfig,
85
+ hardcopyContent,
86
+ observedWidget: widgetRef
87
+ })
94
88
  });
95
89
  };
96
90
  WrappedWidget.displayName = `withBaseWidget(${Widget.displayName || Widget.name || "Component"})`;
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.cjs";
2
- import * as react_jsx_runtime5 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime10 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/hocs/withBaseWidget/withBaseWidget.d.ts
5
5
  declare function withBaseWidget<P extends BaseWidgetProps>(Widget: React.ComponentType<P>, options?: WithBaseWidgetOptions): {
6
- (props: P): react_jsx_runtime5.JSX.Element;
6
+ (props: P): react_jsx_runtime10.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.js";
2
- import * as react_jsx_runtime18 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/hocs/withBaseWidget/withBaseWidget.d.ts
5
5
  declare function withBaseWidget<P extends BaseWidgetProps>(Widget: React.ComponentType<P>, options?: WithBaseWidgetOptions): {
6
- (props: P): react_jsx_runtime18.JSX.Element;
6
+ (props: P): react_jsx_runtime8.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  //#endregion
@@ -1,5 +1,6 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import { SpiffyMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
1
+ import { useEffect, useMemo, useRef, useState } from "react";
2
+ import { useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
3
+ import { useTrackComponentVisibleEvent } from "@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent";
3
4
  import { useHardcopy } from "@envive-ai/react-hooks/contexts/hardcopyContext";
4
5
  import { usePage } from "@envive-ai/react-hooks/contexts/pageContext";
5
6
  import { useWidgetConfig } from "@envive-ai/react-hooks/contexts/widgetConfigContext";
@@ -11,9 +12,9 @@ function withBaseWidget(Widget, options) {
11
12
  const WrappedWidget = (props) => {
12
13
  const { widgetConfigId, widgetType } = props;
13
14
  const widgetRef = useRef(null);
14
- const hasTrackedEvent = useRef(false);
15
- const { trackEvent, isReady } = useAmplitude();
15
+ const { isReady } = useAmplitude();
16
16
  const [hardcopyContent, setHardcopyContent] = useState(void 0);
17
+ const hardcopyFetchedRef = useRef(false);
17
18
  const { getHardcopy, isLoading: isHardcopyLoading } = useHardcopy();
18
19
  const { userEvent, isLoading: isPageLoading } = usePage();
19
20
  const [widgetConfig, setWidgetConfig] = useState(void 0);
@@ -21,75 +22,68 @@ function withBaseWidget(Widget, options) {
21
22
  const [uiConfig, setUiConfig] = useState(void 0);
22
23
  const { getUiConfig, isLoading: isUiConfigLoading } = useUiConfig();
23
24
  const isLoading = isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading;
24
- useEffect(() => {
25
- if (!isReady || hasTrackedEvent.current || !widgetRef.current) return;
26
- const observer = new IntersectionObserver(([entry]) => {
27
- if (entry.isIntersecting && !hasTrackedEvent.current) {
28
- trackEvent({
29
- eventName: options?.visibilityEventName || SpiffyMetricsEventName.ChatComponentVisible,
30
- eventProps: {
31
- widget_config_id: widgetConfigId,
32
- widget_type: widgetType,
33
- ...options?.visibilityEventProps
34
- }
35
- });
36
- hasTrackedEvent.current = true;
37
- observer.disconnect();
38
- }
39
- }, { rootMargin: options?.rootMargin || "0px" });
40
- observer.observe(widgetRef.current);
41
- return () => {
42
- observer.disconnect();
43
- };
25
+ const { isVisible } = useTrackComponentVisibleEvent(widgetRef, {
26
+ widget_config_id: widgetConfigId,
27
+ widget_type: widgetType,
28
+ ...options?.visibilityEventProps
29
+ }, options?.rootMargin || "0px", isReady);
30
+ const startLoading = useMemo(() => {
31
+ if (options?.deferLoading === false) return true;
32
+ return isVisible && !!widgetConfigId && !!widgetType;
44
33
  }, [
45
- isReady,
34
+ isVisible,
46
35
  widgetConfigId,
47
- widgetType,
48
- trackEvent
36
+ widgetType
49
37
  ]);
50
38
  useEffect(() => {
51
- if (!widgetType || !userEvent) return;
39
+ if (!startLoading || hardcopyFetchedRef.current) return;
40
+ hardcopyFetchedRef.current = true;
52
41
  getHardcopy({
53
42
  widgetType,
54
43
  userEvent
55
44
  }).then(setHardcopyContent).catch(() => {});
56
45
  }, [
57
- widgetConfigId,
46
+ startLoading,
58
47
  widgetType,
59
48
  getHardcopy,
60
- userEvent
49
+ userEvent,
50
+ widgetConfigId
61
51
  ]);
62
52
  useEffect(() => {
53
+ if (!startLoading) return;
63
54
  getUiConfig().then(setUiConfig).catch(() => {});
64
55
  }, [
56
+ startLoading,
65
57
  getUiConfig,
66
58
  widgetConfigId,
67
59
  widgetType
68
60
  ]);
69
61
  useEffect(() => {
70
- if (!widgetConfigId || !widgetType) return;
62
+ if (!startLoading) return;
71
63
  getWidgetConfig({
72
64
  widgetConfigId,
73
65
  widgetType
74
- }).then(setWidgetConfig).catch((e) => {
75
- console.error("Error getting widget config", widgetConfigId, widgetType, e);
76
- });
66
+ }).then(setWidgetConfig).catch(() => {});
77
67
  }, [
68
+ startLoading,
78
69
  widgetConfigId,
79
70
  widgetType,
80
71
  getWidgetConfig
81
72
  ]);
82
- return /* @__PURE__ */ jsx(Widget, {
83
- ...props,
84
- isLoading,
85
- isHardcopyLoading,
86
- isPageLoading,
87
- isWidgetConfigLoading,
88
- isUiConfigLoading,
89
- uiConfig,
90
- widgetConfig,
91
- hardcopyContent,
92
- observedWidget: widgetRef
73
+ return /* @__PURE__ */ jsx("span", {
74
+ ref: widgetRef,
75
+ children: /* @__PURE__ */ jsx(Widget, {
76
+ ...props,
77
+ isLoading,
78
+ isHardcopyLoading,
79
+ isPageLoading,
80
+ isWidgetConfigLoading,
81
+ isUiConfigLoading,
82
+ uiConfig,
83
+ widgetConfig,
84
+ hardcopyContent,
85
+ observedWidget: widgetRef
86
+ })
93
87
  });
94
88
  };
95
89
  WrappedWidget.displayName = `withBaseWidget(${Widget.displayName || Widget.name || "Component"})`;
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime18 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime13 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts
5
5
  declare const ChatPreviewComparisonWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime18.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime13.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewComparisonWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewComparisonWidgetProps {
12
12
  declare const ChatPreviewComparisonWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewComparisonWidgetProps): react_jsx_runtime18.JSX.Element;
15
+ }: ChatPreviewComparisonWidgetProps): react_jsx_runtime13.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
2
- import * as react_jsx_runtime16 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime18 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts
5
5
  declare const ChatPreviewComparisonWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime16.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime18.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewComparisonWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewComparisonWidgetProps {
12
12
  declare const ChatPreviewComparisonWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewComparisonWidgetProps): react_jsx_runtime16.JSX.Element;
15
+ }: ChatPreviewComparisonWidgetProps): react_jsx_runtime18.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts
5
5
  declare const ChatPreviewLoadingWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime0.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime7.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewLoadingWidgetProps {
@@ -11,6 +11,6 @@ interface ChatPreviewLoadingWidgetProps {
11
11
  }
12
12
  declare const ChatPreviewLoadingWidget: ({
13
13
  widgetConfigId
14
- }: ChatPreviewLoadingWidgetProps) => react_jsx_runtime0.JSX.Element;
14
+ }: ChatPreviewLoadingWidgetProps) => react_jsx_runtime7.JSX.Element;
15
15
  //#endregion
16
16
  export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetProps, ChatPreviewLoadingWidgetWithBaseWidget };
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
2
- import * as react_jsx_runtime11 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime16 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts
5
5
  declare const ChatPreviewLoadingWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime11.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime16.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewLoadingWidgetProps {
@@ -11,6 +11,6 @@ interface ChatPreviewLoadingWidgetProps {
11
11
  }
12
12
  declare const ChatPreviewLoadingWidget: ({
13
13
  widgetConfigId
14
- }: ChatPreviewLoadingWidgetProps) => react_jsx_runtime11.JSX.Element;
14
+ }: ChatPreviewLoadingWidgetProps) => react_jsx_runtime16.JSX.Element;
15
15
  //#endregion
16
16
  export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetProps, ChatPreviewLoadingWidgetWithBaseWidget };
@@ -36,15 +36,6 @@ const ChatPreviewWidgetHandler = (props) => {
36
36
  const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
37
37
  const { trackWidgetInteraction } = (0, __envive_ai_react_hooks_hooks_WidgetInteraction.useWidgetInteraction)();
38
38
  const { onClick: onPromptClicked, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } = (0, __envive_ai_react_toolkit_v3_PromptCarousel.usePromptCarouselAnalytics)(__envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionComponent.CHAT_PREVIEW, (text) => text);
39
- (0, react.useEffect)(() => {
40
- trackEvent({
41
- eventName: __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
42
- eventProps: {
43
- widget_config_id: widgetConfigId,
44
- widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.ChatPreviewV3
45
- }
46
- });
47
- }, [trackEvent, widgetConfigId]);
48
39
  const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
49
40
  const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
50
41
  const handlePromptButtonClick = (0, react.useCallback)((suggestion) => {
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime16 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts
5
5
  declare const ChatPreviewWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime16.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime3.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewWidgetProps {
12
12
  declare const ChatPreviewWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewWidgetProps): react_jsx_runtime16.JSX.Element;
15
+ }: ChatPreviewWidgetProps): react_jsx_runtime3.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
2
- import * as react_jsx_runtime14 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime13 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts
5
5
  declare const ChatPreviewWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime14.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime13.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewWidgetProps {
12
12
  declare const ChatPreviewWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewWidgetProps): react_jsx_runtime14.JSX.Element;
15
+ }: ChatPreviewWidgetProps): react_jsx_runtime13.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,8 +1,8 @@
1
1
  import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
2
2
  import { getMessageText } from "../utils/functions.js";
3
3
  import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js";
4
- import { useCallback, useEffect, useMemo } from "react";
5
- import { EnviveMetricsEventName, SpiffyMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
4
+ import { useCallback, useMemo } from "react";
5
+ import { EnviveMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
8
8
  import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
@@ -35,15 +35,6 @@ const ChatPreviewWidgetHandler = (props) => {
35
35
  const { trackEvent } = useAmplitude();
36
36
  const { trackWidgetInteraction } = useWidgetInteraction();
37
37
  const { onClick: onPromptClicked, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } = usePromptCarouselAnalytics(WidgetInteractionComponent.CHAT_PREVIEW, (text) => text);
38
- useEffect(() => {
39
- trackEvent({
40
- eventName: SpiffyMetricsEventName.ChatComponentVisible,
41
- eventProps: {
42
- widget_config_id: widgetConfigId,
43
- widget_type: WidgetTypeV3.ChatPreviewV3
44
- }
45
- });
46
- }, [trackEvent, widgetConfigId]);
47
38
  const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
48
39
  const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
49
40
  const handlePromptButtonClick = useCallback((suggestion) => {
@@ -11,6 +11,7 @@ const require_useFloatingButtonVisibility = require('./hooks/useFloatingButtonVi
11
11
  const require_useAutoPopup = require('./hooks/useAutoPopup.cjs');
12
12
  let react = require("react");
13
13
  let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
14
+ let __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent = require("@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent");
14
15
  let react_jsx_runtime = require("react/jsx-runtime");
15
16
  let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
16
17
  let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
@@ -78,20 +79,12 @@ const FloatingChatWidgetHandler = (props) => {
78
79
  return uiConfig?.lookAndFeel?.theme ?? __envive_ai_react_toolkit_v3_Tokens.Theme.GLOBAL_CUSTOM;
79
80
  }, [isUiConfigLoading, uiConfig]);
80
81
  require_useAutoPopup.useAutoPopup({ autoPopupConfig: floatingChat?.autoPopupConfig });
81
- const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
82
- const hasTrackedEvent = (0, react.useRef)(false);
83
- (0, react.useEffect)(() => {
84
- if (buttonShouldRender && !hasTrackedEvent.current) {
85
- trackEvent({
86
- eventName: __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
87
- eventProps: {
88
- widget_config_id: "floating-button",
89
- widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.FloatingButtonV3
90
- }
91
- });
92
- hasTrackedEvent.current = true;
93
- }
94
- }, [trackEvent, buttonShouldRender]);
82
+ const { isReady } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
83
+ const floatingButtonVisibilityRef = (0, react.useRef)(null);
84
+ (0, __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent.useTrackComponentVisibleEvent)(floatingButtonVisibilityRef, {
85
+ widget_config_id: "floating-button",
86
+ widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.FloatingButtonV3
87
+ }, "0px", isReady && buttonShouldRender);
95
88
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CXButtonProvider, {
96
89
  provider: cxProvider,
97
90
  enabled: customerServiceIntegration?.enabled ?? false,
@@ -126,23 +119,26 @@ const FloatingChatWidgetHandler = (props) => {
126
119
  handleClose({ collapse_source: "close_button" });
127
120
  }
128
121
  }) })
129
- }), buttonShouldRender && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_v3_FloatingButton.FloatingButton, {
130
- id: require_constants.FLOATING_BUTTON_ID,
131
- variant: floatingButton?.style,
132
- mode: floatingButton?.mode,
133
- backgroundColor: floatingButton?.backgroundColor,
134
- onClick: previewButtonOnly ? () => {} : () => openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_BUTTON),
135
- onMouseOver: onHover,
136
- customIcon: floatingButton?.iconSVGSrc,
137
- show: floatingButton?.showOption,
138
- location: floatingButton?.position,
139
- hasInteractionHappened: userHasInteractedValue,
140
- ariaLabel: "Open chat",
141
- previewMode: !!previewButtonOnly
122
+ }), buttonShouldRender && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
123
+ ref: floatingButtonVisibilityRef,
124
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_v3_FloatingButton.FloatingButton, {
125
+ id: require_constants.FLOATING_BUTTON_ID,
126
+ variant: floatingButton?.style,
127
+ mode: floatingButton?.mode,
128
+ backgroundColor: floatingButton?.backgroundColor,
129
+ onClick: previewButtonOnly ? () => {} : () => openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_BUTTON),
130
+ onMouseOver: onHover,
131
+ customIcon: floatingButton?.iconSVGSrc,
132
+ show: floatingButton?.showOption,
133
+ location: floatingButton?.position,
134
+ hasInteractionHappened: userHasInteractedValue,
135
+ ariaLabel: "Open chat",
136
+ previewMode: !!previewButtonOnly
137
+ })
142
138
  })] })
143
139
  }, cxProvider);
144
140
  };
145
- const FloatingChatWidgetWithBaseWidget = require_withBaseWidget.withBaseWidget(FloatingChatWidgetHandler);
141
+ const FloatingChatWidgetWithBaseWidget = require_withBaseWidget.withBaseWidget(FloatingChatWidgetHandler, { deferLoading: false });
146
142
  const FloatingChatWidget = ({ previewButtonOnly, previewChatAlwaysOpen } = {}) => {
147
143
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingChatWidgetWithBaseWidget, {
148
144
  widgetType: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.FloatingChatV3,
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime15 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime19 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts
4
4
  interface FloatingChatWidgetProps {
@@ -9,7 +9,7 @@ declare const FloatingChatWidget: {
9
9
  ({
10
10
  previewButtonOnly,
11
11
  previewChatAlwaysOpen
12
- }?: FloatingChatWidgetProps): react_jsx_runtime15.JSX.Element;
12
+ }?: FloatingChatWidgetProps): react_jsx_runtime19.JSX.Element;
13
13
  displayName: string;
14
14
  };
15
15
  //#endregion
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime4 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts
4
4
  interface FloatingChatWidgetProps {
@@ -9,7 +9,7 @@ declare const FloatingChatWidget: {
9
9
  ({
10
10
  previewButtonOnly,
11
11
  previewChatAlwaysOpen
12
- }?: FloatingChatWidgetProps): react_jsx_runtime4.JSX.Element;
12
+ }?: FloatingChatWidgetProps): react_jsx_runtime0.JSX.Element;
13
13
  displayName: string;
14
14
  };
15
15
  //#endregion