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

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 (412) hide show
  1. package/dist/{AmplitudeOperations-DjqOM3uE.js → AmplitudeOperations-D2r56Ptr.js} +2 -2
  2. package/dist/{AmplitudeOperations-DbUiR0N_.cjs → AmplitudeOperations-SkndCrhj.cjs} +2 -2
  3. package/dist/{NewOrgConfig-C_1T1iOt.js → NewOrgConfig-C9aQqGsb.js} +2 -2
  4. package/dist/{NewOrgConfig-D2Kvqa1z.cjs → NewOrgConfig-CHkHRqHx.cjs} +2 -2
  5. package/dist/{TrackComponentVisibleEvent-BxOhr9Da.js → TrackComponentVisibleEvent-BIGvzk4f.js} +2 -2
  6. package/dist/{TrackComponentVisibleEvent-CDbecFPM.cjs → TrackComponentVisibleEvent-DjZUt7LR.cjs} +2 -2
  7. package/dist/amplitudeContext-B3DsV6IO.cjs +248 -0
  8. package/dist/amplitudeContext-S3JYCxr4.js +232 -0
  9. package/dist/{app-Bs2KxG_8.js → app-BT3g-mDp.js} +5 -5
  10. package/dist/{app-DSnDDqcW.cjs → app-DxwdFQlv.cjs} +5 -5
  11. package/dist/application/utils/index.cjs +4 -4
  12. package/dist/application/utils/index.d.cts +2 -2
  13. package/dist/application/utils/index.js +4 -4
  14. package/dist/{atomStore-CfzCqWB9.js → atomStore-BuopbV9k.js} +1 -1
  15. package/dist/{atomStore-BQVO5haU.cjs → atomStore-CZKe3itM.cjs} +1 -1
  16. package/dist/atoms/app/index.cjs +9 -9
  17. package/dist/atoms/app/index.d.cts +7 -7
  18. package/dist/atoms/app/index.d.ts +7 -7
  19. package/dist/atoms/app/index.js +9 -9
  20. package/dist/atoms/atomStore/index.cjs +1 -1
  21. package/dist/atoms/atomStore/index.d.ts +1 -1
  22. package/dist/atoms/atomStore/index.js +1 -1
  23. package/dist/atoms/chat/index.cjs +10 -10
  24. package/dist/atoms/chat/index.d.cts +32 -32
  25. package/dist/atoms/chat/index.d.ts +32 -32
  26. package/dist/atoms/chat/index.js +10 -10
  27. package/dist/atoms/globalSearch/index.d.cts +6 -6
  28. package/dist/atoms/globalSearch/index.d.ts +6 -6
  29. package/dist/atoms/org/index.cjs +2 -2
  30. package/dist/atoms/org/index.d.cts +15 -15
  31. package/dist/atoms/org/index.d.ts +16 -16
  32. package/dist/atoms/org/index.js +2 -2
  33. package/dist/atoms/search/index.cjs +3 -3
  34. package/dist/atoms/search/index.d.cts +15 -15
  35. package/dist/atoms/search/index.d.ts +14 -14
  36. package/dist/atoms/search/index.js +3 -3
  37. package/dist/atoms/search/utils.d.cts +1 -1
  38. package/dist/cdnContext-i5iYA8ig.cjs +53 -0
  39. package/dist/cdnContext-td-gAam0.js +38 -0
  40. package/dist/{chat-EJbfGWRr.js → chat-ClvJ9xEj.js} +1 -1
  41. package/dist/{chat-CJ9D8n7g.cjs → chat-DCGriB7h.cjs} +1 -1
  42. package/dist/{chat-C5afTKUY.js → chat-ZaY3KY-R.js} +3 -3
  43. package/dist/{chat-CCjM6fS_.cjs → chat-rhEjVfrd.cjs} +3 -3
  44. package/dist/{common-CuwWqIJ1.cjs → common-DQPvV_S_.cjs} +1 -1
  45. package/dist/{common-Df2bwzd2.js → common-c_4eX0qn.js} +1 -1
  46. package/dist/{components-QGCWJ26c.js → components-CDpaMUjK.js} +1 -1
  47. package/dist/{components-BCfFLf9X.cjs → components-DKwVHIjq.cjs} +1 -1
  48. package/dist/config/index.cjs +4 -4
  49. package/dist/config/index.js +4 -4
  50. package/dist/config/locators/components/chat/index.cjs +1 -1
  51. package/dist/config/locators/components/chat/index.js +1 -1
  52. package/dist/config/locators/components/common/index.cjs +1 -1
  53. package/dist/config/locators/components/common/index.js +1 -1
  54. package/dist/config/locators/components/index.cjs +1 -1
  55. package/dist/config/locators/components/index.js +1 -1
  56. package/dist/config/locators/index.cjs +4 -4
  57. package/dist/config/locators/index.js +4 -4
  58. package/dist/contexts/amplitudeContext/index.cjs +12 -12
  59. package/dist/contexts/amplitudeContext/index.d.cts +1 -1
  60. package/dist/contexts/amplitudeContext/index.js +12 -12
  61. package/dist/contexts/cdnContext/index.cjs +2 -2
  62. package/dist/contexts/cdnContext/index.d.cts +1 -1
  63. package/dist/contexts/cdnContext/index.d.ts +1 -1
  64. package/dist/contexts/cdnContext/index.js +2 -2
  65. package/dist/contexts/enviveConfigContext/index.cjs +2 -2
  66. package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
  67. package/dist/contexts/enviveConfigContext/index.js +2 -2
  68. package/dist/contexts/enviveCssContext/index.cjs +6 -6
  69. package/dist/contexts/enviveCssContext/index.js +6 -6
  70. package/dist/contexts/featureFlagContext/index.cjs +2 -2
  71. package/dist/contexts/featureFlagContext/index.js +2 -2
  72. package/dist/contexts/graphqlContext/index.cjs +2 -2
  73. package/dist/contexts/graphqlContext/index.js +2 -2
  74. package/dist/contexts/localStorageContext/index.d.cts +1 -1
  75. package/dist/contexts/newOrgConfigContext/index.cjs +5 -5
  76. package/dist/contexts/newOrgConfigContext/index.js +5 -5
  77. package/dist/contexts/searchContext/index.cjs +14 -14
  78. package/dist/contexts/searchContext/index.js +14 -14
  79. package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
  80. package/dist/contexts/shopifyUrlContext/index.d.cts +1 -1
  81. package/dist/contexts/shopifyUrlContext/index.js +2 -2
  82. package/dist/contexts/systemSettingsContext/index.cjs +2 -2
  83. package/dist/contexts/systemSettingsContext/index.d.cts +1 -1
  84. package/dist/contexts/systemSettingsContext/index.d.ts +2 -2
  85. package/dist/contexts/systemSettingsContext/index.js +2 -2
  86. package/dist/contexts/userIdentityContext/index.cjs +9 -9
  87. package/dist/contexts/userIdentityContext/index.js +9 -9
  88. package/dist/{domObserver-DNeeSh1F.js → domObserver-CVhsCSkS.js} +1 -1
  89. package/dist/{domObserver-C2oQO8vi.cjs → domObserver-LCBj1xw4.cjs} +1 -1
  90. package/dist/{enviveConfig-Dp80h9yu.cjs → enviveConfig-CQ_8mT-g.cjs} +1 -1
  91. package/dist/{enviveConfig-Ciq4ASoV.js → enviveConfig-Cwlp7-Qz.js} +1 -1
  92. package/dist/{enviveConfigContext-CCjJUmwp.js → enviveConfigContext-BZbGEgOW.js} +2 -2
  93. package/dist/{enviveConfigContext-DoYP8KSw.cjs → enviveConfigContext-BinpxTCy.cjs} +2 -2
  94. package/dist/events/index.cjs +1 -1
  95. package/dist/events/index.js +1 -1
  96. package/dist/{events-DBin1Z7o.cjs → events-CgFGtanE.cjs} +1 -1
  97. package/dist/{events-CXiS1aTc.js → events-WOOrnUAx.js} +1 -1
  98. package/dist/exceptions/index.d.ts +1 -1
  99. package/dist/{graphqlContext-ChXlE8Ul.cjs → graphqlContext-B8wuRZcp.cjs} +2 -2
  100. package/dist/{graphqlContext-0cg9fEUw.js → graphqlContext-CpHMbKoX.js} +2 -2
  101. package/dist/hooks/AmplitudeOperations/index.cjs +13 -13
  102. package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
  103. package/dist/hooks/AmplitudeOperations/index.js +13 -13
  104. package/dist/hooks/AppDetails/index.cjs +12 -12
  105. package/dist/hooks/AppDetails/index.d.cts +1 -1
  106. package/dist/hooks/AppDetails/index.js +12 -12
  107. package/dist/hooks/BlockBackButton/index.d.cts +1 -1
  108. package/dist/hooks/CdnOperations/index.cjs +2 -2
  109. package/dist/hooks/CdnOperations/index.d.ts +1 -1
  110. package/dist/hooks/CdnOperations/index.js +2 -2
  111. package/dist/hooks/ChatToggle/index.cjs +13 -13
  112. package/dist/hooks/ChatToggle/index.d.cts +1 -1
  113. package/dist/hooks/ChatToggle/index.js +13 -13
  114. package/dist/hooks/ChatToggleAnalytics/index.cjs +13 -13
  115. package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
  116. package/dist/hooks/ChatToggleAnalytics/index.js +13 -13
  117. package/dist/hooks/Debounce/index.d.cts +1 -1
  118. package/dist/hooks/ElementObserver/index.cjs +1 -1
  119. package/dist/hooks/ElementObserver/index.js +1 -1
  120. package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
  121. package/dist/hooks/GraphQLConfig/index.cjs +3 -3
  122. package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
  123. package/dist/hooks/GraphQLConfig/index.js +3 -3
  124. package/dist/hooks/IdentifyUser/index.cjs +9 -9
  125. package/dist/hooks/IdentifyUser/index.d.cts +1 -1
  126. package/dist/hooks/IdentifyUser/index.js +9 -9
  127. package/dist/hooks/ImageResolver/index.cjs +1 -1
  128. package/dist/hooks/ImageResolver/index.d.cts +1 -1
  129. package/dist/hooks/ImageResolver/index.js +1 -1
  130. package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
  131. package/dist/hooks/MessageFilter/index.d.cts +1 -1
  132. package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
  133. package/dist/hooks/NewOrgConfig/index.cjs +6 -6
  134. package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
  135. package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
  136. package/dist/hooks/NewOrgConfig/index.js +6 -6
  137. package/dist/hooks/Search/index.cjs +15 -15
  138. package/dist/hooks/Search/index.js +15 -15
  139. package/dist/hooks/SearchOperations/index.cjs +14 -14
  140. package/dist/hooks/SearchOperations/index.js +14 -14
  141. package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
  142. package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
  143. package/dist/hooks/SystemSettingsContext/index.cjs +2 -2
  144. package/dist/hooks/SystemSettingsContext/index.d.cts +3 -3
  145. package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
  146. package/dist/hooks/SystemSettingsContext/index.js +2 -2
  147. package/dist/hooks/TrackComponentVisibleEvent/index.cjs +13 -13
  148. package/dist/hooks/TrackComponentVisibleEvent/index.js +13 -13
  149. package/dist/hooks/UpdateAnalyticsProps/index.cjs +12 -12
  150. package/dist/hooks/UpdateAnalyticsProps/index.js +12 -12
  151. package/dist/hooks/utils.cjs +1 -1
  152. package/dist/hooks/utils.d.cts +1 -1
  153. package/dist/hooks/utils.js +1 -1
  154. package/dist/index-CMZcE7pk.d.cts +1 -1
  155. package/dist/index-ChiZg0yw.d.cts +1 -1
  156. package/dist/index-CsmO1rDH.d.ts +1 -1
  157. package/dist/index-DtzPIcQp.d.ts +1 -1
  158. package/dist/index-bEjLKG_Q.d.ts +1 -1
  159. package/dist/index-mv7KvWDq.d.ts +1 -1
  160. package/dist/{locators-C2fWd-74.js → locators-BMQGmGLq.js} +1 -1
  161. package/dist/{locators-Cx3q6Z_h.cjs → locators-DxYdak1F.cjs} +1 -1
  162. package/dist/{newOrgConfigAtom-BuQE_zPK.js → newOrgConfigAtom-C8h3w_Ji.js} +1 -1
  163. package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-CDttTiuu.cjs} +1 -1
  164. package/dist/{newOrgConfigContext-d3RHl430.cjs → newOrgConfigContext-Brsggue9.cjs} +4 -4
  165. package/dist/{newOrgConfigContext-D-gU5ppl.js → newOrgConfigContext-Dt_W-wlK.js} +4 -4
  166. package/dist/{org-CIFgIcO4.cjs → org-BNs_maoW.cjs} +1 -1
  167. package/dist/{org-15F128Ah.js → org-CScQqL4k.js} +1 -1
  168. package/dist/{search-Ch6LKNh4.cjs → search-CWkDtqQV.cjs} +2 -2
  169. package/dist/{search--80x6CfL.js → search-OWKKaQQj.js} +2 -2
  170. package/dist/{searchContext-BkPoTq1o.js → searchContext-B-rEZixl.js} +4 -4
  171. package/dist/{searchContext-B0qEUoKb.cjs → searchContext-JCUBg-lA.cjs} +4 -4
  172. package/dist/{shopifyUrlContext-Bw1kAZ2P.cjs → shopifyUrlContext-COc1eDR_.cjs} +2 -2
  173. package/dist/{shopifyUrlContext-DnJiUmMA.js → shopifyUrlContext-CToAt_98.js} +2 -2
  174. package/dist/{systemSettingsContext-DPdDfVhj.js → systemSettingsContext-D9iNGz5v.js} +2 -2
  175. package/dist/{systemSettingsContext-068vQuP2.cjs → systemSettingsContext-DdV7Yte8.cjs} +2 -2
  176. package/dist/types/index.cjs +1 -1
  177. package/dist/types/index.js +1 -1
  178. package/dist/{types-B8HZYWV3.cjs → types-1iJ_FnQQ.cjs} +1 -1
  179. package/dist/{types-y3mhxOUA.js → types-D5du68Vp.js} +1 -1
  180. package/dist/{urlsParser-bb8ciRFg.cjs → urlsParser-Dax4iVNC.cjs} +1 -1
  181. package/dist/{urlsParser-v_1DKvyf.js → urlsParser-NAp2LwWP.js} +1 -1
  182. package/dist/{useAppDetails-eP2hBuid.cjs → useAppDetails-D3T6kJY_.cjs} +4 -4
  183. package/dist/{useAppDetails-BPXln8UE.js → useAppDetails-xPVs6fW7.js} +4 -4
  184. package/dist/{useGraphQLConfig-v9veUbvJ.cjs → useGraphQLConfig-B1DaVvFx.cjs} +2 -2
  185. package/dist/{useGraphQLConfig-Btszi6cG.js → useGraphQLConfig-BtPxjtxw.js} +2 -2
  186. package/dist/{utils-D_nGHczN.js → utils-BZT_oZ3n.js} +1 -1
  187. package/dist/{utils-SjlIHajO.cjs → utils-D3MjNkd3.cjs} +2 -2
  188. package/dist/{utils-CWzuvlOR.js → utils-DMwh3QbT.js} +2 -2
  189. package/dist/{utils-CJk5iwQI.cjs → utils-qtHPLFby.cjs} +1 -1
  190. package/package.json +1 -1
  191. package/src/contexts/amplitudeContext/amplitudeContext.tsx +11 -3
  192. package/src/contexts/cdnContext/cdnContext.tsx +11 -9
  193. package/dist/amplitudeContext-BWmXliMI.cjs +0 -243
  194. package/dist/amplitudeContext-BjMlg5RV.js +0 -227
  195. package/dist/cdnContext-CJ2BNLAD.js +0 -38
  196. package/dist/cdnContext-lkC-AE6A.cjs +0 -53
  197. package/dist/src/application/commerce-api.js +0 -408
  198. package/dist/src/application/logging/logger.js +0 -16
  199. package/dist/src/application/models/graphql/index.js +0 -3
  200. package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +0 -13
  201. package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +0 -13
  202. package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +0 -10
  203. package/dist/src/application/models/guards/api/index.js +0 -12
  204. package/dist/src/application/models/guards/api/isApiFormResponse.js +0 -59
  205. package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +0 -22
  206. package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +0 -91
  207. package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +0 -188
  208. package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +0 -115
  209. package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +0 -16
  210. package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +0 -26
  211. package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +0 -15
  212. package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +0 -65
  213. package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +0 -15
  214. package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +0 -10
  215. package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +0 -4
  216. package/dist/src/application/models/guards/api/isApiResponse.js +0 -33
  217. package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +0 -22
  218. package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +0 -23
  219. package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +0 -20
  220. package/dist/src/application/models/guards/api/isApiSuggestion.js +0 -24
  221. package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +0 -4
  222. package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +0 -4
  223. package/dist/src/application/models/guards/api/isApiUserEvent.js +0 -18
  224. package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +0 -41
  225. package/dist/src/application/models/guards/isBaseEcommerceEvent.js +0 -14
  226. package/dist/src/application/models/guards/isGA4EcommerceEvent.js +0 -14
  227. package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +0 -14
  228. package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +0 -4
  229. package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +0 -1
  230. package/dist/src/application/models/guards/isVariantInfo.js +0 -28
  231. package/dist/src/application/models/guards/utils.js +0 -34
  232. package/dist/src/application/models/index.js +0 -34
  233. package/dist/src/application/models/utils/snakeToCamelTransformer.js +0 -71
  234. package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +0 -65
  235. package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +0 -9
  236. package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +0 -420
  237. package/dist/src/application/models/validators/validateGraphQLOrgId.js +0 -6
  238. package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +0 -9
  239. package/dist/src/application/models/validators/validateOrgConfigResults.js +0 -44
  240. package/dist/src/application/models/validators/validateOrganizationConfig.js +0 -34
  241. package/dist/src/application/models/validators/validateResponse.js +0 -173
  242. package/dist/src/application/models/validators/validateSuggestion.js +0 -13
  243. package/dist/src/application/models/validators/validateUserEvent.js +0 -91
  244. package/dist/src/application/utils/analyticsUtils.js +0 -95
  245. package/dist/src/application/utils/coreContextToApiContext.js +0 -8
  246. package/dist/src/application/utils/coreUserEventToApiUserEvent.js +0 -90
  247. package/dist/src/application/utils/divideArray.js +0 -7
  248. package/dist/src/application/utils/domObserver.js +0 -85
  249. package/dist/src/application/utils/elementObserver.js +0 -186
  250. package/dist/src/application/utils/imageFilter.js +0 -11
  251. package/dist/src/application/utils/index.js +0 -21
  252. package/dist/src/application/utils/merchantUtils.js +0 -15
  253. package/dist/src/application/utils/messageFromFormSubmittedEvent.js +0 -19
  254. package/dist/src/application/utils/messageFromQueryEvent.js +0 -35
  255. package/dist/src/application/utils/messageFromResponse.js +0 -123
  256. package/dist/src/application/utils/messageFromSuggestionEvent.js +0 -27
  257. package/dist/src/application/utils/mouseEventTypes.js +0 -1
  258. package/dist/src/application/utils/mutationHelper.js +0 -33
  259. package/dist/src/application/utils/nextMessageRequestToApiRequest.js +0 -29
  260. package/dist/src/application/utils/nodeSelector.js +0 -101
  261. package/dist/src/application/utils/overrides.js +0 -144
  262. package/dist/src/application/utils/stringUtils.js +0 -47
  263. package/dist/src/application/utils/supportedEventRequestToApiRequest.js +0 -7
  264. package/dist/src/application/utils/urlsParser.js +0 -33
  265. package/dist/src/application/utils/validation.js +0 -5
  266. package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +0 -4
  267. package/dist/src/atoms/app/index.js +0 -23
  268. package/dist/src/atoms/app/variant.js +0 -102
  269. package/dist/src/atoms/atomStore/atomStore.js +0 -28
  270. package/dist/src/atoms/atomStore/index.js +0 -1
  271. package/dist/src/atoms/chat/chatState.js +0 -32
  272. package/dist/src/atoms/chat/form.js +0 -16
  273. package/dist/src/atoms/chat/index.js +0 -23
  274. package/dist/src/atoms/chat/lastMessage.js +0 -10
  275. package/dist/src/atoms/chat/messageQueue.js +0 -68
  276. package/dist/src/atoms/chat/performanceMetrics.js +0 -70
  277. package/dist/src/atoms/chat/renderedWidgetRefs.js +0 -24
  278. package/dist/src/atoms/chat/replies.js +0 -42
  279. package/dist/src/atoms/chat/suggestions.js +0 -29
  280. package/dist/src/atoms/envive/enviveConfig.js +0 -67
  281. package/dist/src/atoms/globalSearch/globalSearch.js +0 -8
  282. package/dist/src/atoms/globalSearch/index.js +0 -1
  283. package/dist/src/atoms/org/customerService.js +0 -6
  284. package/dist/src/atoms/org/graphqlConfig.js +0 -8
  285. package/dist/src/atoms/org/index.js +0 -4
  286. package/dist/src/atoms/org/newOrgConfigAtom.js +0 -2
  287. package/dist/src/atoms/org/orgAnalyticsConfig.js +0 -8
  288. package/dist/src/atoms/search/index.js +0 -1
  289. package/dist/src/atoms/search/productFilters.js +0 -163
  290. package/dist/src/atoms/search/productRetrievalAPI.js +0 -50
  291. package/dist/src/atoms/search/productRetrievalAdapter.js +0 -14
  292. package/dist/src/atoms/search/productSorter.js +0 -13
  293. package/dist/src/atoms/search/searchAPI.js +0 -140
  294. package/dist/src/atoms/search/searchServiceAdapter.js +0 -14
  295. package/dist/src/atoms/search/utils.js +0 -15
  296. package/dist/src/config/index.js +0 -1
  297. package/dist/src/config/locators/components/chat/entrypoints.js +0 -10
  298. package/dist/src/config/locators/components/chat/index.js +0 -21
  299. package/dist/src/config/locators/components/chat/preview.js +0 -11
  300. package/dist/src/config/locators/components/chat/variants/index.js +0 -12
  301. package/dist/src/config/locators/components/common/buttons.js +0 -6
  302. package/dist/src/config/locators/components/common/cards.js +0 -17
  303. package/dist/src/config/locators/components/common/index.js +0 -4
  304. package/dist/src/config/locators/components/common/links.js +0 -1
  305. package/dist/src/config/locators/components/common/tables.js +0 -1
  306. package/dist/src/config/locators/components/floating-button.js +0 -2
  307. package/dist/src/config/locators/components/index.js +0 -3
  308. package/dist/src/config/locators/components/report-issue.js +0 -13
  309. package/dist/src/config/locators/components/search/index.js +0 -5
  310. package/dist/src/config/locators/components/shadow-dom.js +0 -1
  311. package/dist/src/config/locators/embedded.js +0 -20
  312. package/dist/src/config/locators/index.js +0 -4
  313. package/dist/src/contexts/amplitudeContext/amplitudeContext.js +0 -271
  314. package/dist/src/contexts/amplitudeContext/index.js +0 -1
  315. package/dist/src/contexts/cdnContext/cdnContext.js +0 -28
  316. package/dist/src/contexts/cdnContext/index.js +0 -1
  317. package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +0 -37
  318. package/dist/src/contexts/enviveConfigContext/index.js +0 -1
  319. package/dist/src/contexts/enviveCssContext/enviveCssContext.js +0 -31
  320. package/dist/src/contexts/enviveCssContext/index.js +0 -1
  321. package/dist/src/contexts/featureFlagContext/featureFlagContext.js +0 -109
  322. package/dist/src/contexts/featureFlagContext/index.js +0 -1
  323. package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +0 -47
  324. package/dist/src/contexts/featureFlagServiceContext/index.js +0 -1
  325. package/dist/src/contexts/graphqlContext/graphqlContext.js +0 -87
  326. package/dist/src/contexts/graphqlContext/index.js +0 -1
  327. package/dist/src/contexts/localStorageContext/index.js +0 -1
  328. package/dist/src/contexts/localStorageContext/localStorageContext.js +0 -95
  329. package/dist/src/contexts/newOrgConfigContext/index.js +0 -1
  330. package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +0 -33
  331. package/dist/src/contexts/searchContext/index.js +0 -1
  332. package/dist/src/contexts/searchContext/searchContext.js +0 -131
  333. package/dist/src/contexts/sessionStorageContext/index.js +0 -1
  334. package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +0 -43
  335. package/dist/src/contexts/shopifyUrlContext/index.js +0 -1
  336. package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +0 -62
  337. package/dist/src/contexts/systemSettingsContext/index.js +0 -1
  338. package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +0 -29
  339. package/dist/src/contexts/userIdentityContext/index.js +0 -1
  340. package/dist/src/contexts/userIdentityContext/userIdentityContext.js +0 -118
  341. package/dist/src/events/index.js +0 -51
  342. package/dist/src/events/registerAnalyticsListeners.js +0 -32
  343. package/dist/src/exceptions/index.js +0 -2
  344. package/dist/src/exceptions/sessionExceptions.js +0 -6
  345. package/dist/src/exceptions/unsupportedProductExceptions.js +0 -6
  346. package/dist/src/hooks/AmplitudeOperations/index.js +0 -1
  347. package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +0 -24
  348. package/dist/src/hooks/AppDetails/index.js +0 -1
  349. package/dist/src/hooks/AppDetails/useAppDetails.js +0 -26
  350. package/dist/src/hooks/BlockBackButton/index.js +0 -1
  351. package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +0 -23
  352. package/dist/src/hooks/CdnOperations/index.js +0 -1
  353. package/dist/src/hooks/CdnOperations/useCdnOperations.js +0 -13
  354. package/dist/src/hooks/ChatToggle/index.js +0 -1
  355. package/dist/src/hooks/ChatToggle/useChatToggle.js +0 -50
  356. package/dist/src/hooks/ChatToggleAnalytics/index.js +0 -1
  357. package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +0 -11
  358. package/dist/src/hooks/CustomerSupportHandoff/index.js +0 -1
  359. package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +0 -32
  360. package/dist/src/hooks/Debounce/index.js +0 -1
  361. package/dist/src/hooks/Debounce/useDebounce.js +0 -13
  362. package/dist/src/hooks/ElementObserver/index.js +0 -1
  363. package/dist/src/hooks/ElementObserver/useElementObserver.js +0 -208
  364. package/dist/src/hooks/GrabAndScroll/index.js +0 -1
  365. package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +0 -105
  366. package/dist/src/hooks/GraphQLConfig/index.js +0 -1
  367. package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +0 -54
  368. package/dist/src/hooks/IdentifyUser/index.js +0 -1
  369. package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +0 -28
  370. package/dist/src/hooks/ImageResolver/index.js +0 -1
  371. package/dist/src/hooks/ImageResolver/useImageResolver.js +0 -45
  372. package/dist/src/hooks/Intersection/index.js +0 -1
  373. package/dist/src/hooks/Intersection/useIntersection.js +0 -20
  374. package/dist/src/hooks/IsSmallScreen/index.js +0 -1
  375. package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +0 -16
  376. package/dist/src/hooks/LocalStorageOperations/index.js +0 -1
  377. package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +0 -64
  378. package/dist/src/hooks/MessageFilter/index.js +0 -1
  379. package/dist/src/hooks/MessageFilter/useMessageFilter.js +0 -37
  380. package/dist/src/hooks/MessageScrollObserver/index.js +0 -1
  381. package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +0 -35
  382. package/dist/src/hooks/NewOrgConfig/index.js +0 -1
  383. package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +0 -5
  384. package/dist/src/hooks/Search/index.js +0 -1
  385. package/dist/src/hooks/Search/useRecommendedProducts.js +0 -35
  386. package/dist/src/hooks/Search/useSearch.js +0 -224
  387. package/dist/src/hooks/Search/useSearchInput.js +0 -192
  388. package/dist/src/hooks/SearchOperations/index.js +0 -1
  389. package/dist/src/hooks/SearchOperations/useSearchOperations.js +0 -78
  390. package/dist/src/hooks/SessionStorageOperations/index.js +0 -1
  391. package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +0 -20
  392. package/dist/src/hooks/ShopifyUrlOperations/index.js +0 -1
  393. package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +0 -34
  394. package/dist/src/hooks/SnapCalculator/index.js +0 -1
  395. package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +0 -22
  396. package/dist/src/hooks/SystemSettingsContext/index.js +0 -1
  397. package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +0 -9
  398. package/dist/src/hooks/TrackComponentVisibleEvent/index.js +0 -1
  399. package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +0 -45
  400. package/dist/src/hooks/UpdateAnalyticsProps/index.js +0 -1
  401. package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +0 -43
  402. package/dist/src/hooks/utils.js +0 -116
  403. package/dist/src/interceptors/index.js +0 -1
  404. package/dist/src/interceptors/useMessageInterceptor.js +0 -24
  405. package/dist/src/types/ApiResponse.js +0 -1
  406. package/dist/src/types/FilterAttribute.js +0 -3
  407. package/dist/src/types/Message.js +0 -24
  408. package/dist/src/types/Suggestion.js +0 -3
  409. package/dist/src/types/index.js +0 -4
  410. package/dist/src/util/colorVar.js +0 -3
  411. package/dist/src/util/configVersion.js +0 -4
  412. package/dist/src/util/domInsertion.js +0 -16
@@ -1,144 +0,0 @@
1
- function isPlainObject(x) {
2
- return (!!x &&
3
- typeof x === 'object' &&
4
- !Array.isArray(x) &&
5
- !(x instanceof Date) &&
6
- !(x instanceof RegExp));
7
- }
8
- function isReplace(x) {
9
- return !!x && typeof x === 'object' && '$replace' in x;
10
- }
11
- function isDelete(x) {
12
- return !!x && typeof x === 'object' && x.$delete === true;
13
- }
14
- function isPrimitiveValue(x) {
15
- const t = typeof x;
16
- return (x === null ||
17
- t === 'string' ||
18
- t === 'number' ||
19
- t === 'boolean' ||
20
- t === 'bigint' ||
21
- t === 'symbol' ||
22
- t === 'undefined');
23
- }
24
- function isArrayOfPrimitives(arr) {
25
- if (arr.length === 0)
26
- return false; // ambiguous, default to merge-by-index on empty
27
- // If every defined element is primitive, treat as primitives
28
- for (let i = 0; i < arr.length; i += 1) {
29
- const v = arr[i];
30
- if (v !== undefined && !isPrimitiveValue(v))
31
- return false;
32
- }
33
- return true;
34
- }
35
- function mergeAny(baseAny, patchAny, opts) {
36
- var _a;
37
- if (isReplace(patchAny))
38
- return patchAny.$replace;
39
- if (isDelete(patchAny))
40
- return undefined; // caller deletes the key
41
- if (Array.isArray(baseAny)) {
42
- if (Array.isArray(patchAny)) {
43
- const baseArr = baseAny;
44
- const patchArr = patchAny;
45
- const shouldReplace = opts.arrayStrategy === 'replace' ||
46
- isArrayOfPrimitives(baseArr) ||
47
- isArrayOfPrimitives(patchArr);
48
- if (shouldReplace)
49
- return patchAny;
50
- const out = baseArr.slice();
51
- const max = Math.max(out.length, patchArr.length);
52
- for (let i = 0; i < max; i += 1) {
53
- const pVal = patchArr[i];
54
- if (pVal !== undefined) {
55
- out[i] = mergeAny(out[i], pVal, opts);
56
- }
57
- }
58
- return out;
59
- }
60
- return baseAny;
61
- }
62
- if (isPlainObject(baseAny) && isPlainObject(patchAny)) {
63
- const baseObj = baseAny;
64
- const patchObj = patchAny;
65
- const out = { ...baseObj };
66
- for (const key of Object.keys(patchObj)) {
67
- const pVal = patchObj[key];
68
- if (pVal === undefined) {
69
- // leave as-is
70
- }
71
- else if (opts.nullDeletes && pVal === null) {
72
- delete out[key];
73
- }
74
- else if (isReplace(pVal)) {
75
- out[key] = pVal.$replace;
76
- }
77
- else if (isDelete(pVal)) {
78
- delete out[key];
79
- }
80
- else {
81
- out[key] = mergeAny(baseObj === null || baseObj === void 0 ? void 0 : baseObj[key], pVal, opts);
82
- }
83
- }
84
- return out;
85
- }
86
- return (_a = patchAny) !== null && _a !== void 0 ? _a : baseAny;
87
- }
88
- export function applyOverrides(base, patch, opts = {}) {
89
- var _a;
90
- const { arrayStrategy = 'mergeByIndex', nullDeletes = false } = opts;
91
- // Handle whole-node control operators on patch itself
92
- if (isReplace(patch))
93
- return patch.$replace;
94
- if (isDelete(patch))
95
- return undefined;
96
- // Arrays
97
- if (Array.isArray(base)) {
98
- if (isReplace(patch))
99
- return patch.$replace;
100
- if (Array.isArray(patch)) {
101
- if (arrayStrategy === 'replace')
102
- return patch;
103
- // merge by index
104
- const out = base.slice();
105
- const max = Math.max(out.length, patch.length);
106
- for (let i = 0; i < max; i += 1) {
107
- const pVal = patch[i];
108
- if (pVal !== undefined) {
109
- out[i] = mergeAny(out[i], pVal, opts);
110
- }
111
- }
112
- return out;
113
- }
114
- // invalid patch type for an array → ignore and return base
115
- return base;
116
- }
117
- // Plain objects
118
- if (isPlainObject(base) && isPlainObject(patch)) {
119
- const out = { ...base };
120
- const patchObj = patch;
121
- for (const key of Object.keys(patchObj)) {
122
- const pVal = patchObj[key];
123
- if (pVal === undefined) {
124
- // leave existing value
125
- }
126
- else if (nullDeletes && pVal === null) {
127
- delete out[key];
128
- }
129
- else if (isReplace(pVal)) {
130
- out[key] = pVal.$replace;
131
- }
132
- else if (isDelete(pVal)) {
133
- delete out[key];
134
- }
135
- else {
136
- const bVal = base[key];
137
- out[key] = mergeAny(bVal, pVal, opts);
138
- }
139
- }
140
- return out;
141
- }
142
- // For primitives or when patch is primitive, patch wins if defined
143
- return ((_a = patch) !== null && _a !== void 0 ? _a : base);
144
- }
@@ -1,47 +0,0 @@
1
- class StringUtils {
2
- static isNullOrEmpty(value) {
3
- const valueTrimmed = value === null || value === void 0 ? void 0 : value.trim();
4
- return value === undefined || valueTrimmed === '';
5
- }
6
- static trimToNull(value) {
7
- const valueTrimmed = value === null || value === void 0 ? void 0 : value.trim();
8
- return StringUtils.isNullOrEmpty(valueTrimmed) ? undefined : valueTrimmed;
9
- }
10
- static capitalize(type) {
11
- if (type === undefined) {
12
- return '';
13
- }
14
- return type.charAt(0).toUpperCase() + type.substring(1);
15
- }
16
- /**
17
- * Finds the first pattern in an array that matches a given URL.
18
- * Patterns can include a single wildcard '*' which matches any sequence of characters.
19
- *
20
- * @param patterns
21
- * @param urlToTest
22
- * @returns
23
- */
24
- static findMatchingPattern(patterns, urlToTest) {
25
- if (!urlToTest) {
26
- return undefined;
27
- }
28
- for (const pattern of patterns) {
29
- // Test only if a pathname is present.
30
- if (urlToTest.pathname !== '/') {
31
- // Escape special regex characters in the pattern
32
- // This ensures that characters like '.', '+', '?', '(', etc., in the pattern are treated literally.
33
- const escapedPattern = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
34
- // Replace the wildcard '*' with its regex equivalent '.*' (matches any character zero or more times)
35
- const regexPattern = escapedPattern.replace(/\*/g, '.*');
36
- const regex = new RegExp(`^${regexPattern}$`);
37
- if (regex.test(urlToTest.pathname)) {
38
- return pattern;
39
- }
40
- }
41
- else if (pattern.startsWith(urlToTest.hostname)) {
42
- return pattern;
43
- }
44
- }
45
- }
46
- }
47
- export { StringUtils };
@@ -1,7 +0,0 @@
1
- import { coreUserEventToApiUserEvent } from './coreUserEventToApiUserEvent';
2
- import { coreContextToApiContext } from './coreContextToApiContext';
3
- export const coreSupportedEventRequestToApiRequest = (coreSupportedEventRequest) => ({
4
- id: coreSupportedEventRequest.id,
5
- user_event: coreUserEventToApiUserEvent(coreSupportedEventRequest.userEvent),
6
- context: coreContextToApiContext(coreSupportedEventRequest.context),
7
- });
@@ -1,33 +0,0 @@
1
- export const parseHref = (href) => {
2
- try {
3
- const url = new URL(href);
4
- const urlSearchParams = new URLSearchParams(url.search);
5
- return { url, urlSearchParams };
6
- }
7
- catch (e) {
8
- return { url: undefined, urlSearchParams: undefined };
9
- }
10
- };
11
- export const createUrlWithQueryParams = (url, queryParams) => {
12
- const urlObj = new URL(url, window.location.href);
13
- Object.entries(queryParams).forEach(([value, key]) => urlObj.searchParams.append(value, key));
14
- return urlObj.href;
15
- };
16
- export const getQueryParam = (key) => {
17
- const urlObj = new URL(window.location.href);
18
- return urlObj.searchParams.get(key);
19
- };
20
- export const buildSearchHash = (message) => `#evs=true&s=${message.id}&q=${message.metadata.generatedQuery}`;
21
- export const buildSearchStartHash = (query) => `#evs=true&q=${query}`;
22
- // Basic parser for the search hash
23
- export const parseSearchHash = (hash) => {
24
- if (!hash.startsWith('#evs=true')) {
25
- return { id: null, query: null };
26
- }
27
- const params = Object.fromEntries(hash.split('&').map((param) => param.split('=')));
28
- return {
29
- id: params.s ? decodeURIComponent(params.s) : null,
30
- query: params.q ? decodeURIComponent(params.q) : null,
31
- };
32
- };
33
- window.history.pushState(null, '');
@@ -1,5 +0,0 @@
1
- // This email validates that there are one or more characters before the `@` symbol,
2
- // one or more characters between the `@` symbol and the `.` symbol,
3
- // and one or more characters after the `.` symbol
4
- // It does NOT validate all possible email formats, but it is a decent place to start.
5
- export const validateEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
@@ -1,4 +0,0 @@
1
- import { atom } from "jotai";
2
- // This atom will hold the trackEvent function from the Amplitude context.
3
- // It needs to be initialized by a React component that has access to the useAmplitude hook.
4
- export const amplitudeTrackEventAtom = atom(null);
@@ -1,23 +0,0 @@
1
- import { ContextSourceEnum } from '@spiffy-ai/commerce-api-client';
2
- import { atom } from 'jotai';
3
- import { atomWithStorage } from 'jotai/utils';
4
- import { useUserIdentity } from 'src/contexts/userIdentityContext/userIdentityContext';
5
- import { v4 as uuid } from 'uuid';
6
- import { contextSourceAtom } from '../envive/enviveConfig';
7
- export { variantInfoAtom } from './variant';
8
- const internalUserIdAtom = atom(undefined);
9
- export const userIdAtom = atom((get) => {
10
- const maybeUserId = get(internalUserIdAtom);
11
- if (maybeUserId) {
12
- return maybeUserId;
13
- }
14
- const { getUserIdOrDefault } = useUserIdentity();
15
- return getUserIdOrDefault();
16
- }, (_, set, value) => {
17
- set(internalUserIdAtom, value);
18
- });
19
- export const userIdentityAtom = atom(undefined);
20
- export const appSourceAtom = atom((get) => { var _a; return (_a = get(contextSourceAtom)) !== null && _a !== void 0 ? _a : ContextSourceEnum.App; });
21
- export const chatIdAtom = atomWithStorage('v1-spiffy-chat-session-id', uuid(), undefined, {
22
- getOnInit: true,
23
- });
@@ -1,102 +0,0 @@
1
- import { atomWithStorage } from 'jotai/utils';
2
- import { atom } from 'jotai';
3
- import { VariantTypeEnum, } from '@envive-ai/types';
4
- import { sessionStorageUtil } from 'src/atoms/atomStore';
5
- const internalStorageUrlResolverAtom = atomWithStorage('spiffy-url-resolver', undefined, sessionStorageUtil, {
6
- getOnInit: true,
7
- });
8
- export const urlResolverAtom = atom((get) => {
9
- const maybeUrlResolver = get(internalStorageUrlResolverAtom);
10
- if (maybeUrlResolver == null) {
11
- return {};
12
- }
13
- return JSON.parse(maybeUrlResolver);
14
- }, (get, set, value) => {
15
- // Get current cache from storage
16
- const currentCache = get(urlResolverAtom);
17
- const newCache = { ...currentCache, [value.url]: value.response };
18
- set(internalStorageUrlResolverAtom, JSON.stringify(newCache));
19
- });
20
- const internalStorageSupportedEventAtom = atomWithStorage('spiffy-supported-event', undefined, sessionStorageUtil, {
21
- getOnInit: true,
22
- });
23
- const internalSupportedEventAtom = atom(undefined);
24
- export const supportedEventAtom = atom((get) => {
25
- const maybeSupportedEvent = get(internalStorageSupportedEventAtom);
26
- if (maybeSupportedEvent == null) {
27
- return undefined;
28
- }
29
- // TODO this is an unvalidated parse. It may be better to implement a custom storage util
30
- // and perform the object validation on "get" there.
31
- return JSON.parse(maybeSupportedEvent);
32
- }, (_, set, value) => {
33
- if (value == null) {
34
- set(internalStorageSupportedEventAtom, undefined);
35
- set(internalSupportedEventAtom, undefined);
36
- return;
37
- }
38
- set(internalSupportedEventAtom, value);
39
- set(internalStorageSupportedEventAtom, JSON.stringify(value));
40
- });
41
- const internalVariantIdAtom = atom();
42
- const internalProductIdAtom = atom();
43
- const internalParentProductIdAtom = atom();
44
- const internalProductUrlAtom = atom();
45
- const internalPlpIdAtom = atom();
46
- const internalUrlAtom = atom();
47
- const internalPageVisitCategoryAtom = atom();
48
- const internalVariantAtom = atom('pdp');
49
- export const variantIdAtom = atom((get) => get(internalVariantIdAtom));
50
- export const productIdAtom = atom((get) => get(internalProductIdAtom));
51
- export const parentProductIdAtom = atom((get) => get(internalParentProductIdAtom));
52
- export const productUrlAtom = atom((get) => get(internalProductUrlAtom));
53
- export const plpIdAtom = atom((get) => get(internalPlpIdAtom));
54
- export const urlAtom = atom((get) => get(internalUrlAtom));
55
- export const pageVisitCategoryAtom = atom((get) => get(internalPageVisitCategoryAtom));
56
- export const variantAtom = atom((get) => get(internalVariantAtom));
57
- export const hasParsedVariantInfoAtom = atom(false);
58
- export const variantInfoAtom = atom((get) => {
59
- const variant = get(variantAtom);
60
- if (variant === VariantTypeEnum.Pdp) {
61
- return {
62
- variantId: get(variantIdAtom),
63
- variant,
64
- productId: get(productIdAtom),
65
- parentProductId: get(parentProductIdAtom),
66
- url: get(urlAtom),
67
- };
68
- }
69
- if (variant === VariantTypeEnum.Plp) {
70
- return {
71
- variantId: get(variantIdAtom),
72
- variant,
73
- plpId: get(plpIdAtom),
74
- url: get(urlAtom),
75
- };
76
- }
77
- if (variant === VariantTypeEnum.PageVisit) {
78
- return {
79
- variantId: get(variantIdAtom),
80
- variant,
81
- url: get(urlAtom),
82
- pageVisitCategory: get(pageVisitCategoryAtom),
83
- };
84
- }
85
- throw new Error('Invalid variantInfo details');
86
- }, (_, set, newVariant) => {
87
- set(internalVariantAtom, newVariant.variant);
88
- set(internalVariantIdAtom, newVariant.variantId);
89
- if (newVariant.variant === VariantTypeEnum.Pdp) {
90
- set(internalProductIdAtom, newVariant.productId);
91
- set(internalParentProductIdAtom, newVariant.parentProductId);
92
- set(internalUrlAtom, newVariant.url);
93
- }
94
- if (newVariant.variant === VariantTypeEnum.Plp) {
95
- set(internalPlpIdAtom, newVariant.plpId);
96
- set(internalUrlAtom, newVariant.url);
97
- }
98
- if (newVariant.variant === VariantTypeEnum.PageVisit) {
99
- set(internalUrlAtom, newVariant.url);
100
- set(internalPageVisitCategoryAtom, newVariant.pageVisitCategory);
101
- }
102
- });
@@ -1,28 +0,0 @@
1
- import { getDefaultStore } from 'jotai';
2
- import { createJSONStorage } from 'jotai/utils';
3
- let atomStore = null;
4
- export const getAtomStore = () => {
5
- if (!atomStore) {
6
- atomStore = getDefaultStore();
7
- }
8
- return atomStore;
9
- };
10
- /**
11
- * @internal
12
- *
13
- * Sets the global atom store to be the provided store.
14
- *
15
- * @param store - The store to set the global atom store to.
16
- */
17
- export const setAtomStoreForTesting = (store) => {
18
- atomStore = store;
19
- };
20
- /**
21
- * @internal
22
- *
23
- * Resets the global atom store to null
24
- */
25
- export const resetAtomStore = () => {
26
- atomStore = null;
27
- };
28
- export const sessionStorageUtil = createJSONStorage(() => sessionStorage);
@@ -1 +0,0 @@
1
- export * from "./atomStore";
@@ -1,32 +0,0 @@
1
- import { UserEventCategory } from "@spiffy-ai/commerce-api-client/dist/models/UserEventCategory";
2
- import { atom } from "jotai";
3
- import { SpiffyEventName, SpiffyMetricsEventName, } from "@envive-ai/types";
4
- export const userHasRepliedAtom = atom(false);
5
- export const replyEventCategoryAtom = atom(UserEventCategory.AppLoaded);
6
- export const userQueryAtom = atom();
7
- export const suggestionAtom = atom(undefined);
8
- export const askQuestionBtnClickedAtom = atom(false);
9
- export const messagesAtom = atom([]);
10
- export const userEventsAtom = atom([]);
11
- export const suggestionsAtom = atom([]);
12
- export const suggestionsLoadingAtom = atom(false);
13
- export const responseStreamingAtom = atom(false);
14
- export const chatIsOpenAtom = atom(false);
15
- export const requestFailureAtom = atom(false);
16
- export const formSubmitAtom = atom();
17
- export const chatOnToggleAtom = atom(null, (get, set, triggerLocation, track) => {
18
- const isOpen = get(chatIsOpenAtom);
19
- set(chatIsOpenAtom, !isOpen);
20
- if (!isOpen) {
21
- window.dispatchEvent(new CustomEvent(SpiffyEventName.WidgetOpen));
22
- track === null || track === void 0 ? void 0 : track(SpiffyMetricsEventName.ChatComponentExpanded, {
23
- message_metadata: {
24
- trigger_location: triggerLocation,
25
- },
26
- });
27
- }
28
- else {
29
- window.dispatchEvent(new CustomEvent(SpiffyEventName.WidgetClose));
30
- track === null || track === void 0 ? void 0 : track(SpiffyMetricsEventName.ChatComponentCollapsed);
31
- }
32
- });
@@ -1,16 +0,0 @@
1
- import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
2
- import { atom } from 'jotai';
3
- import { v4 as uuid } from 'uuid';
4
- import { formSubmitAtom, replyEventCategoryAtom } from 'src/atoms/chat';
5
- import { queueUserEventAtom } from 'src/atoms/chat/messageQueue';
6
- export const handleFormSubmittedAtom = atom(null, (_, set, form) => {
7
- set(replyEventCategoryAtom, UserEventCategory.FormSubmitted);
8
- set(formSubmitAtom, form);
9
- const formUserEvent = {
10
- eventId: uuid(),
11
- category: UserEventCategory.FormSubmitted,
12
- createdAt: new Date().toISOString(),
13
- attributes: form,
14
- };
15
- set(queueUserEventAtom, formUserEvent);
16
- });
@@ -1,23 +0,0 @@
1
- import { atom } from 'jotai';
2
- import { responseStreamingAtom, suggestionsLoadingAtom, messagesAtom, userQueryAtom, replyEventCategoryAtom, userHasRepliedAtom, askQuestionBtnClickedAtom, suggestionsAtom, chatIsOpenAtom, chatOnToggleAtom, userEventsAtom, suggestionAtom, } from './chatState';
3
- export * from './chatState';
4
- export * from './replies';
5
- export * from './performanceMetrics';
6
- export * from './form';
7
- export * from './suggestions';
8
- export * from './lastMessage';
9
- export * from './renderedWidgetRefs';
10
- export const chatAtom = atom((get) => ({
11
- userHasReplied: get(userHasRepliedAtom),
12
- replyEventCategory: get(replyEventCategoryAtom),
13
- userQuery: get(userQueryAtom),
14
- suggestion: get(suggestionAtom),
15
- askQuestionBtnClicked: get(askQuestionBtnClickedAtom),
16
- messages: get(messagesAtom),
17
- userEvents: get(userEventsAtom),
18
- suggestions: get(suggestionsAtom),
19
- suggestionsLoading: get(suggestionsLoadingAtom),
20
- responseStreaming: get(responseStreamingAtom),
21
- isOpen: get(chatIsOpenAtom),
22
- onToggle: get(chatOnToggleAtom),
23
- }));
@@ -1,10 +0,0 @@
1
- import { atom } from 'jotai';
2
- import { messagesAtom, userHasRepliedAtom } from 'src/atoms/chat';
3
- export const lastAssistantMessageAtom = atom((get) => {
4
- const messages = get(messagesAtom);
5
- const userHasReplied = get(userHasRepliedAtom);
6
- if (messages.length > 0 && !userHasReplied) {
7
- return messages[messages.length - 1];
8
- }
9
- return null;
10
- });
@@ -1,68 +0,0 @@
1
- import { atom } from 'jotai';
2
- import { v4 as uuid } from 'uuid';
3
- import { getAtomStore } from 'src/atoms/atomStore/atomStore';
4
- import { userIdAtom, chatIdAtom } from 'src/atoms/app';
5
- import { orgShortNameAtom, contextSourceAtom, envAtom } from 'src/atoms/envive/enviveConfig';
6
- import { orgIdAtom, featureFlagServiceAtom } from 'src/atoms/org/graphqlConfig';
7
- const internalUserEventQueueAtom = atom([]);
8
- export const userEventQueueAtom = atom((get) => {
9
- const queue = get(internalUserEventQueueAtom);
10
- return queue === undefined ? [] : queue.filter((v) => v !== undefined);
11
- });
12
- /**
13
- * This atom is used to queue a new message for processing on `next_responses`
14
- * It receives a single `userEvent` that is added to the processing queue.
15
- * If the event has the same eventId as an existing message in the queue the NEW
16
- * event is ignored
17
- */
18
- export const queueUserEventAtom = atom(null, (get, set, userEvent) => {
19
- if (userEvent === undefined) {
20
- return;
21
- }
22
- set(internalUserEventQueueAtom, [...get(internalUserEventQueueAtom), userEvent]);
23
- });
24
- /**
25
- * This atom exposes a function to reset the entire queue. All messages in the queue will be purged
26
- */
27
- export const clearUserEventAtom = atom(null, (_, set) => {
28
- set(internalUserEventQueueAtom, []);
29
- });
30
- /**
31
- * This atom is used to mark events as processed and remove them from the queue
32
- * It accepts a list of eventId values and will remove all events with those eventIds from the queue.
33
- */
34
- export const processUserEventAtom = atom(null, (get, set, eventIds) => {
35
- const curr = get(internalUserEventQueueAtom);
36
- const remaining = curr === null || curr === void 0 ? void 0 : curr.filter((event) => !eventIds.includes(event.eventId));
37
- set(internalUserEventQueueAtom, remaining);
38
- });
39
- export const userQueueEventCountAtom = atom((get) => get(userEventQueueAtom).length);
40
- import { ContextSourceEnum, ContextEnvEnum } from '@spiffy-ai/commerce-api-client'; // Import necessary enums
41
- // import type { Context } from "@spiffy-ai/commerce-api-client/dist/models/Context"; // Import Context type
42
- export const createResponsePayload = ({ userEvents, generationParams, }) => {
43
- var _a, _b;
44
- const atomStore = getAtomStore();
45
- const orgShortName = atomStore.get(orgShortNameAtom);
46
- const orgId = atomStore.get(orgIdAtom);
47
- const userId = atomStore.get(userIdAtom);
48
- const chatId = atomStore.get(chatIdAtom);
49
- const source = atomStore.get(contextSourceAtom);
50
- const env = atomStore.get(envAtom);
51
- const featureFlagService = atomStore.get(featureFlagServiceAtom);
52
- const context = {
53
- userId: userId !== null && userId !== void 0 ? userId : '',
54
- org_id: orgId !== null && orgId !== void 0 ? orgId : '',
55
- org_short_name: orgShortName !== null && orgShortName !== void 0 ? orgShortName : '',
56
- chat_id: chatId !== null && chatId !== void 0 ? chatId : '',
57
- source: source !== null && source !== void 0 ? source : ContextSourceEnum.App,
58
- env: (_a = env) !== null && _a !== void 0 ? _a : ContextEnvEnum.Dev,
59
- };
60
- const featureFlags = ((_b = featureFlagService === null || featureFlagService === void 0 ? void 0 : featureFlagService.featureFlagService) === null || _b === void 0 ? void 0 : _b.getFeatureFlags()) || {};
61
- return {
62
- id: uuid(),
63
- context,
64
- userEvents,
65
- featureFlags: Object.fromEntries(Object.entries(featureFlags).filter(([, isEnabled]) => isEnabled)), // Convert back to Record<string, boolean>
66
- generationParams,
67
- };
68
- };
@@ -1,70 +0,0 @@
1
- var _a, _b;
2
- import { atom } from "jotai";
3
- import { atomWithStorage } from "jotai/utils";
4
- import Logger from "src/application/logging/logger";
5
- import { getAtomStore, sessionStorageUtil, } from "src/atoms/atomStore/atomStore";
6
- export const APP_INITIAL_START_TIME_KEY = "spiffy-app-initial-start-time";
7
- export const PAGE_LOAD_OFFSET_TIME_KEY = "spiffy-page-load-offset-time";
8
- /**
9
- * The different performance metrics that can be logged. All times are relative to the
10
- * initial start time of the app and are stored in milliseconds.
11
- */
12
- export var PerfMetricsEvents;
13
- (function (PerfMetricsEvents) {
14
- PerfMetricsEvents["PageLoadOffset"] = "page_load_offset_ms";
15
- PerfMetricsEvents["MainBundleLoaded"] = "main_bundle_loaded_ms";
16
- PerfMetricsEvents["OrgConfigLoadStarted"] = "org_config_load_started_ms";
17
- PerfMetricsEvents["OrgConfigLoadEnded"] = "org_config_load_ended_ms";
18
- PerfMetricsEvents["FirstResponseStarted"] = "first_response_started_ms";
19
- PerfMetricsEvents["FirstResponseCompleted"] = "first_response_completed_ms";
20
- PerfMetricsEvents["FirstSuggestionsStarted"] = "first_suggestions_started_ms";
21
- PerfMetricsEvents["FirstSuggestionsCompleted"] = "first_suggestions_completed_ms";
22
- PerfMetricsEvents["EmbeddedWidgetRendered"] = "embedded_widget_rendered_ms";
23
- PerfMetricsEvents["FloatingButtonRendered"] = "floating_button_rendered_ms";
24
- PerfMetricsEvents["TopSuggestionsBarRendered"] = "top_suggestions_bar_rendered_ms";
25
- PerfMetricsEvents["BottomSuggestionsBarRendered"] = "bottom_suggestions_bar_rendered_ms";
26
- PerfMetricsEvents["SearchPromptRendered"] = "search_prompt_rendered_ms";
27
- })(PerfMetricsEvents || (PerfMetricsEvents = {}));
28
- const internalPerfMetricsAtom = atom(new Map());
29
- export const appInitialStartTimeMsAtom = atomWithStorage(APP_INITIAL_START_TIME_KEY, (_a = sessionStorage.getItem(APP_INITIAL_START_TIME_KEY)) !== null && _a !== void 0 ? _a : undefined, sessionStorageUtil, {
30
- getOnInit: true,
31
- });
32
- export const pageLoadOffsetTimeAtom = atomWithStorage(PAGE_LOAD_OFFSET_TIME_KEY, (_b = sessionStorage.getItem(PAGE_LOAD_OFFSET_TIME_KEY)) !== null && _b !== void 0 ? _b : undefined, sessionStorageUtil, {
33
- getOnInit: true,
34
- });
35
- /**
36
- * Resets the performance metrics atom to an empty map. This should be called after the performance
37
- * metrics have been reported to amplitude. On SPA, it ensures that we can still capture metrics as
38
- * the user navigates around the app (although there is more work to be done to fully enable this).
39
- * On non-SPA, it ensures that previously captured metrics are not reported again.
40
- */
41
- export const resetPerformanceMetricsAtom = () => {
42
- const atomStore = getAtomStore();
43
- atomStore.set(internalPerfMetricsAtom, new Map());
44
- };
45
- export const performanceMetricsAtom = atom((get) => get(internalPerfMetricsAtom));
46
- export const hasReportedPerformanceMetricsAtom = atom(false);
47
- /**
48
- * Logs a performance metric by capturing the delta between the initial app start time
49
- * and the current time. If the metric has already been logged, it will not be logged again.
50
- *
51
- * @param value The performance metric name to log.
52
- */
53
- export const logPerfMetricAtom = atom(null, (get, set, value) => {
54
- const initialTimeStorageValue = get(appInitialStartTimeMsAtom);
55
- const initialTimeMs = initialTimeStorageValue
56
- ? parseInt(initialTimeStorageValue, 10)
57
- : undefined;
58
- if (initialTimeMs == null) {
59
- Logger.logWarn(`[spiffy-ai] No initial app start time found. Skipping...`, undefined);
60
- return;
61
- }
62
- const currentPerfMetrics = get(internalPerfMetricsAtom);
63
- if (currentPerfMetrics.has(value)) {
64
- return;
65
- }
66
- const currentTimeMs = Date.now();
67
- const deltaMs = currentTimeMs - initialTimeMs;
68
- currentPerfMetrics.set(value, deltaMs);
69
- set(internalPerfMetricsAtom, currentPerfMetrics);
70
- });
@@ -1,24 +0,0 @@
1
- import { atom } from "jotai";
2
- import { getAtomStore } from "src/atoms/atomStore/atomStore";
3
- const internalWidgetArrayAtom = atom([]);
4
- export const widgetArrayAtom = atom((get) => get(internalWidgetArrayAtom));
5
- /**
6
- * This function call is used to create a list of the Spiffy widgets
7
- * that are rendering on the page.
8
- *
9
- * It is used by the FloatingButton widget to slide out of view when it
10
- * overlaps with another Spiffy widget.
11
- *
12
- * The spiffy widgets should be added to the this array for the floating button
13
- * to know about them.
14
- *
15
- * Today the "SuggestionBar" widget is not added, but the other widgets are.
16
- *
17
- */
18
- export const addWidget = (ref, idx) => {
19
- const atomStore = getAtomStore();
20
- const val = atomStore.get(internalWidgetArrayAtom);
21
- const insertIdx = idx !== null && idx !== void 0 ? idx : val.length;
22
- val[insertIdx] = ref;
23
- atomStore.set(internalWidgetArrayAtom, val);
24
- };