@envive-ai/react-hooks 0.1.0 → 0.1.2
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.
- package/dist/adapters/amplitude/index.cjs +14 -0
- package/dist/adapters/amplitude/index.d.cts +4 -0
- package/dist/adapters/amplitude/index.d.ts +4 -0
- package/dist/adapters/amplitude/index.js +12 -0
- package/dist/api-B2euFL-5.cjs +268 -0
- package/dist/api-CxGedDxj.cjs +5057 -0
- package/dist/api-NJEaveju.js +4113 -0
- package/dist/api-XRr_lAG6.js +189 -0
- package/dist/application/config/index.cjs +34 -0
- package/dist/application/config/index.d.cts +14 -0
- package/dist/application/config/index.d.ts +14 -0
- package/dist/application/config/index.js +32 -0
- package/dist/application/models/graphql/index.cjs +13 -0
- package/dist/application/models/graphql/index.d.cts +2 -0
- package/dist/application/models/graphql/index.d.ts +2 -0
- package/dist/application/models/graphql/index.js +12 -0
- package/dist/application/models/guards/api/index.cjs +15 -0
- package/dist/application/models/guards/api/index.d.cts +3 -0
- package/dist/application/models/guards/api/index.d.ts +3 -0
- package/dist/application/models/guards/api/index.js +4 -0
- package/dist/application/models/index.cjs +72 -0
- package/dist/application/models/index.d.cts +10 -0
- package/dist/application/models/index.d.ts +10 -0
- package/dist/application/models/index.js +12 -0
- package/dist/application/models/utilityTypes/index.cjs +1 -0
- package/dist/application/models/utilityTypes/index.d.cts +2 -0
- package/dist/application/models/utilityTypes/index.d.ts +2 -0
- package/dist/application/models/utilityTypes/index.js +3 -0
- package/dist/application/models/variantInfo/index.cjs +1 -0
- package/dist/application/models/variantInfo/index.d.cts +2 -0
- package/dist/application/models/variantInfo/index.d.ts +2 -0
- package/dist/application/models/variantInfo/index.js +3 -0
- package/dist/application/service/customerService/index.cjs +4 -0
- package/dist/application/service/customerService/index.d.cts +3 -0
- package/dist/application/service/customerService/index.d.ts +3 -0
- package/dist/application/service/customerService/index.js +4 -0
- package/dist/application/service/index.cjs +761 -0
- package/dist/application/service/index.d.cts +407 -0
- package/dist/application/service/index.d.ts +407 -0
- package/dist/application/service/index.js +727 -0
- package/dist/application/utils/index.cjs +38 -0
- package/dist/application/utils/index.d.cts +254 -0
- package/dist/application/utils/index.d.ts +254 -0
- package/dist/application/utils/index.js +12 -0
- package/dist/atomStore-B3tsg6mF.cjs +0 -0
- package/dist/atomStore-BFtpknLM.js +31 -0
- package/dist/atomStore-CeJm9Llb.cjs +57 -0
- package/dist/atomStore-FSZd_20F.js +1 -0
- package/dist/atoms/app/index.cjs +17 -0
- package/dist/atoms/app/index.d.cts +33 -0
- package/dist/atoms/app/index.d.ts +33 -0
- package/dist/atoms/app/index.js +12 -0
- package/dist/atoms/atomStore/index.cjs +7 -0
- package/dist/atoms/atomStore/index.d.cts +23 -0
- package/dist/atoms/atomStore/index.d.ts +23 -0
- package/dist/atoms/atomStore/index.js +4 -0
- package/dist/atoms/chat/index.cjs +41 -0
- package/dist/atoms/chat/index.d.cts +159 -0
- package/dist/atoms/chat/index.d.ts +159 -0
- package/dist/atoms/chat/index.js +12 -0
- package/dist/atoms/globalSearch/index.cjs +6 -0
- package/dist/atoms/globalSearch/index.d.cts +23 -0
- package/dist/atoms/globalSearch/index.d.ts +23 -0
- package/dist/atoms/globalSearch/index.js +3 -0
- package/dist/atoms/org/index.cjs +41 -0
- package/dist/atoms/org/index.d.cts +93 -0
- package/dist/atoms/org/index.d.ts +93 -0
- package/dist/atoms/org/index.js +13 -0
- package/dist/atoms/search/index.cjs +44 -0
- package/dist/atoms/search/index.d.cts +11 -0
- package/dist/atoms/search/index.d.ts +11 -0
- package/dist/atoms/search/index.js +14 -0
- package/dist/{bandolier-Ble8jEa8.js → bandolier-C7PAIw02.js} +16 -7
- package/dist/{bandolier-Bm2xAt_j.cjs → bandolier-oMkFDJMF.cjs} +55 -46
- package/dist/{carpe-Da7b-LCW.cjs → carpe-C0ccKuR9.cjs} +34 -25
- package/dist/{carpe-W13mhRRP.js → carpe-DFc78_lJ.js} +16 -7
- package/dist/chat-CCgyDehy.cjs +151 -0
- package/dist/chat-Dk6KPb1K.js +25 -0
- package/dist/components-CScS7Ii-.cjs +28 -0
- package/dist/components-DAQxVIn9.js +10 -0
- package/dist/config/locators/components/chat/index.cjs +23 -0
- package/dist/config/locators/components/chat/index.d.cts +2 -0
- package/dist/config/locators/components/chat/index.d.ts +2 -0
- package/dist/config/locators/components/chat/index.js +3 -0
- package/dist/config/locators/components/chat/variants/index.cjs +28 -0
- package/dist/config/locators/components/chat/variants/index.d.cts +15 -0
- package/dist/config/locators/components/chat/variants/index.d.ts +15 -0
- package/dist/config/locators/components/chat/variants/index.js +16 -0
- package/dist/config/locators/components/index.cjs +5 -0
- package/dist/config/locators/components/index.d.cts +2 -0
- package/dist/config/locators/components/index.d.ts +2 -0
- package/dist/config/locators/components/index.js +3 -0
- package/dist/config/locators/components/search/index.cjs +12 -0
- package/dist/config/locators/components/search/index.d.cts +7 -0
- package/dist/config/locators/components/search/index.d.ts +7 -0
- package/dist/config/locators/components/search/index.js +8 -0
- package/dist/config/locators/index.cjs +47 -0
- package/dist/config/locators/index.d.cts +24 -0
- package/dist/config/locators/index.d.ts +24 -0
- package/dist/config/locators/index.js +6 -0
- package/dist/contexts/index.cjs +19 -3
- package/dist/contexts/index.d.cts +16 -22
- package/dist/contexts/index.d.ts +19 -26
- package/dist/contexts/index.js +15 -4
- package/dist/contexts-DO75-Kmx.js +7152 -0
- package/dist/contexts-iAzSvZjb.cjs +7331 -0
- package/dist/{coterie-DOWcJAYv.js → coterie-BGT8hqFR.js} +18 -7
- package/dist/{coterie-3y0D9ko4.cjs → coterie-Cp9FAJTQ.cjs} +25 -14
- package/dist/customerService-CUyZzowx.js +22 -0
- package/dist/customerService-DqPw_XKf.cjs +35 -0
- package/dist/custservice-types-D8Npo-5Z.js +22 -0
- package/dist/custservice-types-E9_OSaZ7.cjs +34 -0
- package/dist/{default-D_KPZdPJ.cjs → default-BAXPatxf.cjs} +1 -1
- package/dist/default-BR3225LZ.js +4 -0
- package/dist/default-DR6YjE9B.cjs +4 -0
- package/dist/{default-C2fEZKXk.js → default-wf_IORgo.js} +1 -1
- package/dist/divIds-BWvq-i6I.js +22 -0
- package/dist/{divIds-DnZNd7rA.cjs → divIds-CFyAjjp3.cjs} +6 -99
- package/dist/{dreamlandBaby-DCIsuU9R.cjs → dreamlandBaby-BzuMvUFS.cjs} +27 -18
- package/dist/{dreamlandBaby-DvSaZGrz.js → dreamlandBaby-DZvM81LQ.js} +16 -7
- package/dist/embedded-BlXJUbik.cjs +130 -0
- package/dist/embedded-C1jvFj3v.js +22 -0
- package/dist/events/index.cjs +4 -0
- package/dist/events/index.d.cts +45 -0
- package/dist/events/index.d.ts +45 -0
- package/dist/events/index.js +3 -0
- package/dist/events-ClCDFK7t.js +77 -0
- package/dist/events-Da7gpmGv.cjs +89 -0
- package/dist/featureFlagService-CroFRxvD.d.cts +17 -0
- package/dist/featureFlagService-NkJ2fuEj.d.ts +17 -0
- package/dist/featureGates-BMWXU0dS.d.ts +90 -0
- package/dist/featureGates-N_gyHCTn.d.cts +90 -0
- package/dist/{fiveCbd-CkOlVby_.cjs → fiveCbd-DE-tDY3d.cjs} +31 -22
- package/dist/{fiveCbd-B1SESMCO.js → fiveCbd-HNBPqPtX.js} +16 -7
- package/dist/{forLoveAndLemons-DmwYZIk0.js → forLoveAndLemons-BKmJJ9pq.js} +13 -5
- package/dist/{forLoveAndLemons-CfYPMnKS.cjs → forLoveAndLemons-BeVEBOiu.cjs} +17 -9
- package/dist/frontendConfig-KeNqU1wa.d.cts +790 -0
- package/dist/frontendConfig-cPvCTWm6.d.ts +790 -0
- package/dist/globalSearch-BC0rOX3E.js +13 -0
- package/dist/globalSearch-hxbXekus.cjs +38 -0
- package/dist/{greenpan-BtOi45lf.js → greenpan-BX1viAZB.js} +16 -7
- package/dist/{greenpan-Bsl3ir59.cjs → greenpan-chd3aa5I.cjs} +29 -20
- package/dist/{grooveLife-6_dtYsRk.js → grooveLife-CHot3rZw.js} +17 -8
- package/dist/{grooveLife-Cmm1PSCL.cjs → grooveLife-DEob7rK0.cjs} +28 -19
- package/dist/{homegrownCannabis-CO0uY_mp.cjs → homegrownCannabis-CoIjcehi.cjs} +27 -16
- package/dist/{homegrownCannabis-C-kw-74X.js → homegrownCannabis-CwkS1qDA.js} +17 -6
- package/dist/hooks/index.cjs +26 -3
- package/dist/hooks/index.d.cts +220 -299
- package/dist/hooks/index.d.ts +220 -299
- package/dist/hooks/index.js +15 -4
- package/dist/index-BdNKc2ix.d.cts +8 -0
- package/dist/index-BkhvV8RZ.d.cts +202 -0
- package/dist/index-BrXuc_Ck.d.cts +24 -0
- package/dist/{chatElementDisplayLocation-CX8fuNao.d.cts → index-C4zjAR1c.d.cts} +18 -30
- package/dist/index-CGB6CAmr.d.ts +6 -0
- package/dist/index-CIco0cCQ.d.ts +183 -0
- package/dist/index-COG1kOZG.d.ts +749 -0
- package/dist/index-CVxe7FpL.d.cts +6 -0
- package/dist/index-Cn1SeI5y.d.cts +183 -0
- package/dist/index-Cqg6ltII.d.ts +38 -0
- package/dist/index-CzMrMKx-.d.ts +202 -0
- package/dist/index-DE_7Q8qK.d.ts +94 -0
- package/dist/index-Da0UzyI9.d.ts +24 -0
- package/dist/index-DbWWcYax.d.cts +749 -0
- package/dist/index-DtoVXd6O.d.cts +97 -0
- package/dist/index-JClBRnSX.d.cts +94 -0
- package/dist/index-ghzD_356.d.ts +8 -0
- package/dist/index-hdbCEjYy.d.cts +38 -0
- package/dist/index-luJrHgPN.d.ts +97 -0
- package/dist/{chatElementDisplayLocation-CwptS9tx.d.ts → index-tfRj22E1.d.ts} +18 -30
- package/dist/interceptors/index.cjs +14 -0
- package/dist/interceptors/index.d.cts +25 -0
- package/dist/interceptors/index.d.ts +25 -0
- package/dist/interceptors/index.js +13 -0
- package/dist/{jackArcher-CLVmwwpI.js → jackArcher-BA-pkB4A.js} +16 -7
- package/dist/{jackArcher-DdYTIzAV.cjs → jackArcher-bewC0q1T.cjs} +33 -24
- package/dist/{jordanCraig-_u3-w4Hp.cjs → jordanCraig-B5k9nlAw.cjs} +76 -67
- package/dist/{jordanCraig-Am-Oor-O.js → jordanCraig-BsQ1mYbt.js} +16 -7
- package/dist/{kindredBravely-eWp-ud_E.js → kindredBravely-BxYkCpGY.js} +15 -6
- package/dist/{kindredBravely-CWovIDSc.cjs → kindredBravely-DsN0fo3s.cjs} +26 -17
- package/dist/{kutFromTheKloth-Q589bAOC.cjs → kutFromTheKloth-BQTCu3ct.cjs} +27 -18
- package/dist/{kutFromTheKloth-BMV4BuGQ.js → kutFromTheKloth-bukOQM3P.js} +16 -7
- package/dist/{larryAndSerges-BMUlTgI-.js → larryAndSerges-D1ecaT5a.js} +14 -5
- package/dist/{larryAndSerges-CEau764j.cjs → larryAndSerges-bj7fgy9b.cjs} +21 -12
- package/dist/{leapsAndRebounds-DHAtRTJD.cjs → leapsAndRebounds-BfneG_0c.cjs} +29 -20
- package/dist/{leapsAndRebounds-DGMzPO7T.js → leapsAndRebounds-DhNpZETg.js} +16 -7
- package/dist/locators-C2DX_nX6.js +1 -0
- package/dist/locators-CUpyd9Wt.cjs +0 -0
- package/dist/{longevityrx-jH2JLhNH.js → longevityrx-CnoGcw0w.js} +16 -7
- package/dist/{longevityrx-CZW8Hxzi.cjs → longevityrx-D0goIuX0.cjs} +24 -15
- package/dist/{lookOptic-CA6RwLbG.cjs → lookOptic-C4afLPZP.cjs} +24 -15
- package/dist/{lookOptic-BGXP5P_V.js → lookOptic-uJWIKpER.js} +16 -7
- package/dist/{mantraBrand-DByNqpnL.cjs → mantraBrand-8JUlYtCE.cjs} +45 -36
- package/dist/{mantraBrand-Cm9_PBCT.js → mantraBrand-DuwKHM26.js} +17 -8
- package/dist/{medterra-B0wxj_PV.js → medterra-BQec8rzn.js} +16 -7
- package/dist/{medterra-DnPN2ksU.cjs → medterra-DH067P-V.cjs} +36 -27
- package/dist/{modells-Bmz8Ag5M.js → modells-DAgLE2xo.js} +16 -7
- package/dist/{modells-CoYgkLSp.cjs → modells-DUFnLmAz.cjs} +30 -21
- package/dist/nodeSelector-DpKXszfU.d.ts +30 -0
- package/dist/nodeSelector-vKB44CDB.d.cts +30 -0
- package/dist/org-C11APG3v.js +63 -0
- package/dist/org-CnHL2I9B.cjs +106 -0
- package/dist/{pressedFloral-DjBiSoUl.cjs → pressedFloral-DVZVfOSQ.cjs} +35 -26
- package/dist/{pressedFloral-DSKs_oVG.js → pressedFloral-MdbuoRyA.js} +16 -7
- package/dist/search-CvHb1M3S.js +542 -0
- package/dist/search-bSYdOBhY.cjs +743 -0
- package/dist/search-filter-types-BsJjrxk0.d.ts +101 -0
- package/dist/search-filter-types-CqaGK3nM.d.cts +101 -0
- package/dist/{skinPerfection-B_3xzVNS.cjs → skinPerfection-BcEWICQN.cjs} +24 -15
- package/dist/{skinPerfection-IDrBuAPt.js → skinPerfection-bGiYxq1i.js} +16 -7
- package/dist/{snapSupplements-BStTsdOZ.cjs → snapSupplements-BXSXTjqF.cjs} +24 -15
- package/dist/{snapSupplements-BJk5T5ba.js → snapSupplements-D7hHhdC9.js} +16 -7
- package/dist/{spanx-BYg0LE7R.js → spanx-5-0yX3iK.js} +18 -9
- package/dist/{spanx-LwU1zSzq.cjs → spanx-lUzP6Lva.cjs} +30 -21
- package/dist/{spanxStaging-CfSmuKYB.js → spanxStaging-HglCMJag.js} +18 -9
- package/dist/{spanxStaging-OZLV9qix.cjs → spanxStaging-hreMR0MS.cjs} +34 -25
- package/dist/suggestionBarV2-types-B0RbMStE.js +9 -0
- package/dist/suggestionBarV2-types-DG3Ekk44.cjs +15 -0
- package/dist/{supergoop-CIlrHND_.js → supergoop-C9DDT3lY.js} +17 -7
- package/dist/{supergoop-BqPXDnKk.cjs → supergoop-CkjtuRck.cjs} +28 -18
- package/dist/test-types-C9b_OdfO.d.ts +39 -0
- package/dist/test-types-CpKCxk8U.d.cts +39 -0
- package/dist/types/index.cjs +6 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +4 -0
- package/dist/types-BE4faOO_.d.cts +32 -0
- package/dist/{types-C4T5UOIW.cjs → types-BUjohkXp.cjs} +58 -58
- package/dist/{types-CYNvLeSA.js → types-BVsTRyxL.js} +58 -58
- package/dist/types-TD8g7LnH.d.ts +32 -0
- package/dist/{uniqueVintage-B30mOqbH.cjs → uniqueVintage-DIMGtYAU.cjs} +46 -37
- package/dist/{uniqueVintage-CFueJOhO.js → uniqueVintage-DPWA5Ed6.js} +16 -7
- package/dist/useMessageInterceptor-B-P_rw73.cjs +72 -0
- package/dist/useMessageInterceptor-C2RZM-fo.js +57 -0
- package/dist/utilityTypes-BVikejDo.js +1 -0
- package/dist/utilityTypes-C4h2wgAK.cjs +0 -0
- package/dist/variant-BGjOVpY3.d.cts +12 -0
- package/dist/variant-XITncuI3.d.ts +12 -0
- package/dist/variantInfo-CNRTY0gH.cjs +0 -0
- package/dist/variantInfo-CzhR5W6h.js +1 -0
- package/dist/{venaCbd-T0CqVD4k.js → venaCbd-B-znfAsl.js} +16 -7
- package/dist/{venaCbd-DHGZy49P.cjs → venaCbd-BOwOtpOz.cjs} +29 -20
- package/dist/{westonJonBoucher-BdMzs_Yg.cjs → westonJonBoucher-CraTzRVt.cjs} +29 -20
- package/dist/{westonJonBoucher-b4TCQ4ev.js → westonJonBoucher-DCRagGu3.js} +16 -7
- package/dist/{wineEnthusiast-BqR0i_54.js → wineEnthusiast-Bv7umajk.js} +16 -7
- package/dist/{wineEnthusiast-BLGlOjgr.cjs → wineEnthusiast-sVuATrq6.cjs} +28 -19
- package/dist/{wolfMattress-CyyO-LoC.js → wolfMattress-BUH-Rhov.js} +17 -6
- package/dist/{wolfMattress-DNGZOivg.cjs → wolfMattress-DpVHIEnJ.cjs} +29 -18
- package/dist/{wolfTactical-BmXYlFjr.cjs → wolfTactical-BcvF_sy-.cjs} +28 -19
- package/dist/{wolfTactical-3Mm2fvVF.js → wolfTactical-Q14A1fpw.js} +16 -7
- package/package.json +101 -3
- package/src/adapters/amplitude/amplitudeAdapter.ts +1 -1
- package/src/adapters/spiffy/commerce/api.ts +1 -1
- package/src/adapters/spiffy/commerce/graphql.ts +61 -37
- package/src/application/config/index.ts +1 -0
- package/src/application/models/index.ts +102 -17
- package/src/application/models/supportedOrgs.ts +89 -65
- package/src/application/service/index.ts +32 -0
- package/src/application/service/pageVariantService.ts +201 -114
- package/src/application/service/searchService.ts +1 -1
- package/src/application/service/windowFrontendConfigService.ts +40 -18
- package/src/application/utils/index.ts +22 -3
- package/src/atoms/app/variant.ts +48 -29
- package/src/atoms/atomStore/index.ts +1 -0
- package/src/atoms/chat/messageQueue.ts +34 -17
- package/src/atoms/chat/performanceMetrics.ts +51 -38
- package/src/atoms/chat/renderedWidgetRefs.ts +14 -15
- package/src/atoms/globalSearch/index.ts +1 -0
- package/src/atoms/org/org.ts +1 -3
- package/src/atoms/org/orgUIConfig.ts +31 -24
- package/src/contexts/chatContext.tsx +124 -72
- package/src/events/registerAnalyticsListeners.ts +13 -9
- package/src/hooks/useFileUpload.ts +9 -7
- package/src/hooks/useSearch.tsx +4 -7
- package/src/initialize.ts +2 -2
- package/src/interceptors/index.ts +3 -0
- package/src/main.tsx +11 -26
- package/src/types/index.ts +4 -0
- package/dist/GridInsertionService-CEYo9pGj.js +0 -22
- package/dist/GridInsertionService-CS_bnPh0.cjs +0 -28
- package/dist/contexts-BRjfVq_k.js +0 -5064
- package/dist/contexts-BYArqZtK.cjs +0 -5164
- package/dist/custservice-types-CFIFwZ-r.js +0 -10
- package/dist/custservice-types-CkfxZiHY.cjs +0 -16
- package/dist/default-CBUq6Q6G.cjs +0 -4
- package/dist/default-CGIFZK6m.js +0 -4
- package/dist/divIds-Bss-btao.js +0 -49
- package/dist/models-DHdb7QWn.js +0 -51
- package/dist/models-ixxUsGL_.cjs +0 -69
- package/dist/suggestionBarV2-types-BllzwsBD.js +0 -34
- package/dist/suggestionBarV2-types-CaovchMP.cjs +0 -46
- package/src/atoms/index.ts +0 -5
- package/src/index.ts +0 -31
- package/src/main.ts +0 -85
- /package/dist/{cdnService-zQfKk3Eb.js → cdnService-DvDSpfVJ.js} +0 -0
- /package/dist/{cdnService-CZ-aXcY6.cjs → cdnService-dJU3sHpF.cjs} +0 -0
- /package/dist/{entrypoints-YLQsbBRD.js → entrypoints-CmmOszXO.js} +0 -0
- /package/dist/{entrypoints-D_JUvkgy.cjs → entrypoints-fowCLUT2.cjs} +0 -0
- /package/dist/{socialProofClasses-CrQBWdSA.cjs → socialProofClasses-BYLiEXpU.cjs} +0 -0
- /package/dist/{socialProofClasses-Bhv2Vulz.js → socialProofClasses-CkJufEGb.js} +0 -0
- /package/src/atoms/{atomStore.ts → atomStore/atomStore.ts} +0 -0
- /package/src/atoms/{globalSearch.ts → globalSearch/globalSearch.ts} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { atom } from
|
|
2
|
-
import { FeatureGates, getOrgInfo } from
|
|
3
|
-
import { findCustomerServiceImpl } from
|
|
4
|
-
import { CustomerServiceIntegrationMode } from
|
|
5
|
-
import { featureFlagServiceAtom, orgShortNameAtom } from
|
|
6
|
-
import { OrgUIConfig } from
|
|
7
|
-
import { getAtomStore } from
|
|
8
|
-
import Logger from
|
|
1
|
+
import { atom } from "jotai";
|
|
2
|
+
import { FeatureGates, getOrgInfo } from "src/application/models";
|
|
3
|
+
import { findCustomerServiceImpl } from "src/application/service/customerService";
|
|
4
|
+
import { CustomerServiceIntegrationMode } from "src/application/service/customerService/types";
|
|
5
|
+
import { featureFlagServiceAtom, orgShortNameAtom } from "src/atoms/org/org";
|
|
6
|
+
import { OrgUIConfig } from "src/contexts/types";
|
|
7
|
+
import { getAtomStore } from "src/atoms/atomStore/atomStore";
|
|
8
|
+
import Logger from "src/application/logging/logger";
|
|
9
9
|
|
|
10
10
|
const getCustomerServiceIntegrationMode = ({
|
|
11
11
|
integrationMode,
|
|
@@ -18,7 +18,9 @@ const getCustomerServiceIntegrationMode = ({
|
|
|
18
18
|
return integrationMode;
|
|
19
19
|
}
|
|
20
20
|
// Only allow CustomerServiceIntegrationMode.full if `isNewFeatureEnabled` is also true
|
|
21
|
-
return isNewFeatureEnabled
|
|
21
|
+
return isNewFeatureEnabled
|
|
22
|
+
? integrationMode
|
|
23
|
+
: CustomerServiceIntegrationMode.simple;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const internalOrgUIConfigAtom = atom<OrgUIConfig | undefined>(undefined);
|
|
@@ -30,16 +32,16 @@ export const orgUIConfigAtom = atom(
|
|
|
30
32
|
return orgUIConfig;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
throw new Error(
|
|
35
|
+
throw new Error("OrgUIConfig is referenced before it is set");
|
|
34
36
|
},
|
|
35
37
|
(_, set, value: OrgUIConfig) => {
|
|
36
38
|
set(internalOrgUIConfigAtom, value);
|
|
37
|
-
}
|
|
39
|
+
}
|
|
38
40
|
);
|
|
39
41
|
|
|
40
42
|
export const getOrgUIConfig = async (
|
|
41
|
-
graphqlOrgUIConfig?: Omit<OrgUIConfig,
|
|
42
|
-
graphqlMerchantOverrideCss?: string
|
|
43
|
+
graphqlOrgUIConfig?: Omit<OrgUIConfig, "merchantOverrideCss">,
|
|
44
|
+
graphqlMerchantOverrideCss?: string
|
|
43
45
|
) => {
|
|
44
46
|
const atomStore = getAtomStore();
|
|
45
47
|
const orgShortName = atomStore.get(orgShortNameAtom);
|
|
@@ -47,18 +49,21 @@ export const getOrgUIConfig = async (
|
|
|
47
49
|
const localOrgUIConfig = orgInfo.orgUIConfig() ?? {};
|
|
48
50
|
const featureFlagService = atomStore.get(featureFlagServiceAtom);
|
|
49
51
|
const isNewFeatureEnabled = featureFlagService.isFeatureGateEnabled(
|
|
50
|
-
FeatureGates.IsNewFeatureEnabled
|
|
52
|
+
FeatureGates.IsNewFeatureEnabled
|
|
53
|
+
);
|
|
54
|
+
const enableWatermark = featureFlagService.isFeatureGateEnabled(
|
|
55
|
+
FeatureGates.IsWatermarkEnabled
|
|
51
56
|
);
|
|
52
|
-
const enableWatermark = featureFlagService.isFeatureGateEnabled(FeatureGates.IsWatermarkEnabled);
|
|
53
57
|
const userQueryAwaysEnabled = featureFlagService.isFeatureGateEnabled(
|
|
54
|
-
FeatureGates.IsUserQueryAlwaysEnabled
|
|
58
|
+
FeatureGates.IsUserQueryAlwaysEnabled
|
|
55
59
|
);
|
|
56
60
|
const isGraphQLUIConfigsEnabled = featureFlagService.isFeatureGateEnabled(
|
|
57
|
-
FeatureGates.IsGraphQLUIConfigsEnabled
|
|
58
|
-
);
|
|
59
|
-
const isGraphQLComponentConfigsEnabled = featureFlagService.isFeatureGateEnabled(
|
|
60
|
-
FeatureGates.IsGraphQLComponentConfigsEnabled,
|
|
61
|
+
FeatureGates.IsGraphQLUIConfigsEnabled
|
|
61
62
|
);
|
|
63
|
+
const isGraphQLComponentConfigsEnabled =
|
|
64
|
+
featureFlagService.isFeatureGateEnabled(
|
|
65
|
+
FeatureGates.IsGraphQLComponentConfigsEnabled
|
|
66
|
+
);
|
|
62
67
|
|
|
63
68
|
let orgUIConfig: Partial<OrgUIConfig> = { ...localOrgUIConfig };
|
|
64
69
|
|
|
@@ -76,7 +81,7 @@ export const getOrgUIConfig = async (
|
|
|
76
81
|
};
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
Logger.logInfo(
|
|
84
|
+
Logger.logInfo("[spiffy-ai] Feature gate enableWatermark check", {
|
|
80
85
|
enableWatermark,
|
|
81
86
|
floatingChatConfig: orgUIConfig.floatingChatConfig,
|
|
82
87
|
});
|
|
@@ -103,9 +108,11 @@ export const getOrgUIConfig = async (
|
|
|
103
108
|
// Only enable the watermark if it is enabled in config and through featureFlag.
|
|
104
109
|
// This enables a quick "off-switch" in case a merchant tells us to turn it off
|
|
105
110
|
// quickly. This can be removed once the config is moved to the backend
|
|
106
|
-
enableWatermark:
|
|
111
|
+
enableWatermark:
|
|
112
|
+
orgUIConfig.floatingChatConfig?.enableWatermark && enableWatermark,
|
|
107
113
|
userQueryInputEnabled:
|
|
108
|
-
orgUIConfig.floatingChatConfig?.userQueryInputEnabled ||
|
|
114
|
+
orgUIConfig.floatingChatConfig?.userQueryInputEnabled ||
|
|
115
|
+
userQueryAwaysEnabled,
|
|
109
116
|
},
|
|
110
117
|
} as OrgUIConfig;
|
|
111
118
|
|
|
@@ -113,7 +120,7 @@ export const getOrgUIConfig = async (
|
|
|
113
120
|
};
|
|
114
121
|
|
|
115
122
|
export const orgCustomerServiceConfig = atom(
|
|
116
|
-
(get) => get(orgUIConfigAtom).customerServiceIntegration
|
|
123
|
+
(get) => get(orgUIConfigAtom).customerServiceIntegration
|
|
117
124
|
);
|
|
118
125
|
|
|
119
126
|
export const orgCustomerServiceService = atom((get) => {
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import { UserEventCategory } from
|
|
2
|
-
import { useAtom, useAtomValue, useSetAtom } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { UserEventCategory } from "@spiffy-ai/commerce-api-client";
|
|
2
|
+
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
ReactNode,
|
|
8
|
+
useCallback,
|
|
9
|
+
useMemo,
|
|
10
|
+
} from "react";
|
|
11
|
+
import CommerceApiClient from "src/adapters/spiffy/commerce/api";
|
|
12
|
+
import { v4 as uuid } from "uuid";
|
|
13
|
+
import { SessionRestartRequired } from "src/adapters/spiffy/commerce/exceptions/sessionExceptions";
|
|
14
|
+
import Logger from "src/application/logging/logger";
|
|
8
15
|
import {
|
|
9
16
|
Message,
|
|
10
17
|
MessageRole,
|
|
11
18
|
MessageType,
|
|
12
19
|
NextMessageRequest,
|
|
13
20
|
Response,
|
|
14
|
-
} from
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
} from "src/application/models";
|
|
22
|
+
import {
|
|
23
|
+
AmplitudeAdapter,
|
|
24
|
+
SpiffyMetricsEventName,
|
|
25
|
+
} from "src/adapters/amplitude";
|
|
26
|
+
import { messageFromResponse } from "src/application/utils";
|
|
27
|
+
import { chatIdAtom, userIdAtom, variantInfoAtom } from "src/atoms/app";
|
|
18
28
|
import {
|
|
19
29
|
messagesAtom,
|
|
20
30
|
requestFailureAtom,
|
|
@@ -25,27 +35,28 @@ import {
|
|
|
25
35
|
userEventsAtom,
|
|
26
36
|
suggestionsLoadingAtom,
|
|
27
37
|
suggestionsAtom,
|
|
28
|
-
} from
|
|
38
|
+
} from "src/atoms/chat";
|
|
29
39
|
import {
|
|
30
40
|
chatSearchProductSortingAtom,
|
|
31
41
|
chatSearchProducts,
|
|
32
42
|
chatSearchStateAtom,
|
|
33
43
|
handleSearchResultsAtom,
|
|
34
44
|
chatSearchIsLoadingAtom,
|
|
35
|
-
} from
|
|
36
|
-
import { orgIdAtom } from
|
|
37
|
-
import { useSystemSettingsContext } from
|
|
38
|
-
import { createAppLoadedEvent, createVisitUserEvent } from
|
|
39
|
-
import { useMessageInterceptor } from
|
|
40
|
-
import { supportedEventAtom } from
|
|
41
|
-
import { chatAtom
|
|
45
|
+
} from "src/atoms/search/chatSearch";
|
|
46
|
+
import { orgIdAtom } from "src/atoms/org/org";
|
|
47
|
+
import { useSystemSettingsContext } from "src/hooks";
|
|
48
|
+
import { createAppLoadedEvent, createVisitUserEvent } from "src/hooks/utils";
|
|
49
|
+
import { useMessageInterceptor } from "src/interceptors/useMessageInterceptor";
|
|
50
|
+
import { supportedEventAtom } from "src/atoms/app/variant";
|
|
51
|
+
import { chatAtom } from "src/atoms/chat";
|
|
52
|
+
import { getAtomStore } from "src/atoms/atomStore";
|
|
42
53
|
import {
|
|
43
54
|
clearUserEventAtom,
|
|
44
55
|
createResponsePayload,
|
|
45
56
|
processUserEventAtom,
|
|
46
57
|
userEventQueueAtom,
|
|
47
58
|
userQueueEventCountAtom,
|
|
48
|
-
} from
|
|
59
|
+
} from "src/atoms/chat/messageQueue";
|
|
49
60
|
|
|
50
61
|
/**
|
|
51
62
|
* Record the chat assistant response in Amplitude
|
|
@@ -53,7 +64,10 @@ import {
|
|
|
53
64
|
* @param startTimeMs The start time of the assistant response
|
|
54
65
|
* @param payload The payload used to generate the response
|
|
55
66
|
*/
|
|
56
|
-
const recordAssistantResponse = (
|
|
67
|
+
const recordAssistantResponse = (
|
|
68
|
+
startTimeMs: number,
|
|
69
|
+
payload: NextMessageRequest
|
|
70
|
+
) => {
|
|
57
71
|
const atomStore = getAtomStore();
|
|
58
72
|
const chatState = atomStore.get(chatAtom);
|
|
59
73
|
const chatSearchState = atomStore.get(chatSearchStateAtom);
|
|
@@ -72,26 +86,31 @@ const recordAssistantResponse = (startTimeMs: number, payload: NextMessageReques
|
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
const eventProps: Record<string, unknown> = {
|
|
75
|
-
response_time_ms:
|
|
89
|
+
response_time_ms:
|
|
90
|
+
assistantResponseTimeMs.end - assistantResponseTimeMs.start,
|
|
76
91
|
user_event_type: chatState.replyEventCategory,
|
|
77
92
|
user_query: userQueryProperty,
|
|
78
93
|
};
|
|
79
94
|
|
|
80
95
|
if (chatState.replyEventCategory === UserEventCategory.FormSubmitted) {
|
|
81
96
|
const lastAssistantTurn = chatState.messages
|
|
82
|
-
.filter(
|
|
97
|
+
.filter(
|
|
98
|
+
(turn) => turn.length > 0 && turn[0].role === MessageRole.Assistant
|
|
99
|
+
)
|
|
83
100
|
.pop();
|
|
84
101
|
const formType = payload.userEvents?.find(
|
|
85
|
-
(event) => event.category === UserEventCategory.FormSubmitted
|
|
102
|
+
(event) => event.category === UserEventCategory.FormSubmitted
|
|
86
103
|
)?.attributes.formType;
|
|
87
|
-
const formStatus = lastAssistantTurn?.some(
|
|
104
|
+
const formStatus = lastAssistantTurn?.some(
|
|
105
|
+
(response) => response.type === MessageType.Order
|
|
106
|
+
);
|
|
88
107
|
eventProps.form_submitted_attributes = {
|
|
89
108
|
form_type: formType,
|
|
90
|
-
status: formStatus ?
|
|
109
|
+
status: formStatus ? "success" : "failed",
|
|
91
110
|
};
|
|
92
111
|
}
|
|
93
112
|
|
|
94
|
-
if (chatSearchState ===
|
|
113
|
+
if (chatSearchState === "product-page") {
|
|
95
114
|
eventProps.search_products_returned = searchProducts.length;
|
|
96
115
|
eventProps.search_products_sort_type = searchProductsSort;
|
|
97
116
|
}
|
|
@@ -109,13 +128,16 @@ const ChatContext = createContext<ChatContextParams | undefined>(undefined);
|
|
|
109
128
|
const updateMessageState = (
|
|
110
129
|
message: Message,
|
|
111
130
|
lastMessage: Message,
|
|
112
|
-
setMessages: (updater: (prev: Message[][]) => Message[][]) => void
|
|
131
|
+
setMessages: (updater: (prev: Message[][]) => Message[][]) => void
|
|
113
132
|
): Message => {
|
|
114
133
|
if (lastMessage == null) {
|
|
115
134
|
setMessages((prev) => [...prev, [message]]);
|
|
116
135
|
return message;
|
|
117
136
|
}
|
|
118
|
-
if (
|
|
137
|
+
if (
|
|
138
|
+
lastMessage.type === MessageType.Text &&
|
|
139
|
+
message.type === MessageType.Text
|
|
140
|
+
) {
|
|
119
141
|
const newMessage = {
|
|
120
142
|
...lastMessage,
|
|
121
143
|
metadata: {
|
|
@@ -132,14 +154,17 @@ const updateMessageState = (
|
|
|
132
154
|
});
|
|
133
155
|
return newMessage;
|
|
134
156
|
}
|
|
135
|
-
setMessages((prev) => [
|
|
157
|
+
setMessages((prev) => [
|
|
158
|
+
...prev.slice(0, prev.length - 1),
|
|
159
|
+
[...prev[prev.length - 1], message],
|
|
160
|
+
]);
|
|
136
161
|
return message;
|
|
137
162
|
};
|
|
138
163
|
|
|
139
164
|
const handleStreamingError = (
|
|
140
165
|
_error: unknown,
|
|
141
166
|
setRequestFailure: (failed: boolean) => void,
|
|
142
|
-
setMessages: (updater: (prev: Message[][]) => Message[][]) => void
|
|
167
|
+
setMessages: (updater: (prev: Message[][]) => Message[][]) => void
|
|
143
168
|
) => {
|
|
144
169
|
setRequestFailure(true);
|
|
145
170
|
setMessages((prev) => [
|
|
@@ -161,11 +186,13 @@ const handleStreamingError = (
|
|
|
161
186
|
|
|
162
187
|
const processStreamingResponse = async (
|
|
163
188
|
stream: AsyncIterable<Response>,
|
|
164
|
-
messageInterceptor: {
|
|
189
|
+
messageInterceptor: {
|
|
190
|
+
intercept: (response?: Response) => boolean | undefined;
|
|
191
|
+
},
|
|
165
192
|
handleSearchResults: (message: Message) => void,
|
|
166
193
|
setMessages: (updater: (prev: Message[][]) => Message[][]) => void,
|
|
167
194
|
setSearchIsLoading: (loading: boolean) => void,
|
|
168
|
-
chatId: string
|
|
195
|
+
chatId: string
|
|
169
196
|
): Promise<{ hasSearchResults: boolean }> => {
|
|
170
197
|
let lastMessage: Message | undefined;
|
|
171
198
|
let hasSearchResults = false;
|
|
@@ -178,7 +205,7 @@ const processStreamingResponse = async (
|
|
|
178
205
|
|
|
179
206
|
const message = messageFromResponse(response);
|
|
180
207
|
if (!message) {
|
|
181
|
-
throw new Error(
|
|
208
|
+
throw new Error("Failed to transform API response to client message");
|
|
182
209
|
}
|
|
183
210
|
|
|
184
211
|
if (message.type === MessageType.ProductSearch) {
|
|
@@ -195,7 +222,7 @@ const processStreamingResponse = async (
|
|
|
195
222
|
{
|
|
196
223
|
lastResponse: lastMessage,
|
|
197
224
|
response,
|
|
198
|
-
}
|
|
225
|
+
}
|
|
199
226
|
);
|
|
200
227
|
}
|
|
201
228
|
}
|
|
@@ -211,8 +238,12 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
211
238
|
const [messages, setMessages] = useAtom<Message[][]>(messagesAtom);
|
|
212
239
|
const setUserEvents = useSetAtom(userEventsAtom);
|
|
213
240
|
const setSuggestions = useSetAtom(suggestionsAtom);
|
|
214
|
-
const [suggestionsLoading, setSuggestionsLoading] = useAtom<boolean>(
|
|
215
|
-
|
|
241
|
+
const [suggestionsLoading, setSuggestionsLoading] = useAtom<boolean>(
|
|
242
|
+
suggestionsLoadingAtom
|
|
243
|
+
);
|
|
244
|
+
const [responseStreaming, setResponseStreaming] = useAtom<boolean>(
|
|
245
|
+
responseStreamingAtom
|
|
246
|
+
);
|
|
216
247
|
const setRequestFailure = useSetAtom(requestFailureAtom);
|
|
217
248
|
const userEvents = useAtomValue(userEventQueueAtom);
|
|
218
249
|
const userQueueEventCount = useAtomValue(userQueueEventCountAtom);
|
|
@@ -230,7 +261,9 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
230
261
|
const setSearchIsLoading = useSetAtom(chatSearchIsLoadingAtom);
|
|
231
262
|
|
|
232
263
|
const getStreamingResponses = useCallback(
|
|
233
|
-
async (
|
|
264
|
+
async (
|
|
265
|
+
payload: NextMessageRequest
|
|
266
|
+
): Promise<{ hasSearchResults: boolean }> => {
|
|
234
267
|
logPerfMetric(PerfMetricsEvents.FirstResponseStarted);
|
|
235
268
|
const stream = CommerceApiClient.getNextResponseStreaming(payload);
|
|
236
269
|
|
|
@@ -243,7 +276,7 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
243
276
|
handleSearchResults,
|
|
244
277
|
setMessages,
|
|
245
278
|
setSearchIsLoading,
|
|
246
|
-
chatId
|
|
279
|
+
chatId
|
|
247
280
|
);
|
|
248
281
|
|
|
249
282
|
return { hasSearchResults };
|
|
@@ -262,7 +295,7 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
262
295
|
setMessages,
|
|
263
296
|
setSearchIsLoading,
|
|
264
297
|
chatId,
|
|
265
|
-
]
|
|
298
|
+
]
|
|
266
299
|
);
|
|
267
300
|
|
|
268
301
|
const getSuggestions = useCallback(async () => {
|
|
@@ -274,13 +307,22 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
274
307
|
userEvents: [],
|
|
275
308
|
generationParams: settingsContext.generationParams,
|
|
276
309
|
});
|
|
277
|
-
const response = await CommerceApiClient.getNextSuggestions(
|
|
310
|
+
const response = await CommerceApiClient.getNextSuggestions(
|
|
311
|
+
payloadWithoutAppLoaded
|
|
312
|
+
);
|
|
278
313
|
|
|
279
314
|
// sort the suggestions by shortest length so the pills can be stacked horizontally
|
|
280
|
-
setSuggestions(
|
|
315
|
+
setSuggestions(
|
|
316
|
+
response.sort((a, b) => a.content.length - b.content.length)
|
|
317
|
+
);
|
|
281
318
|
setSuggestionsLoading(false);
|
|
282
319
|
logPerfMetric(PerfMetricsEvents.FirstSuggestionsCompleted);
|
|
283
|
-
}, [
|
|
320
|
+
}, [
|
|
321
|
+
logPerfMetric,
|
|
322
|
+
setSuggestionsLoading,
|
|
323
|
+
setSuggestions,
|
|
324
|
+
settingsContext.generationParams,
|
|
325
|
+
]);
|
|
284
326
|
|
|
285
327
|
const getResponses = useCallback(
|
|
286
328
|
async (payload?: NextMessageRequest) => {
|
|
@@ -301,7 +343,7 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
301
343
|
recordAssistantResponse(startTimeMs, requestPayload);
|
|
302
344
|
await getSuggestions();
|
|
303
345
|
} catch (error) {
|
|
304
|
-
Logger.logError(
|
|
346
|
+
Logger.logError("[spiffy-ai] getResponses error", error);
|
|
305
347
|
} finally {
|
|
306
348
|
// Remove search loading management from here - it's now handled independently
|
|
307
349
|
// in the processStreamingResponse function when search results are detected
|
|
@@ -319,7 +361,7 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
319
361
|
markUserEventsProcessed,
|
|
320
362
|
getSuggestions,
|
|
321
363
|
setUserHasReplied,
|
|
322
|
-
]
|
|
364
|
+
]
|
|
323
365
|
);
|
|
324
366
|
|
|
325
367
|
useEffect(() => {
|
|
@@ -329,25 +371,28 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
329
371
|
}
|
|
330
372
|
|
|
331
373
|
if (
|
|
332
|
-
(variantInfo.variant ===
|
|
333
|
-
(variantInfo.variant ===
|
|
334
|
-
(variantInfo.variant ===
|
|
374
|
+
(variantInfo.variant === "pdp" && !variantInfo.productId) ||
|
|
375
|
+
(variantInfo.variant === "plp" && !variantInfo.plpId) ||
|
|
376
|
+
(variantInfo.variant === "page_visit" && !variantInfo.url)
|
|
335
377
|
) {
|
|
336
|
-
Logger.logDebug(
|
|
337
|
-
variantInfo,
|
|
338
|
-
|
|
339
|
-
|
|
378
|
+
Logger.logDebug(
|
|
379
|
+
"[spiffy-ai] variantInfo has invalid values, skipping...",
|
|
380
|
+
{
|
|
381
|
+
variantInfo,
|
|
382
|
+
supportedEvent,
|
|
383
|
+
}
|
|
384
|
+
);
|
|
340
385
|
return;
|
|
341
386
|
}
|
|
342
387
|
|
|
343
388
|
Logger.logDebug(
|
|
344
|
-
`Assistants Turn is_currently_streaming=${responseStreaming} initialized=${widgetInitialized}
|
|
389
|
+
`Assistants Turn is_currently_streaming=${responseStreaming} initialized=${widgetInitialized}`
|
|
345
390
|
);
|
|
346
391
|
try {
|
|
347
392
|
await getResponses();
|
|
348
393
|
Logger.logInfo(`Assistants Turn [finished]`);
|
|
349
394
|
} catch (error: unknown) {
|
|
350
|
-
Logger.logError(
|
|
395
|
+
Logger.logError("[spiffy-ai] Assistants Turn error", error);
|
|
351
396
|
}
|
|
352
397
|
};
|
|
353
398
|
if (userQueueEventCount > 0) {
|
|
@@ -365,7 +410,7 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
365
410
|
useEffect(() => {
|
|
366
411
|
if (widgetInitialized || responseStreaming) {
|
|
367
412
|
Logger.logDebug(
|
|
368
|
-
`[spiffy-ai] initializeWidget [skipped] is_currently_streaming=${responseStreaming} is_initialized=${widgetInitialized}
|
|
413
|
+
`[spiffy-ai] initializeWidget [skipped] is_currently_streaming=${responseStreaming} is_initialized=${widgetInitialized}`
|
|
369
414
|
);
|
|
370
415
|
return;
|
|
371
416
|
}
|
|
@@ -373,20 +418,20 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
373
418
|
const hydrateChat = async () => {
|
|
374
419
|
try {
|
|
375
420
|
Logger.logDebug(
|
|
376
|
-
`[spiffy-ai] initializeWidget is_currently_streaming=${responseStreaming} is_initialized=${widgetInitialized}
|
|
421
|
+
`[spiffy-ai] initializeWidget is_currently_streaming=${responseStreaming} is_initialized=${widgetInitialized}`
|
|
377
422
|
);
|
|
378
423
|
// on mount, try to get the responses from an active session if one exists
|
|
379
|
-
const { messages: existingMessages, userEvents } =
|
|
380
|
-
orgId,
|
|
381
|
-
chatId,
|
|
382
|
-
userId,
|
|
383
|
-
);
|
|
424
|
+
const { messages: existingMessages, userEvents } =
|
|
425
|
+
await CommerceApiClient.getResponses(orgId, chatId, userId);
|
|
384
426
|
setMessages([...existingMessages]);
|
|
385
427
|
setUserEvents([...userEvents]);
|
|
386
428
|
getResponses();
|
|
387
429
|
} catch (error) {
|
|
388
430
|
// no active chat session was found, start a new one
|
|
389
|
-
Logger.logInfo(
|
|
431
|
+
Logger.logInfo(
|
|
432
|
+
`Init chat [exception] chat_id=${chatId} error=${error}`,
|
|
433
|
+
error
|
|
434
|
+
);
|
|
390
435
|
if (error instanceof SessionRestartRequired) {
|
|
391
436
|
const appLoadedEvent = createAppLoadedEvent();
|
|
392
437
|
const visitEvent = createVisitUserEvent({ variantInfo });
|
|
@@ -411,11 +456,8 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
411
456
|
const onFocus = useCallback(async () => {
|
|
412
457
|
try {
|
|
413
458
|
if (!responseStreaming && !suggestionsLoading) {
|
|
414
|
-
const { messages: existingMessages } =
|
|
415
|
-
orgId,
|
|
416
|
-
chatId,
|
|
417
|
-
userId,
|
|
418
|
-
);
|
|
459
|
+
const { messages: existingMessages } =
|
|
460
|
+
await CommerceApiClient.getResponses(orgId, chatId, userId);
|
|
419
461
|
|
|
420
462
|
if (existingMessages.length > messages.length) {
|
|
421
463
|
setMessages([...existingMessages]);
|
|
@@ -429,22 +471,32 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
429
471
|
}
|
|
430
472
|
}
|
|
431
473
|
} catch (error: unknown) {
|
|
432
|
-
Logger.logError(
|
|
474
|
+
Logger.logError("[spiffy-ai] onFocus error", error);
|
|
433
475
|
}
|
|
434
|
-
}, [
|
|
476
|
+
}, [
|
|
477
|
+
responseStreaming,
|
|
478
|
+
suggestionsLoading,
|
|
479
|
+
orgId,
|
|
480
|
+
chatId,
|
|
481
|
+
userId,
|
|
482
|
+
messages.length,
|
|
483
|
+
setMessages,
|
|
484
|
+
]);
|
|
435
485
|
|
|
436
486
|
// listen for page focus to get latest messages from the server
|
|
437
487
|
useEffect(() => {
|
|
438
|
-
window.addEventListener(
|
|
488
|
+
window.addEventListener("focus", onFocus);
|
|
439
489
|
|
|
440
490
|
return () => {
|
|
441
|
-
window.removeEventListener(
|
|
491
|
+
window.removeEventListener("focus", onFocus);
|
|
442
492
|
};
|
|
443
493
|
}, [onFocus]);
|
|
444
494
|
|
|
445
495
|
const chatContext = useMemo(() => ({}), []);
|
|
446
496
|
|
|
447
|
-
return
|
|
497
|
+
return (
|
|
498
|
+
<ChatContext.Provider value={chatContext}>{children}</ChatContext.Provider>
|
|
499
|
+
);
|
|
448
500
|
};
|
|
449
501
|
|
|
450
502
|
export { ChatContext, ChatContextProvider };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
AmplitudeAdapter,
|
|
3
|
+
SpiffyMetricsEventName,
|
|
4
|
+
} from "src/adapters/amplitude";
|
|
5
|
+
import { getAtomStore } from "src/atoms/atomStore/atomStore";
|
|
3
6
|
import {
|
|
4
7
|
pageLoadOffsetTimeAtom,
|
|
5
8
|
performanceMetricsAtom,
|
|
6
9
|
resetPerformanceMetricsAtom,
|
|
7
|
-
} from
|
|
10
|
+
} from "src/atoms/chat";
|
|
8
11
|
|
|
9
12
|
const registerPerformanceMetricsListener = () => {
|
|
10
13
|
const atomStore = getAtomStore();
|
|
@@ -12,19 +15,19 @@ const registerPerformanceMetricsListener = () => {
|
|
|
12
15
|
const pageLoadOffsetTime = atomStore.get(pageLoadOffsetTimeAtom);
|
|
13
16
|
|
|
14
17
|
const handleVisibilityChange = () => {
|
|
15
|
-
if (document.visibilityState ===
|
|
18
|
+
if (document.visibilityState === "hidden" && performanceMetrics.size > 0) {
|
|
16
19
|
const perfMetricsProperties = Object.fromEntries(
|
|
17
20
|
Array.from(performanceMetrics.entries()).map(([key, value]) => [
|
|
18
21
|
`performanceMetrics.${key}`,
|
|
19
22
|
value,
|
|
20
|
-
])
|
|
23
|
+
])
|
|
21
24
|
);
|
|
22
25
|
|
|
23
26
|
AmplitudeAdapter.trackEvent({
|
|
24
27
|
eventName: SpiffyMetricsEventName.PerformanceMetrics,
|
|
25
28
|
eventProps: {
|
|
26
29
|
...perfMetricsProperties,
|
|
27
|
-
|
|
30
|
+
"performance_metrics.page_load_offset_ms": pageLoadOffsetTime,
|
|
28
31
|
},
|
|
29
32
|
});
|
|
30
33
|
resetPerformanceMetricsAtom();
|
|
@@ -33,15 +36,16 @@ const registerPerformanceMetricsListener = () => {
|
|
|
33
36
|
|
|
34
37
|
// do not use anything other than visibilitychange to detect when a page or
|
|
35
38
|
// session has ended as other events may not fire in all browsers/devices
|
|
36
|
-
window.addEventListener(
|
|
39
|
+
window.addEventListener("visibilitychange", handleVisibilityChange);
|
|
37
40
|
|
|
38
41
|
return () => {
|
|
39
|
-
window.removeEventListener(
|
|
42
|
+
window.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
40
43
|
};
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
export const registerAnalyticsListeners = () => {
|
|
44
|
-
const cleanupPerformanceMetricsListener =
|
|
47
|
+
const cleanupPerformanceMetricsListener =
|
|
48
|
+
registerPerformanceMetricsListener();
|
|
45
49
|
|
|
46
50
|
return () => {
|
|
47
51
|
cleanupPerformanceMetricsListener();
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { AttachmentRequest } from
|
|
2
|
-
import { useAtom, useAtomValue } from
|
|
3
|
-
import { useRef, useState } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { AttachmentRequest } from "@spiffy-ai/commerce-api-client";
|
|
2
|
+
import { useAtom, useAtomValue } from "jotai";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
orgCustomerServiceService,
|
|
6
|
+
customerServiceAttachment,
|
|
7
|
+
} from "src/atoms/org";
|
|
6
8
|
|
|
7
9
|
export const useFileUpload = () => {
|
|
8
10
|
const fileInputRef = useRef(null);
|
|
9
11
|
const [attachment, setAttachment] = useAtom(customerServiceAttachment);
|
|
10
12
|
const customerServiceImpl = useAtomValue(orgCustomerServiceService);
|
|
11
|
-
const [error, setError] = useState(
|
|
13
|
+
const [error, setError] = useState("");
|
|
12
14
|
|
|
13
15
|
const isValidFile = (file?: File) => {
|
|
14
16
|
const maxSize = customerServiceImpl.maxfileUploadSize;
|
|
@@ -41,7 +43,7 @@ export const useFileUpload = () => {
|
|
|
41
43
|
if (attachment) {
|
|
42
44
|
return {
|
|
43
45
|
...attachment,
|
|
44
|
-
base64_content: attachment?.base64_content.split(
|
|
46
|
+
base64_content: attachment?.base64_content.split(",")[1],
|
|
45
47
|
} as AttachmentRequest;
|
|
46
48
|
}
|
|
47
49
|
};
|
package/src/hooks/useSearch.tsx
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
clearSearchFiltersAtom,
|
|
8
8
|
createFilterOption,
|
|
9
9
|
filteredSearchProductsAtom,
|
|
10
|
-
orgUIConfigAtom,
|
|
11
10
|
performSearchAtom,
|
|
12
11
|
removeSearchFilterAtom,
|
|
13
12
|
searchAtom,
|
|
@@ -16,11 +15,11 @@ import {
|
|
|
16
15
|
searchProductSortingAtom,
|
|
17
16
|
searchSelectedFiltersAtom,
|
|
18
17
|
SelectedFilterOption,
|
|
19
|
-
} from "src/atoms";
|
|
18
|
+
} from "src/atoms/search";
|
|
20
19
|
import {
|
|
21
20
|
autocompleteStateAtom,
|
|
22
21
|
isFilterOpenAtom,
|
|
23
|
-
} from "src/atoms/globalSearch";
|
|
22
|
+
} from "src/atoms/globalSearch/globalSearch";
|
|
24
23
|
import { formatFilterDisplayName } from "src/atoms/search/utils";
|
|
25
24
|
import { ProductSorting } from "src/atoms/search/types";
|
|
26
25
|
import {
|
|
@@ -32,11 +31,9 @@ import { ProductCardConfig } from "src/contexts/types";
|
|
|
32
31
|
import Logger from "src/application/logging/logger";
|
|
33
32
|
import { SearchResult } from "src/application/models/api/search";
|
|
34
33
|
import { SearchResponseProduct } from "@spiffy-ai/commerce-api-client";
|
|
35
|
-
import {
|
|
36
|
-
SearchFilter,
|
|
37
|
-
SelectFilterItem,
|
|
38
|
-
} from "src/types/search-filter-types.ts";
|
|
34
|
+
import { SearchFilter, SelectFilterItem } from "src/types/search-filter-types";
|
|
39
35
|
import { getSearchResultsState, SearchResultsState } from "./utils";
|
|
36
|
+
import { orgUIConfigAtom } from "src/atoms/org";
|
|
40
37
|
|
|
41
38
|
export interface SearchResultsHocProps {
|
|
42
39
|
// Data
|
package/src/initialize.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
initAmplitude,
|
|
12
12
|
initDataLayerWrapper,
|
|
13
13
|
} from "src/application/utils/analyticsUtils";
|
|
14
|
-
import { getAtomStore } from "src/atoms/atomStore";
|
|
14
|
+
import { getAtomStore } from "src/atoms/atomStore/atomStore";
|
|
15
15
|
import {
|
|
16
16
|
apiKeyAtom,
|
|
17
17
|
featureFlagServiceAtom,
|
|
@@ -89,7 +89,7 @@ const loadAndInit = async () => {
|
|
|
89
89
|
script.id = "spiffy-injection-script";
|
|
90
90
|
document.head.appendChild(script);
|
|
91
91
|
// #else
|
|
92
|
-
const { initApp } = await import("./main
|
|
92
|
+
const { initApp } = await import("./main");
|
|
93
93
|
await initApp();
|
|
94
94
|
// #endif
|
|
95
95
|
};
|