@envive-ai/react-hooks 0.3.3 → 0.3.4

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 (462) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +2 -0
  2. package/dist/_virtual/rolldown_runtime.js +29 -0
  3. package/dist/application/commerce-api.cjs +11 -3
  4. package/dist/application/commerce-api.js +11 -3
  5. package/dist/application/models/api/userEvent.d.cts +4 -2
  6. package/dist/application/models/api/userEvent.d.ts +4 -2
  7. package/dist/application/models/chatElementDisplayLocationV3.cjs +18 -0
  8. package/dist/application/models/chatElementDisplayLocationV3.d.cts +15 -0
  9. package/dist/application/models/chatElementDisplayLocationV3.d.ts +15 -0
  10. package/dist/application/models/chatElementDisplayLocationV3.js +17 -0
  11. package/dist/application/models/colorsConfigV3.cjs +26 -0
  12. package/dist/application/models/colorsConfigV3.d.cts +22 -0
  13. package/dist/application/models/colorsConfigV3.d.ts +22 -0
  14. package/dist/application/models/colorsConfigV3.js +24 -0
  15. package/dist/application/models/featureGates.cjs +2 -1
  16. package/dist/application/models/featureGates.d.cts +2 -1
  17. package/dist/application/models/featureGates.d.ts +2 -1
  18. package/dist/application/models/featureGates.js +2 -1
  19. package/dist/application/models/frontendConfig.d.cts +4 -2
  20. package/dist/application/models/frontendConfig.d.ts +4 -2
  21. package/dist/application/models/frontendConfigV3.d.cts +14 -0
  22. package/dist/application/models/frontendConfigV3.d.ts +14 -0
  23. package/dist/application/models/index.cjs +3 -0
  24. package/dist/application/models/index.d.cts +4 -3
  25. package/dist/application/models/index.d.ts +4 -3
  26. package/dist/application/models/index.js +3 -2
  27. package/dist/application/models/utils/snakeToCamelTransformer.cjs +2 -1
  28. package/dist/application/models/utils/snakeToCamelTransformer.d.cts +7 -2
  29. package/dist/application/models/utils/snakeToCamelTransformer.d.ts +7 -2
  30. package/dist/application/models/utils/snakeToCamelTransformer.js +2 -2
  31. package/dist/application/utils/analyticsUtils.cjs +5 -4
  32. package/dist/application/utils/analyticsUtils.d.cts +1 -1
  33. package/dist/application/utils/analyticsUtils.d.ts +1 -1
  34. package/dist/application/utils/analyticsUtils.js +3 -2
  35. package/dist/application/utils/elementObserver.cjs +1 -1
  36. package/dist/application/utils/elementObserver.js +1 -1
  37. package/dist/application/utils/index.d.cts +1 -1
  38. package/dist/application/utils/index.d.ts +1 -1
  39. package/dist/application/utils/widgetTextFromApiWidgetTextResponse.cjs +14 -0
  40. package/dist/application/utils/widgetTextFromApiWidgetTextResponse.js +13 -0
  41. package/dist/application/utils/widgetTextRequestToApiRequest.cjs +30 -0
  42. package/dist/application/utils/widgetTextRequestToApiRequest.js +29 -0
  43. package/dist/atoms/amplitude/amplitudeTrackEventAtom.cjs +1 -1
  44. package/dist/atoms/amplitude/amplitudeTrackEventAtom.js +1 -1
  45. package/dist/atoms/app/index.cjs +4 -3
  46. package/dist/atoms/app/index.d.cts +3 -3
  47. package/dist/atoms/app/index.d.ts +9 -9
  48. package/dist/atoms/app/index.js +4 -5
  49. package/dist/atoms/app/variant.cjs +5 -1
  50. package/dist/atoms/app/variant.d.cts +11 -4
  51. package/dist/atoms/app/variant.d.ts +11 -4
  52. package/dist/atoms/app/variant.js +4 -2
  53. package/dist/atoms/chat/chatState.cjs +9 -4
  54. package/dist/atoms/chat/chatState.d.cts +25 -18
  55. package/dist/atoms/chat/chatState.d.ts +25 -18
  56. package/dist/atoms/chat/chatState.js +6 -3
  57. package/dist/atoms/chat/form.cjs +4 -4
  58. package/dist/atoms/chat/form.d.cts +2 -2
  59. package/dist/atoms/chat/form.d.ts +2 -2
  60. package/dist/atoms/chat/index.cjs +32 -30
  61. package/dist/atoms/chat/index.d.cts +4 -4
  62. package/dist/atoms/chat/index.d.ts +5 -5
  63. package/dist/atoms/chat/index.js +2 -2
  64. package/dist/atoms/chat/lastMessage.cjs +4 -4
  65. package/dist/atoms/chat/lastMessage.d.cts +2 -2
  66. package/dist/atoms/chat/lastMessage.d.ts +2 -2
  67. package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
  68. package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
  69. package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
  70. package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
  71. package/dist/atoms/chat/replies.cjs +9 -8
  72. package/dist/atoms/chat/replies.d.cts +3 -3
  73. package/dist/atoms/chat/replies.d.ts +3 -3
  74. package/dist/atoms/chat/replies.js +3 -2
  75. package/dist/atoms/chat/suggestions.cjs +6 -6
  76. package/dist/atoms/chat/suggestions.d.cts +2 -2
  77. package/dist/atoms/chat/suggestions.d.ts +2 -2
  78. package/dist/atoms/envive/enviveConfig.cjs +5 -2
  79. package/dist/atoms/envive/enviveConfig.js +5 -2
  80. package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
  81. package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
  82. package/dist/atoms/org/customerService.d.cts +6 -6
  83. package/dist/atoms/org/customerService.d.ts +6 -6
  84. package/dist/atoms/org/graphqlConfig.cjs +1 -3
  85. package/dist/atoms/org/graphqlConfig.d.cts +6 -9
  86. package/dist/atoms/org/graphqlConfig.d.ts +6 -9
  87. package/dist/atoms/org/graphqlConfig.js +2 -3
  88. package/dist/atoms/org/index.cjs +2 -3
  89. package/dist/atoms/org/index.d.cts +2 -2
  90. package/dist/atoms/org/index.d.ts +2 -2
  91. package/dist/atoms/org/index.js +2 -2
  92. package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
  93. package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
  94. package/dist/atoms/org/orgAnalyticsConfig.d.cts +5 -5
  95. package/dist/atoms/org/orgAnalyticsConfig.d.ts +5 -5
  96. package/dist/atoms/search/chatSearch.cjs +7 -7
  97. package/dist/atoms/search/chatSearch.d.cts +20 -18
  98. package/dist/atoms/search/chatSearch.d.ts +20 -18
  99. package/dist/atoms/search/searchAPI.cjs +1 -1
  100. package/dist/atoms/search/searchAPI.d.cts +15 -14
  101. package/dist/atoms/search/searchAPI.d.ts +15 -14
  102. package/dist/atoms/search/searchAPI.js +1 -1
  103. package/dist/atoms/search/utils.d.cts +1 -1
  104. package/dist/atoms/widget/chatPreviewLoading.cjs +23 -0
  105. package/dist/atoms/widget/chatPreviewLoading.d.cts +26 -0
  106. package/dist/atoms/widget/chatPreviewLoading.d.ts +26 -0
  107. package/dist/atoms/widget/chatPreviewLoading.js +22 -0
  108. package/dist/atoms/widget/index.cjs +3 -0
  109. package/dist/atoms/widget/index.d.cts +2 -0
  110. package/dist/atoms/widget/index.d.ts +2 -0
  111. package/dist/atoms/widget/index.js +3 -0
  112. package/dist/contexts/amplitudeContext/amplitudeContext.cjs +40 -227
  113. package/dist/contexts/amplitudeContext/amplitudeContext.d.cts +4 -39
  114. package/dist/contexts/amplitudeContext/amplitudeContext.d.ts +4 -39
  115. package/dist/contexts/amplitudeContext/amplitudeContext.js +44 -230
  116. package/dist/contexts/amplitudeContext/index.cjs +2 -1
  117. package/dist/contexts/amplitudeContext/index.d.cts +2 -1
  118. package/dist/contexts/amplitudeContext/index.d.ts +2 -1
  119. package/dist/contexts/amplitudeContext/index.js +2 -1
  120. package/dist/contexts/enviveConfigContext/enviveConfigContext.cjs +3 -2
  121. package/dist/contexts/enviveConfigContext/enviveConfigContext.d.cts +2 -1
  122. package/dist/contexts/enviveConfigContext/enviveConfigContext.d.ts +2 -1
  123. package/dist/contexts/enviveConfigContext/enviveConfigContext.js +3 -2
  124. package/dist/contexts/enviveContext/enviveContext.cjs +67 -16
  125. package/dist/contexts/enviveContext/enviveContext.d.cts +9 -1
  126. package/dist/contexts/enviveContext/enviveContext.d.ts +9 -1
  127. package/dist/contexts/enviveContext/enviveContext.js +69 -18
  128. package/dist/contexts/enviveCssContext/enviveCssContext.cjs +96 -24
  129. package/dist/contexts/enviveCssContext/enviveCssContext.js +96 -24
  130. package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.cjs +5 -7
  131. package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.cts +2 -2
  132. package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +2 -2
  133. package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.js +5 -7
  134. package/dist/contexts/graphqlContext/graphqlContext.cjs +69 -7
  135. package/dist/contexts/graphqlContext/graphqlContext.d.cts +17 -5
  136. package/dist/contexts/graphqlContext/graphqlContext.d.ts +17 -5
  137. package/dist/contexts/graphqlContext/graphqlContext.js +69 -7
  138. package/dist/contexts/graphqlContext/index.d.cts +2 -2
  139. package/dist/contexts/graphqlContext/index.d.ts +2 -2
  140. package/dist/contexts/graphqlContext/mockV3Config.cjs +208 -0
  141. package/dist/contexts/graphqlContext/mockV3Config.js +207 -0
  142. package/dist/contexts/hardcopyContext/hardcopyContext.cjs +119 -12
  143. package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +3 -2
  144. package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +3 -2
  145. package/dist/contexts/hardcopyContext/hardcopyContext.js +120 -13
  146. package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +7 -8
  147. package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +8 -9
  148. package/dist/contexts/pageContext/mapping.cjs +5 -1
  149. package/dist/contexts/pageContext/mapping.d.cts +1 -1
  150. package/dist/contexts/pageContext/mapping.d.ts +1 -1
  151. package/dist/contexts/pageContext/mapping.js +5 -1
  152. package/dist/contexts/pageContext/pageContext.cjs +29 -9
  153. package/dist/contexts/pageContext/pageContext.d.cts +5 -2
  154. package/dist/contexts/pageContext/pageContext.d.ts +5 -2
  155. package/dist/contexts/pageContext/pageContext.js +30 -10
  156. package/dist/contexts/pageContext/types.d.cts +5 -1
  157. package/dist/contexts/pageContext/types.d.ts +5 -1
  158. package/dist/contexts/salesAgentContext/chatAPI.cjs +6 -3
  159. package/dist/contexts/salesAgentContext/chatAPI.js +6 -3
  160. package/dist/contexts/salesAgentContext/salesAgentContext.cjs +65 -25
  161. package/dist/contexts/salesAgentContext/salesAgentContext.js +64 -24
  162. package/dist/contexts/salesAgentContext/salesAgentService.cjs +43 -7
  163. package/dist/contexts/salesAgentContext/salesAgentService.js +42 -6
  164. package/dist/contexts/salesAgentContext/statusCodeError.cjs +14 -0
  165. package/dist/contexts/salesAgentContext/statusCodeError.js +13 -0
  166. package/dist/contexts/searchContext/searchContext.cjs +1 -1
  167. package/dist/contexts/searchContext/searchContext.js +1 -1
  168. package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
  169. package/dist/contexts/types.cjs +2 -13
  170. package/dist/contexts/types.d.cts +12 -16
  171. package/dist/contexts/types.d.ts +12 -16
  172. package/dist/contexts/types.js +3 -13
  173. package/dist/contexts/typesV3.cjs +125 -0
  174. package/dist/contexts/typesV3.d.cts +246 -0
  175. package/dist/contexts/typesV3.d.ts +246 -0
  176. package/dist/contexts/typesV3.js +113 -0
  177. package/dist/contexts/uiConfigContext/index.cjs +4 -0
  178. package/dist/contexts/uiConfigContext/index.d.cts +2 -0
  179. package/dist/contexts/uiConfigContext/index.d.ts +2 -0
  180. package/dist/contexts/uiConfigContext/index.js +3 -0
  181. package/dist/contexts/uiConfigContext/uiConfigContext.cjs +44 -0
  182. package/dist/contexts/uiConfigContext/uiConfigContext.d.cts +15 -0
  183. package/dist/contexts/uiConfigContext/uiConfigContext.d.ts +15 -0
  184. package/dist/contexts/uiConfigContext/uiConfigContext.js +42 -0
  185. package/dist/contexts/userIdentityContext/userIdentityContext.cjs +1 -1
  186. package/dist/contexts/userIdentityContext/userIdentityContext.js +1 -1
  187. package/dist/contexts/widgetConfigContext/index.cjs +4 -0
  188. package/dist/contexts/widgetConfigContext/index.d.cts +2 -0
  189. package/dist/contexts/widgetConfigContext/index.d.ts +2 -0
  190. package/dist/contexts/widgetConfigContext/index.js +3 -0
  191. package/dist/contexts/widgetConfigContext/widgetConfigContext.cjs +67 -0
  192. package/dist/contexts/widgetConfigContext/widgetConfigContext.d.cts +19 -0
  193. package/dist/contexts/widgetConfigContext/widgetConfigContext.d.ts +19 -0
  194. package/dist/contexts/widgetConfigContext/widgetConfigContext.js +65 -0
  195. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.cts +1 -1
  196. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.ts +1 -1
  197. package/dist/hooks/AppDetails/useAppDetails.cjs +2 -4
  198. package/dist/hooks/AppDetails/useAppDetails.js +3 -5
  199. package/dist/hooks/ChatToggle/useChatToggle.cjs +6 -5
  200. package/dist/hooks/ChatToggle/useChatToggle.js +3 -2
  201. package/dist/hooks/ChatToggleAnalytics/useChatToggleAnalytics.cjs +3 -3
  202. package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
  203. package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.ts +3 -3
  204. package/dist/hooks/GraphQLConfig/index.cjs +1 -1
  205. package/dist/hooks/GraphQLConfig/index.d.cts +2 -2
  206. package/dist/hooks/GraphQLConfig/index.d.ts +2 -2
  207. package/dist/hooks/GraphQLConfig/index.js +2 -2
  208. package/dist/hooks/GraphQLConfig/useGraphQLConfig.cjs +27 -24
  209. package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.cts +5 -4
  210. package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.ts +5 -4
  211. package/dist/hooks/GraphQLConfig/useGraphQLConfig.js +27 -24
  212. package/dist/hooks/Search/useSearch.cjs +10 -9
  213. package/dist/hooks/Search/useSearch.js +6 -5
  214. package/dist/hooks/Search/useSearchInput.cjs +4 -4
  215. package/dist/hooks/Search/useSearchInput.js +1 -1
  216. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.cjs +5 -4
  217. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.cts +1 -1
  218. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.ts +1 -1
  219. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +3 -2
  220. package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.cjs +3 -2
  221. package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +3 -2
  222. package/dist/hooks/utils.d.cts +1 -1
  223. package/dist/node_modules/classnames/index.cjs +52 -0
  224. package/dist/node_modules/classnames/index.js +49 -0
  225. package/dist/packages/components-v3/dist/Container/Container.cjs +11 -0
  226. package/dist/packages/components-v3/dist/Container/Container.js +12 -0
  227. package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.cjs +1 -0
  228. package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.js +3 -0
  229. package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.cjs +1 -0
  230. package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.js +3 -0
  231. package/dist/packages/components-v3/dist/Container/index.cjs +1 -0
  232. package/dist/packages/components-v3/dist/Container/index.js +3 -0
  233. package/dist/packages/components-v3/dist/Image/Image.cjs +16 -0
  234. package/dist/packages/components-v3/dist/Image/Image.js +17 -0
  235. package/dist/packages/components-v3/dist/Image/hooks/useGetAccessibilityProperties.cjs +1 -0
  236. package/dist/packages/components-v3/dist/Image/hooks/useGetAccessibilityProperties.js +3 -0
  237. package/dist/packages/components-v3/dist/Image/hooks/useGetAspectRatioProperties.cjs +1 -0
  238. package/dist/packages/components-v3/dist/Image/hooks/useGetAspectRatioProperties.js +3 -0
  239. package/dist/packages/components-v3/dist/Image/hooks/useGetObjectFitProperties.cjs +1 -0
  240. package/dist/packages/components-v3/dist/Image/hooks/useGetObjectFitProperties.js +3 -0
  241. package/dist/packages/components-v3/dist/Image/hooks/useGetRoundedProperties.cjs +1 -0
  242. package/dist/packages/components-v3/dist/Image/hooks/useGetRoundedProperties.js +3 -0
  243. package/dist/packages/components-v3/dist/Image/hooks/useGetSkeletonProperties.cjs +1 -0
  244. package/dist/packages/components-v3/dist/Image/hooks/useGetSkeletonProperties.js +3 -0
  245. package/dist/packages/components-v3/dist/Image/hooks/useGetWidthProperties.cjs +1 -0
  246. package/dist/packages/components-v3/dist/Image/hooks/useGetWidthProperties.js +3 -0
  247. package/dist/packages/components-v3/dist/Image/hooks/useHandleImageLoading.cjs +1 -0
  248. package/dist/packages/components-v3/dist/Image/hooks/useHandleImageLoading.js +3 -0
  249. package/dist/packages/components-v3/dist/ImageGallery/ImageGallery.cjs +2 -0
  250. package/dist/packages/components-v3/dist/ImageGallery/ImageGallery.js +4 -0
  251. package/dist/packages/components-v3/dist/ImageGallery/components/ImageItem.cjs +2 -0
  252. package/dist/packages/components-v3/dist/ImageGallery/components/ImageItem.js +4 -0
  253. package/dist/packages/components-v3/dist/ImageGallery/components/Layout.cjs +15 -0
  254. package/dist/packages/components-v3/dist/ImageGallery/components/Layout.js +16 -0
  255. package/dist/packages/components-v3/dist/ImageGallery/components/NormalLayout.cjs +4 -0
  256. package/dist/packages/components-v3/dist/ImageGallery/components/NormalLayout.js +4 -0
  257. package/dist/packages/components-v3/dist/ImageGallery/components/OverlappedLayout.cjs +1 -0
  258. package/dist/packages/components-v3/dist/ImageGallery/components/OverlappedLayout.js +3 -0
  259. package/dist/packages/components-v3/dist/ImageGallery/components/index.cjs +4 -0
  260. package/dist/packages/components-v3/dist/ImageGallery/components/index.js +6 -0
  261. package/dist/packages/components-v3/dist/ImageGallery/hooks/useGetContainerProperties.cjs +1 -0
  262. package/dist/packages/components-v3/dist/ImageGallery/hooks/useGetContainerProperties.js +3 -0
  263. package/dist/packages/components-v3/dist/ImageGallery/index.cjs +2 -0
  264. package/dist/packages/components-v3/dist/ImageGallery/index.js +4 -0
  265. package/dist/packages/components-v3/dist/ImageGallery/types/types.cjs +13 -0
  266. package/dist/packages/components-v3/dist/ImageGallery/types/types.js +12 -0
  267. package/dist/packages/components-v3/dist/PromptButton/PromptButton.cjs +12 -0
  268. package/dist/packages/components-v3/dist/PromptButton/PromptButton.js +13 -0
  269. package/dist/packages/components-v3/dist/PromptButton/components/Icon.cjs +1 -0
  270. package/dist/packages/components-v3/dist/PromptButton/components/Icon.js +3 -0
  271. package/dist/packages/components-v3/dist/PromptButton/components/Label.cjs +3 -0
  272. package/dist/packages/components-v3/dist/PromptButton/components/Label.js +5 -0
  273. package/dist/packages/components-v3/dist/PromptButton/components/Layout.cjs +12 -0
  274. package/dist/packages/components-v3/dist/PromptButton/components/Layout.js +13 -0
  275. package/dist/packages/components-v3/dist/PromptButton/components/Loading.cjs +9 -0
  276. package/dist/packages/components-v3/dist/PromptButton/components/Loading.js +10 -0
  277. package/dist/packages/components-v3/dist/PromptButton/components/index.cjs +4 -0
  278. package/dist/packages/components-v3/dist/PromptButton/components/index.js +6 -0
  279. package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.cjs +1 -0
  280. package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.js +3 -0
  281. package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.cjs +8 -0
  282. package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.js +9 -0
  283. package/dist/packages/components-v3/dist/PromptButton/index.cjs +2 -0
  284. package/dist/packages/components-v3/dist/PromptButton/index.js +4 -0
  285. package/dist/packages/components-v3/dist/PromptButton/types/index.cjs +13 -0
  286. package/dist/packages/components-v3/dist/PromptButton/types/index.js +12 -0
  287. package/dist/packages/components-v3/dist/PromptCarousel/PromptCarousel.cjs +12 -0
  288. package/dist/packages/components-v3/dist/PromptCarousel/PromptCarousel.js +14 -0
  289. package/dist/packages/components-v3/dist/PromptCarousel/components/BlockScrollContainer.cjs +9 -0
  290. package/dist/packages/components-v3/dist/PromptCarousel/components/BlockScrollContainer.js +10 -0
  291. package/dist/packages/components-v3/dist/PromptCarousel/components/ButtonContainerRow.cjs +11 -0
  292. package/dist/packages/components-v3/dist/PromptCarousel/components/ButtonContainerRow.js +12 -0
  293. package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithBlockScroll.cjs +4 -0
  294. package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithBlockScroll.js +6 -0
  295. package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithRowScroll.cjs +4 -0
  296. package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithRowScroll.js +6 -0
  297. package/dist/packages/components-v3/dist/PromptCarousel/components/index.cjs +3 -0
  298. package/dist/packages/components-v3/dist/PromptCarousel/components/index.js +5 -0
  299. package/dist/packages/components-v3/dist/PromptCarousel/hooks/index.cjs +5 -0
  300. package/dist/packages/components-v3/dist/PromptCarousel/hooks/index.js +7 -0
  301. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useButtonScrollPosition.cjs +1 -0
  302. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useButtonScrollPosition.js +3 -0
  303. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselAnimation.cjs +3 -0
  304. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselAnimation.js +5 -0
  305. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselButtons.cjs +1 -0
  306. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselButtons.js +3 -0
  307. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselRefs.cjs +1 -0
  308. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselRefs.js +3 -0
  309. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.cjs +1 -0
  310. package/dist/packages/components-v3/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.js +3 -0
  311. package/dist/packages/components-v3/dist/PromptCarousel/index.cjs +2 -0
  312. package/dist/packages/components-v3/dist/PromptCarousel/index.js +4 -0
  313. package/dist/packages/components-v3/dist/PromptCarousel/types/types.cjs +19 -0
  314. package/dist/packages/components-v3/dist/PromptCarousel/types/types.js +17 -0
  315. package/dist/packages/components-v3/dist/Stack/Stack.cjs +36 -0
  316. package/dist/packages/components-v3/dist/Stack/Stack.js +36 -0
  317. package/dist/packages/components-v3/dist/Stack/hooks/useFormatStackChildren.cjs +27 -0
  318. package/dist/packages/components-v3/dist/Stack/hooks/useFormatStackChildren.js +26 -0
  319. package/dist/packages/components-v3/dist/Stack/hooks/useGetAlignProperties.cjs +20 -0
  320. package/dist/packages/components-v3/dist/Stack/hooks/useGetAlignProperties.js +19 -0
  321. package/dist/packages/components-v3/dist/Stack/hooks/useGetDirectionProperties.cjs +19 -0
  322. package/dist/packages/components-v3/dist/Stack/hooks/useGetDirectionProperties.js +18 -0
  323. package/dist/packages/components-v3/dist/Stack/hooks/useGetGapProperties.cjs +16 -0
  324. package/dist/packages/components-v3/dist/Stack/hooks/useGetGapProperties.js +15 -0
  325. package/dist/packages/components-v3/dist/Stack/hooks/useGetJustifyProperties.cjs +21 -0
  326. package/dist/packages/components-v3/dist/Stack/hooks/useGetJustifyProperties.js +20 -0
  327. package/dist/packages/components-v3/dist/Stack/hooks/useGetStyleProperties.cjs +38 -0
  328. package/dist/packages/components-v3/dist/Stack/hooks/useGetStyleProperties.js +38 -0
  329. package/dist/packages/components-v3/dist/Stack/hooks/useGetWrapProperties.cjs +13 -0
  330. package/dist/packages/components-v3/dist/Stack/hooks/useGetWrapProperties.js +12 -0
  331. package/dist/packages/components-v3/dist/Stack/index.cjs +1 -0
  332. package/dist/packages/components-v3/dist/Stack/index.js +3 -0
  333. package/dist/packages/components-v3/dist/Stack/utils/constants.cjs +42 -0
  334. package/dist/packages/components-v3/dist/Stack/utils/constants.js +41 -0
  335. package/dist/packages/components-v3/dist/Typography/Typography.cjs +15 -0
  336. package/dist/packages/components-v3/dist/Typography/Typography.js +16 -0
  337. package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.cjs +1 -0
  338. package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.js +3 -0
  339. package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.cjs +1 -0
  340. package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.js +3 -0
  341. package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.cjs +1 -0
  342. package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.js +3 -0
  343. package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.cjs +1 -0
  344. package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.js +3 -0
  345. package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.cjs +1 -0
  346. package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.js +3 -0
  347. package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.cjs +1 -0
  348. package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.js +3 -0
  349. package/dist/packages/components-v3/dist/Typography/index.cjs +1 -0
  350. package/dist/packages/components-v3/dist/Typography/index.js +3 -0
  351. package/dist/packages/components-v3/dist/WidgetWrapper/WidgetWrapper.cjs +12 -0
  352. package/dist/packages/components-v3/dist/WidgetWrapper/WidgetWrapper.js +13 -0
  353. package/dist/packages/components-v3/dist/WidgetWrapper/hooks/useGetWrapperProperties.cjs +1 -0
  354. package/dist/packages/components-v3/dist/WidgetWrapper/hooks/useGetWrapperProperties.js +3 -0
  355. package/dist/packages/components-v3/dist/WidgetWrapper/index.cjs +2 -0
  356. package/dist/packages/components-v3/dist/WidgetWrapper/index.js +4 -0
  357. package/dist/packages/components-v3/dist/WidgetWrapper/types/types.cjs +13 -0
  358. package/dist/packages/components-v3/dist/WidgetWrapper/types/types.js +12 -0
  359. package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.cjs +25 -0
  360. package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.js +23 -0
  361. package/dist/packages/components-v3/dist/utils/useCheckIsMobile.cjs +1 -0
  362. package/dist/packages/components-v3/dist/utils/useCheckIsMobile.js +3 -0
  363. package/dist/packages/components-v3/dist/utils/useResponsiveValue.cjs +57 -0
  364. package/dist/packages/components-v3/dist/utils/useResponsiveValue.js +56 -0
  365. package/dist/packages/icons/dist/FourPointStar.cjs +8 -0
  366. package/dist/packages/icons/dist/FourPointStar.js +9 -0
  367. package/dist/packages/icons/dist/_virtual/rolldown_runtime.cjs +28 -0
  368. package/dist/packages/icons/dist/_virtual/rolldown_runtime.js +26 -0
  369. package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +697 -0
  370. package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.js +697 -0
  371. package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs +44 -0
  372. package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.js +44 -0
  373. package/dist/packages/icons/dist/node_modules/react/cjs/react.development.cjs +1529 -0
  374. package/dist/packages/icons/dist/node_modules/react/cjs/react.development.js +1529 -0
  375. package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.cjs +330 -0
  376. package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.js +330 -0
  377. package/dist/packages/icons/dist/node_modules/react/index.cjs +14 -0
  378. package/dist/packages/icons/dist/node_modules/react/index.js +14 -0
  379. package/dist/packages/icons/dist/node_modules/react/jsx-runtime.cjs +14 -0
  380. package/dist/packages/icons/dist/node_modules/react/jsx-runtime.js +14 -0
  381. package/dist/services/amplitudeService/amplitudeService.cjs +204 -0
  382. package/dist/services/amplitudeService/amplitudeService.d.cts +75 -0
  383. package/dist/services/amplitudeService/amplitudeService.d.ts +75 -0
  384. package/dist/services/amplitudeService/amplitudeService.js +202 -0
  385. package/dist/services/amplitudeService/index.cjs +4 -0
  386. package/dist/services/amplitudeService/index.d.cts +2 -0
  387. package/dist/services/amplitudeService/index.d.ts +2 -0
  388. package/dist/services/amplitudeService/index.js +3 -0
  389. package/dist/services/enviveConfigService/enviveConfigService.cjs +36 -0
  390. package/dist/services/enviveConfigService/enviveConfigService.d.cts +43 -0
  391. package/dist/services/enviveConfigService/enviveConfigService.d.ts +43 -0
  392. package/dist/services/enviveConfigService/enviveConfigService.js +36 -0
  393. package/dist/services/enviveConfigService/index.cjs +3 -0
  394. package/dist/services/enviveConfigService/index.d.cts +2 -0
  395. package/dist/services/enviveConfigService/index.d.ts +2 -0
  396. package/dist/services/enviveConfigService/index.js +3 -0
  397. package/dist/types/enviveConfig.d.cts +29 -0
  398. package/dist/types/enviveConfig.d.ts +29 -0
  399. package/dist/types/index.d.cts +2 -1
  400. package/dist/types/index.d.ts +2 -1
  401. package/package.json +36 -4
  402. package/src/application/commerce-api.ts +14 -1
  403. package/src/application/models/api/userEvent.ts +3 -1
  404. package/src/application/models/api/widgetText.ts +9 -0
  405. package/src/application/models/api/widgetTextRequest.ts +10 -0
  406. package/src/application/models/chatElementDisplayLocationV3.ts +12 -0
  407. package/src/application/models/colorsConfigV3.ts +26 -0
  408. package/src/application/models/featureGates.ts +1 -0
  409. package/src/application/models/frontendConfig.ts +5 -0
  410. package/src/application/models/frontendConfigV3.ts +10 -0
  411. package/src/application/models/index.ts +1 -0
  412. package/src/application/models/utils/snakeToCamelTransformer.ts +1 -1
  413. package/src/application/utils/elementObserver.ts +2 -2
  414. package/src/application/utils/widgetTextFromApiWidgetTextResponse.ts +30 -0
  415. package/src/application/utils/widgetTextRequestToApiRequest.ts +45 -0
  416. package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -8
  417. package/src/atoms/app/index.ts +3 -3
  418. package/src/atoms/app/variant.ts +5 -0
  419. package/src/atoms/chat/chatState.ts +10 -2
  420. package/src/atoms/envive/enviveConfig.ts +5 -0
  421. package/src/atoms/org/graphqlConfig.ts +0 -1
  422. package/src/atoms/widget/chatPreviewLoading.ts +36 -0
  423. package/src/atoms/widget/index.ts +1 -0
  424. package/src/contexts/amplitudeContext/__tests__/amplitudeContext.test.tsx +197 -187
  425. package/src/contexts/amplitudeContext/amplitudeContext.tsx +56 -334
  426. package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +3 -0
  427. package/src/contexts/enviveContext/enviveContext.tsx +101 -27
  428. package/src/contexts/enviveCssContext/enviveCssContext.tsx +121 -22
  429. package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +12 -11
  430. package/src/contexts/graphqlContext/graphqlContext.tsx +131 -13
  431. package/src/contexts/graphqlContext/mockV3Config.ts +209 -0
  432. package/src/contexts/hardcopyContext/hardcopyContext.tsx +136 -14
  433. package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +6 -6
  434. package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +5 -13
  435. package/src/contexts/pageContext/__tests__/pageContext.test.tsx +24 -8
  436. package/src/contexts/pageContext/mapping.ts +4 -0
  437. package/src/contexts/pageContext/pageContext.tsx +41 -12
  438. package/src/contexts/pageContext/types.ts +4 -0
  439. package/src/contexts/salesAgentContext/chatAPI.ts +1 -0
  440. package/src/contexts/salesAgentContext/salesAgentContext.tsx +94 -42
  441. package/src/contexts/salesAgentContext/salesAgentService.ts +78 -3
  442. package/src/contexts/salesAgentContext/statusCodeError.ts +10 -0
  443. package/src/contexts/searchContext/__tests__/searchContext.test.tsx +8 -2
  444. package/src/contexts/types.ts +15 -19
  445. package/src/contexts/typesV3.ts +316 -0
  446. package/src/contexts/uiConfigContext/__tests__/uiConfigContext.test.tsx +321 -0
  447. package/src/contexts/uiConfigContext/index.ts +1 -0
  448. package/src/contexts/uiConfigContext/uiConfigContext.tsx +44 -0
  449. package/src/contexts/widgetConfigContext/__tests__/widgetConfigContext.test.tsx +512 -0
  450. package/src/contexts/widgetConfigContext/index.ts +1 -0
  451. package/src/contexts/widgetConfigContext/widgetConfigContext.tsx +84 -0
  452. package/src/hooks/AppDetails/useAppDetails.ts +2 -2
  453. package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +22 -21
  454. package/src/hooks/Search/__tests__/useSearch.test.tsx +15 -6
  455. package/src/hooks/Search/useSearch.tsx +6 -5
  456. package/src/services/amplitudeService/__tests__/amplitudeService.test.ts +558 -0
  457. package/src/services/amplitudeService/amplitudeService.ts +324 -0
  458. package/src/services/amplitudeService/index.ts +1 -0
  459. package/src/services/enviveConfigService/enviveConfigService.ts +72 -0
  460. package/src/services/enviveConfigService/index.ts +1 -0
  461. package/src/types/enviveConfig.ts +27 -0
  462. package/src/types/index.ts +1 -0
@@ -7,7 +7,10 @@ import { EnviveConfigProvider } from 'src/contexts/enviveConfigContext/enviveCon
7
7
  import { LocalStorageProvider } from 'src/contexts/localStorageContext/localStorageContext';
8
8
  import { GraphQLProvider } from 'src/contexts/graphqlContext/graphqlContext';
9
9
  import { UserIdentityProvider } from 'src/contexts/userIdentityContext/userIdentityContext';
10
- import { FeatureFlagServiceProvider } from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
10
+ import {
11
+ FeatureFlagService,
12
+ FeatureFlagServiceProvider,
13
+ } from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
11
14
  import { NewOrgConfigProvider } from 'src/contexts/newOrgConfigContext/newOrgConfigContext';
12
15
  import { SearchProvider } from 'src/contexts/searchContext/searchContext';
13
16
  import {
@@ -74,7 +77,7 @@ vi.mock('src/contexts/enviveConfigContext/enviveConfigContext', async () => {
74
77
 
75
78
  // Mock useColorsAndFrontendConfig
76
79
  vi.mock('src/hooks/GraphQLConfig/useGraphQLConfig', () => ({
77
- useColorsAndFrontendConfig: vi.fn(() => ({
80
+ useUIConfig: vi.fn(() => ({
78
81
  data: {
79
82
  colorsConfig: { accentPrimary: '#FF0000' },
80
83
  frontendConfig: {
@@ -168,6 +171,9 @@ vi.mock('src/events', () => ({
168
171
  },
169
172
  }));
170
173
 
174
+ // FeatureFlagService
175
+ const testFeatureFlagService = new FeatureFlagService([]);
176
+
171
177
  const mockSearchData: SearchResult = {
172
178
  products: [
173
179
  {
@@ -393,7 +399,7 @@ const TestWrapper: React.FC<{
393
399
  <LocalStorageProvider>
394
400
  <GraphQLProvider>
395
401
  <UserIdentityProvider>
396
- <FeatureFlagServiceProvider featureGates={[]}>
402
+ <FeatureFlagServiceProvider featureFlagService={testFeatureFlagService}>
397
403
  <AmplitudeProvider>
398
404
  <NewOrgConfigProvider>
399
405
  <SearchProvider>
@@ -405,9 +411,12 @@ const TestWrapper: React.FC<{
405
411
  sorting={sorting}
406
412
  isFilterOpen={isFilterOpen}
407
413
  />
408
- {React.cloneElement(children as React.ReactElement, {
409
- allowRedirect,
410
- })}
414
+ {React.cloneElement(
415
+ children as React.ReactElement<{ allowRedirect?: boolean }>,
416
+ {
417
+ allowRedirect,
418
+ },
419
+ )}
411
420
  </SearchProvider>
412
421
  </NewOrgConfigProvider>
413
422
  </AmplitudeProvider>
@@ -1,5 +1,5 @@
1
1
  import { useAtom, useAtomValue, useSetAtom } from 'jotai';
2
- import { useCallback, useEffect, useMemo, useRef } from 'react';
2
+ import { RefObject, useCallback, useEffect, useMemo, useRef } from 'react';
3
3
 
4
4
  import {
5
5
  SelectedFilterOption,
@@ -28,7 +28,7 @@ import { SearchResult } from 'src/application/models/api/search';
28
28
  import { SearchResponseProduct } from '@spiffy-ai/commerce-api-client';
29
29
  import { SearchFilterDatum, SelectFilterItem } from 'src/types/search-filter-types';
30
30
  import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
31
- import { SearchResponseProductAttributes } from 'src/application/models';
31
+ import { FrontendConfig, SearchResponseProductAttributes } from 'src/application/models';
32
32
  import { SearchResultsState, getSearchResultsState } from '../utils';
33
33
  import { useTrackComponentVisibleEvent } from '../TrackComponentVisibleEvent';
34
34
  import { useSearchInput } from './useSearchInput';
@@ -147,7 +147,8 @@ export const useSearch = ({
147
147
  const dynamicFilters = searchData?.filters || [];
148
148
 
149
149
  // Provide fallback values when orgUIConfig is not yet available
150
- const safeProductCardConfig = config?.frontendConfig?.uiConfigs?.productCardConfig || {
150
+ const safeProductCardConfig = (config?.frontendConfig as FrontendConfig)?.uiConfigs
151
+ ?.productCardConfig || {
151
152
  variant: 'minimal',
152
153
  hoverVariant: 'none',
153
154
  layoutVariant: 'square',
@@ -296,7 +297,7 @@ export const useSearch = ({
296
297
  // Side Effects
297
298
  useTrackComponentVisibleEvent(
298
299
  SpiffyWidgets.SearchResults,
299
- searchResultsRef,
300
+ searchResultsRef as RefObject<HTMLElement>,
300
301
  {},
301
302
  SpiffyMetricsEventName.SearchComponentVisible,
302
303
  );
@@ -360,6 +361,6 @@ export const useSearch = ({
360
361
  onClearAllFilters: handleClearAllFilters,
361
362
  setIsFilterOpen,
362
363
  resetSearch,
363
- searchResultsRef,
364
+ searchResultsRef: searchResultsRef as RefObject<HTMLDivElement>,
364
365
  };
365
366
  };
@@ -0,0 +1,558 @@
1
+ import { FeatureFlagService } from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
2
+ import { FeatureGates } from 'src/application/models/featureGates';
3
+ import { LocalStorageKeys } from 'src/contexts/localStorageContext';
4
+ import Logger from 'src/application/logging/logger';
5
+ import { SpiffyEvent } from 'src/events';
6
+ import {
7
+ AmplitudeService,
8
+ AmplitudeServiceConfig,
9
+ SpiffyMetricsEventName,
10
+ } from '../amplitudeService';
11
+
12
+ const { mockTrack, mockInit, mockAdd, mockDispatch } = vi.hoisted(() => {
13
+ return {
14
+ // Mock Amplitude
15
+ mockTrack: vi.fn(),
16
+ mockInit: vi.fn(),
17
+ mockAdd: vi.fn(),
18
+ // Mock EventsDispatcher
19
+ mockDispatch: vi.fn(),
20
+ };
21
+ });
22
+
23
+ vi.mock('@amplitude/analytics-browser', () => ({
24
+ createInstance: vi.fn(() => ({
25
+ track: mockTrack,
26
+ init: mockInit,
27
+ add: mockAdd,
28
+ })),
29
+ }));
30
+
31
+ vi.mock('src/events', () => ({
32
+ EventsDispatcher: {
33
+ dispatch: mockDispatch,
34
+ },
35
+ SpiffyEvent: {
36
+ AMPLITUDE_EVENT: 'AMPLITUDE_EVENT',
37
+ },
38
+ }));
39
+
40
+ // Mock crypto.subtle.digest for insert_id generation
41
+ const mockDigest = vi.fn().mockResolvedValue(new Uint8Array(32).fill(0));
42
+ Object.defineProperty(global, 'crypto', {
43
+ value: {
44
+ subtle: {
45
+ digest: mockDigest,
46
+ },
47
+ },
48
+ writable: true,
49
+ });
50
+
51
+ describe('AmplitudeService', () => {
52
+ let featureFlagService: FeatureFlagService;
53
+ let mockGetLocalStorageItem: (key: string) => string | null;
54
+
55
+ beforeEach(() => {
56
+ vi.clearAllMocks();
57
+ mockGetLocalStorageItem = vi.fn((key: string) => {
58
+ if (key === LocalStorageKeys.ChatId) {
59
+ return 'test-chat-id';
60
+ }
61
+ return null;
62
+ });
63
+ featureFlagService = new FeatureFlagService([]);
64
+ mockTrack.mockClear();
65
+ mockInit.mockClear();
66
+ mockAdd.mockClear();
67
+ mockDigest.mockResolvedValue(new Uint8Array(32).fill(0));
68
+ mockDispatch.mockClear();
69
+ });
70
+
71
+ const createService = (overrides?: Partial<AmplitudeServiceConfig>) => {
72
+ return new AmplitudeService({
73
+ userId: 'test-user-id',
74
+ amplitudeApiKey: 'test-api-key',
75
+ dataResidency: 'US',
76
+ env: 'test',
77
+ contextSource: 'app',
78
+ orgShortName: 'test-org',
79
+ featureFlagService,
80
+ getLocalStorageItem: mockGetLocalStorageItem,
81
+ ...overrides,
82
+ });
83
+ };
84
+
85
+ describe('Initialization', () => {
86
+ it('should initialize Amplitude client when all required config is provided', () => {
87
+ createService();
88
+
89
+ expect(mockInit).toHaveBeenCalledWith(
90
+ 'test-api-key',
91
+ 'test-user-id',
92
+ expect.objectContaining({
93
+ serverZone: 'US',
94
+ trackingOptions: {
95
+ ipAddress: true,
96
+ },
97
+ }),
98
+ );
99
+ });
100
+
101
+ it('should not be ready if userId is missing', () => {
102
+ const service = new AmplitudeService({
103
+ userId: '',
104
+ amplitudeApiKey: 'test-api-key',
105
+ dataResidency: 'US',
106
+ env: 'test',
107
+ contextSource: 'app',
108
+ orgShortName: 'test-org',
109
+ featureFlagService,
110
+ });
111
+
112
+ expect(service.isReady).toBe(false);
113
+ });
114
+
115
+ it('should not be ready if amplitudeApiKey is missing', () => {
116
+ const service = new AmplitudeService({
117
+ userId: 'test-user-id',
118
+ amplitudeApiKey: '',
119
+ dataResidency: 'US',
120
+ env: 'test',
121
+ contextSource: 'app',
122
+ orgShortName: 'test-org',
123
+ featureFlagService,
124
+ });
125
+
126
+ expect(service.isReady).toBe(false);
127
+ });
128
+
129
+ it('should not be ready if featureFlagService is missing', () => {
130
+ const service = new AmplitudeService({
131
+ userId: 'test-user-id',
132
+ amplitudeApiKey: 'test-api-key',
133
+ dataResidency: 'US',
134
+ env: 'test',
135
+ contextSource: 'app',
136
+ orgShortName: 'test-org',
137
+ featureFlagService: null as any,
138
+ });
139
+
140
+ expect(service.isReady).toBe(false);
141
+ });
142
+
143
+ it('should be ready when all required config is provided', () => {
144
+ const service = createService();
145
+
146
+ expect(service.isReady).toBe(true);
147
+ });
148
+ });
149
+
150
+ describe('trackEvent', () => {
151
+ it('should track events with correct event name format', async () => {
152
+ const service = createService();
153
+
154
+ await service.trackEvent({
155
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
156
+ eventProps: { message: 'test' },
157
+ });
158
+
159
+ expect(mockTrack).toHaveBeenCalledWith(
160
+ '[Spiffy] Chat User Message Input',
161
+ expect.objectContaining({
162
+ message: 'test',
163
+ }),
164
+ expect.objectContaining({
165
+ insert_id: expect.any(String),
166
+ }),
167
+ );
168
+ });
169
+
170
+ it('should include default tracking props in events', async () => {
171
+ const service = createService({
172
+ env: 'test',
173
+ contextSource: 'app',
174
+ orgShortName: 'test-org',
175
+ });
176
+
177
+ await service.trackEvent({
178
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
179
+ eventProps: { message: 'test' },
180
+ });
181
+
182
+ const callArgs = mockTrack.mock.calls[0];
183
+ const eventProps = callArgs[1];
184
+
185
+ expect(eventProps).toHaveProperty('user.id', 'test-user-id');
186
+ expect(eventProps).toHaveProperty('env', 'test');
187
+ expect(eventProps).toHaveProperty('app_source', 'app');
188
+ expect(eventProps).toHaveProperty('org.short_name', 'test-org');
189
+ expect(eventProps).toHaveProperty('chat_id', 'test-chat-id');
190
+ expect(eventProps).toHaveProperty('app_id', 'commerce-chat-react-component');
191
+ });
192
+
193
+ it('should prefix event props with event name', async () => {
194
+ const service = createService();
195
+
196
+ await service.trackEvent({
197
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
198
+ eventProps: { message: 'test', count: 5 },
199
+ });
200
+
201
+ const callArgs = mockTrack.mock.calls[0];
202
+ const eventProps = callArgs[1];
203
+
204
+ expect(eventProps).toHaveProperty('chat_user_message_input.message', 'test');
205
+ expect(eventProps).toHaveProperty('chat_user_message_input.count', 5);
206
+ });
207
+
208
+ it('should generate insert_id from event data', async () => {
209
+ const service = createService();
210
+
211
+ await service.trackEvent({
212
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
213
+ eventProps: { message: 'test' },
214
+ });
215
+
216
+ expect(mockDigest).toHaveBeenCalled();
217
+ const callArgs = mockTrack.mock.calls[0];
218
+ expect(callArgs[2]).toHaveProperty('insert_id');
219
+ });
220
+
221
+ it('should include eventGroups in track call', async () => {
222
+ const service = createService();
223
+
224
+ await service.trackEvent({
225
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
226
+ eventProps: { message: 'test' },
227
+ eventGroups: { group1: 'value1', group2: 'value2' },
228
+ });
229
+
230
+ const callArgs = mockTrack.mock.calls[0];
231
+ expect(callArgs[2]).toHaveProperty('group1', 'value1');
232
+ expect(callArgs[2]).toHaveProperty('group2', 'value2');
233
+ });
234
+
235
+ it('should not track if client is not initialized', async () => {
236
+ const service = new AmplitudeService({
237
+ userId: '',
238
+ amplitudeApiKey: 'test-api-key',
239
+ dataResidency: 'US',
240
+ env: 'test',
241
+ contextSource: 'app',
242
+ orgShortName: 'test-org',
243
+ featureFlagService,
244
+ });
245
+
246
+ const logWarnSpy = vi.spyOn(Logger, 'logWarn');
247
+
248
+ await service.trackEvent({
249
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
250
+ });
251
+
252
+ expect(mockTrack).not.toHaveBeenCalled();
253
+ expect(logWarnSpy).toHaveBeenCalledWith(
254
+ 'amplitude client undefined',
255
+ undefined,
256
+ expect.objectContaining({
257
+ event_name: '[Spiffy] Chat User Message Input',
258
+ }),
259
+ );
260
+ });
261
+
262
+ it('should handle tracking errors gracefully', async () => {
263
+ const service = createService();
264
+ const error = new Error('Tracking error');
265
+ mockTrack.mockImplementationOnce(() => {
266
+ throw error;
267
+ });
268
+
269
+ const logErrorSpy = vi.spyOn(Logger, 'logError');
270
+
271
+ await service.trackEvent({
272
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
273
+ eventProps: { message: 'test' },
274
+ });
275
+
276
+ expect(logErrorSpy).toHaveBeenCalledWith(
277
+ '[spiffy-ai] Error tracking event',
278
+ error,
279
+ expect.objectContaining({
280
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
281
+ }),
282
+ );
283
+ });
284
+
285
+ it('should send to Google Analytics when alsoSendToGoogleAnalytics is true', async () => {
286
+ const service = createService({
287
+ orgGaConfig: { enabled: true },
288
+ });
289
+
290
+ const dataLayer: any[] = [];
291
+ Object.defineProperty(global, 'window', {
292
+ value: {
293
+ dataLayer,
294
+ },
295
+ writable: true,
296
+ configurable: true,
297
+ });
298
+
299
+ await service.trackEvent({
300
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
301
+ eventProps: { message: 'test' },
302
+ alsoSendToGoogleAnalytics: true,
303
+ });
304
+
305
+ expect(dataLayer).toHaveLength(1);
306
+ expect(dataLayer[0]).toEqual({
307
+ event: '[Spiffy] Chat User Message Input',
308
+ eventProps: { message: 'test' },
309
+ });
310
+ });
311
+
312
+ it('should not send to Google Analytics when orgGaConfig is not provided', async () => {
313
+ const service = createService();
314
+
315
+ const dataLayer: any[] = [];
316
+ Object.defineProperty(global, 'window', {
317
+ value: {
318
+ dataLayer,
319
+ },
320
+ writable: true,
321
+ configurable: true,
322
+ });
323
+
324
+ await service.trackEvent({
325
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
326
+ eventProps: { message: 'test' },
327
+ alsoSendToGoogleAnalytics: true,
328
+ });
329
+
330
+ expect(dataLayer).toHaveLength(0);
331
+ });
332
+ });
333
+
334
+ describe('Default tracking props', () => {
335
+ it('should include feature gates in default props', async () => {
336
+ const featureGates = [
337
+ { name: FeatureGates.IsNewFeatureEnabled, value: true },
338
+ { name: FeatureGates.IsClientSessionEnabled, value: false },
339
+ ];
340
+ const featureFlagServiceWithGates = new FeatureFlagService(featureGates);
341
+ const service = createService({ featureFlagService: featureFlagServiceWithGates });
342
+
343
+ await service.trackEvent({
344
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
345
+ });
346
+
347
+ const callArgs = mockTrack.mock.calls[0];
348
+ const eventProps = callArgs[1];
349
+
350
+ expect(eventProps).toHaveProperty('feature_gate.is_new_feature_enabled', true);
351
+ expect(eventProps).toHaveProperty('feature_gate.is_client_session_enabled', false);
352
+ });
353
+
354
+ it('should use localStorage getItem when provided', async () => {
355
+ const customGetItem = vi.fn((key: string) => {
356
+ if (key === LocalStorageKeys.ChatId) {
357
+ return 'custom-chat-id';
358
+ }
359
+ return null;
360
+ });
361
+ const service = createService({ getLocalStorageItem: customGetItem });
362
+
363
+ await service.trackEvent({
364
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
365
+ });
366
+
367
+ expect(customGetItem).toHaveBeenCalledWith(LocalStorageKeys.ChatId);
368
+ const callArgs = mockTrack.mock.calls[0];
369
+ expect(callArgs[1]).toHaveProperty('chat_id', 'custom-chat-id');
370
+ });
371
+
372
+ it('should fall back to window.localStorage when getLocalStorageItem is not provided', async () => {
373
+ const service = new AmplitudeService({
374
+ userId: 'test-user-id',
375
+ amplitudeApiKey: 'test-api-key',
376
+ dataResidency: 'US',
377
+ env: 'test',
378
+ contextSource: 'app',
379
+ orgShortName: 'test-org',
380
+ featureFlagService,
381
+ });
382
+
383
+ // Mock window.localStorage
384
+ const mockLocalStorage = {
385
+ getItem: vi.fn((key: string) => {
386
+ if (key === LocalStorageKeys.ChatId) {
387
+ return 'window-chat-id';
388
+ }
389
+ return null;
390
+ }),
391
+ };
392
+ Object.defineProperty(global, 'window', {
393
+ value: {
394
+ localStorage: mockLocalStorage,
395
+ },
396
+ writable: true,
397
+ configurable: true,
398
+ });
399
+
400
+ await service.trackEvent({
401
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
402
+ });
403
+
404
+ expect(mockLocalStorage.getItem).toHaveBeenCalledWith(LocalStorageKeys.ChatId);
405
+ const callArgs = mockTrack.mock.calls[0];
406
+ expect(callArgs[1]).toHaveProperty('chat_id', 'window-chat-id');
407
+ });
408
+
409
+ it('should include supplemental default props', async () => {
410
+ const service = createService();
411
+ service.setSupplementalDefaultProps({ customProp: 'customValue', anotherProp: 123 });
412
+
413
+ await service.trackEvent({
414
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
415
+ });
416
+
417
+ const callArgs = mockTrack.mock.calls[0];
418
+ const eventProps = callArgs[1];
419
+
420
+ expect(eventProps).toHaveProperty('customProp', 'customValue');
421
+ expect(eventProps).toHaveProperty('anotherProp', 123);
422
+ });
423
+ });
424
+
425
+ describe('setSupplementalDefaultProps', () => {
426
+ it('should set supplemental default props', async () => {
427
+ const service = createService();
428
+ service.setSupplementalDefaultProps({ test: 'value' });
429
+
430
+ await service.trackEvent({
431
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
432
+ });
433
+
434
+ const callArgs = mockTrack.mock.calls[0];
435
+ const eventProps = callArgs[1];
436
+ expect(eventProps).toHaveProperty('test', 'value');
437
+ });
438
+
439
+ it('should replace existing supplemental props', async () => {
440
+ const service = createService();
441
+ service.setSupplementalDefaultProps({ prop1: 'value1' });
442
+ service.setSupplementalDefaultProps({ prop2: 'value2' });
443
+
444
+ await service.trackEvent({
445
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
446
+ });
447
+
448
+ const callArgs = mockTrack.mock.calls[0];
449
+ const eventProps = callArgs[1];
450
+ expect(eventProps).toHaveProperty('prop2', 'value2');
451
+ expect(eventProps).not.toHaveProperty('prop1');
452
+ });
453
+ });
454
+
455
+ describe('Event enrichment', () => {
456
+ it('should enrich Page Viewed events', async () => {
457
+ createService({
458
+ show: true,
459
+ });
460
+
461
+ // Simulate a Page Viewed event by calling the enrichment plugin
462
+ // The enrichment is added during initialization
463
+ expect(mockAdd).toHaveBeenCalled();
464
+
465
+ // Get the enrichment plugin that was added
466
+ const enrichmentCall = mockAdd.mock.calls[0];
467
+ const enrichment = enrichmentCall[0];
468
+
469
+ const mockEvent = {
470
+ event_type: '[Amplitude] Page Viewed',
471
+ event_properties: {},
472
+ };
473
+
474
+ await enrichment.execute(mockEvent as any);
475
+
476
+ expect(mockDispatch).toHaveBeenCalledWith(
477
+ SpiffyEvent.AMPLITUDE_EVENT,
478
+ expect.objectContaining({
479
+ event_type: '[Amplitude] Page Viewed',
480
+ event_properties: expect.objectContaining({
481
+ 'globalProperties.show': 'true',
482
+ }),
483
+ }),
484
+ );
485
+ });
486
+
487
+ it('should enrich Bundle Loaded events', async () => {
488
+ createService();
489
+
490
+ const enrichmentCall = mockAdd.mock.calls[0];
491
+ const enrichment = enrichmentCall[0];
492
+
493
+ const mockEvent = {
494
+ event_type: `[Spiffy] ${SpiffyMetricsEventName.BundleLoaded}`,
495
+ event_properties: {},
496
+ };
497
+
498
+ await enrichment.execute(mockEvent as any);
499
+
500
+ expect(mockDispatch).toHaveBeenCalled();
501
+ });
502
+
503
+ it('should not enrich non-specified events', async () => {
504
+ createService();
505
+
506
+ const enrichmentCall = mockAdd.mock.calls[0];
507
+ const enrichment = enrichmentCall[0];
508
+
509
+ const mockEvent = {
510
+ event_type: '[Spiffy] Some Other Event',
511
+ event_properties: {},
512
+ };
513
+
514
+ const result = await enrichment.execute(mockEvent as any);
515
+
516
+ expect(result).toEqual(mockEvent);
517
+ expect(mockDispatch).toHaveBeenCalledWith(SpiffyEvent.AMPLITUDE_EVENT, mockEvent);
518
+ });
519
+ });
520
+
521
+ describe('Session replay initialization', () => {
522
+ it('should disable session replay by default', () => {
523
+ createService();
524
+
525
+ // Session replay is always disabled in the current implementation
526
+ expect(mockInit).toHaveBeenCalledWith(
527
+ expect.any(String),
528
+ expect.any(String),
529
+ expect.objectContaining({
530
+ autocapture: expect.objectContaining({
531
+ sessions: false,
532
+ }),
533
+ }),
534
+ );
535
+ });
536
+ });
537
+
538
+ describe('Multiple events', () => {
539
+ it('should track multiple events with correct userId', async () => {
540
+ const service = createService();
541
+
542
+ await service.trackEvent({
543
+ eventName: SpiffyMetricsEventName.ChatUserMessageInput,
544
+ eventProps: { event1: true },
545
+ });
546
+
547
+ await service.trackEvent({
548
+ eventName: SpiffyMetricsEventName.ChatSuggestionClicked,
549
+ eventProps: { event2: true },
550
+ });
551
+
552
+ expect(mockTrack).toHaveBeenCalledTimes(2);
553
+ mockTrack.mock.calls.forEach((call: any[]) => {
554
+ expect(call[1]).toHaveProperty('user.id', 'test-user-id');
555
+ });
556
+ });
557
+ });
558
+ });