@envive-ai/react-hooks 0.2.6-alpha-5 → 0.2.6-alpha-6
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/{AmplitudeOperations-cmAprPCA.js → AmplitudeOperations-CaA5jTCq.js} +2 -2
- package/dist/{AmplitudeOperations-CNFlPr53.cjs → AmplitudeOperations-CufFJLkn.cjs} +3 -3
- package/dist/{NewOrgConfig-Bicbf8I7.js → NewOrgConfig-BnLPlU6Z.js} +2 -2
- package/dist/{NewOrgConfig-6dFyYjJG.cjs → NewOrgConfig-CKHO6QW_.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-COwxsJRE.cjs → TrackComponentVisibleEvent-BvrgpJuY.cjs} +5 -5
- package/dist/{TrackComponentVisibleEvent-BebTjNtS.js → TrackComponentVisibleEvent-CKELFJhI.js} +4 -4
- package/dist/amplitudeContext-Bh4SVVse.js +227 -0
- package/dist/amplitudeContext-CjFkl5yr.cjs +243 -0
- package/dist/amplitudeTrackEventAtom-D66l5oFp.js +8 -0
- package/dist/amplitudeTrackEventAtom-f22P2U0u.cjs +15 -0
- package/dist/app-CrmrUsr6.js +514 -0
- package/dist/app-DudAJOe4.cjs +569 -0
- package/dist/application/models/graphql/index.d.ts +1 -1
- package/dist/application/models/guards/api/index.d.ts +2 -2
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/index.cjs +2 -2
- package/dist/application/models/index.d.cts +1 -1
- package/dist/application/models/index.d.ts +4 -4
- package/dist/application/models/index.js +2 -2
- package/dist/application/utils/index.cjs +6 -15
- package/dist/application/utils/index.d.cts +5 -6
- package/dist/application/utils/index.d.ts +8 -9
- package/dist/application/utils/index.js +6 -15
- package/dist/atoms/app/index.cjs +17 -19
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/index.d.ts +6 -6
- package/dist/atoms/app/index.js +12 -14
- package/dist/atoms/atomStore/index.d.cts +1 -1
- package/dist/atoms/chat/index.cjs +15 -17
- package/dist/atoms/chat/index.d.cts +33 -34
- package/dist/atoms/chat/index.d.ts +34 -35
- package/dist/atoms/chat/index.js +15 -17
- package/dist/atoms/globalSearch/index.cjs +1 -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 +1 -1
- package/dist/atoms/org/index.cjs +2 -2
- package/dist/atoms/org/index.d.cts +17 -17
- package/dist/atoms/org/index.d.ts +16 -16
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/search/index.cjs +6 -6
- package/dist/atoms/search/index.d.cts +14 -14
- package/dist/atoms/search/index.d.ts +14 -14
- package/dist/atoms/search/index.js +6 -6
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/{cdnContext-ClAEcKhO.cjs → cdnContext-B9s1XSTE.cjs} +2 -2
- package/dist/{cdnContext-CuZwc-PI.js → cdnContext-BKQT9bPr.js} +2 -2
- package/dist/{chat-BJL3nXR7.cjs → chat-B87y65R0.cjs} +6 -7
- package/dist/chat-DfVncvc2.js +226 -0
- package/dist/chatState-AYi1RPOJ.js +33 -0
- package/dist/chatState-COd-Dczh.cjs +119 -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/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/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +18 -17
- package/dist/contexts/amplitudeContext/index.d.cts +11 -2
- package/dist/contexts/amplitudeContext/index.d.ts +11 -2
- package/dist/contexts/amplitudeContext/index.js +17 -15
- package/dist/contexts/cdnContext/index.cjs +3 -3
- package/dist/contexts/cdnContext/index.js +3 -3
- package/dist/contexts/enviveConfigContext/index.cjs +3 -3
- package/dist/contexts/enviveConfigContext/index.js +3 -3
- package/dist/contexts/enviveCssContext/index.cjs +10 -10
- package/dist/contexts/enviveCssContext/index.js +10 -10
- package/dist/contexts/featureFlagContext/index.cjs +4 -4
- package/dist/contexts/featureFlagContext/index.js +4 -4
- package/dist/contexts/featureFlagServiceContext/index.cjs +3 -3
- package/dist/contexts/featureFlagServiceContext/index.d.cts +1 -1
- package/dist/contexts/featureFlagServiceContext/index.d.ts +1 -1
- package/dist/contexts/featureFlagServiceContext/index.js +3 -3
- package/dist/contexts/graphqlContext/index.cjs +4 -4
- package/dist/contexts/graphqlContext/index.d.cts +1 -1
- package/dist/contexts/graphqlContext/index.js +4 -4
- package/dist/contexts/localStorageContext/index.cjs +2 -2
- package/dist/contexts/localStorageContext/index.js +2 -2
- package/dist/contexts/newOrgConfigContext/index.cjs +9 -9
- package/dist/contexts/newOrgConfigContext/index.d.cts +1 -1
- package/dist/contexts/newOrgConfigContext/index.js +9 -9
- package/dist/contexts/searchContext/index.cjs +18 -19
- package/dist/contexts/searchContext/index.js +18 -19
- package/dist/contexts/sessionStorageContext/index.cjs +1 -1
- package/dist/contexts/sessionStorageContext/index.js +1 -1
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +3 -3
- package/dist/contexts/systemSettingsContext/index.d.cts +2 -2
- package/dist/contexts/systemSettingsContext/index.d.ts +2 -2
- package/dist/contexts/systemSettingsContext/index.js +3 -3
- package/dist/contexts/userIdentityContext/index.cjs +14 -16
- package/dist/contexts/userIdentityContext/index.js +12 -14
- package/dist/{dist-BZX_Mgfn.cjs → dist-B7BErEyV.cjs} +1 -1
- package/dist/{dist-CIM4YRqp.js → dist-CtkINi1R.js} +1 -1
- package/dist/{domObserver-B19-69gW.js → domObserver-CVhsCSkS.js} +1 -1
- package/dist/{domObserver-CwieVNgj.cjs → domObserver-LCBj1xw4.cjs} +1 -1
- package/dist/{enviveConfig-BwIaVAAm.cjs → enviveConfig-D3hmiaPh.cjs} +2 -2
- package/dist/{enviveConfig-CBnoutoK.js → enviveConfig-DyvNVrxm.js} +2 -2
- package/dist/{enviveConfigContext-DgewMgYS.cjs → enviveConfigContext-BADXcRZr.cjs} +2 -2
- package/dist/{enviveConfigContext-B4nejwV9.js → enviveConfigContext-D8ijWYZf.js} +2 -2
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/{events-C8LA-0Tp.cjs → events-CgFGtanE.cjs} +1 -1
- package/dist/{events-BHBRLPWS.js → events-WOOrnUAx.js} +1 -1
- package/dist/exceptions/index.cjs +1 -1
- package/dist/exceptions/index.js +1 -1
- package/dist/{exceptions-BBXmiU8P.cjs → exceptions-BjDgLzGi.cjs} +1 -1
- package/dist/{exceptions--fSXOzkB.js → exceptions-CUGY31Ua.js} +1 -1
- package/dist/{featureFlagServiceContext-B7je7VZV.d.cts → featureFlagServiceContext-ClnlCJV5.d.cts} +1 -1
- package/dist/{featureFlagServiceContext-DiYIv0jI.d.ts → featureFlagServiceContext-CyPGEe2d.d.ts} +1 -1
- package/dist/{featureFlagServiceContext-BkamHViU.cjs → featureFlagServiceContext-DQYo0d6Q.cjs} +2 -2
- package/dist/{featureFlagServiceContext-CZj3qPX7.js → featureFlagServiceContext-GIO9xKV0.js} +2 -2
- package/dist/{globalSearch-C94-vEVh.cjs → globalSearch-Cpc8egsM.cjs} +1 -1
- package/dist/{globalSearch-Dlbnfasm.js → globalSearch-nmrfGLOn.js} +1 -1
- package/dist/{graphqlContext-C3HXFiHx.cjs → graphqlContext-BXdtsubh.cjs} +3 -3
- package/dist/{graphqlContext-Capum8x6.js → graphqlContext-i_3n2qoK.js} +3 -3
- package/dist/hooks/AmplitudeOperations/index.cjs +17 -15
- package/dist/hooks/AmplitudeOperations/index.js +17 -15
- package/dist/hooks/AppDetails/index.cjs +15 -17
- package/dist/hooks/AppDetails/index.js +15 -17
- package/dist/hooks/CdnOperations/index.cjs +3 -3
- package/dist/hooks/CdnOperations/index.js +3 -3
- package/dist/hooks/ChatToggle/index.cjs +21 -19
- package/dist/hooks/ChatToggle/index.js +20 -18
- package/dist/hooks/ChatToggleAnalytics/index.cjs +19 -17
- package/dist/hooks/ChatToggleAnalytics/index.js +19 -17
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.d.ts +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +5 -5
- package/dist/hooks/GraphQLConfig/index.js +5 -5
- package/dist/hooks/IdentifyUser/index.cjs +14 -16
- package/dist/hooks/IdentifyUser/index.js +13 -15
- package/dist/hooks/ImageResolver/index.cjs +2 -2
- package/dist/hooks/ImageResolver/index.js +2 -2
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/LocalStorageOperations/index.cjs +2 -2
- package/dist/hooks/LocalStorageOperations/index.js +2 -2
- package/dist/hooks/MessageFilter/index.cjs +1 -1
- package/dist/hooks/MessageFilter/index.js +1 -1
- package/dist/hooks/NewOrgConfig/index.cjs +10 -10
- package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
- package/dist/hooks/NewOrgConfig/index.js +10 -10
- package/dist/hooks/Search/index.cjs +24 -22
- package/dist/hooks/Search/index.js +24 -22
- package/dist/hooks/SearchOperations/index.cjs +19 -20
- package/dist/hooks/SearchOperations/index.js +19 -20
- package/dist/hooks/SessionStorageOperations/index.cjs +1 -1
- package/dist/hooks/SessionStorageOperations/index.js +1 -1
- package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
- package/dist/hooks/SystemSettingsContext/index.cjs +3 -3
- package/dist/hooks/SystemSettingsContext/index.d.cts +3 -3
- package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
- package/dist/hooks/SystemSettingsContext/index.js +3 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +18 -16
- package/dist/hooks/TrackComponentVisibleEvent/index.js +18 -16
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +20 -18
- package/dist/hooks/UpdateAnalyticsProps/index.js +17 -15
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/{index-CAhGZxMI.d.ts → index-5li6ZMDu.d.ts} +1 -1
- package/dist/index-BVZbvpx_.d.cts +1 -1
- package/dist/{index-ca7Qn8o0.d.cts → index-BbqT4BQv.d.cts} +1 -1
- package/dist/{index-w64il54a.d.cts → index-CAJq_8bO.d.cts} +1 -1
- package/dist/index-CMZcE7pk.d.cts +1 -1
- package/dist/{index-BQpWG3Jm.d.cts → index-ChiZg0yw.d.cts} +1 -1
- package/dist/{index-DNccxbJi.d.ts → index-CsmO1rDH.d.ts} +1 -1
- package/dist/{index-Dgu085Lu.d.ts → index-CuihhoIF.d.ts} +2 -2
- package/dist/{index-BR1G8yyg.d.ts → index-DtzPIcQp.d.ts} +1 -1
- package/dist/{index-ZQMda2Iu.d.ts → index-bEjLKG_Q.d.ts} +1 -1
- package/dist/{index-DiIHuPq2.d.ts → index-jFQefHda.d.ts} +1 -1
- package/dist/{index-BO-ZLYtR.d.ts → index-mv7KvWDq.d.ts} +1 -1
- package/dist/{index-ClVBVK15.d.cts → index-npqPeJ1g.d.cts} +1 -1
- package/dist/interceptors/index.cjs +1 -1
- package/dist/interceptors/index.d.ts +1 -1
- package/dist/interceptors/index.js +1 -1
- package/dist/{localStorageContext-CPrkpt8i.cjs → localStorageContext-CMQMTX56.cjs} +2 -2
- package/dist/{localStorageContext-p_4U0RPI.js → localStorageContext-znToxGBM.js} +2 -2
- package/dist/{models-L2w8FYCa.js → models-DmsMlaHT.js} +2 -2
- package/dist/{models-OyYkll03.cjs → models-wh2gh_Qz.cjs} +2 -2
- package/dist/{newOrgConfigAtom-Dsk0fJNR.js → newOrgConfigAtom-CKuuohFM.js} +1 -1
- package/dist/{newOrgConfigAtom-hs5A1pbZ.cjs → newOrgConfigAtom-Cy66eryV.cjs} +1 -1
- package/dist/{newOrgConfigContext-BuqDUkPz.js → newOrgConfigContext-UdjemITl.js} +5 -5
- package/dist/{newOrgConfigContext-N4CQzvlH.cjs → newOrgConfigContext-kCipbRua.cjs} +5 -5
- package/dist/{nodeSelector-0gJ8Xayf.d.ts → nodeSelector-BAKg1h_y.d.ts} +1 -1
- package/dist/{nodeSelector-Cj-Xl1LP.d.cts → nodeSelector-BYEAyrsj.d.cts} +1 -1
- package/dist/org-D_QTp1ex.js +32 -0
- package/dist/org-DnpLYVzD.cjs +111 -0
- package/dist/{search-C_N_oRVZ.js → search-CP6Tnjsb.js} +5 -5
- package/dist/{search-8bPfo07V.cjs → search-JN-IYDIE.cjs} +5 -5
- package/dist/{searchContext-DdJbpDsU.cjs → searchContext-BrymLMqU.cjs} +6 -6
- package/dist/{searchContext-BohH5i8s.js → searchContext-CgXwm6aL.js} +6 -6
- package/dist/{searchServiceAdapter-BSPZOg1r.js → searchServiceAdapter-B0h7psvh.js} +1 -1
- package/dist/{searchServiceAdapter-DrjFCiw8.cjs → searchServiceAdapter-BclWy4fE.cjs} +1 -1
- package/dist/{sessionStorageContext-CH37Dkb-.cjs → sessionStorageContext-BuWrJQwc.cjs} +1 -1
- package/dist/{sessionStorageContext-CqrutoVq.js → sessionStorageContext-DvFHbk81.js} +1 -1
- package/dist/{shopifyUrlContext-Ba6MQdNV.cjs → shopifyUrlContext-COc1eDR_.cjs} +2 -2
- package/dist/{shopifyUrlContext-BI3fVtA5.js → shopifyUrlContext-CToAt_98.js} +2 -2
- package/dist/{systemSettingsContext-D9BZ9EwQ.js → systemSettingsContext-B8a7vEqE.js} +2 -2
- package/dist/{systemSettingsContext-CYce8iqH.cjs → systemSettingsContext-D-4ma13L.cjs} +2 -2
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/{types-B8HZYWV3.cjs → types-1iJ_FnQQ.cjs} +1 -1
- package/dist/{types-y3mhxOUA.js → types-D5du68Vp.js} +1 -1
- package/dist/{urlsParser-C-Vzs--G.cjs → urlsParser-Dax4iVNC.cjs} +1 -1
- package/dist/{urlsParser-G7Ocwg0M.js → urlsParser-NAp2LwWP.js} +1 -1
- package/dist/{useAppDetails-DNG_-DI9.cjs → useAppDetails-BkTsIODv.cjs} +7 -7
- package/dist/{useAppDetails-CSpw8teP.js → useAppDetails-HS5GtU5O.js} +4 -4
- package/dist/{useGraphQLConfig-CKtaLlQ-.cjs → useGraphQLConfig-DCd-kR81.cjs} +2 -2
- package/dist/{useGraphQLConfig-D1REGfFB.js → useGraphQLConfig-arTbYTKS.js} +2 -2
- package/dist/{useIntersection-BQMfiS4x.cjs → useIntersection-BcBCa890.cjs} +1 -1
- package/dist/{useIntersection-D-ol9eH8.js → useIntersection-BkMkuJcZ.js} +1 -1
- package/dist/{utils-sosM0bEk.d.ts → utils-BitIIghf.d.ts} +1 -1
- package/dist/{utils-BBICrPjW.cjs → utils-CqVRbvfN.cjs} +1 -1
- package/dist/utils-CxDOv-yL.js +607 -0
- package/dist/{utils-w4-xONRA.js → utils-DQhbbAnt.js} +1 -1
- package/dist/utils-DucG4gQ7.cjs +716 -0
- package/package.json +1 -1
- package/src/application/commerce-api.ts +2 -0
- package/src/application/utils/analyticsUtils.ts +31 -16
- package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -1
- package/src/atoms/chat/chatState.ts +12 -7
- package/src/atoms/chat/replies.ts +42 -40
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +116 -130
- package/dist/amplitudeContext-CMTvCsJC.d.ts +0 -52
- package/dist/amplitudeContext-ZkerrMUa.d.cts +0 -52
- package/dist/amplitudeTrackEventAtom-D9vs8dpE.cjs +0 -15
- package/dist/amplitudeTrackEventAtom-iEIu11Om.js +0 -8
- package/dist/chat-ChCtIEwh.js +0 -227
- package/dist/chatState-BYB77nbx.cjs +0 -120
- package/dist/chatState-CzH7APPP.js +0 -34
- package/dist/org-C2kLSSe9.cjs +0 -111
- package/dist/org-CIczyLRP.js +0 -32
- package/dist/utils-DGpMn2pp.js +0 -1364
- package/dist/utils-DqxtxrFe.cjs +0 -1546
- /package/dist/{featureFlagServiceContext-DgoR6euC.js → featureFlagServiceContext-CISyb90N.js} +0 -0
- /package/dist/{featureFlagServiceContext-b-rYgf0u.cjs → featureFlagServiceContext-Csgo-MUv.cjs} +0 -0
package/package.json
CHANGED
|
@@ -545,6 +545,8 @@ class CommerceApiClient {
|
|
|
545
545
|
return V1OrgConfigGetSourceEnum.App;
|
|
546
546
|
case ContextSourceEnum.Test:
|
|
547
547
|
return V1OrgConfigGetSourceEnum.Test;
|
|
548
|
+
case ContextSourceEnum.Eval:
|
|
549
|
+
return V1OrgConfigGetSourceEnum.Test;
|
|
548
550
|
default: {
|
|
549
551
|
// This ensures that if new values are added to ContextSourceEnum, we catch it
|
|
550
552
|
const exhaustiveCheck: never = source;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import Logger from
|
|
1
|
+
import Logger from "src/application/logging/logger";
|
|
2
2
|
import {
|
|
3
3
|
isLegacyUAEcommerceEvent,
|
|
4
4
|
isGA4EcommerceEvent,
|
|
5
5
|
isBaseEcommerceEvent,
|
|
6
|
-
} from
|
|
7
|
-
import { BaseEcommerceEvent } from
|
|
8
|
-
import { SpiffyMetricsEventName } from 'src/contexts/amplitudeContext/amplitudeContext';
|
|
6
|
+
} from "src/application/models";
|
|
7
|
+
import { BaseEcommerceEvent, SpiffyMetricsEventName } from "@envive-ai/types";
|
|
9
8
|
|
|
10
|
-
const NORMALIZED_ADD_TO_CART_EVENT_NAMES = [
|
|
9
|
+
const NORMALIZED_ADD_TO_CART_EVENT_NAMES = ["addtocart", "addedtocart"];
|
|
11
10
|
const CHECK_DATA_LAYER_INTERVAL_MS = 500;
|
|
12
11
|
const CHECK_DATA_LAYER_MAX_ATTEMPTS = 10;
|
|
13
12
|
|
|
@@ -19,8 +18,10 @@ const CHECK_DATA_LAYER_MAX_ATTEMPTS = 10;
|
|
|
19
18
|
* @returns True if the event is an add_to_cart event, false otherwise.
|
|
20
19
|
*/
|
|
21
20
|
const isAddToCartEvent = (event: string): boolean => {
|
|
22
|
-
const normalizedEvent = event.replace(/[-_]/g,
|
|
23
|
-
return NORMALIZED_ADD_TO_CART_EVENT_NAMES.some((name) =>
|
|
21
|
+
const normalizedEvent = event.replace(/[-_]/g, "").toLowerCase();
|
|
22
|
+
return NORMALIZED_ADD_TO_CART_EVENT_NAMES.some((name) =>
|
|
23
|
+
normalizedEvent.includes(name)
|
|
24
|
+
);
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -30,7 +31,10 @@ const isAddToCartEvent = (event: string): boolean => {
|
|
|
30
31
|
*/
|
|
31
32
|
const handleAddToCartEvent = (
|
|
32
33
|
event: BaseEcommerceEvent,
|
|
33
|
-
track: (
|
|
34
|
+
track: (
|
|
35
|
+
eventName: SpiffyMetricsEventName,
|
|
36
|
+
eventProps?: Record<string, unknown>
|
|
37
|
+
) => void
|
|
34
38
|
) => {
|
|
35
39
|
let eventProps: Record<string, unknown>;
|
|
36
40
|
|
|
@@ -43,7 +47,7 @@ const handleAddToCartEvent = (
|
|
|
43
47
|
quantity: product.quantity,
|
|
44
48
|
})),
|
|
45
49
|
currency: event.ecommerce.add.currencyCode,
|
|
46
|
-
event_format_version:
|
|
50
|
+
event_format_version: "legacy_universal_analytics",
|
|
47
51
|
};
|
|
48
52
|
} else if (isGA4EcommerceEvent(event)) {
|
|
49
53
|
eventProps = {
|
|
@@ -54,12 +58,12 @@ const handleAddToCartEvent = (
|
|
|
54
58
|
quantity: item.quantity,
|
|
55
59
|
})),
|
|
56
60
|
currency: event.ecommerce.currency,
|
|
57
|
-
event_format_version:
|
|
61
|
+
event_format_version: "google_analytics_4",
|
|
58
62
|
};
|
|
59
63
|
} else {
|
|
60
64
|
eventProps = {
|
|
61
65
|
event_properties: { ...event },
|
|
62
|
-
event_format_version:
|
|
66
|
+
event_format_version: "unknown",
|
|
63
67
|
};
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -73,7 +77,10 @@ const handleAddToCartEvent = (
|
|
|
73
77
|
* This function runs on an interval until the dataLayer is available.
|
|
74
78
|
*/
|
|
75
79
|
export const initDataLayerWrapper = (
|
|
76
|
-
track: (
|
|
80
|
+
track: (
|
|
81
|
+
eventName: SpiffyMetricsEventName,
|
|
82
|
+
eventProps?: Record<string, unknown>
|
|
83
|
+
) => void
|
|
77
84
|
) => {
|
|
78
85
|
let attempts = 0;
|
|
79
86
|
|
|
@@ -85,7 +92,7 @@ export const initDataLayerWrapper = (
|
|
|
85
92
|
|
|
86
93
|
if (attempts >= CHECK_DATA_LAYER_MAX_ATTEMPTS) {
|
|
87
94
|
Logger.logDebug(
|
|
88
|
-
`[spiffy-ai] dataLayer not available after ${CHECK_DATA_LAYER_MAX_ATTEMPTS} attempts
|
|
95
|
+
`[spiffy-ai] dataLayer not available after ${CHECK_DATA_LAYER_MAX_ATTEMPTS} attempts`
|
|
89
96
|
);
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
@@ -94,10 +101,15 @@ export const initDataLayerWrapper = (
|
|
|
94
101
|
return;
|
|
95
102
|
}
|
|
96
103
|
|
|
97
|
-
Logger.logDebug(
|
|
104
|
+
Logger.logDebug(
|
|
105
|
+
"[spiffy-ai] dataLayer is available, wrapping push function..."
|
|
106
|
+
);
|
|
98
107
|
const originalPush = window.dataLayer.push;
|
|
99
108
|
window.dataLayer.push = (...args: unknown[]) => {
|
|
100
|
-
if (
|
|
109
|
+
if (
|
|
110
|
+
isBaseEcommerceEvent(args[0]) &&
|
|
111
|
+
isAddToCartEvent((args[0] as any).event)
|
|
112
|
+
) {
|
|
101
113
|
handleAddToCartEvent(args[0] as BaseEcommerceEvent, track);
|
|
102
114
|
}
|
|
103
115
|
|
|
@@ -110,7 +122,10 @@ export const initDataLayerWrapper = (
|
|
|
110
122
|
};
|
|
111
123
|
|
|
112
124
|
export const initAmplitude = (
|
|
113
|
-
track: (
|
|
125
|
+
track: (
|
|
126
|
+
eventName: SpiffyMetricsEventName,
|
|
127
|
+
eventProps?: Record<string, unknown>
|
|
128
|
+
) => void
|
|
114
129
|
) => {
|
|
115
130
|
// This function might not be needed anymore if Amplitude is initialized via context.
|
|
116
131
|
// For now, we'll keep it and pass the track function.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { UserEventCategory } from
|
|
2
|
-
import { atom } from
|
|
3
|
-
import { SpiffyMetricsEventName } from 'src/contexts/amplitudeContext/amplitudeContext';
|
|
1
|
+
import { UserEventCategory } from "@spiffy-ai/commerce-api-client/dist/models/UserEventCategory";
|
|
2
|
+
import { atom } from "jotai";
|
|
4
3
|
import {
|
|
5
4
|
FormSubmittedAttributes,
|
|
6
5
|
Message,
|
|
@@ -8,10 +7,13 @@ import {
|
|
|
8
7
|
UserEvent,
|
|
9
8
|
SpiffyEventName,
|
|
10
9
|
ChatElementDisplayLocation,
|
|
11
|
-
|
|
10
|
+
SpiffyMetricsEventName,
|
|
11
|
+
} from "@envive-ai/types";
|
|
12
12
|
|
|
13
13
|
export const userHasRepliedAtom = atom<boolean>(false);
|
|
14
|
-
export const replyEventCategoryAtom = atom<UserEventCategory>(
|
|
14
|
+
export const replyEventCategoryAtom = atom<UserEventCategory>(
|
|
15
|
+
UserEventCategory.AppLoaded
|
|
16
|
+
);
|
|
15
17
|
export const userQueryAtom = atom<string>();
|
|
16
18
|
export const suggestionAtom = atom<Suggestion | undefined>(undefined);
|
|
17
19
|
export const askQuestionBtnClickedAtom = atom<boolean>(false);
|
|
@@ -29,7 +31,10 @@ export const chatOnToggleAtom = atom(
|
|
|
29
31
|
get,
|
|
30
32
|
set,
|
|
31
33
|
triggerLocation?: ChatElementDisplayLocation,
|
|
32
|
-
track?: (
|
|
34
|
+
track?: (
|
|
35
|
+
eventName: SpiffyMetricsEventName,
|
|
36
|
+
eventProps?: Record<string, unknown>
|
|
37
|
+
) => void
|
|
33
38
|
) => {
|
|
34
39
|
const isOpen = get(chatIsOpenAtom);
|
|
35
40
|
set(chatIsOpenAtom, !isOpen);
|
|
@@ -45,5 +50,5 @@ export const chatOnToggleAtom = atom(
|
|
|
45
50
|
window.dispatchEvent(new CustomEvent(SpiffyEventName.WidgetClose));
|
|
46
51
|
track?.(SpiffyMetricsEventName.ChatComponentCollapsed);
|
|
47
52
|
}
|
|
48
|
-
}
|
|
53
|
+
}
|
|
49
54
|
);
|
|
@@ -1,56 +1,58 @@
|
|
|
1
|
-
import { atom } from
|
|
2
|
-
import { Message, MessageType } from
|
|
1
|
+
import { atom } from "jotai";
|
|
2
|
+
import { Message, MessageType, SpiffyMetricsEventName } from "@envive-ai/types";
|
|
3
3
|
import {
|
|
4
4
|
userHasRepliedAtom,
|
|
5
5
|
messagesAtom,
|
|
6
6
|
userQueryAtom,
|
|
7
7
|
replyEventCategoryAtom,
|
|
8
|
-
} from
|
|
9
|
-
import { UserEventCategory } from
|
|
10
|
-
import { queueUserEventAtom } from
|
|
11
|
-
import {
|
|
12
|
-
import { amplitudeTrackEventAtom } from 'src/atoms/amplitude/amplitudeTrackEventAtom';
|
|
8
|
+
} from "src/atoms/chat";
|
|
9
|
+
import { UserEventCategory } from "@spiffy-ai/commerce-api-client";
|
|
10
|
+
import { queueUserEventAtom } from "./messageQueue";
|
|
11
|
+
import { amplitudeTrackEventAtom } from "src/atoms/amplitude/amplitudeTrackEventAtom";
|
|
13
12
|
|
|
14
13
|
type HandleReplyParams = {
|
|
15
14
|
message: Message;
|
|
16
15
|
userTyped: boolean;
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
export const handleReplyAtom = atom(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const queryTyped = message.metadata.content;
|
|
18
|
+
export const handleReplyAtom = atom(
|
|
19
|
+
null,
|
|
20
|
+
(get, set, { message, userTyped }: HandleReplyParams) => {
|
|
21
|
+
if (message.type !== MessageType.QueryTyped) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
set(messagesAtom, [...get(messagesAtom), [message]]);
|
|
30
|
-
set(userHasRepliedAtom, true);
|
|
31
|
-
set(queueUserEventAtom, {
|
|
32
|
-
eventId: message.id,
|
|
33
|
-
createdAt: message.createdAt,
|
|
34
|
-
category: UserEventCategory.QueryTyped,
|
|
35
|
-
attributes: {
|
|
36
|
-
query: queryTyped,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
25
|
+
const trackEvent = get(amplitudeTrackEventAtom);
|
|
26
|
+
const queryTyped = message.metadata.content;
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
user_typed: userTyped,
|
|
51
|
-
},
|
|
28
|
+
set(replyEventCategoryAtom, UserEventCategory.QueryTyped);
|
|
29
|
+
set(userQueryAtom, queryTyped);
|
|
30
|
+
set(messagesAtom, [...get(messagesAtom), [message]]);
|
|
31
|
+
set(userHasRepliedAtom, true);
|
|
32
|
+
set(queueUserEventAtom, {
|
|
33
|
+
eventId: message.id,
|
|
34
|
+
createdAt: message.createdAt,
|
|
35
|
+
category: UserEventCategory.QueryTyped,
|
|
36
|
+
attributes: {
|
|
37
|
+
query: queryTyped,
|
|
52
38
|
},
|
|
53
|
-
alsoSendToGoogleAnalytics: true,
|
|
54
39
|
});
|
|
40
|
+
|
|
41
|
+
if (trackEvent) {
|
|
42
|
+
trackEvent({
|
|
43
|
+
eventName: SpiffyMetricsEventName.ChatUserMessageInput,
|
|
44
|
+
eventProps: {
|
|
45
|
+
message_id: message.id,
|
|
46
|
+
message_role: message.role,
|
|
47
|
+
message_type: message.type,
|
|
48
|
+
message_metadata: {
|
|
49
|
+
content: message?.metadata?.content, // Removed amplitudeSafeString
|
|
50
|
+
created_at: message.createdAt,
|
|
51
|
+
user_typed: userTyped,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
alsoSendToGoogleAnalytics: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
);
|