@envive-ai/react-hooks 0.2.6-alpha-arthur-1 → 0.2.6-alpha.11
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/{NewOrgConfig-CUQGpmw9.js → NewOrgConfig-BZCP9E7v.js} +2 -2
- package/dist/{NewOrgConfig-DD0oloeK.cjs → NewOrgConfig-DWLMI1ga.cjs} +2 -2
- package/dist/SystemSettingsContext-CO5c1L62.cjs +20 -0
- package/dist/SystemSettingsContext-CXmUlH8i.js +13 -0
- package/dist/TrackComponentVisibleEvent-BJgNOypY.js +52 -0
- package/dist/TrackComponentVisibleEvent-BRC2FTp-.cjs +59 -0
- package/dist/amplitudeContext-CCVyp5RU.d.cts +52 -0
- package/dist/amplitudeContext-DFYBDc0h.d.ts +52 -0
- package/dist/api-BWSsazAG.js +166 -0
- package/dist/api-DeW6rHj3.cjs +239 -0
- package/dist/application/models/graphql/index.cjs +3 -3
- package/dist/application/models/graphql/index.d.cts +2 -2
- package/dist/application/models/graphql/index.d.ts +2 -2
- package/dist/application/models/graphql/index.js +3 -2
- package/dist/application/models/guards/api/index.cjs +3 -3
- package/dist/application/models/guards/api/index.d.cts +2 -2
- package/dist/application/models/guards/api/index.d.ts +2 -2
- package/dist/application/models/guards/api/index.js +3 -3
- package/dist/application/models/guards/utils.cjs +1 -1
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/guards/utils.js +1 -1
- package/dist/application/models/index.cjs +23 -7
- package/dist/application/models/index.d.cts +12 -167
- package/dist/application/models/index.d.ts +13 -168
- package/dist/application/models/index.js +11 -7
- 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 +3 -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/utils/index.cjs +19 -10
- package/dist/application/utils/index.d.cts +64 -13
- package/dist/application/utils/index.d.ts +64 -13
- package/dist/application/utils/index.js +19 -10
- package/dist/{atomStore-CZKe3itM.cjs → atomStore-DNji91Im.cjs} +1 -1
- package/dist/{atomStore-BuopbV9k.js → atomStore-DXTVqiKc.js} +1 -1
- package/dist/atoms/app/index.cjs +24 -22
- package/dist/atoms/app/index.d.cts +21 -9
- package/dist/atoms/app/index.d.ts +20 -8
- package/dist/atoms/app/index.js +19 -17
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.d.ts +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +21 -20
- package/dist/atoms/chat/index.d.cts +46 -36
- package/dist/atoms/chat/index.d.ts +44 -34
- package/dist/atoms/chat/index.js +21 -20
- package/dist/atoms/globalSearch/index.cjs +2 -1
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/globalSearch/index.js +2 -1
- package/dist/atoms/org/index.cjs +11 -10
- package/dist/atoms/org/index.d.cts +32 -19
- package/dist/atoms/org/index.d.ts +32 -19
- package/dist/atoms/org/index.js +3 -2
- package/dist/atoms/search/index.cjs +47 -7
- package/dist/atoms/search/index.d.cts +15 -76
- package/dist/atoms/search/index.d.ts +15 -76
- package/dist/atoms/search/index.js +29 -7
- package/dist/atoms/search/types.cjs +5 -0
- package/dist/atoms/search/types.d.cts +2 -0
- package/dist/atoms/search/types.d.ts +2 -0
- package/dist/atoms/search/types.js +3 -0
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/cdnContext-BnqmnEvR.js +38 -0
- package/dist/cdnContext-CnYcBOr9.cjs +53 -0
- package/dist/chat-CqPuT9_V.cjs +393 -0
- package/dist/chat-DH70QqJp.js +257 -0
- package/dist/chatElementDisplayLocation-CpgV2wR1.d.ts +25 -0
- package/dist/chatElementDisplayLocation-DWmfNX_u.d.cts +25 -0
- package/dist/chatSearch-ChyGuHbu.js +295 -0
- package/dist/chatSearch-DpnpRWAW.cjs +418 -0
- package/dist/chatState-CcFtSqJT.cjs +120 -0
- package/dist/chatState-DKnNHmwe.js +34 -0
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/locators/components/chat/index.d.cts +1 -1
- package/dist/config/locators/components/chat/index.d.ts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.cts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.ts +1 -1
- package/dist/config/locators/components/common/index.d.cts +1 -1
- package/dist/config/locators/components/common/index.d.ts +1 -1
- package/dist/config/locators/components/index.d.cts +1 -1
- package/dist/config/locators/components/index.d.ts +1 -1
- package/dist/config/locators/components/search/index.d.cts +1 -1
- package/dist/config/locators/components/search/index.d.ts +1 -1
- package/dist/config/locators/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +22 -23
- package/dist/contexts/amplitudeContext/index.d.cts +2 -11
- package/dist/contexts/amplitudeContext/index.d.ts +2 -11
- package/dist/contexts/amplitudeContext/index.js +20 -22
- package/dist/contexts/cdnContext/index.cjs +4 -4
- package/dist/contexts/cdnContext/index.d.cts +6 -2
- package/dist/contexts/cdnContext/index.d.ts +6 -2
- package/dist/contexts/cdnContext/index.js +4 -4
- package/dist/contexts/chatContext/index.cjs +326 -0
- package/dist/contexts/chatContext/index.d.cts +15 -0
- package/dist/contexts/chatContext/index.d.ts +15 -0
- package/dist/contexts/chatContext/index.js +319 -0
- package/dist/contexts/enviveConfigContext/index.cjs +4 -4
- package/dist/contexts/enviveConfigContext/index.d.cts +25 -3
- package/dist/contexts/enviveConfigContext/index.d.ts +25 -3
- package/dist/contexts/enviveConfigContext/index.js +4 -4
- package/dist/contexts/enviveCssContext/index.cjs +19 -15
- package/dist/contexts/enviveCssContext/index.d.cts +5 -3
- package/dist/contexts/enviveCssContext/index.d.ts +5 -3
- package/dist/contexts/enviveCssContext/index.js +19 -15
- package/dist/contexts/featureFlagContext/index.cjs +10 -9
- package/dist/contexts/featureFlagContext/index.d.cts +12 -3
- package/dist/contexts/featureFlagContext/index.d.ts +12 -3
- package/dist/contexts/featureFlagContext/index.js +7 -6
- package/dist/contexts/featureFlagServiceContext/index.cjs +3 -4
- package/dist/contexts/featureFlagServiceContext/index.d.cts +5 -1
- package/dist/contexts/featureFlagServiceContext/index.d.ts +5 -1
- package/dist/contexts/featureFlagServiceContext/index.js +3 -4
- package/dist/contexts/graphqlContext/index.cjs +13 -8
- package/dist/contexts/graphqlContext/index.d.cts +15 -11
- package/dist/contexts/graphqlContext/index.d.ts +15 -11
- package/dist/contexts/graphqlContext/index.js +13 -8
- package/dist/contexts/localStorageContext/index.cjs +3 -3
- package/dist/contexts/localStorageContext/index.d.cts +22 -3
- package/dist/contexts/localStorageContext/index.d.ts +22 -3
- package/dist/contexts/localStorageContext/index.js +3 -4
- package/dist/contexts/newOrgConfigContext/index.cjs +17 -13
- package/dist/contexts/newOrgConfigContext/index.d.cts +16 -12
- package/dist/contexts/newOrgConfigContext/index.d.ts +16 -12
- package/dist/contexts/newOrgConfigContext/index.js +17 -13
- package/dist/contexts/searchContext/index.cjs +24 -23
- package/dist/contexts/searchContext/index.d.cts +7 -2
- package/dist/contexts/searchContext/index.d.ts +7 -2
- package/dist/contexts/searchContext/index.js +24 -23
- package/dist/contexts/sessionStorageContext/index.cjs +2 -2
- package/dist/contexts/sessionStorageContext/index.d.cts +6 -2
- package/dist/contexts/sessionStorageContext/index.d.ts +6 -2
- package/dist/contexts/sessionStorageContext/index.js +2 -2
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +12 -2
- package/dist/contexts/shopifyUrlContext/index.d.ts +12 -2
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +4 -4
- package/dist/contexts/systemSettingsContext/index.d.cts +15 -4
- package/dist/contexts/systemSettingsContext/index.d.ts +17 -6
- package/dist/contexts/systemSettingsContext/index.js +4 -4
- package/dist/contexts/types.cjs +7 -0
- package/dist/contexts/types.d.cts +5 -0
- package/dist/contexts/types.d.ts +5 -0
- package/dist/contexts/types.js +3 -0
- package/dist/contexts/userIdentityContext/index.cjs +21 -19
- package/dist/contexts/userIdentityContext/index.d.cts +2 -11
- package/dist/contexts/userIdentityContext/index.d.ts +2 -11
- package/dist/contexts/userIdentityContext/index.js +19 -17
- package/dist/custservice-types-CcPnAJ5k.d.ts +29 -0
- package/dist/custservice-types-_Dnz4sMy.d.cts +29 -0
- package/dist/domObserver-Bqf3ooj8.cjs +304 -0
- package/dist/{domObserver-LCBj1xw4.cjs → domObserver-v9ODTyfT.js} +4 -23
- package/dist/enviveConfig-DZBohDpc.js +62 -0
- package/dist/enviveConfig-Dv9-esGV.cjs +130 -0
- package/dist/enviveConfigContext-D2OELZDR.cjs +60 -0
- package/dist/enviveConfigContext-DrDjCems.js +45 -0
- package/dist/events/index.cjs +3 -2
- package/dist/events/index.d.cts +15 -2
- package/dist/events/index.d.ts +15 -2
- package/dist/events/index.js +2 -2
- package/dist/events-DYY4l817.cjs +90 -0
- package/dist/events-DyUix-Bn.js +78 -0
- package/dist/featureFlagServiceContext-B01ZkIwj.d.cts +23 -0
- package/dist/featureFlagServiceContext-CJyYItqu.cjs +62 -0
- package/dist/featureFlagServiceContext-FBM6DdMJ.js +42 -0
- package/dist/featureFlagServiceContext-jZzoym5C.d.ts +23 -0
- package/dist/featureGates-KEwAL8p_.js +26 -0
- package/dist/featureGates-qU_ulhpC.cjs +32 -0
- package/dist/frontendConfig-BIq8r6nC.d.cts +858 -0
- package/dist/frontendConfig-CixANNjw.d.ts +858 -0
- package/dist/{globalSearch-Cpc8egsM.cjs → globalSearch-Ba342VVG.cjs} +1 -1
- package/dist/globalSearch-DQCMamhv.js +1 -0
- package/dist/globalSearch-DYxPE02f.cjs +0 -0
- package/dist/{globalSearch-nmrfGLOn.js → globalSearch-eGx-9JQz.js} +1 -1
- package/dist/graphql-3PxNRFOc.js +36 -0
- package/dist/graphql-DGYfelZp.cjs +53 -0
- package/dist/graphqlConfig-GHZ1UgCw.cjs +73 -0
- package/dist/graphqlConfig-mDg6J44N.js +24 -0
- package/dist/graphqlContext-B4twVCqw.d.ts +28 -0
- package/dist/graphqlContext-BZPEAFSR.cjs +111 -0
- package/dist/graphqlContext-W6iEyEkv.d.cts +28 -0
- package/dist/graphqlContext-eaZPxgRE.js +96 -0
- package/dist/hooks/AmplitudeOperations/index.cjs +22 -23
- package/dist/hooks/AmplitudeOperations/index.d.cts +2 -2
- package/dist/hooks/AmplitudeOperations/index.d.ts +2 -2
- package/dist/hooks/AmplitudeOperations/index.js +21 -22
- package/dist/hooks/AppDetails/index.cjs +22 -20
- package/dist/hooks/AppDetails/index.d.cts +24 -3
- package/dist/hooks/AppDetails/index.d.ts +24 -3
- package/dist/hooks/AppDetails/index.js +22 -20
- package/dist/hooks/CdnOperations/index.cjs +4 -4
- package/dist/hooks/CdnOperations/index.js +4 -4
- package/dist/hooks/ChatToggle/index.cjs +25 -28
- package/dist/hooks/ChatToggle/index.d.cts +2 -2
- package/dist/hooks/ChatToggle/index.d.ts +2 -2
- package/dist/hooks/ChatToggle/index.js +22 -25
- package/dist/hooks/ChatToggleAnalytics/index.cjs +24 -25
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.js +23 -24
- package/dist/hooks/CustomerSupportHandoff/index.cjs +2 -2
- package/dist/hooks/CustomerSupportHandoff/index.d.cts +1 -1
- package/dist/hooks/CustomerSupportHandoff/index.js +2 -2
- package/dist/hooks/Debounce/index.cjs +2 -20
- package/dist/hooks/Debounce/index.d.cts +1 -1
- package/dist/hooks/Debounce/index.d.ts +1 -1
- package/dist/hooks/Debounce/index.js +2 -18
- package/dist/hooks/ElementObserver/index.cjs +6 -4
- package/dist/hooks/ElementObserver/index.d.cts +25 -4
- package/dist/hooks/ElementObserver/index.d.ts +25 -4
- package/dist/hooks/ElementObserver/index.js +6 -4
- package/dist/hooks/FloatingButtonVisibility/index.cjs +73 -0
- package/dist/hooks/FloatingButtonVisibility/index.d.cts +7 -0
- package/dist/hooks/FloatingButtonVisibility/index.d.ts +7 -0
- package/dist/hooks/FloatingButtonVisibility/index.js +69 -0
- package/dist/hooks/GrabAndScroll/index.cjs +1 -1
- package/dist/hooks/GrabAndScroll/index.d.ts +2 -2
- package/dist/hooks/GrabAndScroll/index.js +1 -1
- package/dist/hooks/GraphQLConfig/index.cjs +14 -9
- package/dist/hooks/GraphQLConfig/index.d.cts +14 -2
- package/dist/hooks/GraphQLConfig/index.d.ts +14 -2
- package/dist/hooks/GraphQLConfig/index.js +14 -9
- package/dist/hooks/IdentifyUser/index.cjs +21 -19
- package/dist/hooks/IdentifyUser/index.js +20 -18
- package/dist/hooks/ImageResolver/index.cjs +29 -20
- package/dist/hooks/ImageResolver/index.d.ts +1 -1
- package/dist/hooks/ImageResolver/index.js +29 -20
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/LastInteraction/index.cjs +34 -0
- package/dist/hooks/LastInteraction/index.d.cts +7 -0
- package/dist/hooks/LastInteraction/index.d.ts +7 -0
- package/dist/hooks/LastInteraction/index.js +32 -0
- package/dist/hooks/LocalStorageOperations/index.cjs +7 -8
- package/dist/hooks/LocalStorageOperations/index.js +3 -4
- package/dist/hooks/MessageFilter/index.cjs +12 -3
- package/dist/hooks/MessageFilter/index.d.cts +18 -2
- package/dist/hooks/MessageFilter/index.d.ts +18 -2
- package/dist/hooks/MessageFilter/index.js +11 -2
- package/dist/hooks/NewOrgConfig/index.cjs +18 -14
- package/dist/hooks/NewOrgConfig/index.d.cts +17 -3
- package/dist/hooks/NewOrgConfig/index.d.ts +17 -3
- package/dist/hooks/NewOrgConfig/index.js +18 -14
- package/dist/hooks/Search/index.cjs +173 -314
- package/dist/hooks/Search/index.d.cts +58 -3
- package/dist/hooks/Search/index.d.ts +58 -3
- package/dist/hooks/Search/index.js +162 -302
- package/dist/hooks/SearchOperations/index.cjs +25 -24
- package/dist/hooks/SearchOperations/index.d.cts +3 -2
- package/dist/hooks/SearchOperations/index.d.ts +3 -2
- package/dist/hooks/SearchOperations/index.js +25 -24
- package/dist/hooks/SessionStorageOperations/index.cjs +2 -2
- package/dist/hooks/SessionStorageOperations/index.js +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.cjs +3 -3
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +5 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +5 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +3 -3
- package/dist/hooks/SnapCalculator/index.cjs +1 -1
- package/dist/hooks/SnapCalculator/index.d.cts +3 -4
- package/dist/hooks/SnapCalculator/index.d.ts +3 -4
- package/dist/hooks/SnapCalculator/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +6 -17
- package/dist/hooks/SystemSettingsContext/index.d.cts +16 -5
- package/dist/hooks/SystemSettingsContext/index.d.ts +15 -4
- package/dist/hooks/SystemSettingsContext/index.js +6 -15
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +21 -23
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +3 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +3 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.js +21 -23
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +24 -26
- package/dist/hooks/UpdateAnalyticsProps/index.js +20 -22
- package/dist/hooks/utils.cjs +1 -1
- package/dist/hooks/utils.d.cts +14 -20
- package/dist/hooks/utils.d.ts +14 -20
- package/dist/hooks/utils.js +1 -1
- package/dist/index-9oqgeOVC.d.cts +186 -0
- package/dist/index-A0HvA68Y.d.cts +1 -0
- package/dist/index-BC93l5Th.d.ts +1 -0
- package/dist/index-BEzmil_W.d.ts +44 -0
- package/dist/{index-DtzPIcQp.d.ts → index-BdjH4aRG.d.ts} +1 -1
- package/dist/{index-CsmO1rDH.d.ts → index-BfM7zKRO.d.ts} +1 -1
- package/dist/index-Bmub8e38.d.cts +98 -0
- package/dist/{index-mv7KvWDq.d.ts → index-CA1Eo7DA.d.ts} +1 -1
- package/dist/index-CCa4tZuO.d.ts +184 -0
- package/dist/{index-ChiZg0yw.d.cts → index-CCboEuTO.d.cts} +1 -1
- package/dist/index-CESxqFso.d.cts +228 -0
- package/dist/{index-BbqT4BQv.d.cts → index-COXkY78t.d.cts} +1 -1
- package/dist/index-CboygwjO.d.ts +676 -0
- package/dist/index-CiWEYzXl.d.cts +184 -0
- package/dist/{index-jFQefHda.d.ts → index-Cw9oYJnq.d.ts} +1 -1
- package/dist/index-D5lw0cMx.d.ts +186 -0
- package/dist/{index-CAJq_8bO.d.cts → index-DZtnHhlr.d.cts} +1 -1
- package/dist/index-Dfwnna1j.d.ts +228 -0
- package/dist/index-Dt_C-I-2.d.cts +676 -0
- package/dist/index-OkKEOL6H.d.cts +44 -0
- package/dist/index-bjMvkcBF.d.ts +98 -0
- package/dist/{index-npqPeJ1g.d.cts → index-hAqp0oYb.d.cts} +1 -1
- package/dist/interceptors/index.cjs +3 -28
- package/dist/interceptors/index.d.cts +16 -4
- package/dist/interceptors/index.d.ts +16 -4
- package/dist/interceptors/index.js +3 -25
- package/dist/interceptors/types.cjs +1 -0
- package/dist/interceptors/types.d.cts +14 -0
- package/dist/interceptors/types.d.ts +14 -0
- package/dist/interceptors/types.js +3 -0
- package/dist/localStorageContext-BPZ82q-G.js +95 -0
- package/dist/localStorageContext-NRP-CdmF.cjs +115 -0
- package/dist/{logger-BqHq67zN.cjs → logger-TBIl4uIH.cjs} +1 -1
- package/dist/{logger-BMVdhQOV.js → logger-W3lqg-4b.js} +1 -1
- package/dist/models-D-4db7XW.cjs +1537 -0
- package/dist/models-c86hYW-F.js +1296 -0
- package/dist/{newOrgConfigAtom-CDttTiuu.cjs → newOrgConfigAtom-D6R-7HCk.cjs} +1 -1
- package/dist/newOrgConfigAtom-bn1lnljf.js +8 -0
- package/dist/newOrgConfigContext-BC79qoiV.d.ts +16 -0
- package/dist/newOrgConfigContext-BqZwD8-B.cjs +68 -0
- package/dist/newOrgConfigContext-DbcDClwd.js +53 -0
- package/dist/newOrgConfigContext-eS4ZLo58.d.cts +16 -0
- package/dist/nodeSelector-DybpVr-i.d.ts +31 -0
- package/dist/nodeSelector-vKB44CDB.d.cts +31 -0
- package/dist/org-CIhjzxWr.cjs +43 -0
- package/dist/org-CeWXnpwF.js +12 -0
- package/dist/search-6RrxBXD6.d.cts +20 -0
- package/dist/search-BBu5YeQa.js +126 -0
- package/dist/search-D23INSNg.cjs +205 -0
- package/dist/search-filter-types-BItKtezf.d.cts +102 -0
- package/dist/search-filter-types-fZf91Pdw.d.ts +102 -0
- package/dist/search-nuWWnRRV.d.ts +20 -0
- package/dist/searchContext-BPT44uk-.js +129 -0
- package/dist/searchContext-CwRRiXQ3.cjs +145 -0
- package/dist/searchServiceAdapter-DEv1tTn0.cjs +34 -0
- package/dist/searchServiceAdapter-WyCU55NV.js +16 -0
- package/dist/sessionStorageContext-1Ks_d4Z0.cjs +66 -0
- package/dist/sessionStorageContext-CDcl7NVl.js +52 -0
- package/dist/shopifyUrlContext-CejRZfj7.js +61 -0
- package/dist/shopifyUrlContext-lnHoAOEf.cjs +75 -0
- package/dist/spiffyWidgets-CdxRcXhW.d.ts +20 -0
- package/dist/spiffyWidgets-eNbU1gMc.d.cts +20 -0
- package/dist/systemSettingsContext-Ba-wi2NZ.cjs +60 -0
- package/dist/systemSettingsContext-DumUaV0m.js +39 -0
- package/dist/test-types-B3YQpECG.d.cts +13 -0
- package/dist/test-types-C8NHqaUS.d.ts +13 -0
- package/dist/types/index.cjs +48 -3
- package/dist/types/index.d.cts +18 -2
- package/dist/types/index.d.ts +18 -2
- package/dist/types/index.js +44 -2
- package/dist/types-BGqrvAsw.d.ts +10 -0
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CS0Hrzja.js +30 -0
- package/dist/types-CtUb63bt.js +76 -0
- package/dist/types-CxObxLKs.cjs +48 -0
- package/dist/types-DIiH_5gL.d.cts +10 -0
- package/dist/types-Dc6hx6ei.js +1 -0
- package/dist/types-UUvB6h05.cjs +106 -0
- package/dist/types-aQTzSrH1.d.cts +51 -0
- package/dist/types-kAjmR2du.d.ts +51 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +16 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +1 -0
- package/dist/urlsParser-COzMdJaX.cjs +78 -0
- package/dist/urlsParser-DxjoLj98.js +42 -0
- package/dist/useAmplitudeOperations-Cv0fi3uj.cjs +41 -0
- package/dist/useAmplitudeOperations-Ti6phPPq.js +34 -0
- package/dist/useAppDetails-CsXHPAh1.cjs +38 -0
- package/dist/useAppDetails-PUfYwCjK.js +30 -0
- package/dist/useDebounce-DZ8Cgiwc.cjs +26 -0
- package/dist/useDebounce-v9cezyjn.js +19 -0
- package/dist/useGraphQLConfig-BizpCw23.cjs +76 -0
- package/dist/useGraphQLConfig-DFWl9Z89.js +63 -0
- package/dist/{useIntersection-BkMkuJcZ.js → useIntersection-Cncgxdmy.js} +1 -1
- package/dist/{useIntersection-BcBCa890.cjs → useIntersection-m4PEpvG7.cjs} +1 -1
- package/dist/useMessageInterceptor-BjGP_uXm.js +25 -0
- package/dist/useMessageInterceptor-arAqUq1Q.cjs +33 -0
- package/dist/userIdentityContext-W1OWF3cG.d.ts +20 -0
- package/dist/userIdentityContext-kU1PIo8K.d.cts +20 -0
- package/dist/utilityTypes-B2KuRn37.js +1 -0
- package/dist/utilityTypes-BGbL2WTP.cjs +0 -0
- package/dist/{utils-Buo4KU5l.cjs → utils-2SWrJ12w.cjs} +1 -1
- package/dist/utils-BewguHW0.d.cts +22 -0
- package/dist/{utils-CiJLDPjY.cjs → utils-CDw74BCO.cjs} +1 -1
- package/dist/utils-CLGXsOwE.cjs +1591 -0
- package/dist/{utils-BRNaQkCK.js → utils-CqBxIpEV.js} +1 -1
- package/dist/{utils-B1LVzQYK.js → utils-DIvMgPe8.js} +1 -1
- package/dist/utils-D_kATUj6.js +92 -0
- package/dist/{utils-BitIIghf.d.ts → utils-DpneNSJf.d.ts} +1 -1
- package/dist/utils-hKYwSBo9.d.ts +22 -0
- package/dist/utils-hYTjy7hJ.cjs +130 -0
- package/dist/utils-jYtD3hmA.js +1385 -0
- package/dist/variantInfo-BfKlkaWU.js +11 -0
- package/dist/variantInfo-DpLn4nHz.cjs +17 -0
- package/package.json +36 -9
- package/src/application/commerce-api.ts +37 -40
- package/src/application/models/api/context.ts +4 -0
- package/src/application/models/api/generationParams.ts +4 -0
- package/src/application/models/api/nextMessageRequest.ts +11 -0
- package/src/application/models/api/orgAnalyticsConfig.ts +19 -0
- package/src/application/models/api/orgConfigResults.ts +44 -0
- package/src/application/models/api/organizationConfig.ts +12 -0
- package/src/{types/ApiResponse.ts → application/models/api/response.ts} +29 -35
- package/src/application/models/api/responseGenerics.ts +67 -0
- package/src/application/models/api/search.ts +26 -0
- package/src/application/models/api/suggestion.ts +4 -0
- package/src/application/models/api/supportedEventRequest.ts +8 -0
- package/src/application/models/api/userEvent.ts +101 -0
- package/src/application/models/cachedValue.ts +8 -0
- package/src/application/models/chatElementDisplayLocation.ts +22 -0
- package/src/application/models/clientDetails.ts +18 -0
- package/src/application/models/colorsConfig.ts +28 -0
- package/src/application/models/conversationalSearchIds.ts +5 -0
- package/src/application/models/dataLayer.ts +45 -0
- package/src/application/models/events.ts +5 -0
- package/src/application/models/featureGates.ts +21 -0
- package/src/application/models/frontendConfig.ts +14 -0
- package/src/application/models/googleAnalyticsEvents.ts +8 -0
- package/src/application/models/graphql/index.ts +0 -1
- package/src/application/models/graphql/queries/getMerchantColorsQuery.ts +23 -1
- package/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.ts +89 -1
- package/src/application/models/guards/api/isApiFormResponse.ts +4 -4
- package/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.ts +2 -2
- package/src/application/models/guards/api/isApiOrderResponseAttributes.ts +20 -2
- package/src/application/models/guards/api/isApiOrgConfigResults.ts +9 -3
- package/src/application/models/guards/api/isApiOrganizationConfig.ts +32 -8
- package/src/application/models/guards/api/isApiPDPEventAttributes.ts +5 -8
- package/src/application/models/guards/api/isApiPLPEventAttributes.ts +10 -14
- package/src/application/models/guards/api/isApiPageResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiProductResponseAttributes.ts +4 -2
- package/src/application/models/guards/api/isApiProductSearchAttributes.ts +6 -9
- package/src/application/models/guards/api/isApiProductSearchFilterAttributes.ts +4 -7
- package/src/application/models/guards/api/isApiQueryTypedEventAttributes.ts +3 -8
- package/src/application/models/guards/api/isApiResponse.ts +15 -22
- package/src/application/models/guards/api/isApiReviewResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiReviewRichInformation.ts +1 -1
- package/src/application/models/guards/api/isApiTextResponseAttributes.ts +1 -1
- package/src/application/models/guards/graphQL/isGraphQLColorsConfig.ts +1 -1
- package/src/application/models/guards/isBaseEcommerceEvent.ts +2 -1
- package/src/application/models/guards/isGA4EcommerceEvent.ts +1 -1
- package/src/application/models/guards/isLegacyUAEcommerceEvent.ts +1 -1
- package/src/application/models/guards/isMobilePLPChatPlacementParameter.ts +3 -1
- package/src/application/models/guards/isSpanxTakeAQuizCtaParameter.ts +3 -5
- package/src/application/models/guards/isVariantInfo.ts +1 -6
- package/src/application/models/index.ts +95 -30
- package/src/application/models/localStorageEventListener.ts +4 -0
- package/src/{types/Message.ts → application/models/message.ts} +34 -38
- package/src/application/models/mobilePLPChatPlacementParameter.ts +3 -0
- package/src/application/models/orgsEnum.ts +36 -0
- package/src/application/models/productExperiment.ts +5 -0
- package/src/application/models/spanxTakeAQuizCtaParameter.ts +4 -0
- package/src/application/models/spiffyWidgets.ts +16 -0
- package/src/application/models/utilityTypes/camelCase.ts +87 -0
- package/src/application/models/utilityTypes/camelCasedPropertiesDeep.ts +80 -0
- package/src/application/models/utilityTypes/delimiterCase.ts +121 -0
- package/src/application/models/utilityTypes/delimiterCasedPropertiesDeep.ts +98 -0
- package/src/application/models/utilityTypes/index.ts +1 -0
- package/src/application/models/utilityTypes/internal.ts +93 -0
- package/src/application/models/utilityTypes/primitive.ts +8 -0
- package/src/application/models/utilityTypes/snakeCasedPropertiesDeep.ts +49 -0
- package/src/application/models/utilityTypes/splitWords.ts +76 -0
- package/src/application/models/utilityTypes/trim.ts +28 -0
- package/src/application/models/utilityTypes/unknownArray.ts +25 -0
- package/src/application/models/utils/snakeToCamelTransformer.ts +8 -8
- package/src/application/models/validators/validateGraphQLColorsConfig.ts +2 -6
- package/src/application/models/validators/validateGraphQLFrontendConfig.ts +6 -6
- package/src/application/models/validators/validateMobilePLPChatPlacementParameter.ts +3 -5
- package/src/application/models/validators/validateOrgConfigResults.ts +5 -6
- package/src/application/models/validators/validateOrganizationConfig.ts +8 -11
- package/src/application/models/validators/validateResponse.ts +44 -66
- package/src/application/models/validators/validateSuggestion.ts +1 -1
- package/src/application/models/validators/validateUserEvent.ts +12 -23
- package/src/application/models/variantInfo/index.ts +1 -0
- package/src/application/models/variantInfo/pageVisitInfo.ts +6 -0
- package/src/application/models/variantInfo/plpInfo.ts +3 -0
- package/src/application/models/variantInfo/productInfo.ts +5 -0
- package/src/application/models/variantInfo/variantInfo.ts +29 -0
- package/src/application/utils/__tests__/divideArrays.test.ts +14 -0
- package/src/application/utils/analyticsUtils.ts +8 -1
- package/src/application/utils/cdnUtils.ts +11 -0
- package/src/application/utils/coreContextToApiContext.ts +1 -3
- package/src/application/utils/coreUserEventToApiUserEvent.ts +2 -2
- package/src/application/utils/elementObserver.ts +1 -1
- package/src/application/utils/imageFilter.ts +2 -5
- package/src/application/utils/index.ts +21 -20
- package/src/application/utils/messageFromFormSubmittedEvent.ts +1 -1
- package/src/application/utils/messageFromQueryEvent.ts +1 -1
- package/src/application/utils/messageFromResponse.ts +10 -14
- package/src/application/utils/messageFromSuggestionEvent.ts +4 -6
- package/src/application/utils/mouseEventTypes.ts +1 -1
- package/src/application/utils/nextMessageRequestToApiRequest.ts +1 -1
- package/src/application/utils/overrides.ts +49 -1
- package/src/application/utils/supportedEventRequestToApiRequest.ts +1 -3
- package/src/application/utils/urlsParser.ts +7 -1
- package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -1
- package/src/atoms/app/index.ts +25 -15
- package/src/atoms/app/variant.ts +1 -1
- package/src/atoms/chat/chatState.ts +4 -4
- package/src/atoms/chat/form.ts +1 -1
- package/src/atoms/chat/messageQueue.ts +50 -25
- package/src/atoms/chat/replies.ts +2 -1
- package/src/atoms/chat/suggestions.ts +29 -34
- package/src/atoms/envive/enviveConfig.ts +20 -14
- package/src/atoms/org/customerService.ts +8 -4
- package/src/atoms/org/graphqlConfig.ts +15 -7
- package/src/atoms/org/index.ts +6 -4
- package/src/atoms/org/newOrgConfigAtom.ts +2 -2
- package/src/atoms/org/orgAnalyticsConfig.ts +1 -1
- package/src/atoms/search/chatSearch.ts +317 -0
- package/src/atoms/search/index.ts +1 -0
- package/src/atoms/search/productFilters.ts +52 -72
- package/src/atoms/search/productSorter.ts +2 -2
- package/src/atoms/search/searchAPI.ts +60 -42
- package/src/atoms/search/searchServiceAdapter.ts +1 -1
- package/src/atoms/search/types.ts +55 -0
- package/src/config/divIds.ts +27 -0
- package/src/config/socialProofClasses.ts +17 -0
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +57 -16
- package/src/contexts/cdnContext/cdnContext.tsx +6 -1
- package/src/contexts/chatContext/chatContext.tsx +509 -0
- package/src/contexts/chatContext/index.ts +1 -0
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +26 -12
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +12 -5
- package/src/contexts/featureFlagContext/featureFlagContext.tsx +48 -27
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +3 -11
- package/src/contexts/graphqlContext/graphqlContext.tsx +95 -40
- package/src/contexts/localStorageContext/localStorageContext.tsx +60 -26
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +22 -10
- package/src/contexts/searchContext/searchContext.tsx +49 -29
- package/src/contexts/sessionStorageContext/sessionStorageContext.tsx +33 -12
- package/src/contexts/shopifyUrlContext/shopifyUrlContext.tsx +37 -20
- package/src/contexts/systemSettingsContext/systemSettingsContext.tsx +21 -8
- package/src/contexts/types.ts +1067 -0
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +77 -33
- package/src/events/event-types.ts +11 -0
- package/src/events/index.ts +5 -8
- package/src/events/registerAnalyticsListeners.ts +13 -10
- package/src/hooks/AmplitudeOperations/useAmplitudeOperations.ts +11 -6
- package/src/hooks/AppDetails/useAppDetails.ts +24 -10
- package/src/hooks/ChatToggle/useChatToggle.ts +19 -7
- package/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.ts +4 -4
- package/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.ts +1 -1
- package/src/hooks/ElementObserver/useElementObserver.ts +32 -14
- package/src/hooks/FloatingButtonVisibility/index.ts +1 -0
- package/src/hooks/FloatingButtonVisibility/useFloatingButtonVisibility.ts +99 -0
- package/src/hooks/GrabAndScroll/useGrabAndScroll.ts +124 -125
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +7 -5
- package/src/hooks/ImageResolver/useImageResolver.ts +31 -24
- package/src/hooks/LastInteraction/index.ts +1 -0
- package/src/hooks/LastInteraction/useLastInteraction.ts +42 -0
- package/src/hooks/LocalStorageOperations/useLocalStorageOperations.ts +19 -12
- package/src/hooks/MessageFilter/useMessageFilter.ts +7 -1
- package/src/hooks/Search/useSearch.tsx +217 -87
- package/src/hooks/SearchOperations/useSearchOperations.ts +12 -8
- package/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.ts +14 -8
- package/src/hooks/SnapCalculator/useSnapCalculator.ts +2 -1
- package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +11 -8
- package/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.ts +25 -11
- package/src/hooks/utils.ts +29 -19
- package/src/interceptors/index.ts +2 -1
- package/src/interceptors/types.ts +6 -0
- package/src/interceptors/useMessageInterceptor.ts +6 -10
- package/src/merchants/domInsertion.ts +30 -0
- package/src/merchants/gridInsertion.ts +19 -0
- package/src/types/config-versions.ts +6 -0
- package/src/types/customerService.ts +31 -0
- package/src/types/custservice-types.ts +28 -0
- package/src/{exceptions → types/exceptions}/unsupportedProductExceptions.ts +2 -2
- package/src/types/floatingbuttonoverrides-types.ts +10 -0
- package/src/types/index.ts +5 -4
- package/src/types/search-filter-types.ts +111 -0
- package/src/types/suggestionBarV2-types.ts +4 -0
- package/src/types/test-types.ts +3 -0
- package/src/types.ts +11 -0
- package/dist/AmplitudeOperations-CXU93q_4.js +0 -34
- package/dist/AmplitudeOperations-_uIb5QED.cjs +0 -41
- package/dist/TrackComponentVisibleEvent-D-hN3owz.cjs +0 -60
- package/dist/TrackComponentVisibleEvent-D-pvNVOP.js +0 -53
- package/dist/amplitudeContext-DFXeRauX.js +0 -233
- package/dist/amplitudeContext-DrFGH7Q7.cjs +0 -249
- package/dist/amplitudeTrackEventAtom-D66l5oFp.js +0 -8
- package/dist/amplitudeTrackEventAtom-f22P2U0u.cjs +0 -15
- package/dist/api-D4HaU2Gf.js +0 -166
- package/dist/api-D4Xoibs9.cjs +0 -239
- package/dist/app-BT3g-mDp.js +0 -515
- package/dist/app-DxwdFQlv.cjs +0 -570
- package/dist/cdnContext-D-qi0lub.js +0 -38
- package/dist/cdnContext-DIVgBnsl.cjs +0 -53
- package/dist/chat-ZaY3KY-R.js +0 -226
- package/dist/chat-rhEjVfrd.cjs +0 -326
- package/dist/chatState-BbI93m6r.js +0 -33
- package/dist/chatState-DlJpHAsW.cjs +0 -119
- package/dist/dist-C38adNK1.js +0 -5923
- package/dist/dist-VxRI6eQv.cjs +0 -6019
- package/dist/domObserver-CVhsCSkS.js +0 -285
- package/dist/enviveConfig-CQ_8mT-g.cjs +0 -130
- package/dist/enviveConfig-Cwlp7-Qz.js +0 -62
- package/dist/enviveConfigContext-CIavPzcm.js +0 -47
- package/dist/enviveConfigContext-DHEs077z.cjs +0 -62
- package/dist/events-CgFGtanE.cjs +0 -69
- package/dist/events-WOOrnUAx.js +0 -63
- package/dist/exceptions/index.cjs +0 -4
- package/dist/exceptions/index.d.cts +0 -12
- package/dist/exceptions/index.d.ts +0 -12
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions-BjDgLzGi.cjs +0 -32
- package/dist/exceptions-CUGY31Ua.js +0 -20
- package/dist/featureFlagServiceContext-ClnlCJV5.d.cts +0 -24
- package/dist/featureFlagServiceContext-CyPGEe2d.d.ts +0 -24
- package/dist/featureFlagServiceContext-Dr8Cw23n.js +0 -46
- package/dist/featureFlagServiceContext-rxZhpdEj.cjs +0 -66
- package/dist/graphql-CvAHWmel.js +0 -46
- package/dist/graphql-JaGqsToc.cjs +0 -70
- package/dist/graphqlContext-B8wuRZcp.cjs +0 -111
- package/dist/graphqlContext-CpHMbKoX.js +0 -96
- package/dist/index-5li6ZMDu.d.ts +0 -11
- package/dist/index-BVZbvpx_.d.cts +0 -11
- package/dist/index-CMZcE7pk.d.cts +0 -224
- package/dist/index-CuihhoIF.d.ts +0 -42
- package/dist/index-bEjLKG_Q.d.ts +0 -224
- package/dist/index-qOBU4GEh.d.cts +0 -42
- package/dist/localStorageContext-BFwvuEcf.js +0 -90
- package/dist/localStorageContext-CWc5xJ6U.cjs +0 -104
- package/dist/models-Cw0QcbQv.js +0 -1118
- package/dist/models-Dl0_Ujgj.cjs +0 -1305
- package/dist/newOrgConfigAtom-C8h3w_Ji.js +0 -8
- package/dist/newOrgConfigContext-BdzDnzUM.js +0 -53
- package/dist/newOrgConfigContext-cWeJAT6E.cjs +0 -68
- package/dist/nodeSelector-BAKg1h_y.d.ts +0 -28
- package/dist/nodeSelector-BYEAyrsj.d.cts +0 -28
- package/dist/org-BNs_maoW.cjs +0 -111
- package/dist/org-CScQqL4k.js +0 -32
- package/dist/search-CsXXamht.js +0 -233
- package/dist/search-DHhDpeQU.cjs +0 -312
- package/dist/searchContext-B5ZNLtvd.js +0 -129
- package/dist/searchContext-SFvF_Y8J.cjs +0 -145
- package/dist/searchServiceAdapter-BkvDIhV8.js +0 -16
- package/dist/searchServiceAdapter-C4zzBUl0.cjs +0 -34
- package/dist/sessionStorageContext-BuWrJQwc.cjs +0 -66
- package/dist/sessionStorageContext-DvFHbk81.js +0 -52
- package/dist/shopifyUrlContext-COc1eDR_.cjs +0 -75
- package/dist/shopifyUrlContext-CToAt_98.js +0 -61
- package/dist/systemSettingsContext-D9iNGz5v.js +0 -39
- package/dist/systemSettingsContext-DdV7Yte8.cjs +0 -60
- package/dist/types-1iJ_FnQQ.cjs +0 -39
- package/dist/types-D5du68Vp.js +0 -27
- package/dist/urlsParser-Dax4iVNC.cjs +0 -78
- package/dist/urlsParser-NAp2LwWP.js +0 -42
- package/dist/useAppDetails-D3T6kJY_.cjs +0 -38
- package/dist/useAppDetails-xPVs6fW7.js +0 -30
- package/dist/useGraphQLConfig-B1DaVvFx.cjs +0 -76
- package/dist/useGraphQLConfig-BtPxjtxw.js +0 -63
- package/dist/utils-BZT_oZ3n.js +0 -92
- package/dist/utils-D3MjNkd3.cjs +0 -716
- package/dist/utils-DMwh3QbT.js +0 -607
- package/dist/utils-qtHPLFby.cjs +0 -130
- package/src/atoms/search/productRetrievalAPI.ts +0 -72
- package/src/atoms/search/productRetrievalAdapter.ts +0 -28
- package/src/exceptions/index.ts +0 -2
- package/src/global.d.ts +0 -8
- package/src/hooks/Search/useRecommendedProducts.ts +0 -50
- package/src/hooks/Search/useSearchInput.ts +0 -237
- package/src/types/FilterAttribute.ts +0 -35
- package/src/types/Suggestion.ts +0 -6
- package/src/util/colorVar.ts +0 -4
- package/src/util/configVersion.ts +0 -4
- package/src/util/domInsertion.ts +0 -17
- /package/dist/{featureFlagServiceContext-Csgo-MUv.cjs → AmplitudeOperations-DxQnurSG.cjs} +0 -0
- /package/dist/{featureFlagServiceContext-CISyb90N.js → AmplitudeOperations-ni7wVevx.js} +0 -0
- /package/src/{exceptions → types/exceptions}/sessionExceptions.ts +0 -0
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
|
-
import {
|
|
4
|
-
SearchResultsHocProps,
|
|
5
|
-
ProductSorting,
|
|
6
|
-
SearchFilterDatum,
|
|
7
|
-
SpiffyMetricsEventName,
|
|
8
|
-
SelectedFilterOption,
|
|
9
|
-
SelectFilterItem,
|
|
10
|
-
SpiffyWidgets,
|
|
11
|
-
} from "@envive-ai/types";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useDebounce } from "src/hooks/Debounce/useDebounce";
|
|
12
4
|
import {
|
|
13
5
|
addSearchFilterAtom,
|
|
14
6
|
clearSearchFiltersAtom,
|
|
@@ -21,26 +13,90 @@ import {
|
|
|
21
13
|
searchParamsAtom,
|
|
22
14
|
searchProductSortingAtom,
|
|
23
15
|
searchSelectedFiltersAtom,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import {
|
|
16
|
+
SelectedFilterOption,
|
|
17
|
+
} from "src/atoms/search";
|
|
18
|
+
import {
|
|
19
|
+
autocompleteStateAtom,
|
|
20
|
+
isFilterOpenAtom,
|
|
21
|
+
} from "src/atoms/globalSearch/globalSearch";
|
|
22
|
+
import { formatFilterDisplayName } from "src/atoms/search/utils";
|
|
23
|
+
import { ProductSorting } from "src/atoms/search/types";
|
|
24
|
+
import {
|
|
25
|
+
SpiffyMetricsEventName,
|
|
26
|
+
useAmplitude,
|
|
27
|
+
} from "src/contexts/amplitudeContext/amplitudeContext";
|
|
28
|
+
import { SpiffyWidgets } from "src/application/models/spiffyWidgets";
|
|
29
|
+
import { ProductCardConfig } from "src/contexts/types";
|
|
30
|
+
import Logger from "src/application/logging/logger";
|
|
31
|
+
import { SearchResult } from "src/application/models/api/search";
|
|
32
|
+
import { SearchResponseProduct } from "@spiffy-ai/commerce-api-client";
|
|
33
|
+
import {
|
|
34
|
+
SearchFilterDatum,
|
|
35
|
+
SelectFilterItem,
|
|
36
|
+
} from "src/types/search-filter-types";
|
|
37
|
+
import { getSearchResultsState, SearchResultsState } from "../utils";
|
|
38
|
+
import { orgShortNameAtom } from "src/atoms/envive/enviveConfig";
|
|
39
|
+
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
31
40
|
import { useTrackComponentVisibleEvent } from "../TrackComponentVisibleEvent";
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
|
|
42
|
+
export interface SearchResultsHocProps {
|
|
43
|
+
// Data
|
|
44
|
+
searchData: SearchResult | null;
|
|
45
|
+
searchResponseId: string;
|
|
46
|
+
merchantShortName: string;
|
|
47
|
+
productCardConfig: ProductCardConfig;
|
|
48
|
+
productList: SearchResponseProduct[];
|
|
49
|
+
autocompleteResults: string[];
|
|
50
|
+
searchFilters: SearchFilterDatum[];
|
|
51
|
+
availableDynamicFilters: { name: string; displayName: string }[];
|
|
52
|
+
selectedFilterOptions: SelectedFilterOption[];
|
|
53
|
+
|
|
54
|
+
// State
|
|
55
|
+
searchText: string;
|
|
56
|
+
searchResultsState: SearchResultsState;
|
|
57
|
+
isLoadingAutocomplete: boolean;
|
|
58
|
+
isLoadingSearch: boolean;
|
|
59
|
+
isFilterOpen: boolean;
|
|
60
|
+
isDirty: boolean;
|
|
61
|
+
focusedIndex: number;
|
|
62
|
+
focusedOptionId: string | undefined;
|
|
63
|
+
|
|
64
|
+
// UI
|
|
65
|
+
filterButtonText: string;
|
|
66
|
+
|
|
67
|
+
// Event Handlers
|
|
68
|
+
onSearchInputChange: (value: string) => void;
|
|
69
|
+
onSubmitSearch: () => void;
|
|
70
|
+
onAutocompleteSelect: (suggestion: string) => void;
|
|
71
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
72
|
+
onToggleDynamicFilter: ({
|
|
73
|
+
filter,
|
|
74
|
+
dynamicFilterDisplayName,
|
|
75
|
+
}: {
|
|
76
|
+
filter: string;
|
|
77
|
+
dynamicFilterDisplayName: string;
|
|
78
|
+
}) => void;
|
|
79
|
+
onSelectFilterItem: SelectFilterItem;
|
|
80
|
+
onRemoveFilter: (filter: SelectedFilterOption) => void;
|
|
81
|
+
onClearAllFilters: () => void;
|
|
82
|
+
setIsFilterOpen: (isFilterOpen: boolean) => void;
|
|
83
|
+
|
|
84
|
+
// Refs
|
|
85
|
+
searchResultsRef: React.RefObject<HTMLDivElement>;
|
|
86
|
+
}
|
|
34
87
|
|
|
35
88
|
export const useSearch = (): SearchResultsHocProps => {
|
|
36
89
|
// Atoms
|
|
37
|
-
const
|
|
38
|
-
const config = useAtomValue(newOrgConfigAtom);
|
|
90
|
+
const config = useNewOrgConfig();
|
|
39
91
|
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
40
92
|
const { data: searchData, loading: isLoadingSearch } =
|
|
41
93
|
useAtomValue(searchAtom);
|
|
42
94
|
const productList = useAtomValue(filteredSearchProductsAtom);
|
|
43
95
|
const performSearch = useSetAtom(performSearchAtom);
|
|
96
|
+
const [
|
|
97
|
+
{ results: autocompleteResults, isLoading: isLoadingAutocomplete },
|
|
98
|
+
setAutocompleteState,
|
|
99
|
+
] = useAtom(autocompleteStateAtom);
|
|
44
100
|
const [{ query }] = useAtom(searchParamsAtom);
|
|
45
101
|
const [isFilterOpen, setIsFilterOpen] = useAtom(isFilterOpenAtom);
|
|
46
102
|
const [selectedFilterOptions] = useAtom(searchSelectedFiltersAtom);
|
|
@@ -49,49 +105,25 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
49
105
|
const [productSorting, setProductSorting] = useAtom(searchProductSortingAtom);
|
|
50
106
|
const clearFilters = useSetAtom(clearSearchFiltersAtom);
|
|
51
107
|
const searchFilters = useAtomValue(searchFiltersAtom);
|
|
52
|
-
|
|
108
|
+
|
|
109
|
+
// State
|
|
110
|
+
const [isDirty, setIsDirty] = useState(true);
|
|
111
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
112
|
+
const [focusedOptionId, setFocusedOptionId] = useState<string | undefined>(
|
|
113
|
+
undefined
|
|
114
|
+
);
|
|
115
|
+
const [searchText, setSearchText] = useState(query || "");
|
|
53
116
|
|
|
54
117
|
// Refs
|
|
55
118
|
const searchResultsRef = useRef<HTMLDivElement>(null);
|
|
56
119
|
|
|
57
|
-
//
|
|
58
|
-
const
|
|
59
|
-
const container = searchResultsRef.current;
|
|
60
|
-
if (container) {
|
|
61
|
-
container.scrollTo({ top: 0, behavior: "smooth" });
|
|
62
|
-
} else {
|
|
63
|
-
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
64
|
-
}
|
|
65
|
-
}, []);
|
|
66
|
-
|
|
67
|
-
// Search Input Hook
|
|
68
|
-
const searchInput = useSearchInput({
|
|
69
|
-
initialSearchText: query || "",
|
|
70
|
-
searchOrigin: SpiffyWidgets.SearchResults,
|
|
71
|
-
onSearchSubmit: (searchQuery) => {
|
|
72
|
-
performSearch({ query: searchQuery });
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const {
|
|
77
|
-
searchText,
|
|
78
|
-
focusedIndex,
|
|
79
|
-
focusedOptionId,
|
|
80
|
-
autocompleteResults,
|
|
81
|
-
shouldShowAutocomplete,
|
|
82
|
-
handleSearchInputChange,
|
|
83
|
-
handleSearchInputFocus,
|
|
84
|
-
handleSearchInputBlur,
|
|
85
|
-
handleKeyDown,
|
|
86
|
-
handleAutocompleteSelect,
|
|
87
|
-
handleSubmitSearch,
|
|
88
|
-
setSearchText,
|
|
89
|
-
} = searchInput;
|
|
120
|
+
// Derived State
|
|
121
|
+
const debouncedSearchText = useDebounce(searchText, 200);
|
|
90
122
|
const searchResultsState = getSearchResultsState(isLoadingSearch, searchData);
|
|
91
123
|
|
|
92
124
|
const dynamicFilters = searchData?.filters || [];
|
|
93
125
|
|
|
94
|
-
// Provide fallback values when
|
|
126
|
+
// Provide fallback values when orgUIConfig is not yet available
|
|
95
127
|
const safeProductCardConfig = config?.frontendConfig?.uiConfigs
|
|
96
128
|
?.productCardConfig || {
|
|
97
129
|
variant: "minimal",
|
|
@@ -156,6 +188,8 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
156
188
|
}, [filters]);
|
|
157
189
|
|
|
158
190
|
// Callbacks
|
|
191
|
+
const { trackEvent } = useAmplitude();
|
|
192
|
+
|
|
159
193
|
const handleToggleDynamicFilter = useCallback(
|
|
160
194
|
({
|
|
161
195
|
filter,
|
|
@@ -164,7 +198,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
164
198
|
filter: string;
|
|
165
199
|
dynamicFilterDisplayName: string;
|
|
166
200
|
}) => {
|
|
167
|
-
trackEvent
|
|
201
|
+
trackEvent({
|
|
168
202
|
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
169
203
|
eventProps: {
|
|
170
204
|
filterType: "Dynamic",
|
|
@@ -175,19 +209,92 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
175
209
|
addFilter(
|
|
176
210
|
createFilterOption("dynamic", filter, dynamicFilterDisplayName)
|
|
177
211
|
);
|
|
178
|
-
scrollToTop();
|
|
179
212
|
},
|
|
180
|
-
[addFilter, searchText,
|
|
213
|
+
[addFilter, searchText, trackEvent]
|
|
181
214
|
);
|
|
182
215
|
|
|
183
216
|
const handleRemoveFilter = useCallback(
|
|
184
217
|
(filter: SelectedFilterOption) => {
|
|
185
218
|
removeFilter(filter.id);
|
|
186
|
-
scrollToTop();
|
|
187
219
|
},
|
|
188
|
-
[removeFilter
|
|
220
|
+
[removeFilter]
|
|
189
221
|
);
|
|
190
222
|
|
|
223
|
+
const handleSubmitSearch = useCallback(async () => {
|
|
224
|
+
if (searchText.trim()) {
|
|
225
|
+
trackEvent({
|
|
226
|
+
eventName: SpiffyMetricsEventName.SearchQuerySubmitted,
|
|
227
|
+
eventProps: {
|
|
228
|
+
searchOrigin: SpiffyWidgets.SearchResults,
|
|
229
|
+
queryText: searchText.trim(),
|
|
230
|
+
},
|
|
231
|
+
alsoSendToGoogleAnalytics: true,
|
|
232
|
+
});
|
|
233
|
+
const url = new URL(window.location.href);
|
|
234
|
+
url.searchParams.set("esq", searchText.trim());
|
|
235
|
+
window.history.pushState({}, "", url);
|
|
236
|
+
performSearch({ query: searchText.trim() });
|
|
237
|
+
}
|
|
238
|
+
}, [performSearch, searchText, trackEvent]);
|
|
239
|
+
|
|
240
|
+
const handleAutocompleteSelect = useCallback(
|
|
241
|
+
(suggestion: string) => {
|
|
242
|
+
setSearchText(suggestion);
|
|
243
|
+
handleSubmitSearch();
|
|
244
|
+
},
|
|
245
|
+
[handleSubmitSearch, setSearchText]
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const handleKeyDown = useCallback(
|
|
249
|
+
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
250
|
+
if (event.key === "ArrowDown") {
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
const newIndex = (focusedIndex + 1) % autocompleteResults.length;
|
|
253
|
+
setFocusedIndex(newIndex);
|
|
254
|
+
setFocusedOptionId(`option-${newIndex}`);
|
|
255
|
+
} else if (event.key === "ArrowUp") {
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
const newIndex =
|
|
258
|
+
(focusedIndex - 1 + autocompleteResults.length) %
|
|
259
|
+
autocompleteResults.length;
|
|
260
|
+
setFocusedIndex(newIndex);
|
|
261
|
+
setFocusedOptionId(`option-${newIndex}`);
|
|
262
|
+
} else if (event.key === "Enter") {
|
|
263
|
+
if (focusedIndex === -1) {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
handleSubmitSearch();
|
|
266
|
+
} else {
|
|
267
|
+
event.preventDefault();
|
|
268
|
+
const suggestionText = autocompleteResults[focusedIndex];
|
|
269
|
+
handleAutocompleteSelect(suggestionText);
|
|
270
|
+
}
|
|
271
|
+
} else if (event.key === "Escape") {
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
setFocusedIndex(-1);
|
|
274
|
+
setFocusedOptionId(undefined);
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
[
|
|
278
|
+
autocompleteResults,
|
|
279
|
+
focusedIndex,
|
|
280
|
+
handleAutocompleteSelect,
|
|
281
|
+
handleSubmitSearch,
|
|
282
|
+
]
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const handleSearchInputChange = (newValue: string) => {
|
|
286
|
+
if (newValue.length === 1) {
|
|
287
|
+
trackEvent({
|
|
288
|
+
eventName: SpiffyMetricsEventName.SearchInputStarted,
|
|
289
|
+
eventProps: {
|
|
290
|
+
searchOrigin: SpiffyWidgets.SearchResults,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
setSearchText(newValue);
|
|
295
|
+
setIsDirty(true);
|
|
296
|
+
};
|
|
297
|
+
|
|
191
298
|
const handleSelectFilterItem: SelectFilterItem = useCallback(
|
|
192
299
|
({
|
|
193
300
|
filterId,
|
|
@@ -202,7 +309,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
202
309
|
}) => {
|
|
203
310
|
if (filterId === "sort") {
|
|
204
311
|
const newSort = filterItemId as ProductSorting;
|
|
205
|
-
trackEvent
|
|
312
|
+
trackEvent({
|
|
206
313
|
eventName: SpiffyMetricsEventName.SearchSortClicked,
|
|
207
314
|
eventProps: {
|
|
208
315
|
sortType: newSort,
|
|
@@ -210,12 +317,10 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
210
317
|
},
|
|
211
318
|
});
|
|
212
319
|
setProductSorting(newSort);
|
|
213
|
-
scrollToTop();
|
|
214
320
|
} else if (!isSelected) {
|
|
215
321
|
removeFilter(`${filterId}:${filterItemId}`);
|
|
216
|
-
scrollToTop();
|
|
217
322
|
} else {
|
|
218
|
-
trackEvent
|
|
323
|
+
trackEvent({
|
|
219
324
|
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
220
325
|
eventProps: {
|
|
221
326
|
filterType: "Static",
|
|
@@ -225,24 +330,15 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
225
330
|
},
|
|
226
331
|
});
|
|
227
332
|
addFilter(createFilterOption(filterId, filterItemId, displayName));
|
|
228
|
-
scrollToTop();
|
|
229
333
|
}
|
|
230
334
|
},
|
|
231
|
-
[
|
|
232
|
-
addFilter,
|
|
233
|
-
removeFilter,
|
|
234
|
-
setProductSorting,
|
|
235
|
-
searchText,
|
|
236
|
-
scrollToTop,
|
|
237
|
-
trackEvent,
|
|
238
|
-
]
|
|
335
|
+
[addFilter, removeFilter, setProductSorting, searchText, trackEvent]
|
|
239
336
|
);
|
|
240
337
|
|
|
241
338
|
const handleClearAllFilters = useCallback(() => {
|
|
242
339
|
setProductSorting(ProductSorting.FEATURED);
|
|
243
340
|
clearFilters();
|
|
244
|
-
|
|
245
|
-
}, [setProductSorting, clearFilters, scrollToTop]);
|
|
341
|
+
}, [setProductSorting, clearFilters]);
|
|
246
342
|
|
|
247
343
|
// Side Effects
|
|
248
344
|
useTrackComponentVisibleEvent(
|
|
@@ -254,7 +350,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
254
350
|
|
|
255
351
|
useEffect(() => {
|
|
256
352
|
if (productList.length > 0) {
|
|
257
|
-
trackEvent
|
|
353
|
+
trackEvent({
|
|
258
354
|
eventName: SpiffyMetricsEventName.SearchResultsViewed,
|
|
259
355
|
eventProps: {
|
|
260
356
|
queryText: searchText,
|
|
@@ -264,15 +360,53 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
264
360
|
}
|
|
265
361
|
}, [productList.length, searchText, trackEvent]);
|
|
266
362
|
|
|
267
|
-
// This is the single source of truth for the search text triggering a search
|
|
268
363
|
useEffect(() => {
|
|
269
364
|
if (query && query !== searchText) {
|
|
270
|
-
const esq = new URLSearchParams(window.location.search).get("esq");
|
|
271
365
|
setSearchText(query);
|
|
272
|
-
performSearch({ query: esq ?? query });
|
|
273
366
|
}
|
|
274
367
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
275
|
-
}, [
|
|
368
|
+
}, [query]);
|
|
369
|
+
|
|
370
|
+
useEffect(() => {
|
|
371
|
+
const esq = new URLSearchParams(window.location.search).get("esq");
|
|
372
|
+
if (esq) {
|
|
373
|
+
setSearchText(esq);
|
|
374
|
+
performSearch({ query: esq });
|
|
375
|
+
}
|
|
376
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
377
|
+
}, [performSearch]);
|
|
378
|
+
|
|
379
|
+
const fetchAutocompleteSuggestions = (_query: string) => {
|
|
380
|
+
// TODO: implement autocomplete suggestions
|
|
381
|
+
return Promise.resolve([]);
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
useEffect(() => {
|
|
385
|
+
if (fetchAutocompleteSuggestions === undefined) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (!isDirty || debouncedSearchText.length <= 2) {
|
|
390
|
+
setAutocompleteState({ results: [], isLoading: false });
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
setAutocompleteState((prev) => ({ ...prev, isLoading: true }));
|
|
395
|
+
|
|
396
|
+
const fetchData = async () => {
|
|
397
|
+
try {
|
|
398
|
+
const results = await fetchAutocompleteSuggestions?.(
|
|
399
|
+
debouncedSearchText
|
|
400
|
+
);
|
|
401
|
+
setAutocompleteState({ results: results ?? [], isLoading: false });
|
|
402
|
+
} catch (error) {
|
|
403
|
+
Logger.logError("Failed to fetch autocomplete suggestions:", error);
|
|
404
|
+
setAutocompleteState({ results: [], isLoading: false });
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
fetchData();
|
|
409
|
+
}, [debouncedSearchText, isDirty, setAutocompleteState]);
|
|
276
410
|
|
|
277
411
|
return {
|
|
278
412
|
searchData,
|
|
@@ -280,18 +414,16 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
280
414
|
merchantShortName: safeMerchantShortName,
|
|
281
415
|
productCardConfig: safeProductCardConfig,
|
|
282
416
|
productList,
|
|
283
|
-
recommendedProducts,
|
|
284
417
|
autocompleteResults,
|
|
285
418
|
searchFilters: filters,
|
|
286
419
|
availableDynamicFilters,
|
|
287
420
|
selectedFilterOptions,
|
|
288
421
|
searchText,
|
|
289
|
-
query: query || "",
|
|
290
422
|
searchResultsState,
|
|
423
|
+
isLoadingAutocomplete,
|
|
291
424
|
isLoadingSearch,
|
|
292
|
-
isLoadingAutocomplete: false,
|
|
293
425
|
isFilterOpen,
|
|
294
|
-
|
|
426
|
+
isDirty,
|
|
295
427
|
focusedIndex,
|
|
296
428
|
focusedOptionId,
|
|
297
429
|
filterButtonText,
|
|
@@ -299,8 +431,6 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
299
431
|
onSubmitSearch: handleSubmitSearch,
|
|
300
432
|
onAutocompleteSelect: handleAutocompleteSelect,
|
|
301
433
|
onKeyDown: handleKeyDown,
|
|
302
|
-
onSearchInputFocus: handleSearchInputFocus,
|
|
303
|
-
onSearchInputBlur: handleSearchInputBlur,
|
|
304
434
|
onToggleDynamicFilter: handleToggleDynamicFilter,
|
|
305
435
|
onSelectFilterItem: handleSelectFilterItem,
|
|
306
436
|
onRemoveFilter: handleRemoveFilter,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useState, useCallback, useEffect } from "react";
|
|
2
|
+
import { useSearchService } from "src/contexts/searchContext";
|
|
3
|
+
import { SearchResult, SearchParams } from "src/application/models/api/search";
|
|
4
4
|
|
|
5
5
|
export const useProductSearch = () => {
|
|
6
6
|
const { searchProducts, isReady } = useSearchService();
|
|
@@ -11,7 +11,7 @@ export const useProductSearch = () => {
|
|
|
11
11
|
const search = useCallback(
|
|
12
12
|
async (params: SearchParams) => {
|
|
13
13
|
if (!isReady) {
|
|
14
|
-
setError(new Error(
|
|
14
|
+
setError(new Error("Search service not ready - missing dependencies"));
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -22,12 +22,14 @@ export const useProductSearch = () => {
|
|
|
22
22
|
const result = await searchProducts(params);
|
|
23
23
|
setData(result);
|
|
24
24
|
} catch (err) {
|
|
25
|
-
setError(
|
|
25
|
+
setError(
|
|
26
|
+
err instanceof Error ? err : new Error("Unknown search error")
|
|
27
|
+
);
|
|
26
28
|
} finally {
|
|
27
29
|
setLoading(false);
|
|
28
30
|
}
|
|
29
31
|
},
|
|
30
|
-
[searchProducts, isReady]
|
|
32
|
+
[searchProducts, isReady]
|
|
31
33
|
);
|
|
32
34
|
|
|
33
35
|
const reset = useCallback(() => {
|
|
@@ -63,12 +65,14 @@ export const useSearchWithQuery = (params: SearchParams | null) => {
|
|
|
63
65
|
const result = await searchProducts(searchParams);
|
|
64
66
|
setData(result);
|
|
65
67
|
} catch (err) {
|
|
66
|
-
setError(
|
|
68
|
+
setError(
|
|
69
|
+
err instanceof Error ? err : new Error("Unknown search error")
|
|
70
|
+
);
|
|
67
71
|
} finally {
|
|
68
72
|
setLoading(false);
|
|
69
73
|
}
|
|
70
74
|
},
|
|
71
|
-
[searchProducts, isReady]
|
|
75
|
+
[searchProducts, isReady]
|
|
72
76
|
);
|
|
73
77
|
|
|
74
78
|
useEffect(() => {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useShopifyUrl } from "src/contexts/shopifyUrlContext/shopifyUrlContext";
|
|
3
|
+
import { IdExtractor } from "src/contexts/types";
|
|
4
4
|
|
|
5
5
|
export const useShopifyUrlOperations = () => {
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
getTrimmedPathName,
|
|
8
|
+
getPlpOrPdpId,
|
|
9
|
+
isOnPdpPage,
|
|
10
|
+
isOnPlpPage,
|
|
11
|
+
isReady,
|
|
12
|
+
} = useShopifyUrl();
|
|
7
13
|
|
|
8
14
|
return {
|
|
9
15
|
getTrimmedPathName,
|
|
@@ -18,10 +24,10 @@ export const useCurrentPageType = () => {
|
|
|
18
24
|
const { isOnPdpPage, isOnPlpPage, isReady } = useShopifyUrl();
|
|
19
25
|
|
|
20
26
|
const getPageType = useCallback(() => {
|
|
21
|
-
if (!isReady) return
|
|
22
|
-
if (isOnPdpPage()) return
|
|
23
|
-
if (isOnPlpPage()) return
|
|
24
|
-
return
|
|
27
|
+
if (!isReady) return "unknown";
|
|
28
|
+
if (isOnPdpPage()) return "pdp";
|
|
29
|
+
if (isOnPlpPage()) return "plp";
|
|
30
|
+
return "other";
|
|
25
31
|
}, [isReady, isOnPdpPage, isOnPlpPage]);
|
|
26
32
|
|
|
27
33
|
return { getPageType, isReady };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
export type Unit = 'percent' | 'pixel';
|
|
3
4
|
|
|
4
5
|
export const useSnapCalculator = (snaps: number[], maxHeight: number, unit: Unit) => {
|
|
5
6
|
const viewportHeightPx = document.documentElement.clientHeight;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { RefObject, useEffect, useRef } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { RefObject, useEffect, useRef } from "react";
|
|
2
|
+
import { SpiffyWidgets } from "src/application/models/spiffyWidgets";
|
|
3
|
+
import { useIntersection } from "src/hooks/Intersection/useIntersection";
|
|
4
|
+
import {
|
|
5
|
+
SpiffyMetricsEventName,
|
|
6
|
+
useAmplitude,
|
|
7
|
+
} from "src/contexts/amplitudeContext/amplitudeContext";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Tracks a component and logs an event to Amplitude when the component is visible.
|
|
@@ -15,9 +18,9 @@ export const useTrackComponentVisibleEvent = (
|
|
|
15
18
|
component: SpiffyWidgets,
|
|
16
19
|
element: RefObject<HTMLElement>,
|
|
17
20
|
eventProps?: Record<string, unknown>,
|
|
18
|
-
eventName: SpiffyMetricsEventName = SpiffyMetricsEventName.ChatComponentVisible
|
|
21
|
+
eventName: SpiffyMetricsEventName = SpiffyMetricsEventName.ChatComponentVisible
|
|
19
22
|
) => {
|
|
20
|
-
const isVisible = useIntersection(element,
|
|
23
|
+
const isVisible = useIntersection(element, "0px");
|
|
21
24
|
const hasTrackedEvent = useRef(false);
|
|
22
25
|
const { trackEvent } = useAmplitude();
|
|
23
26
|
|
|
@@ -36,7 +39,7 @@ export const useTrackComponentVisibleEvent = (
|
|
|
36
39
|
}
|
|
37
40
|
// Default case for other event types
|
|
38
41
|
return {
|
|
39
|
-
component,
|
|
42
|
+
component: component,
|
|
40
43
|
...eventProps,
|
|
41
44
|
};
|
|
42
45
|
})();
|
|
@@ -44,7 +47,7 @@ export const useTrackComponentVisibleEvent = (
|
|
|
44
47
|
useEffect(() => {
|
|
45
48
|
if (isVisible && !hasTrackedEvent.current) {
|
|
46
49
|
trackEvent({
|
|
47
|
-
eventName,
|
|
50
|
+
eventName: eventName,
|
|
48
51
|
eventProps: componentProps,
|
|
49
52
|
});
|
|
50
53
|
hasTrackedEvent.current = true;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { useAtomValue } from
|
|
2
|
-
import { useEffect, useRef } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useAtomValue } from "jotai";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
SpiffyMetricsEventName,
|
|
5
|
+
useAmplitude,
|
|
6
|
+
} from "src/contexts/amplitudeContext/amplitudeContext";
|
|
7
|
+
import {
|
|
8
|
+
hasParsedVariantInfoAtom,
|
|
9
|
+
variantInfoAtom,
|
|
10
|
+
} from "src/atoms/app/variant";
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Updates the default analytics properties whenever the variant info changes. This hook also
|
|
@@ -16,7 +21,10 @@ export const useUpdateAnalyticsProps = () => {
|
|
|
16
21
|
|
|
17
22
|
useEffect(() => {
|
|
18
23
|
const variantInfoWithPrefix = Object.fromEntries(
|
|
19
|
-
Object.entries(variantInfo).map(([key, value]) => [
|
|
24
|
+
Object.entries(variantInfo).map(([key, value]) => [
|
|
25
|
+
`variantInfo.${key}`,
|
|
26
|
+
value,
|
|
27
|
+
])
|
|
20
28
|
);
|
|
21
29
|
|
|
22
30
|
const defaultEventProperties: Record<string, unknown> = {
|
|
@@ -25,18 +33,19 @@ export const useUpdateAnalyticsProps = () => {
|
|
|
25
33
|
};
|
|
26
34
|
|
|
27
35
|
// TODO: should be removed over time, after migration
|
|
28
|
-
if (variantInfo.variant ===
|
|
36
|
+
if (variantInfo.variant === "pdp") {
|
|
29
37
|
defaultEventProperties.product_id = variantInfo.productId;
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
// TODO: should be removed over time, after migration
|
|
33
|
-
if (variantInfo.variant ===
|
|
41
|
+
if (variantInfo.variant === "plp") {
|
|
34
42
|
defaultEventProperties.plp_id = variantInfo.plpId;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
// TODO: should be removed over time, after migration
|
|
38
|
-
if (variantInfo.variant ===
|
|
39
|
-
defaultEventProperties.page_visit_category =
|
|
46
|
+
if (variantInfo.variant === "page_visit") {
|
|
47
|
+
defaultEventProperties.page_visit_category =
|
|
48
|
+
variantInfo.pageVisitCategory;
|
|
40
49
|
defaultEventProperties.page_visit_url = variantInfo.url;
|
|
41
50
|
}
|
|
42
51
|
|
|
@@ -49,5 +58,10 @@ export const useUpdateAnalyticsProps = () => {
|
|
|
49
58
|
});
|
|
50
59
|
hasInitialized.current = true;
|
|
51
60
|
}
|
|
52
|
-
}, [
|
|
61
|
+
}, [
|
|
62
|
+
variantInfo,
|
|
63
|
+
hasParsedVariantInfo,
|
|
64
|
+
trackEvent,
|
|
65
|
+
setSupplementalDefaultProps,
|
|
66
|
+
]);
|
|
53
67
|
};
|