@envive-ai/react-hooks 0.2.6-alpha-6 → 0.2.6-alpha-7

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 (433) hide show
  1. package/dist/{AmplitudeOperations-CufFJLkn.cjs → AmplitudeOperations-DbUiR0N_.cjs} +2 -2
  2. package/dist/{AmplitudeOperations-CaA5jTCq.js → AmplitudeOperations-DjqOM3uE.js} +2 -2
  3. package/dist/{NewOrgConfig-BnLPlU6Z.js → NewOrgConfig-C_1T1iOt.js} +2 -2
  4. package/dist/{NewOrgConfig-CKHO6QW_.cjs → NewOrgConfig-D2Kvqa1z.cjs} +2 -2
  5. package/dist/{TrackComponentVisibleEvent-CKELFJhI.js → TrackComponentVisibleEvent-BxOhr9Da.js} +3 -3
  6. package/dist/{TrackComponentVisibleEvent-BvrgpJuY.cjs → TrackComponentVisibleEvent-CDbecFPM.cjs} +3 -3
  7. package/dist/{amplitudeContext-CjFkl5yr.cjs → amplitudeContext-BWmXliMI.cjs} +9 -9
  8. package/dist/{amplitudeContext-Bh4SVVse.js → amplitudeContext-BjMlg5RV.js} +9 -9
  9. package/dist/{app-CrmrUsr6.js → app-Bs2KxG_8.js} +10 -9
  10. package/dist/{app-DudAJOe4.cjs → app-DSnDDqcW.cjs} +11 -10
  11. package/dist/application/models/index.cjs +2 -2
  12. package/dist/application/models/index.d.cts +1 -1
  13. package/dist/application/models/index.js +2 -2
  14. package/dist/application/utils/index.cjs +6 -6
  15. package/dist/application/utils/index.d.cts +2 -2
  16. package/dist/application/utils/index.js +6 -6
  17. package/dist/{atomStore-CZKe3itM.cjs → atomStore-BQVO5haU.cjs} +1 -1
  18. package/dist/{atomStore-BuopbV9k.js → atomStore-CfzCqWB9.js} +1 -1
  19. package/dist/atoms/app/index.cjs +12 -12
  20. package/dist/atoms/app/index.d.cts +7 -7
  21. package/dist/atoms/app/index.d.ts +7 -7
  22. package/dist/atoms/app/index.js +12 -12
  23. package/dist/atoms/atomStore/index.cjs +1 -1
  24. package/dist/atoms/atomStore/index.d.cts +1 -1
  25. package/dist/atoms/atomStore/index.d.ts +1 -1
  26. package/dist/atoms/atomStore/index.js +1 -1
  27. package/dist/atoms/chat/index.cjs +14 -14
  28. package/dist/atoms/chat/index.d.cts +31 -31
  29. package/dist/atoms/chat/index.d.ts +32 -32
  30. package/dist/atoms/chat/index.js +14 -14
  31. package/dist/atoms/globalSearch/index.d.cts +1 -1
  32. package/dist/atoms/org/index.cjs +2 -2
  33. package/dist/atoms/org/index.d.cts +15 -15
  34. package/dist/atoms/org/index.d.ts +16 -16
  35. package/dist/atoms/org/index.js +2 -2
  36. package/dist/atoms/search/index.cjs +4 -4
  37. package/dist/atoms/search/index.d.cts +14 -14
  38. package/dist/atoms/search/index.d.ts +14 -14
  39. package/dist/atoms/search/index.js +4 -4
  40. package/dist/atoms/search/utils.d.ts +1 -1
  41. package/dist/{cdnContext-BKQT9bPr.js → cdnContext-CJ2BNLAD.js} +2 -2
  42. package/dist/{cdnContext-B9s1XSTE.cjs → cdnContext-lkC-AE6A.cjs} +2 -2
  43. package/dist/{chat-DfVncvc2.js → chat-C5afTKUY.js} +5 -5
  44. package/dist/{chat-B87y65R0.cjs → chat-CCjM6fS_.cjs} +5 -5
  45. package/dist/{chat-DCGriB7h.cjs → chat-CJ9D8n7g.cjs} +1 -1
  46. package/dist/{chat-ClvJ9xEj.js → chat-EJbfGWRr.js} +1 -1
  47. package/dist/{chatState-AYi1RPOJ.js → chatState-BbI93m6r.js} +2 -2
  48. package/dist/{chatState-COd-Dczh.cjs → chatState-DlJpHAsW.cjs} +2 -2
  49. package/dist/{common-DQPvV_S_.cjs → common-CuwWqIJ1.cjs} +1 -1
  50. package/dist/{common-c_4eX0qn.js → common-Df2bwzd2.js} +1 -1
  51. package/dist/{components-DKwVHIjq.cjs → components-BCfFLf9X.cjs} +1 -1
  52. package/dist/{components-CDpaMUjK.js → components-QGCWJ26c.js} +1 -1
  53. package/dist/config/index.cjs +4 -4
  54. package/dist/config/index.js +4 -4
  55. package/dist/config/locators/components/chat/index.cjs +1 -1
  56. package/dist/config/locators/components/chat/index.js +1 -1
  57. package/dist/config/locators/components/common/index.cjs +1 -1
  58. package/dist/config/locators/components/common/index.js +1 -1
  59. package/dist/config/locators/components/index.cjs +1 -1
  60. package/dist/config/locators/components/index.js +1 -1
  61. package/dist/config/locators/index.cjs +4 -4
  62. package/dist/config/locators/index.js +4 -4
  63. package/dist/contexts/amplitudeContext/index.cjs +16 -16
  64. package/dist/contexts/amplitudeContext/index.d.cts +1 -1
  65. package/dist/contexts/amplitudeContext/index.js +16 -16
  66. package/dist/contexts/cdnContext/index.cjs +3 -3
  67. package/dist/contexts/cdnContext/index.d.cts +1 -1
  68. package/dist/contexts/cdnContext/index.js +3 -3
  69. package/dist/contexts/enviveConfigContext/index.cjs +3 -3
  70. package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
  71. package/dist/contexts/enviveConfigContext/index.js +3 -3
  72. package/dist/contexts/enviveCssContext/index.cjs +9 -9
  73. package/dist/contexts/enviveCssContext/index.js +9 -9
  74. package/dist/contexts/featureFlagContext/index.cjs +3 -3
  75. package/dist/contexts/featureFlagContext/index.js +3 -3
  76. package/dist/contexts/featureFlagServiceContext/index.cjs +2 -2
  77. package/dist/contexts/featureFlagServiceContext/index.js +2 -2
  78. package/dist/contexts/graphqlContext/index.cjs +4 -4
  79. package/dist/contexts/graphqlContext/index.d.cts +1 -1
  80. package/dist/contexts/graphqlContext/index.js +4 -4
  81. package/dist/contexts/localStorageContext/index.cjs +2 -2
  82. package/dist/contexts/localStorageContext/index.d.cts +1 -1
  83. package/dist/contexts/localStorageContext/index.js +2 -2
  84. package/dist/contexts/newOrgConfigContext/index.cjs +8 -8
  85. package/dist/contexts/newOrgConfigContext/index.d.cts +1 -1
  86. package/dist/contexts/newOrgConfigContext/index.js +8 -8
  87. package/dist/contexts/searchContext/index.cjs +17 -17
  88. package/dist/contexts/searchContext/index.js +17 -17
  89. package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
  90. package/dist/contexts/shopifyUrlContext/index.d.cts +1 -1
  91. package/dist/contexts/shopifyUrlContext/index.js +2 -2
  92. package/dist/contexts/systemSettingsContext/index.cjs +3 -3
  93. package/dist/contexts/systemSettingsContext/index.d.ts +2 -2
  94. package/dist/contexts/systemSettingsContext/index.js +3 -3
  95. package/dist/contexts/userIdentityContext/index.cjs +12 -12
  96. package/dist/contexts/userIdentityContext/index.js +12 -12
  97. package/dist/{dist-CtkINi1R.js → dist-C38adNK1.js} +1 -1
  98. package/dist/{dist-B7BErEyV.cjs → dist-VxRI6eQv.cjs} +1 -1
  99. package/dist/{domObserver-LCBj1xw4.cjs → domObserver-C2oQO8vi.cjs} +1 -1
  100. package/dist/{domObserver-CVhsCSkS.js → domObserver-DNeeSh1F.js} +1 -1
  101. package/dist/{enviveConfig-DyvNVrxm.js → enviveConfig-Ciq4ASoV.js} +2 -2
  102. package/dist/{enviveConfig-D3hmiaPh.cjs → enviveConfig-Dp80h9yu.cjs} +2 -2
  103. package/dist/{enviveConfigContext-D8ijWYZf.js → enviveConfigContext-CCjJUmwp.js} +2 -2
  104. package/dist/{enviveConfigContext-BADXcRZr.cjs → enviveConfigContext-DoYP8KSw.cjs} +2 -2
  105. package/dist/events/index.cjs +1 -1
  106. package/dist/events/index.js +1 -1
  107. package/dist/{events-WOOrnUAx.js → events-CXiS1aTc.js} +1 -1
  108. package/dist/{events-CgFGtanE.cjs → events-DBin1Z7o.cjs} +1 -1
  109. package/dist/exceptions/index.d.ts +1 -1
  110. package/dist/featureFlagServiceContext-ClnlCJV5.d.cts +1 -1
  111. package/dist/{featureFlagServiceContext-GIO9xKV0.js → featureFlagServiceContext-Cvp7NlpC.js} +2 -2
  112. package/dist/{featureFlagServiceContext-DQYo0d6Q.cjs → featureFlagServiceContext-DHtkQAtq.cjs} +2 -2
  113. package/dist/{graphqlContext-i_3n2qoK.js → graphqlContext-0cg9fEUw.js} +3 -3
  114. package/dist/{graphqlContext-BXdtsubh.cjs → graphqlContext-ChXlE8Ul.cjs} +3 -3
  115. package/dist/hooks/AmplitudeOperations/index.cjs +17 -17
  116. package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
  117. package/dist/hooks/AmplitudeOperations/index.js +17 -17
  118. package/dist/hooks/AppDetails/index.cjs +15 -15
  119. package/dist/hooks/AppDetails/index.js +15 -15
  120. package/dist/hooks/BlockBackButton/index.d.cts +1 -1
  121. package/dist/hooks/CdnOperations/index.cjs +3 -3
  122. package/dist/hooks/CdnOperations/index.d.cts +1 -1
  123. package/dist/hooks/CdnOperations/index.d.ts +1 -1
  124. package/dist/hooks/CdnOperations/index.js +3 -3
  125. package/dist/hooks/ChatToggle/index.cjs +18 -18
  126. package/dist/hooks/ChatToggle/index.d.cts +1 -1
  127. package/dist/hooks/ChatToggle/index.js +18 -18
  128. package/dist/hooks/ChatToggleAnalytics/index.cjs +18 -18
  129. package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
  130. package/dist/hooks/ChatToggleAnalytics/index.js +18 -18
  131. package/dist/hooks/Debounce/index.d.cts +1 -1
  132. package/dist/hooks/ElementObserver/index.cjs +1 -1
  133. package/dist/hooks/ElementObserver/index.js +1 -1
  134. package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
  135. package/dist/hooks/GrabAndScroll/index.d.ts +2 -2
  136. package/dist/hooks/GraphQLConfig/index.cjs +5 -5
  137. package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
  138. package/dist/hooks/GraphQLConfig/index.js +5 -5
  139. package/dist/hooks/IdentifyUser/index.cjs +12 -12
  140. package/dist/hooks/IdentifyUser/index.d.cts +1 -1
  141. package/dist/hooks/IdentifyUser/index.js +12 -12
  142. package/dist/hooks/ImageResolver/index.cjs +2 -2
  143. package/dist/hooks/ImageResolver/index.d.cts +1 -1
  144. package/dist/hooks/ImageResolver/index.js +2 -2
  145. package/dist/hooks/IsSmallScreen/index.d.cts +1 -1
  146. package/dist/hooks/LocalStorageOperations/index.cjs +2 -2
  147. package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
  148. package/dist/hooks/LocalStorageOperations/index.js +2 -2
  149. package/dist/hooks/MessageFilter/index.cjs +1 -1
  150. package/dist/hooks/MessageFilter/index.d.cts +1 -1
  151. package/dist/hooks/MessageFilter/index.js +1 -1
  152. package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
  153. package/dist/hooks/NewOrgConfig/index.cjs +9 -9
  154. package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
  155. package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
  156. package/dist/hooks/NewOrgConfig/index.js +9 -9
  157. package/dist/hooks/Search/index.cjs +19 -19
  158. package/dist/hooks/Search/index.js +19 -19
  159. package/dist/hooks/SearchOperations/index.cjs +17 -17
  160. package/dist/hooks/SearchOperations/index.js +17 -17
  161. package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
  162. package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
  163. package/dist/hooks/SystemSettingsContext/index.cjs +3 -3
  164. package/dist/hooks/SystemSettingsContext/index.d.cts +4 -4
  165. package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
  166. package/dist/hooks/SystemSettingsContext/index.js +3 -3
  167. package/dist/hooks/TrackComponentVisibleEvent/index.cjs +17 -17
  168. package/dist/hooks/TrackComponentVisibleEvent/index.js +17 -17
  169. package/dist/hooks/UpdateAnalyticsProps/index.cjs +16 -16
  170. package/dist/hooks/UpdateAnalyticsProps/index.js +16 -16
  171. package/dist/hooks/utils.cjs +1 -1
  172. package/dist/hooks/utils.d.cts +1 -1
  173. package/dist/hooks/utils.js +1 -1
  174. package/dist/index-BVZbvpx_.d.cts +1 -1
  175. package/dist/index-ChiZg0yw.d.cts +1 -1
  176. package/dist/index-CsmO1rDH.d.ts +1 -1
  177. package/dist/index-DtzPIcQp.d.ts +1 -1
  178. package/dist/index-bEjLKG_Q.d.ts +1 -1
  179. package/dist/index-mv7KvWDq.d.ts +1 -1
  180. package/dist/interceptors/index.cjs +1 -1
  181. package/dist/interceptors/index.d.cts +1 -1
  182. package/dist/interceptors/index.js +1 -1
  183. package/dist/{localStorageContext-znToxGBM.js → localStorageContext-BFwvuEcf.js} +2 -2
  184. package/dist/{localStorageContext-CMQMTX56.cjs → localStorageContext-CWc5xJ6U.cjs} +2 -2
  185. package/dist/{locators-BMQGmGLq.js → locators-C2fWd-74.js} +1 -1
  186. package/dist/{locators-DxYdak1F.cjs → locators-Cx3q6Z_h.cjs} +1 -1
  187. package/dist/{models-DmsMlaHT.js → models-Cw0QcbQv.js} +2 -2
  188. package/dist/{models-wh2gh_Qz.cjs → models-Dl0_Ujgj.cjs} +2 -2
  189. package/dist/{newOrgConfigAtom-CKuuohFM.js → newOrgConfigAtom-BuQE_zPK.js} +1 -1
  190. package/dist/{newOrgConfigAtom-Cy66eryV.cjs → newOrgConfigAtom-rrYHmp1b.cjs} +1 -1
  191. package/dist/{newOrgConfigContext-UdjemITl.js → newOrgConfigContext-D-gU5ppl.js} +5 -5
  192. package/dist/{newOrgConfigContext-kCipbRua.cjs → newOrgConfigContext-d3RHl430.cjs} +5 -5
  193. package/dist/{org-D_QTp1ex.js → org-15F128Ah.js} +1 -1
  194. package/dist/{org-DnpLYVzD.cjs → org-CIFgIcO4.cjs} +1 -1
  195. package/dist/{search-CP6Tnjsb.js → search--80x6CfL.js} +3 -3
  196. package/dist/{search-JN-IYDIE.cjs → search-Ch6LKNh4.cjs} +3 -3
  197. package/dist/{searchContext-BrymLMqU.cjs → searchContext-B0qEUoKb.cjs} +4 -4
  198. package/dist/{searchContext-CgXwm6aL.js → searchContext-BkPoTq1o.js} +4 -4
  199. package/dist/{shopifyUrlContext-COc1eDR_.cjs → shopifyUrlContext-Bw1kAZ2P.cjs} +2 -2
  200. package/dist/{shopifyUrlContext-CToAt_98.js → shopifyUrlContext-DnJiUmMA.js} +2 -2
  201. package/dist/src/application/commerce-api.js +408 -0
  202. package/dist/src/application/logging/logger.js +16 -0
  203. package/dist/src/application/models/graphql/index.js +3 -0
  204. package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +13 -0
  205. package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +13 -0
  206. package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +10 -0
  207. package/dist/src/application/models/guards/api/index.js +12 -0
  208. package/dist/src/application/models/guards/api/isApiFormResponse.js +59 -0
  209. package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +22 -0
  210. package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +91 -0
  211. package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +188 -0
  212. package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +115 -0
  213. package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +16 -0
  214. package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +26 -0
  215. package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +15 -0
  216. package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +65 -0
  217. package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +15 -0
  218. package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +10 -0
  219. package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +4 -0
  220. package/dist/src/application/models/guards/api/isApiResponse.js +33 -0
  221. package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +22 -0
  222. package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +23 -0
  223. package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +20 -0
  224. package/dist/src/application/models/guards/api/isApiSuggestion.js +24 -0
  225. package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +4 -0
  226. package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +4 -0
  227. package/dist/src/application/models/guards/api/isApiUserEvent.js +18 -0
  228. package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +41 -0
  229. package/dist/src/application/models/guards/isBaseEcommerceEvent.js +14 -0
  230. package/dist/src/application/models/guards/isGA4EcommerceEvent.js +14 -0
  231. package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +14 -0
  232. package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +4 -0
  233. package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +1 -0
  234. package/dist/src/application/models/guards/isVariantInfo.js +28 -0
  235. package/dist/src/application/models/guards/utils.js +34 -0
  236. package/dist/src/application/models/index.js +34 -0
  237. package/dist/src/application/models/utils/snakeToCamelTransformer.js +71 -0
  238. package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +65 -0
  239. package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +9 -0
  240. package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +420 -0
  241. package/dist/src/application/models/validators/validateGraphQLOrgId.js +6 -0
  242. package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +9 -0
  243. package/dist/src/application/models/validators/validateOrgConfigResults.js +44 -0
  244. package/dist/src/application/models/validators/validateOrganizationConfig.js +34 -0
  245. package/dist/src/application/models/validators/validateResponse.js +173 -0
  246. package/dist/src/application/models/validators/validateSuggestion.js +13 -0
  247. package/dist/src/application/models/validators/validateUserEvent.js +91 -0
  248. package/dist/src/application/utils/analyticsUtils.js +95 -0
  249. package/dist/src/application/utils/coreContextToApiContext.js +8 -0
  250. package/dist/src/application/utils/coreUserEventToApiUserEvent.js +90 -0
  251. package/dist/src/application/utils/divideArray.js +7 -0
  252. package/dist/src/application/utils/domObserver.js +85 -0
  253. package/dist/src/application/utils/elementObserver.js +186 -0
  254. package/dist/src/application/utils/imageFilter.js +11 -0
  255. package/dist/src/application/utils/index.js +21 -0
  256. package/dist/src/application/utils/merchantUtils.js +15 -0
  257. package/dist/src/application/utils/messageFromFormSubmittedEvent.js +19 -0
  258. package/dist/src/application/utils/messageFromQueryEvent.js +35 -0
  259. package/dist/src/application/utils/messageFromResponse.js +123 -0
  260. package/dist/src/application/utils/messageFromSuggestionEvent.js +27 -0
  261. package/dist/src/application/utils/mouseEventTypes.js +1 -0
  262. package/dist/src/application/utils/mutationHelper.js +33 -0
  263. package/dist/src/application/utils/nextMessageRequestToApiRequest.js +29 -0
  264. package/dist/src/application/utils/nodeSelector.js +101 -0
  265. package/dist/src/application/utils/overrides.js +144 -0
  266. package/dist/src/application/utils/stringUtils.js +47 -0
  267. package/dist/src/application/utils/supportedEventRequestToApiRequest.js +7 -0
  268. package/dist/src/application/utils/urlsParser.js +33 -0
  269. package/dist/src/application/utils/validation.js +5 -0
  270. package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +4 -0
  271. package/dist/src/atoms/app/index.js +23 -0
  272. package/dist/src/atoms/app/variant.js +102 -0
  273. package/dist/src/atoms/atomStore/atomStore.js +28 -0
  274. package/dist/src/atoms/atomStore/index.js +1 -0
  275. package/dist/src/atoms/chat/chatState.js +32 -0
  276. package/dist/src/atoms/chat/form.js +16 -0
  277. package/dist/src/atoms/chat/index.js +23 -0
  278. package/dist/src/atoms/chat/lastMessage.js +10 -0
  279. package/dist/src/atoms/chat/messageQueue.js +68 -0
  280. package/dist/src/atoms/chat/performanceMetrics.js +70 -0
  281. package/dist/src/atoms/chat/renderedWidgetRefs.js +24 -0
  282. package/dist/src/atoms/chat/replies.js +42 -0
  283. package/dist/src/atoms/chat/suggestions.js +29 -0
  284. package/dist/src/atoms/envive/enviveConfig.js +67 -0
  285. package/dist/src/atoms/globalSearch/globalSearch.js +8 -0
  286. package/dist/src/atoms/globalSearch/index.js +1 -0
  287. package/dist/src/atoms/org/customerService.js +6 -0
  288. package/dist/src/atoms/org/graphqlConfig.js +8 -0
  289. package/dist/src/atoms/org/index.js +4 -0
  290. package/dist/src/atoms/org/newOrgConfigAtom.js +2 -0
  291. package/dist/src/atoms/org/orgAnalyticsConfig.js +8 -0
  292. package/dist/src/atoms/search/index.js +1 -0
  293. package/dist/src/atoms/search/productFilters.js +163 -0
  294. package/dist/src/atoms/search/productRetrievalAPI.js +50 -0
  295. package/dist/src/atoms/search/productRetrievalAdapter.js +14 -0
  296. package/dist/src/atoms/search/productSorter.js +13 -0
  297. package/dist/src/atoms/search/searchAPI.js +140 -0
  298. package/dist/src/atoms/search/searchServiceAdapter.js +14 -0
  299. package/dist/src/atoms/search/utils.js +15 -0
  300. package/dist/src/config/index.js +1 -0
  301. package/dist/src/config/locators/components/chat/entrypoints.js +10 -0
  302. package/dist/src/config/locators/components/chat/index.js +21 -0
  303. package/dist/src/config/locators/components/chat/preview.js +11 -0
  304. package/dist/src/config/locators/components/chat/variants/index.js +12 -0
  305. package/dist/src/config/locators/components/common/buttons.js +6 -0
  306. package/dist/src/config/locators/components/common/cards.js +17 -0
  307. package/dist/src/config/locators/components/common/index.js +4 -0
  308. package/dist/src/config/locators/components/common/links.js +1 -0
  309. package/dist/src/config/locators/components/common/tables.js +1 -0
  310. package/dist/src/config/locators/components/floating-button.js +2 -0
  311. package/dist/src/config/locators/components/index.js +3 -0
  312. package/dist/src/config/locators/components/report-issue.js +13 -0
  313. package/dist/src/config/locators/components/search/index.js +5 -0
  314. package/dist/src/config/locators/components/shadow-dom.js +1 -0
  315. package/dist/src/config/locators/embedded.js +20 -0
  316. package/dist/src/config/locators/index.js +4 -0
  317. package/dist/src/contexts/amplitudeContext/amplitudeContext.js +271 -0
  318. package/dist/src/contexts/amplitudeContext/index.js +1 -0
  319. package/dist/src/contexts/cdnContext/cdnContext.js +28 -0
  320. package/dist/src/contexts/cdnContext/index.js +1 -0
  321. package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +37 -0
  322. package/dist/src/contexts/enviveConfigContext/index.js +1 -0
  323. package/dist/src/contexts/enviveCssContext/enviveCssContext.js +31 -0
  324. package/dist/src/contexts/enviveCssContext/index.js +1 -0
  325. package/dist/src/contexts/featureFlagContext/featureFlagContext.js +109 -0
  326. package/dist/src/contexts/featureFlagContext/index.js +1 -0
  327. package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +47 -0
  328. package/dist/src/contexts/featureFlagServiceContext/index.js +1 -0
  329. package/dist/src/contexts/graphqlContext/graphqlContext.js +87 -0
  330. package/dist/src/contexts/graphqlContext/index.js +1 -0
  331. package/dist/src/contexts/localStorageContext/index.js +1 -0
  332. package/dist/src/contexts/localStorageContext/localStorageContext.js +95 -0
  333. package/dist/src/contexts/newOrgConfigContext/index.js +1 -0
  334. package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +33 -0
  335. package/dist/src/contexts/searchContext/index.js +1 -0
  336. package/dist/src/contexts/searchContext/searchContext.js +131 -0
  337. package/dist/src/contexts/sessionStorageContext/index.js +1 -0
  338. package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +43 -0
  339. package/dist/src/contexts/shopifyUrlContext/index.js +1 -0
  340. package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +62 -0
  341. package/dist/src/contexts/systemSettingsContext/index.js +1 -0
  342. package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +29 -0
  343. package/dist/src/contexts/userIdentityContext/index.js +1 -0
  344. package/dist/src/contexts/userIdentityContext/userIdentityContext.js +118 -0
  345. package/dist/src/events/index.js +51 -0
  346. package/dist/src/events/registerAnalyticsListeners.js +32 -0
  347. package/dist/src/exceptions/index.js +2 -0
  348. package/dist/src/exceptions/sessionExceptions.js +6 -0
  349. package/dist/src/exceptions/unsupportedProductExceptions.js +6 -0
  350. package/dist/src/hooks/AmplitudeOperations/index.js +1 -0
  351. package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +24 -0
  352. package/dist/src/hooks/AppDetails/index.js +1 -0
  353. package/dist/src/hooks/AppDetails/useAppDetails.js +26 -0
  354. package/dist/src/hooks/BlockBackButton/index.js +1 -0
  355. package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +23 -0
  356. package/dist/src/hooks/CdnOperations/index.js +1 -0
  357. package/dist/src/hooks/CdnOperations/useCdnOperations.js +13 -0
  358. package/dist/src/hooks/ChatToggle/index.js +1 -0
  359. package/dist/src/hooks/ChatToggle/useChatToggle.js +50 -0
  360. package/dist/src/hooks/ChatToggleAnalytics/index.js +1 -0
  361. package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +11 -0
  362. package/dist/src/hooks/CustomerSupportHandoff/index.js +1 -0
  363. package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +32 -0
  364. package/dist/src/hooks/Debounce/index.js +1 -0
  365. package/dist/src/hooks/Debounce/useDebounce.js +13 -0
  366. package/dist/src/hooks/ElementObserver/index.js +1 -0
  367. package/dist/src/hooks/ElementObserver/useElementObserver.js +208 -0
  368. package/dist/src/hooks/GrabAndScroll/index.js +1 -0
  369. package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +105 -0
  370. package/dist/src/hooks/GraphQLConfig/index.js +1 -0
  371. package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +54 -0
  372. package/dist/src/hooks/IdentifyUser/index.js +1 -0
  373. package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +28 -0
  374. package/dist/src/hooks/ImageResolver/index.js +1 -0
  375. package/dist/src/hooks/ImageResolver/useImageResolver.js +45 -0
  376. package/dist/src/hooks/Intersection/index.js +1 -0
  377. package/dist/src/hooks/Intersection/useIntersection.js +20 -0
  378. package/dist/src/hooks/IsSmallScreen/index.js +1 -0
  379. package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +16 -0
  380. package/dist/src/hooks/LocalStorageOperations/index.js +1 -0
  381. package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +64 -0
  382. package/dist/src/hooks/MessageFilter/index.js +1 -0
  383. package/dist/src/hooks/MessageFilter/useMessageFilter.js +37 -0
  384. package/dist/src/hooks/MessageScrollObserver/index.js +1 -0
  385. package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +35 -0
  386. package/dist/src/hooks/NewOrgConfig/index.js +1 -0
  387. package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +5 -0
  388. package/dist/src/hooks/Search/index.js +1 -0
  389. package/dist/src/hooks/Search/useRecommendedProducts.js +35 -0
  390. package/dist/src/hooks/Search/useSearch.js +224 -0
  391. package/dist/src/hooks/Search/useSearchInput.js +192 -0
  392. package/dist/src/hooks/SearchOperations/index.js +1 -0
  393. package/dist/src/hooks/SearchOperations/useSearchOperations.js +78 -0
  394. package/dist/src/hooks/SessionStorageOperations/index.js +1 -0
  395. package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +20 -0
  396. package/dist/src/hooks/ShopifyUrlOperations/index.js +1 -0
  397. package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +34 -0
  398. package/dist/src/hooks/SnapCalculator/index.js +1 -0
  399. package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +22 -0
  400. package/dist/src/hooks/SystemSettingsContext/index.js +1 -0
  401. package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +9 -0
  402. package/dist/src/hooks/TrackComponentVisibleEvent/index.js +1 -0
  403. package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +45 -0
  404. package/dist/src/hooks/UpdateAnalyticsProps/index.js +1 -0
  405. package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +43 -0
  406. package/dist/src/hooks/utils.js +116 -0
  407. package/dist/src/interceptors/index.js +1 -0
  408. package/dist/src/interceptors/useMessageInterceptor.js +24 -0
  409. package/dist/src/types/ApiResponse.js +1 -0
  410. package/dist/src/types/FilterAttribute.js +3 -0
  411. package/dist/src/types/Message.js +24 -0
  412. package/dist/src/types/Suggestion.js +3 -0
  413. package/dist/src/types/index.js +4 -0
  414. package/dist/src/util/colorVar.js +3 -0
  415. package/dist/src/util/configVersion.js +4 -0
  416. package/dist/src/util/domInsertion.js +16 -0
  417. package/dist/{systemSettingsContext-D-4ma13L.cjs → systemSettingsContext-068vQuP2.cjs} +2 -2
  418. package/dist/{systemSettingsContext-B8a7vEqE.js → systemSettingsContext-DPdDfVhj.js} +2 -2
  419. package/dist/types/index.cjs +1 -1
  420. package/dist/types/index.js +1 -1
  421. package/dist/{types-1iJ_FnQQ.cjs → types-B8HZYWV3.cjs} +1 -1
  422. package/dist/{types-D5du68Vp.js → types-y3mhxOUA.js} +1 -1
  423. package/dist/{urlsParser-Dax4iVNC.cjs → urlsParser-bb8ciRFg.cjs} +1 -1
  424. package/dist/{urlsParser-NAp2LwWP.js → urlsParser-v_1DKvyf.js} +1 -1
  425. package/dist/{useAppDetails-HS5GtU5O.js → useAppDetails-BPXln8UE.js} +4 -4
  426. package/dist/{useAppDetails-BkTsIODv.cjs → useAppDetails-eP2hBuid.cjs} +4 -4
  427. package/dist/{useGraphQLConfig-arTbYTKS.js → useGraphQLConfig-Btszi6cG.js} +2 -2
  428. package/dist/{useGraphQLConfig-DCd-kR81.cjs → useGraphQLConfig-v9veUbvJ.cjs} +2 -2
  429. package/dist/{utils-hYTjy7hJ.cjs → utils-CJk5iwQI.cjs} +1 -1
  430. package/dist/{utils-CxDOv-yL.js → utils-CWzuvlOR.js} +4 -4
  431. package/dist/{utils-D_kATUj6.js → utils-D_nGHczN.js} +1 -1
  432. package/dist/{utils-DucG4gQ7.cjs → utils-SjlIHajO.cjs} +4 -4
  433. package/package.json +1 -1
@@ -0,0 +1,173 @@
1
+ import { ResponseCategory } from "@spiffy-ai/commerce-api-client";
2
+ import { isApiPageResponseAttributes } from "src/application/models/guards/api/isApiPageResponseAttributes";
3
+ import { isApiProductResponseAttributes } from "src/application/models/guards/api/isApiProductResponseAttributes";
4
+ import { isApiResponse } from "src/application/models/guards/api/isApiResponse";
5
+ import { isApiReviewResponseAttributes } from "src/application/models/guards/api/isApiReviewResponseAttributes";
6
+ import { isApiTextResponseAttributes } from "src/application/models/guards/api/isApiTextResponseAttributes";
7
+ import { isApiProductSearchResponseAttributes } from "src/application/models/guards/api/isApiProductSearchAttributes";
8
+ import { isApiFormResponseAttributes } from "src/application/models/guards/api/isApiFormResponse";
9
+ import { isApiOrderResponseAttributes } from "src/application/models/guards/api/isApiOrderResponseAttributes";
10
+ import { stringToFulfillmentDisplayStatusEnumValue } from "src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue";
11
+ import { isApiProductSearchFilterResponseAttributes } from "src/application/models/guards/api/isApiProductSearchFilterAttributes";
12
+ const richInformationFromCommerceRichInformation = (data) => ({
13
+ cons: data.cons,
14
+ pros: data.pros,
15
+ reviewDate: data.review_date,
16
+ reviewerTitle: data.reviewer_title,
17
+ productFamiliarity: data.product_familiarity,
18
+ });
19
+ export const validateResponse = (data) => {
20
+ if (!isApiResponse(data)) {
21
+ return undefined;
22
+ }
23
+ if (data.category === ResponseCategory.Text &&
24
+ isApiTextResponseAttributes(data.attributes)) {
25
+ return {
26
+ id: data.id,
27
+ createdAt: data.createdAt,
28
+ category: ResponseCategory.Text,
29
+ attributes: {
30
+ content: data.attributes.content,
31
+ },
32
+ };
33
+ }
34
+ if (data.category === ResponseCategory.Product &&
35
+ isApiProductResponseAttributes(data.attributes)) {
36
+ return {
37
+ id: data.id,
38
+ createdAt: data.createdAt,
39
+ category: ResponseCategory.Product,
40
+ attributes: {
41
+ id: data.attributes.id,
42
+ description: data.attributes.description,
43
+ imageUrl: data.attributes.imageUrl,
44
+ imageUrls: data.attributes.imageUrls,
45
+ title: data.attributes.title,
46
+ url: data.attributes.url,
47
+ originalPrice: data.attributes.originalPrice,
48
+ salePrice: data.attributes.salePrice,
49
+ averageRating: data.attributes.averageRating,
50
+ numberReviews: data.attributes.numberReviews,
51
+ metadata: data.attributes.metadata,
52
+ isForGrid: data.attributes.isForGrid,
53
+ colors: data.attributes.colors,
54
+ sizes: data.attributes.sizes,
55
+ filters: data.attributes.filters,
56
+ },
57
+ };
58
+ }
59
+ if (data.category === ResponseCategory.Review &&
60
+ isApiReviewResponseAttributes(data.attributes)) {
61
+ return {
62
+ id: data.id,
63
+ createdAt: data.createdAt,
64
+ category: ResponseCategory.Review,
65
+ attributes: {
66
+ id: data.attributes.id,
67
+ productId: data.attributes.productId,
68
+ title: data.attributes.title,
69
+ reviewer: data.attributes.reviewer,
70
+ review: data.attributes.review,
71
+ stars: data.attributes.stars,
72
+ richInformation: data.attributes.richInformation
73
+ ? richInformationFromCommerceRichInformation(data.attributes.richInformation)
74
+ : undefined,
75
+ },
76
+ };
77
+ }
78
+ if (data.category === ResponseCategory.Separator) {
79
+ return {
80
+ id: data.id,
81
+ createdAt: data.createdAt,
82
+ category: ResponseCategory.Separator,
83
+ };
84
+ }
85
+ if (data.category === ResponseCategory.Page &&
86
+ isApiPageResponseAttributes(data.attributes)) {
87
+ return {
88
+ id: data.id,
89
+ createdAt: data.createdAt,
90
+ category: ResponseCategory.Page,
91
+ attributes: {
92
+ id: data.attributes.id,
93
+ title: data.attributes.title,
94
+ description: data.attributes.description,
95
+ url: data.attributes.url,
96
+ },
97
+ };
98
+ }
99
+ if (data.category === ResponseCategory.Form &&
100
+ isApiFormResponseAttributes(data.attributes)) {
101
+ return {
102
+ id: data.id,
103
+ createdAt: data.createdAt,
104
+ category: ResponseCategory.Form,
105
+ attributes: {
106
+ formCategory: data.attributes.formCategory
107
+ ? {
108
+ formType: data.attributes.formCategory.formType,
109
+ }
110
+ : undefined,
111
+ schema: {
112
+ properties: data.attributes.schema.properties,
113
+ required: data.attributes.schema.required.map(String),
114
+ },
115
+ },
116
+ };
117
+ }
118
+ if (data.category === ResponseCategory.ProductSearch &&
119
+ isApiProductSearchResponseAttributes(data.attributes)) {
120
+ return {
121
+ id: data.id,
122
+ createdAt: data.createdAt,
123
+ category: ResponseCategory.ProductSearch,
124
+ attributes: {
125
+ generatedQuery: data.attributes.generated_query,
126
+ productCount: data.attributes.product_count,
127
+ },
128
+ };
129
+ }
130
+ if (data.category === ResponseCategory.ProductSearchFilter &&
131
+ isApiProductSearchFilterResponseAttributes(data.attributes)) {
132
+ return {
133
+ id: data.id,
134
+ createdAt: data.createdAt,
135
+ category: ResponseCategory.ProductSearchFilter,
136
+ attributes: {
137
+ filterName: data.attributes.filter_name,
138
+ },
139
+ };
140
+ }
141
+ if (data.category === ResponseCategory.Order &&
142
+ isApiOrderResponseAttributes(data.attributes)) {
143
+ return {
144
+ id: data.id,
145
+ createdAt: data.createdAt,
146
+ category: ResponseCategory.Order,
147
+ attributes: {
148
+ orderId: data.attributes.orderId,
149
+ orderNumber: data.attributes.orderNumber,
150
+ createdAt: data.attributes.created_at,
151
+ latestEventDate: data.attributes.latest_event_date,
152
+ lineItems: data.attributes.line_items.map((item) => {
153
+ var _a, _b, _c, _d, _e;
154
+ return ({
155
+ itemTitle: item.item_title,
156
+ itemPrice: item.item_price,
157
+ itemQuantity: item.item_quantity,
158
+ orderItemId: item.order_item_id,
159
+ image: (_a = item.image) !== null && _a !== void 0 ? _a : undefined,
160
+ inTransitAt: (_b = item.in_transit_at) !== null && _b !== void 0 ? _b : undefined,
161
+ deliveredAt: (_c = item.delivered_at) !== null && _c !== void 0 ? _c : undefined,
162
+ estimatedDeliveryAt: (_d = item.estimated_delivery_at) !== null && _d !== void 0 ? _d : undefined,
163
+ fulfillmentDisplayStatus: item.fulfillment_display_status
164
+ ? stringToFulfillmentDisplayStatusEnumValue(item.fulfillment_display_status)
165
+ : undefined,
166
+ trackingUrl: (_e = item.tracking_url) !== null && _e !== void 0 ? _e : undefined,
167
+ });
168
+ }),
169
+ },
170
+ };
171
+ }
172
+ return undefined;
173
+ };
@@ -0,0 +1,13 @@
1
+ import { isSuggestion } from '../guards/api/isApiSuggestion';
2
+ export const validateSuggestion = (data) => {
3
+ if (!isSuggestion(data)) {
4
+ return undefined;
5
+ }
6
+ return {
7
+ id: data.id,
8
+ category: data.category,
9
+ content: data.content,
10
+ createdAt: data.created_at,
11
+ isAnswer: data.is_answer,
12
+ };
13
+ };
@@ -0,0 +1,91 @@
1
+ import { UserEventCategory } from "@spiffy-ai/commerce-api-client";
2
+ import { isApiUserEvent, isApiPDPAttributes, isApiQueryTypedAttributes, isApiSearchAttributes, isApiSuggestionClickedAttributes, } from "../guards/api";
3
+ import { isApiFormSubmittedResponseAttributes } from "../guards/api/isApiFormSubmittedResponseAttributes";
4
+ import { isApiPLPEventAttributes, isApiPLPIdAttribute, } from "../guards/api/isApiPLPEventAttributes";
5
+ export const validateUserEvent = (data) => {
6
+ if (!isApiUserEvent(data)) {
7
+ return undefined;
8
+ }
9
+ if (data.category === UserEventCategory.PdpVisit &&
10
+ isApiPDPAttributes(data.attributes)) {
11
+ return {
12
+ eventId: data.event_id,
13
+ createdAt: data.created_at,
14
+ category: UserEventCategory.PdpVisit,
15
+ attributes: {
16
+ productId: data.attributes.product_id,
17
+ parentProductId: data.attributes.parent_product_id,
18
+ url: data.attributes.url,
19
+ },
20
+ };
21
+ }
22
+ if (data.category === UserEventCategory.QueryTyped &&
23
+ isApiQueryTypedAttributes(data.attributes)) {
24
+ return {
25
+ eventId: data.event_id,
26
+ createdAt: data.created_at,
27
+ category: UserEventCategory.QueryTyped,
28
+ attributes: {
29
+ query: data.attributes.query,
30
+ },
31
+ };
32
+ }
33
+ if (data.category === UserEventCategory.Search &&
34
+ isApiSearchAttributes(data.attributes)) {
35
+ return {
36
+ eventId: data.event_id,
37
+ createdAt: data.created_at,
38
+ category: UserEventCategory.Search,
39
+ attributes: {
40
+ searchTerm: data.attributes.search_term,
41
+ selectedFilters: data.attributes.selected_filters,
42
+ },
43
+ };
44
+ }
45
+ if (data.category === UserEventCategory.SuggestionClicked &&
46
+ isApiSuggestionClickedAttributes(data.attributes)) {
47
+ return {
48
+ eventId: data.event_id,
49
+ createdAt: data.created_at,
50
+ category: UserEventCategory.SuggestionClicked,
51
+ attributes: {
52
+ suggestionId: data.attributes.suggestion_id,
53
+ },
54
+ };
55
+ }
56
+ if (data.category === UserEventCategory.PlpVisit &&
57
+ isApiPLPEventAttributes(data.attributes)) {
58
+ if (isApiPLPIdAttribute(data.attributes)) {
59
+ return {
60
+ eventId: data.event_id,
61
+ createdAt: data.created_at,
62
+ category: UserEventCategory.PlpVisit,
63
+ attributes: {
64
+ category: data.attributes.category,
65
+ attributes: {
66
+ id: data.attributes.id,
67
+ },
68
+ },
69
+ };
70
+ }
71
+ }
72
+ if (data.category === UserEventCategory.FormSubmitted &&
73
+ isApiFormSubmittedResponseAttributes(data.attributes)) {
74
+ return {
75
+ eventId: data.event_id,
76
+ createdAt: data.created_at,
77
+ category: UserEventCategory.FormSubmitted,
78
+ attributes: {
79
+ filledSchema: { ...data.attributes.filled_schema },
80
+ formResponseId: data.attributes.form_response_id,
81
+ formType: data.attributes.form_type,
82
+ },
83
+ };
84
+ }
85
+ // we're not using app_unloaded at the moment so return the app_loaded event as default
86
+ return {
87
+ eventId: data.event_id,
88
+ createdAt: data.created_at,
89
+ category: UserEventCategory.AppLoaded,
90
+ };
91
+ };
@@ -0,0 +1,95 @@
1
+ import Logger from "src/application/logging/logger";
2
+ import { isLegacyUAEcommerceEvent, isGA4EcommerceEvent, isBaseEcommerceEvent, } from "src/application/models";
3
+ import { SpiffyMetricsEventName } from "@envive-ai/types";
4
+ const NORMALIZED_ADD_TO_CART_EVENT_NAMES = ["addtocart", "addedtocart"];
5
+ const CHECK_DATA_LAYER_INTERVAL_MS = 500;
6
+ const CHECK_DATA_LAYER_MAX_ATTEMPTS = 10;
7
+ /**
8
+ * Checks if a Google Analytics event is an add_to_cart event.
9
+ *
10
+ * @param event The event name to check.
11
+ *
12
+ * @returns True if the event is an add_to_cart event, false otherwise.
13
+ */
14
+ const isAddToCartEvent = (event) => {
15
+ const normalizedEvent = event.replace(/[-_]/g, "").toLowerCase();
16
+ return NORMALIZED_ADD_TO_CART_EVENT_NAMES.some((name) => normalizedEvent.includes(name));
17
+ };
18
+ /**
19
+ * Tracks an add_to_cart event in Amplitude.
20
+ *
21
+ * @param event The event to track.
22
+ */
23
+ const handleAddToCartEvent = (event, track) => {
24
+ let eventProps;
25
+ if (isLegacyUAEcommerceEvent(event)) {
26
+ eventProps = {
27
+ items: event.ecommerce.add.products.map((product) => ({
28
+ item_name: product.name,
29
+ item_category: product.category,
30
+ price: product.price,
31
+ quantity: product.quantity,
32
+ })),
33
+ currency: event.ecommerce.add.currencyCode,
34
+ event_format_version: "legacy_universal_analytics",
35
+ };
36
+ }
37
+ else if (isGA4EcommerceEvent(event)) {
38
+ eventProps = {
39
+ items: event.ecommerce.items.map((item) => ({
40
+ item_name: item.item_name,
41
+ item_category: item.item_category,
42
+ price: item.price,
43
+ quantity: item.quantity,
44
+ })),
45
+ currency: event.ecommerce.currency,
46
+ event_format_version: "google_analytics_4",
47
+ };
48
+ }
49
+ else {
50
+ eventProps = {
51
+ event_properties: { ...event },
52
+ event_format_version: "unknown",
53
+ };
54
+ }
55
+ track(SpiffyMetricsEventName.AddToCartClicked, {
56
+ eventProps,
57
+ });
58
+ };
59
+ /**
60
+ * Wraps the window.dataLayer.push method to intercept add_to_cart events and send them to Amplitude.
61
+ * This function runs on an interval until the dataLayer is available.
62
+ */
63
+ export const initDataLayerWrapper = (track) => {
64
+ let attempts = 0;
65
+ // currently, our bundle is always loaded after GTM has initialized GA/dataLayer
66
+ // we'll need this check here if/when we load spiffy before/outside of GTM
67
+ const checkAndInitialize = () => {
68
+ if (!window.dataLayer || !window.dataLayer.push) {
69
+ attempts += 1;
70
+ if (attempts >= CHECK_DATA_LAYER_MAX_ATTEMPTS) {
71
+ Logger.logDebug(`[spiffy-ai] dataLayer not available after ${CHECK_DATA_LAYER_MAX_ATTEMPTS} attempts`);
72
+ return;
73
+ }
74
+ setTimeout(checkAndInitialize, CHECK_DATA_LAYER_INTERVAL_MS);
75
+ return;
76
+ }
77
+ Logger.logDebug("[spiffy-ai] dataLayer is available, wrapping push function...");
78
+ const originalPush = window.dataLayer.push;
79
+ window.dataLayer.push = (...args) => {
80
+ if (isBaseEcommerceEvent(args[0]) &&
81
+ isAddToCartEvent(args[0].event)) {
82
+ handleAddToCartEvent(args[0], track);
83
+ }
84
+ // IMPORTANT: call the original push method so that the event is still logged to GA
85
+ return originalPush.apply(window.dataLayer, args);
86
+ };
87
+ };
88
+ checkAndInitialize();
89
+ };
90
+ export const initAmplitude = (track) => {
91
+ // This function might not be needed anymore if Amplitude is initialized via context.
92
+ // For now, we'll keep it and pass the track function.
93
+ // If it's truly redundant, it can be removed later.
94
+ track(SpiffyMetricsEventName.BundleLoaded); // Example usage, adjust as needed
95
+ };
@@ -0,0 +1,8 @@
1
+ export const coreContextToApiContext = (context) => ({
2
+ chat_id: context.chatId,
3
+ org_id: context.orgId,
4
+ user_id: context.userId,
5
+ org_short_name: context.orgShortName,
6
+ source: context.source,
7
+ env: context.env,
8
+ });
@@ -0,0 +1,90 @@
1
+ import { PLPAttributeCategory, UserEventCategory, } from '@spiffy-ai/commerce-api-client';
2
+ export const coreUserEventToApiUserEvent = (data) => {
3
+ if (data.category === UserEventCategory.PdpVisit ||
4
+ data.category === UserEventCategory.AddToCart) {
5
+ return {
6
+ event_id: data.eventId,
7
+ created_at: data.createdAt,
8
+ category: data.category,
9
+ attributes: {
10
+ product_id: data.attributes.productId,
11
+ parent_product_id: data.attributes.parentProductId,
12
+ url: data.attributes.url,
13
+ },
14
+ };
15
+ }
16
+ if (data.category === UserEventCategory.PlpVisit) {
17
+ return {
18
+ event_id: data.eventId,
19
+ created_at: data.createdAt,
20
+ category: data.category,
21
+ attributes: {
22
+ category: PLPAttributeCategory.Id,
23
+ attributes: {
24
+ // we're only handling id attributes for now
25
+ id: data.attributes.attributes.id,
26
+ },
27
+ },
28
+ };
29
+ }
30
+ if (data.category === UserEventCategory.QueryTyped) {
31
+ return {
32
+ event_id: data.eventId,
33
+ created_at: data.createdAt,
34
+ category: data.category,
35
+ attributes: {
36
+ query: data.attributes.query,
37
+ },
38
+ };
39
+ }
40
+ if (data.category === UserEventCategory.Search) {
41
+ return {
42
+ event_id: data.eventId,
43
+ created_at: data.createdAt,
44
+ category: data.category,
45
+ attributes: {
46
+ search_term: data.attributes.searchTerm,
47
+ selected_filters: data.attributes.selectedFilters,
48
+ },
49
+ };
50
+ }
51
+ if (data.category === UserEventCategory.SuggestionClicked) {
52
+ return {
53
+ event_id: data.eventId,
54
+ created_at: data.createdAt,
55
+ category: data.category,
56
+ attributes: {
57
+ suggestion_id: data.attributes.suggestionId,
58
+ },
59
+ };
60
+ }
61
+ if (data.category === UserEventCategory.PageVisit) {
62
+ return {
63
+ event_id: data.eventId,
64
+ created_at: data.createdAt,
65
+ category: data.category,
66
+ attributes: {
67
+ url: data.attributes.url,
68
+ page_visit_category: data.attributes.pageVisitCategory,
69
+ },
70
+ };
71
+ }
72
+ if (data.category === UserEventCategory.FormSubmitted) {
73
+ return {
74
+ event_id: data.eventId,
75
+ created_at: data.createdAt,
76
+ category: data.category,
77
+ attributes: {
78
+ filled_schema: { ...data.attributes.filledSchema },
79
+ form_response_id: data.attributes.formResponseId,
80
+ form_type: data.attributes.formType,
81
+ },
82
+ };
83
+ }
84
+ // This is the default app_loaded event, when we start to use app_unloaded we need to handle it here
85
+ return {
86
+ event_id: data.eventId,
87
+ created_at: data.createdAt,
88
+ category: data.category,
89
+ };
90
+ };
@@ -0,0 +1,7 @@
1
+ export const divideArray = (array, size) => {
2
+ const rows = [];
3
+ for (let i = 0; i < size; i += 1) {
4
+ rows.push(array.filter((_, index) => index % size === i));
5
+ }
6
+ return rows;
7
+ };
@@ -0,0 +1,85 @@
1
+ import { ElementObserver } from './elementObserver';
2
+ /**
3
+ * This class manages a `MutationObserver` for the `document.body`. It monitors nodes that are
4
+ * added or removed from the DOM and notifies the observers for each observable element
5
+ * when they are ready to be watched.
6
+ *
7
+ * How that works:
8
+ *
9
+ * When the `observe` function is called, it attaches a `MutationObserver` to the `document.body` element.
10
+ * All changes to `document.body` are tracked by this observer. When changes are detected, the `MutationObserver`
11
+ * iterates through all added and removed nodes and checks if each node exists in the main map of observable elements.
12
+ *
13
+ * If a match is found, it notifies the corresponding `ElementObserver` instance to start monitoring changes for that element.
14
+ *
15
+ * The primary `MutationObserver` remains active until the `destroy` function is called. Calling `destroy` will disconnect all
16
+ * individual element observers and release any associated resources.
17
+ *
18
+ * There is no need to explicitly call the `observe` function. It is automatically invoked when a `useElementObserver` hook is instantiated.
19
+ *
20
+ */
21
+ export class DOMObserver {
22
+ static notifyAdition(records, nodeMapping) {
23
+ records.forEach((record) => record.addedNodes.forEach((node) => {
24
+ var _a;
25
+ (_a = nodeMapping.get(node)) === null || _a === void 0 ? void 0 : _a.watch(node);
26
+ nodeMapping.delete(node);
27
+ }));
28
+ }
29
+ static notifyRemoval(records, nodeMapping) {
30
+ records.forEach((record) => record.removedNodes.forEach((node) => {
31
+ var _a;
32
+ (_a = nodeMapping.get(node)) === null || _a === void 0 ? void 0 : _a.destroy();
33
+ nodeMapping.delete(node);
34
+ }));
35
+ }
36
+ static notifyChildrenChanges(nodeMapping) {
37
+ Array.from(nodeMapping.values()).forEach((observer) => observer.synchronize());
38
+ }
39
+ static mapNodeInstancesToListeners() {
40
+ const nodeMapping = new Map();
41
+ this.listeners.forEach((observer) => {
42
+ var _a;
43
+ const node = observer.getNode() || ((_a = observer.getSelector()) === null || _a === void 0 ? void 0 : _a.parse());
44
+ if (node) {
45
+ nodeMapping.set(node, observer);
46
+ }
47
+ });
48
+ return nodeMapping;
49
+ }
50
+ static add(selector) {
51
+ const node = selector.getPattern();
52
+ let elementObserver = this.listeners.get(node);
53
+ if (elementObserver) {
54
+ return elementObserver;
55
+ }
56
+ elementObserver = new ElementObserver(selector);
57
+ this.listeners.set(node, elementObserver);
58
+ return elementObserver;
59
+ }
60
+ static remove(selector) {
61
+ var _a;
62
+ const node = selector.getPattern();
63
+ (_a = this.listeners.get(node)) === null || _a === void 0 ? void 0 : _a.destroy();
64
+ this.listeners.delete(node);
65
+ }
66
+ static observe() {
67
+ if (!this.documentObserver) {
68
+ this.documentObserver = new MutationObserver((mutations) => {
69
+ const nodeMapping = this.mapNodeInstancesToListeners();
70
+ this.notifyAdition(mutations, nodeMapping);
71
+ this.notifyRemoval(mutations, nodeMapping);
72
+ this.notifyChildrenChanges(nodeMapping);
73
+ });
74
+ this.documentObserver.observe(document.body, { childList: true, subtree: true });
75
+ }
76
+ }
77
+ static destroy() {
78
+ var _a;
79
+ (_a = this.documentObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
80
+ this.listeners.forEach((listener) => listener.destroy());
81
+ this.listeners.clear();
82
+ this.documentObserver = null;
83
+ }
84
+ }
85
+ DOMObserver.listeners = new Map();