@shopify/hydrogen 2026.4.6 → 2026.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/index.cjs +26 -9
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +27 -10
- package/dist/development/index.js.map +1 -1
- package/dist/production/index.cjs +45 -45
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +45 -45
- package/dist/production/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, forwardRef, lazy, useContext, useRef, useState, useMemo, useEffect, useCallback, createElement, Fragment as Fragment$1, Suspense } from 'react';
|
|
1
|
+
import { createContext, forwardRef, lazy, useContext, useRef, useState, useMemo, useEffect, useCallback, startTransition, createElement, Fragment as Fragment$1, Suspense } from 'react';
|
|
2
2
|
import { createContext as createContext$1, useRevalidator, useFetcher, useFetchers, RouterContextProvider, createRequestHandler as createRequestHandler$1, useNavigation, useLocation, useNavigate, Link, useMatches } from 'react-router';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useLoadScript, createStorefrontClient as createStorefrontClient$1, SHOPIFY_STOREFRONT_ID_HEADER, SHOPIFY_STOREFRONT_Y_HEADER, SHOPIFY_STOREFRONT_S_HEADER, SHOPIFY_UNIQUE_TOKEN_HEADER, SHOPIFY_VISIT_TOKEN_HEADER, flattenConnection, RichText as RichText$1, ShopPayButton as ShopPayButton$1, parseGid, getTrackingValues, sendShopifyAnalytics, AnalyticsEventName, AnalyticsPageType, getClientBrowserParameters } from '@shopify/hydrogen-react';
|
|
@@ -314,7 +314,7 @@ function getPrivacyBanner() {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
// package.json
|
|
317
|
-
var version = "2026.4.
|
|
317
|
+
var version = "2026.4.7";
|
|
318
318
|
|
|
319
319
|
// src/analytics-manager/ShopifyAnalytics.tsx
|
|
320
320
|
function getCustomerPrivacyRequired() {
|
|
@@ -816,6 +816,8 @@ function register(key) {
|
|
|
816
816
|
}
|
|
817
817
|
};
|
|
818
818
|
}
|
|
819
|
+
var noopPublish = () => {
|
|
820
|
+
};
|
|
819
821
|
function messageOnError(field, envVar) {
|
|
820
822
|
return `[h2:error:Analytics.Provider] - ${field} is required. Make sure ${envVar} is defined in your environment variables. See https://h2o.fyi/analytics/consent to learn how to setup environment variables in the Shopify admin.`;
|
|
821
823
|
}
|
|
@@ -830,11 +832,25 @@ function AnalyticsProvider({
|
|
|
830
832
|
const { shop } = useShopAnalytics(shopProp);
|
|
831
833
|
const [consentVersion, setConsentVersion] = useState(0);
|
|
832
834
|
const [privacyReady, setPrivacyReady] = useState(false);
|
|
833
|
-
const [carts,
|
|
835
|
+
const [carts, setCartsState] = useState({ cart: null, prevCart: null });
|
|
836
|
+
const setCarts = useCallback(
|
|
837
|
+
(update) => startTransition(() => setCartsState(update)),
|
|
838
|
+
[]
|
|
839
|
+
);
|
|
834
840
|
const canTrack = customCanTrack ?? hasAnalyticsConsent;
|
|
841
|
+
const canTrackRef = useRef(canTrack);
|
|
842
|
+
canTrackRef.current = canTrack;
|
|
843
|
+
const guardedPublish = useCallback(
|
|
844
|
+
(event, payload) => {
|
|
845
|
+
if (canTrackRef.current()) publish(event, payload);
|
|
846
|
+
},
|
|
847
|
+
[]
|
|
848
|
+
);
|
|
835
849
|
const onConsentChange = useCallback(() => {
|
|
836
|
-
|
|
837
|
-
|
|
850
|
+
startTransition(() => {
|
|
851
|
+
setPrivacyReady(true);
|
|
852
|
+
setConsentVersion((version2) => version2 + 1);
|
|
853
|
+
});
|
|
838
854
|
}, []);
|
|
839
855
|
if (!!shop) {
|
|
840
856
|
if (/\/68817551382$/.test(shop.shopId)) {
|
|
@@ -872,8 +888,7 @@ function AnalyticsProvider({
|
|
|
872
888
|
canTrack,
|
|
873
889
|
...carts,
|
|
874
890
|
customData,
|
|
875
|
-
publish: canTrack() ?
|
|
876
|
-
},
|
|
891
|
+
publish: canTrack() ? guardedPublish : noopPublish,
|
|
877
892
|
shop,
|
|
878
893
|
subscribe,
|
|
879
894
|
register,
|
|
@@ -886,7 +901,7 @@ function AnalyticsProvider({
|
|
|
886
901
|
carts,
|
|
887
902
|
carts.cart?.updatedAt,
|
|
888
903
|
carts.prevCart,
|
|
889
|
-
|
|
904
|
+
guardedPublish,
|
|
890
905
|
subscribe,
|
|
891
906
|
customData,
|
|
892
907
|
shop,
|
|
@@ -915,7 +930,9 @@ function useAnalytics() {
|
|
|
915
930
|
function useShopAnalytics(shopProp) {
|
|
916
931
|
const [shop, setShop] = useState(null);
|
|
917
932
|
useEffect(() => {
|
|
918
|
-
Promise.resolve(shopProp).then(
|
|
933
|
+
Promise.resolve(shopProp).then((resolvedShop) => {
|
|
934
|
+
startTransition(() => setShop(resolvedShop));
|
|
935
|
+
});
|
|
919
936
|
return () => {
|
|
920
937
|
};
|
|
921
938
|
}, [setShop, shopProp]);
|
|
@@ -1681,7 +1698,7 @@ function generateUUID() {
|
|
|
1681
1698
|
}
|
|
1682
1699
|
|
|
1683
1700
|
// src/version.ts
|
|
1684
|
-
var LIB_VERSION = "2026.4.
|
|
1701
|
+
var LIB_VERSION = "2026.4.7";
|
|
1685
1702
|
|
|
1686
1703
|
// src/utils/graphql.ts
|
|
1687
1704
|
function minifyQuery(string) {
|