@shopify/hydrogen 2024.4.1 → 2024.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/index.cjs +171 -73
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +170 -73
- package/dist/development/index.js.map +1 -1
- package/dist/production/index.cjs +86 -78
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.d.cts +47 -15
- package/dist/production/index.d.ts +47 -15
- package/dist/production/index.js +42 -35
- package/dist/production/index.js.map +1 -1
- package/dist/vite/plugin.js +1 -3
- package/package.json +4 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createStorefrontClient as createStorefrontClient$1, StorefrontClientProps, ShopPayButton as ShopPayButton$1 } from '@shopify/hydrogen-react';
|
|
2
2
|
export { AnalyticsEventName, AnalyticsPageType, ClientBrowserParameters, ExternalVideo, IMAGE_FRAGMENT, Image, MediaFile, ModelViewer, Money, ParsedMetafields, ShopifyAnalytics as SendShopifyAnalyticsEvent, ShopifyAddToCart, ShopifyAddToCartPayload, ShopifyAnalyticsPayload, ShopifyAnalyticsProduct, ShopifyCookies, ShopifyPageView, ShopifyPageViewPayload, ShopifySalesChannel, StorefrontApiResponse, StorefrontApiResponseError, StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponsePartial, Video, customerAccountApiCustomScalars, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseGid, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useLoadScript, useMoney, useShopifyCookies } from '@shopify/hydrogen-react';
|
|
3
|
-
import { LanguageCode, CountryCode, Maybe, PageInfo, CartMetafieldsSetInput, Cart, Scalars, CartUserError, MetafieldsSetUserError, MetafieldDeleteUserError, AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CartSelectedDeliveryOptionInput, ProductOption, ProductVariantConnection, ProductVariant, SelectedOptionInput, CartLine, ComponentizableCartLine, Product, CurrencyCode } from '@shopify/hydrogen-react/storefront-api-types';
|
|
3
|
+
import { LanguageCode, CountryCode, Maybe, PageInfo, BuyerInput, CartMetafieldsSetInput, Cart, Scalars, CartUserError, MetafieldsSetUserError, MetafieldDeleteUserError, AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CartSelectedDeliveryOptionInput, ProductOption, ProductVariantConnection, ProductVariant, SelectedOptionInput, CartLine, ComponentizableCartLine, Product, CurrencyCode } from '@shopify/hydrogen-react/storefront-api-types';
|
|
4
4
|
import { ExecutionArgs } from 'graphql';
|
|
5
5
|
import { LoaderFunctionArgs, LoaderFunction, SerializeFrom, SessionData, FlashSessionData, Session, SessionStorage } from '@remix-run/server-runtime';
|
|
6
6
|
import * as react from 'react';
|
|
@@ -238,14 +238,7 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
238
238
|
|
|
239
239
|
@example
|
|
240
240
|
```
|
|
241
|
-
import type {IsNever} from 'type-fest';
|
|
242
|
-
|
|
243
|
-
type And<A, B> =
|
|
244
|
-
A extends true
|
|
245
|
-
? B extends true
|
|
246
|
-
? true
|
|
247
|
-
: false
|
|
248
|
-
: false;
|
|
241
|
+
import type {IsNever, And} from 'type-fest';
|
|
249
242
|
|
|
250
243
|
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
251
244
|
type AreStringsEqual<A extends string, B extends string> =
|
|
@@ -1039,8 +1032,10 @@ type RequestEventPayload = {
|
|
|
1039
1032
|
displayName?: string;
|
|
1040
1033
|
};
|
|
1041
1034
|
|
|
1035
|
+
declare const CUSTOMER_ACCOUNT_SESSION_KEY = "customerAccount";
|
|
1036
|
+
|
|
1042
1037
|
interface HydrogenSessionData {
|
|
1043
|
-
|
|
1038
|
+
[CUSTOMER_ACCOUNT_SESSION_KEY]: {
|
|
1044
1039
|
accessToken?: string;
|
|
1045
1040
|
expiresAt?: string;
|
|
1046
1041
|
refreshToken?: string;
|
|
@@ -1050,6 +1045,8 @@ interface HydrogenSessionData {
|
|
|
1050
1045
|
state?: string;
|
|
1051
1046
|
redirectPath?: string;
|
|
1052
1047
|
};
|
|
1048
|
+
// for B2B buyer context
|
|
1049
|
+
[BUYER_SESSION_KEY]: Partial<BuyerInput>;
|
|
1053
1050
|
}
|
|
1054
1051
|
|
|
1055
1052
|
interface HydrogenSession<
|
|
@@ -1090,6 +1087,7 @@ declare global {
|
|
|
1090
1087
|
|
|
1091
1088
|
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
1092
1089
|
type JsonGraphQLError = ReturnType<GraphQLError['toJSON']>;
|
|
1090
|
+
type Buyer = Partial<BuyerInput>;
|
|
1093
1091
|
type CustomerAPIResponse<ReturnType> = {
|
|
1094
1092
|
data: ReturnType;
|
|
1095
1093
|
errors: Array<{
|
|
@@ -1159,6 +1157,10 @@ type CustomerAccount = {
|
|
|
1159
1157
|
mutate: <OverrideReturnType extends any = never, RawGqlString extends string = string>(mutation: RawGqlString, ...options: ClientVariablesInRestParams<CustomerAccountMutations, RawGqlString>) => Promise<Omit<CustomerAPIResponse<ClientReturn<CustomerAccountMutations, RawGqlString, OverrideReturnType>>, 'errors'> & {
|
|
1160
1158
|
errors?: JsonGraphQLError[];
|
|
1161
1159
|
}>;
|
|
1160
|
+
/** UNSTABLE feature. Set buyer information into session.*/
|
|
1161
|
+
UNSTABLE_setBuyer: (buyer: Buyer) => void;
|
|
1162
|
+
/** UNSTABLE feature. Get buyer token and company location id from session.*/
|
|
1163
|
+
UNSTABLE_getBuyer: () => Promise<Buyer>;
|
|
1162
1164
|
};
|
|
1163
1165
|
type CustomerAccountOptions = {
|
|
1164
1166
|
/** The client requires a session to persist the auth and refresh token. By default Hydrogen ships with cookie session storage, but you can use [another session storage](https://remix.run/docs/en/main/utils/sessions) implementation. */
|
|
@@ -1179,9 +1181,11 @@ type CustomerAccountOptions = {
|
|
|
1179
1181
|
customAuthStatusHandler?: () => DataFunctionValue;
|
|
1180
1182
|
/** Whether it should print GraphQL errors automatically. Defaults to true */
|
|
1181
1183
|
logErrors?: boolean | ((error?: Error) => boolean);
|
|
1184
|
+
/** UNSTABLE feature, this will eventually goes away. If true then we will exchange customerAccessToken for storefrontCustomerAccessToken. */
|
|
1185
|
+
unstableB2b?: boolean;
|
|
1182
1186
|
};
|
|
1183
1187
|
|
|
1184
|
-
declare function createCustomerAccountClient({ session, customerAccountId, customerAccountUrl, customerApiVersion, request, waitUntil, authUrl, customAuthStatusHandler, logErrors, }: CustomerAccountOptions): CustomerAccount;
|
|
1188
|
+
declare function createCustomerAccountClient({ session, customerAccountId, customerAccountUrl, customerApiVersion, request, waitUntil, authUrl, customAuthStatusHandler, logErrors, unstableB2b, }: CustomerAccountOptions): CustomerAccount;
|
|
1185
1189
|
|
|
1186
1190
|
/**
|
|
1187
1191
|
* A custom Remix loader handler that fetches the changelog.json from GitHub.
|
|
@@ -1223,6 +1227,10 @@ type CartQueryOptions = {
|
|
|
1223
1227
|
* The cart fragment to override the one used in this query.
|
|
1224
1228
|
*/
|
|
1225
1229
|
cartFragment?: string;
|
|
1230
|
+
/**
|
|
1231
|
+
* The customer account instance created by [`createCustomerAccount`](docs/api/hydrogen/latest/customer/createcustomeraccount).
|
|
1232
|
+
*/
|
|
1233
|
+
customerAccount?: CustomerAccount;
|
|
1226
1234
|
};
|
|
1227
1235
|
type CartReturn = Cart & {
|
|
1228
1236
|
errors?: StorefrontApiErrors;
|
|
@@ -1555,6 +1563,26 @@ declare function VariantSelector({ handle, options, variants: _variants, product
|
|
|
1555
1563
|
children?: ReactNode;
|
|
1556
1564
|
}>;
|
|
1557
1565
|
type GetSelectedProductOptions = (request: Request) => SelectedOptionInput[];
|
|
1566
|
+
/**
|
|
1567
|
+
* Extract searchParams from a Request instance and return an array of selected options.
|
|
1568
|
+
* @param request - The Request instance to extract searchParams from.
|
|
1569
|
+
* @returns An array of selected options.
|
|
1570
|
+
* @example Basic usage:
|
|
1571
|
+
* ```tsx
|
|
1572
|
+
*
|
|
1573
|
+
* import {getSelectedProductOptions} from '@shopify/hydrogen';
|
|
1574
|
+
*
|
|
1575
|
+
* // Given a request url of `/products/product-handle?color=red&size=large`
|
|
1576
|
+
*
|
|
1577
|
+
* const selectedOptions = getSelectedProductOptions(request);
|
|
1578
|
+
*
|
|
1579
|
+
* // selectedOptions will equal:
|
|
1580
|
+
* // [
|
|
1581
|
+
* // {name: 'color', value: 'red'},
|
|
1582
|
+
* // {name: 'size', value: 'large'}
|
|
1583
|
+
* // ]
|
|
1584
|
+
* ```
|
|
1585
|
+
**/
|
|
1558
1586
|
declare const getSelectedProductOptions: GetSelectedProductOptions;
|
|
1559
1587
|
|
|
1560
1588
|
declare const useNonce: () => string | undefined;
|
|
@@ -1787,7 +1815,7 @@ type SetConsentHeadlessParams = VisitorConsent & CustomerPrivacyConsentConfig &
|
|
|
1787
1815
|
**/
|
|
1788
1816
|
type CustomerPrivacy$1 = {
|
|
1789
1817
|
currentVisitorConsent: () => VisitorConsent;
|
|
1790
|
-
|
|
1818
|
+
preferencesProcessingAllowed: () => boolean;
|
|
1791
1819
|
saleOfDataAllowed: () => boolean;
|
|
1792
1820
|
marketingAllowed: () => boolean;
|
|
1793
1821
|
analyticsProcessingAllowed: () => boolean;
|
|
@@ -1809,6 +1837,8 @@ type CustomerPrivacyApiProps = {
|
|
|
1809
1837
|
withPrivacyBanner?: boolean;
|
|
1810
1838
|
/** Callback to be called when visitor consent is collected. */
|
|
1811
1839
|
onVisitorConsentCollected?: (consent: VisitorConsentCollected) => void;
|
|
1840
|
+
/** Callback to be call when customer privacy api is ready. */
|
|
1841
|
+
onReady?: () => void;
|
|
1812
1842
|
};
|
|
1813
1843
|
declare function useCustomerPrivacy(props: CustomerPrivacyApiProps): void;
|
|
1814
1844
|
declare function getCustomerPrivacy(): any;
|
|
@@ -1828,7 +1858,7 @@ type AnalyticsProviderProps = {
|
|
|
1828
1858
|
children?: ReactNode;
|
|
1829
1859
|
/** The cart or cart promise to track for cart analytics. When there is a difference between the state of the cart, `AnalyticsProvider` will trigger a `cart_updated` event. It will also produce `product_added_to_cart` and `product_removed_from_cart` based on cart line quantity and cart line id changes. */
|
|
1830
1860
|
cart: Promise<CartReturn | null> | CartReturn | null;
|
|
1831
|
-
/** An optional function to set wether the user can be tracked. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.
|
|
1861
|
+
/** An optional function to set wether the user can be tracked. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.analyticsProcessingAllowed()`. */
|
|
1832
1862
|
canTrack?: () => boolean;
|
|
1833
1863
|
/** An optional custom payload to pass to all events. e.g language/locale/currency. */
|
|
1834
1864
|
customData?: Record<string, unknown>;
|
|
@@ -1836,9 +1866,11 @@ type AnalyticsProviderProps = {
|
|
|
1836
1866
|
shop: Promise<ShopAnalytics | null> | ShopAnalytics | null;
|
|
1837
1867
|
/** The customer privacy consent configuration and options. */
|
|
1838
1868
|
consent: CustomerPrivacyApiProps;
|
|
1869
|
+
/** Disable throwing errors when required props are missing. */
|
|
1870
|
+
disableThrowOnError?: boolean;
|
|
1839
1871
|
};
|
|
1840
1872
|
type AnalyticsContextValue = {
|
|
1841
|
-
/** A function to tell you the current state of if the user can be tracked by analytics. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.
|
|
1873
|
+
/** A function to tell you the current state of if the user can be tracked by analytics. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.analyticsProcessingAllowed()`. */
|
|
1842
1874
|
canTrack: NonNullable<AnalyticsProviderProps['canTrack']>;
|
|
1843
1875
|
/** The current cart state. */
|
|
1844
1876
|
cart: Awaited<AnalyticsProviderProps['cart']>;
|
|
@@ -1874,7 +1906,7 @@ declare function publish(event: typeof AnalyticsEvent.CART_UPDATED, payload: Car
|
|
|
1874
1906
|
declare function publish(event: typeof AnalyticsEvent.PRODUCT_ADD_TO_CART, payload: CartLineUpdatePayload): void;
|
|
1875
1907
|
declare function publish(event: typeof AnalyticsEvent.PRODUCT_REMOVED_FROM_CART, payload: CartLineUpdatePayload): void;
|
|
1876
1908
|
declare function publish(event: typeof AnalyticsEvent.CUSTOM_EVENT, payload: OtherData): void;
|
|
1877
|
-
declare function AnalyticsProvider({ canTrack: customCanTrack, cart: currentCart, children, consent, customData, shop: shopProp, }: AnalyticsProviderProps): JSX.Element;
|
|
1909
|
+
declare function AnalyticsProvider({ canTrack: customCanTrack, cart: currentCart, children, consent, customData, shop: shopProp, disableThrowOnError, }: AnalyticsProviderProps): JSX.Element;
|
|
1878
1910
|
declare function useAnalytics(): AnalyticsContextValue;
|
|
1879
1911
|
type ShopAnalyticsProps = {
|
|
1880
1912
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createStorefrontClient as createStorefrontClient$1, StorefrontClientProps, ShopPayButton as ShopPayButton$1 } from '@shopify/hydrogen-react';
|
|
2
2
|
export { AnalyticsEventName, AnalyticsPageType, ClientBrowserParameters, ExternalVideo, IMAGE_FRAGMENT, Image, MediaFile, ModelViewer, Money, ParsedMetafields, ShopifyAnalytics as SendShopifyAnalyticsEvent, ShopifyAddToCart, ShopifyAddToCartPayload, ShopifyAnalyticsPayload, ShopifyAnalyticsProduct, ShopifyCookies, ShopifyPageView, ShopifyPageViewPayload, ShopifySalesChannel, StorefrontApiResponse, StorefrontApiResponseError, StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponsePartial, Video, customerAccountApiCustomScalars, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseGid, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useLoadScript, useMoney, useShopifyCookies } from '@shopify/hydrogen-react';
|
|
3
|
-
import { LanguageCode, CountryCode, Maybe, PageInfo, CartMetafieldsSetInput, Cart, Scalars, CartUserError, MetafieldsSetUserError, MetafieldDeleteUserError, AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CartSelectedDeliveryOptionInput, ProductOption, ProductVariantConnection, ProductVariant, SelectedOptionInput, CartLine, ComponentizableCartLine, Product, CurrencyCode } from '@shopify/hydrogen-react/storefront-api-types';
|
|
3
|
+
import { LanguageCode, CountryCode, Maybe, PageInfo, BuyerInput, CartMetafieldsSetInput, Cart, Scalars, CartUserError, MetafieldsSetUserError, MetafieldDeleteUserError, AttributeInput, CartBuyerIdentityInput, CartInput, CartLineInput, CartLineUpdateInput, CartSelectedDeliveryOptionInput, ProductOption, ProductVariantConnection, ProductVariant, SelectedOptionInput, CartLine, ComponentizableCartLine, Product, CurrencyCode } from '@shopify/hydrogen-react/storefront-api-types';
|
|
4
4
|
import { ExecutionArgs } from 'graphql';
|
|
5
5
|
import { LoaderFunctionArgs, LoaderFunction, SerializeFrom, SessionData, FlashSessionData, Session, SessionStorage } from '@remix-run/server-runtime';
|
|
6
6
|
import * as react from 'react';
|
|
@@ -238,14 +238,7 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
238
238
|
|
|
239
239
|
@example
|
|
240
240
|
```
|
|
241
|
-
import type {IsNever} from 'type-fest';
|
|
242
|
-
|
|
243
|
-
type And<A, B> =
|
|
244
|
-
A extends true
|
|
245
|
-
? B extends true
|
|
246
|
-
? true
|
|
247
|
-
: false
|
|
248
|
-
: false;
|
|
241
|
+
import type {IsNever, And} from 'type-fest';
|
|
249
242
|
|
|
250
243
|
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
251
244
|
type AreStringsEqual<A extends string, B extends string> =
|
|
@@ -1039,8 +1032,10 @@ type RequestEventPayload = {
|
|
|
1039
1032
|
displayName?: string;
|
|
1040
1033
|
};
|
|
1041
1034
|
|
|
1035
|
+
declare const CUSTOMER_ACCOUNT_SESSION_KEY = "customerAccount";
|
|
1036
|
+
|
|
1042
1037
|
interface HydrogenSessionData {
|
|
1043
|
-
|
|
1038
|
+
[CUSTOMER_ACCOUNT_SESSION_KEY]: {
|
|
1044
1039
|
accessToken?: string;
|
|
1045
1040
|
expiresAt?: string;
|
|
1046
1041
|
refreshToken?: string;
|
|
@@ -1050,6 +1045,8 @@ interface HydrogenSessionData {
|
|
|
1050
1045
|
state?: string;
|
|
1051
1046
|
redirectPath?: string;
|
|
1052
1047
|
};
|
|
1048
|
+
// for B2B buyer context
|
|
1049
|
+
[BUYER_SESSION_KEY]: Partial<BuyerInput>;
|
|
1053
1050
|
}
|
|
1054
1051
|
|
|
1055
1052
|
interface HydrogenSession<
|
|
@@ -1090,6 +1087,7 @@ declare global {
|
|
|
1090
1087
|
|
|
1091
1088
|
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
1092
1089
|
type JsonGraphQLError = ReturnType<GraphQLError['toJSON']>;
|
|
1090
|
+
type Buyer = Partial<BuyerInput>;
|
|
1093
1091
|
type CustomerAPIResponse<ReturnType> = {
|
|
1094
1092
|
data: ReturnType;
|
|
1095
1093
|
errors: Array<{
|
|
@@ -1159,6 +1157,10 @@ type CustomerAccount = {
|
|
|
1159
1157
|
mutate: <OverrideReturnType extends any = never, RawGqlString extends string = string>(mutation: RawGqlString, ...options: ClientVariablesInRestParams<CustomerAccountMutations, RawGqlString>) => Promise<Omit<CustomerAPIResponse<ClientReturn<CustomerAccountMutations, RawGqlString, OverrideReturnType>>, 'errors'> & {
|
|
1160
1158
|
errors?: JsonGraphQLError[];
|
|
1161
1159
|
}>;
|
|
1160
|
+
/** UNSTABLE feature. Set buyer information into session.*/
|
|
1161
|
+
UNSTABLE_setBuyer: (buyer: Buyer) => void;
|
|
1162
|
+
/** UNSTABLE feature. Get buyer token and company location id from session.*/
|
|
1163
|
+
UNSTABLE_getBuyer: () => Promise<Buyer>;
|
|
1162
1164
|
};
|
|
1163
1165
|
type CustomerAccountOptions = {
|
|
1164
1166
|
/** The client requires a session to persist the auth and refresh token. By default Hydrogen ships with cookie session storage, but you can use [another session storage](https://remix.run/docs/en/main/utils/sessions) implementation. */
|
|
@@ -1179,9 +1181,11 @@ type CustomerAccountOptions = {
|
|
|
1179
1181
|
customAuthStatusHandler?: () => DataFunctionValue;
|
|
1180
1182
|
/** Whether it should print GraphQL errors automatically. Defaults to true */
|
|
1181
1183
|
logErrors?: boolean | ((error?: Error) => boolean);
|
|
1184
|
+
/** UNSTABLE feature, this will eventually goes away. If true then we will exchange customerAccessToken for storefrontCustomerAccessToken. */
|
|
1185
|
+
unstableB2b?: boolean;
|
|
1182
1186
|
};
|
|
1183
1187
|
|
|
1184
|
-
declare function createCustomerAccountClient({ session, customerAccountId, customerAccountUrl, customerApiVersion, request, waitUntil, authUrl, customAuthStatusHandler, logErrors, }: CustomerAccountOptions): CustomerAccount;
|
|
1188
|
+
declare function createCustomerAccountClient({ session, customerAccountId, customerAccountUrl, customerApiVersion, request, waitUntil, authUrl, customAuthStatusHandler, logErrors, unstableB2b, }: CustomerAccountOptions): CustomerAccount;
|
|
1185
1189
|
|
|
1186
1190
|
/**
|
|
1187
1191
|
* A custom Remix loader handler that fetches the changelog.json from GitHub.
|
|
@@ -1223,6 +1227,10 @@ type CartQueryOptions = {
|
|
|
1223
1227
|
* The cart fragment to override the one used in this query.
|
|
1224
1228
|
*/
|
|
1225
1229
|
cartFragment?: string;
|
|
1230
|
+
/**
|
|
1231
|
+
* The customer account instance created by [`createCustomerAccount`](docs/api/hydrogen/latest/customer/createcustomeraccount).
|
|
1232
|
+
*/
|
|
1233
|
+
customerAccount?: CustomerAccount;
|
|
1226
1234
|
};
|
|
1227
1235
|
type CartReturn = Cart & {
|
|
1228
1236
|
errors?: StorefrontApiErrors;
|
|
@@ -1555,6 +1563,26 @@ declare function VariantSelector({ handle, options, variants: _variants, product
|
|
|
1555
1563
|
children?: ReactNode;
|
|
1556
1564
|
}>;
|
|
1557
1565
|
type GetSelectedProductOptions = (request: Request) => SelectedOptionInput[];
|
|
1566
|
+
/**
|
|
1567
|
+
* Extract searchParams from a Request instance and return an array of selected options.
|
|
1568
|
+
* @param request - The Request instance to extract searchParams from.
|
|
1569
|
+
* @returns An array of selected options.
|
|
1570
|
+
* @example Basic usage:
|
|
1571
|
+
* ```tsx
|
|
1572
|
+
*
|
|
1573
|
+
* import {getSelectedProductOptions} from '@shopify/hydrogen';
|
|
1574
|
+
*
|
|
1575
|
+
* // Given a request url of `/products/product-handle?color=red&size=large`
|
|
1576
|
+
*
|
|
1577
|
+
* const selectedOptions = getSelectedProductOptions(request);
|
|
1578
|
+
*
|
|
1579
|
+
* // selectedOptions will equal:
|
|
1580
|
+
* // [
|
|
1581
|
+
* // {name: 'color', value: 'red'},
|
|
1582
|
+
* // {name: 'size', value: 'large'}
|
|
1583
|
+
* // ]
|
|
1584
|
+
* ```
|
|
1585
|
+
**/
|
|
1558
1586
|
declare const getSelectedProductOptions: GetSelectedProductOptions;
|
|
1559
1587
|
|
|
1560
1588
|
declare const useNonce: () => string | undefined;
|
|
@@ -1787,7 +1815,7 @@ type SetConsentHeadlessParams = VisitorConsent & CustomerPrivacyConsentConfig &
|
|
|
1787
1815
|
**/
|
|
1788
1816
|
type CustomerPrivacy$1 = {
|
|
1789
1817
|
currentVisitorConsent: () => VisitorConsent;
|
|
1790
|
-
|
|
1818
|
+
preferencesProcessingAllowed: () => boolean;
|
|
1791
1819
|
saleOfDataAllowed: () => boolean;
|
|
1792
1820
|
marketingAllowed: () => boolean;
|
|
1793
1821
|
analyticsProcessingAllowed: () => boolean;
|
|
@@ -1809,6 +1837,8 @@ type CustomerPrivacyApiProps = {
|
|
|
1809
1837
|
withPrivacyBanner?: boolean;
|
|
1810
1838
|
/** Callback to be called when visitor consent is collected. */
|
|
1811
1839
|
onVisitorConsentCollected?: (consent: VisitorConsentCollected) => void;
|
|
1840
|
+
/** Callback to be call when customer privacy api is ready. */
|
|
1841
|
+
onReady?: () => void;
|
|
1812
1842
|
};
|
|
1813
1843
|
declare function useCustomerPrivacy(props: CustomerPrivacyApiProps): void;
|
|
1814
1844
|
declare function getCustomerPrivacy(): any;
|
|
@@ -1828,7 +1858,7 @@ type AnalyticsProviderProps = {
|
|
|
1828
1858
|
children?: ReactNode;
|
|
1829
1859
|
/** The cart or cart promise to track for cart analytics. When there is a difference between the state of the cart, `AnalyticsProvider` will trigger a `cart_updated` event. It will also produce `product_added_to_cart` and `product_removed_from_cart` based on cart line quantity and cart line id changes. */
|
|
1830
1860
|
cart: Promise<CartReturn | null> | CartReturn | null;
|
|
1831
|
-
/** An optional function to set wether the user can be tracked. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.
|
|
1861
|
+
/** An optional function to set wether the user can be tracked. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.analyticsProcessingAllowed()`. */
|
|
1832
1862
|
canTrack?: () => boolean;
|
|
1833
1863
|
/** An optional custom payload to pass to all events. e.g language/locale/currency. */
|
|
1834
1864
|
customData?: Record<string, unknown>;
|
|
@@ -1836,9 +1866,11 @@ type AnalyticsProviderProps = {
|
|
|
1836
1866
|
shop: Promise<ShopAnalytics | null> | ShopAnalytics | null;
|
|
1837
1867
|
/** The customer privacy consent configuration and options. */
|
|
1838
1868
|
consent: CustomerPrivacyApiProps;
|
|
1869
|
+
/** Disable throwing errors when required props are missing. */
|
|
1870
|
+
disableThrowOnError?: boolean;
|
|
1839
1871
|
};
|
|
1840
1872
|
type AnalyticsContextValue = {
|
|
1841
|
-
/** A function to tell you the current state of if the user can be tracked by analytics. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.
|
|
1873
|
+
/** A function to tell you the current state of if the user can be tracked by analytics. Defaults to Customer Privacy API's `window.Shopify.customerPrivacy.analyticsProcessingAllowed()`. */
|
|
1842
1874
|
canTrack: NonNullable<AnalyticsProviderProps['canTrack']>;
|
|
1843
1875
|
/** The current cart state. */
|
|
1844
1876
|
cart: Awaited<AnalyticsProviderProps['cart']>;
|
|
@@ -1874,7 +1906,7 @@ declare function publish(event: typeof AnalyticsEvent.CART_UPDATED, payload: Car
|
|
|
1874
1906
|
declare function publish(event: typeof AnalyticsEvent.PRODUCT_ADD_TO_CART, payload: CartLineUpdatePayload): void;
|
|
1875
1907
|
declare function publish(event: typeof AnalyticsEvent.PRODUCT_REMOVED_FROM_CART, payload: CartLineUpdatePayload): void;
|
|
1876
1908
|
declare function publish(event: typeof AnalyticsEvent.CUSTOM_EVENT, payload: OtherData): void;
|
|
1877
|
-
declare function AnalyticsProvider({ canTrack: customCanTrack, cart: currentCart, children, consent, customData, shop: shopProp, }: AnalyticsProviderProps): JSX.Element;
|
|
1909
|
+
declare function AnalyticsProvider({ canTrack: customCanTrack, cart: currentCart, children, consent, customData, shop: shopProp, disableThrowOnError, }: AnalyticsProviderProps): JSX.Element;
|
|
1878
1910
|
declare function useAnalytics(): AnalyticsContextValue;
|
|
1879
1911
|
type ShopAnalyticsProps = {
|
|
1880
1912
|
/**
|