@behio/storefront-sdk 0.20.0 → 0.22.0

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.
@@ -0,0 +1,36 @@
1
+ // src/react/utils/format-price.ts
2
+ function formatPrice(amount, currency, locale) {
3
+ const resolvedLocale = locale ?? "cs";
4
+ try {
5
+ return new Intl.NumberFormat(resolvedLocale, {
6
+ style: "currency",
7
+ currency,
8
+ minimumFractionDigits: Number.isInteger(amount) ? 0 : 2,
9
+ maximumFractionDigits: 2
10
+ }).format(amount);
11
+ } catch {
12
+ return `${amount} ${currency}`;
13
+ }
14
+ }
15
+
16
+ // src/analytics.ts
17
+ function trackEcommerceEvent(event, payload) {
18
+ if (typeof window === "undefined") return;
19
+ const w = window;
20
+ try {
21
+ if (typeof w.gtag === "function") {
22
+ w.gtag("event", event, payload);
23
+ return;
24
+ }
25
+ if (Array.isArray(w.dataLayer)) {
26
+ w.dataLayer.push({ ecommerce: null });
27
+ w.dataLayer.push({ event, ecommerce: payload });
28
+ }
29
+ } catch {
30
+ }
31
+ }
32
+
33
+ export {
34
+ formatPrice,
35
+ trackEcommerceEvent
36
+ };
@@ -558,8 +558,13 @@ var AuthModule = class {
558
558
  auth: false
559
559
  });
560
560
  if (res.error) return res;
561
- this.client.setTokens(res.data);
562
- this.client.emit("auth:login", { email: input.email });
561
+ if (res.data.accessToken && res.data.refreshToken) {
562
+ this.client.setTokens({
563
+ accessToken: res.data.accessToken,
564
+ refreshToken: res.data.refreshToken
565
+ });
566
+ this.client.emit("auth:login", { email: input.email });
567
+ }
563
568
  return res;
564
569
  }
565
570
  /** Login with email and password */
@@ -13,6 +13,24 @@ function formatPrice(amount, currency, locale) {
13
13
  }
14
14
  }
15
15
 
16
+ // src/analytics.ts
17
+ function trackEcommerceEvent(event, payload) {
18
+ if (typeof window === "undefined") return;
19
+ const w = window;
20
+ try {
21
+ if (typeof w.gtag === "function") {
22
+ w.gtag("event", event, payload);
23
+ return;
24
+ }
25
+ if (Array.isArray(w.dataLayer)) {
26
+ w.dataLayer.push({ ecommerce: null });
27
+ w.dataLayer.push({ event, ecommerce: payload });
28
+ }
29
+ } catch (e2) {
30
+ }
31
+ }
32
+
33
+
16
34
 
17
35
 
18
- exports.formatPrice = formatPrice;
36
+ exports.formatPrice = formatPrice; exports.trackEcommerceEvent = trackEcommerceEvent;
@@ -558,8 +558,13 @@ var AuthModule = class {
558
558
  auth: false
559
559
  });
560
560
  if (res.error) return res;
561
- this.client.setTokens(res.data);
562
- this.client.emit("auth:login", { email: input.email });
561
+ if (res.data.accessToken && res.data.refreshToken) {
562
+ this.client.setTokens({
563
+ accessToken: res.data.accessToken,
564
+ refreshToken: res.data.refreshToken
565
+ });
566
+ this.client.emit("auth:login", { email: input.email });
567
+ }
563
568
  return res;
564
569
  }
565
570
  /** Login with email and password */
@@ -342,6 +342,17 @@ interface AuthTokens {
342
342
  accessToken: string;
343
343
  refreshToken: string;
344
344
  }
345
+ /**
346
+ * Result of a registration. When the eshop requires admin approval,
347
+ * `pendingApproval` is true and the tokens are null (the account is created but
348
+ * inactive and can't log in until approved) — the storefront should show a
349
+ * "waiting for approval" message instead of a logged-in session.
350
+ */
351
+ interface RegisterResult {
352
+ pendingApproval: boolean;
353
+ accessToken: string | null;
354
+ refreshToken: string | null;
355
+ }
345
356
  interface RegisterInput {
346
357
  email: string;
347
358
  password: string;
@@ -1158,7 +1169,7 @@ declare class AuthModule {
1158
1169
  private client;
1159
1170
  constructor(client: BehioStorefront);
1160
1171
  /** Register a new customer */
1161
- register(input: RegisterInput): Promise<SdkResult<AuthTokens>>;
1172
+ register(input: RegisterInput): Promise<SdkResult<RegisterResult>>;
1162
1173
  /** Login with email and password */
1163
1174
  login(input: LoginInput): Promise<SdkResult<AuthTokens>>;
1164
1175
  /** Refresh access token using refresh token */
@@ -1432,4 +1443,4 @@ declare class ShippingModule {
1432
1443
  }>>;
1433
1444
  }
1434
1445
 
1435
- export { type OrderStatus as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type SubmitReturnInput as D, type CookieConsent as E, type FilterField as F, type GiftCardBalance as G, type CookieConsentInput as H, type SubmitQuoteInput as I, type BackInStockSubscription as J, type AddToCartInput as K, type AuthTokens as L, BehioApiError as M, type BundleItem as N, type OrderListItem as O, type ProductsQuery as P, type QuoteRequest as Q, type RegisterInput as R, type ShopInfo as S, type CartDiscount as T, type CartItem as U, type CheckoutAddress as V, type WishlistItem as W, type FulfillmentStatus as X, type LoginInput as Y, type MessageResponse as Z, type OrderItem as _, BehioStorefront as a, type PaymentStatus as a0, type ProductPrice as a1, type ProductReview as a2, type ProductVariant as a3, type AddressType as a4, AddressTypes as a5, type BehioErrorCode as a6, type BehioEventHandler as a7, type BehioEventType as a8, BehioNetworkError as a9, type SdkResult as aA, type ShippingMethodSummary as aB, type ShippingQuote as aC, type ShippingQuoteInput as aD, type ShopScript as aE, type ShopScriptPlacement as aF, type ShopScriptType as aG, err as aH, ok as aI, toSdkError as aJ, type CartBundleLine as aa, type CartBundleLineItem as ab, type CartItemProduct as ac, type CheckoutPaymentMethod as ad, type DataGroupFieldType as ae, FulfillmentStatuses as af, type GiftCardSummary as ag, type OrderStatusHistory as ah, OrderStatuses as ai, type OrderTracking as aj, type PageAttachment as ak, PaymentStatuses as al, type ProductMedia as am, type ProductMediaVariant as an, ProductSort as ao, type ProductSortValue as ap, type ProductVolumePrice as aq, type QuoteItem as ar, type RequestInterceptor as as, type RequestInterceptorConfig as at, type ResponseInterceptor as au, type ResponseInterceptorData as av, type ReturnRequestItem as aw, type ReturnStatusItem as ax, type ReturnableOrderItem as ay, type SdkError as az, type PaginatedResponse as b, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type OrderDetail as k, type OrderAccessRequestResponse as l, type OrderAccessVerifyResponse as m, type CheckoutInput as n, type PageDetail as o, type Page as p, type ShopScripts as q, type ShopSeo as r, type Bundle as s, type CrossSellItem as t, type ActivePromotion as u, type ProductReviewsResponse as v, type SubmitReviewInput as w, type ReturnableOrder as x, type ReturnStatus as y, type ReturnRequest as z };
1446
+ export { type OrderStatus as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type SubmitReturnInput as D, type CookieConsent as E, type FilterField as F, type GiftCardBalance as G, type CookieConsentInput as H, type SubmitQuoteInput as I, type BackInStockSubscription as J, type AddToCartInput as K, type AuthTokens as L, BehioApiError as M, type BundleItem as N, type OrderListItem as O, type ProductsQuery as P, type QuoteRequest as Q, type RegisterInput as R, type ShopInfo as S, type CartDiscount as T, type CartItem as U, type CheckoutAddress as V, type WishlistItem as W, type FulfillmentStatus as X, type LoginInput as Y, type MessageResponse as Z, type OrderItem as _, BehioStorefront as a, type PaymentStatus as a0, type ProductPrice as a1, type ProductReview as a2, type ProductVariant as a3, type AddressType as a4, AddressTypes as a5, type BehioErrorCode as a6, type BehioEventHandler as a7, type BehioEventType as a8, BehioNetworkError as a9, type SdkError as aA, type SdkResult as aB, type ShippingMethodSummary as aC, type ShippingQuote as aD, type ShippingQuoteInput as aE, type ShopScript as aF, type ShopScriptPlacement as aG, type ShopScriptType as aH, err as aI, ok as aJ, toSdkError as aK, type CartBundleLine as aa, type CartBundleLineItem as ab, type CartItemProduct as ac, type CheckoutPaymentMethod as ad, type DataGroupFieldType as ae, FulfillmentStatuses as af, type GiftCardSummary as ag, type OrderStatusHistory as ah, OrderStatuses as ai, type OrderTracking as aj, type PageAttachment as ak, PaymentStatuses as al, type ProductMedia as am, type ProductMediaVariant as an, ProductSort as ao, type ProductSortValue as ap, type ProductVolumePrice as aq, type QuoteItem as ar, type RegisterResult as as, type RequestInterceptor as at, type RequestInterceptorConfig as au, type ResponseInterceptor as av, type ResponseInterceptorData as aw, type ReturnRequestItem as ax, type ReturnStatusItem as ay, type ReturnableOrderItem as az, type PaginatedResponse as b, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type OrderDetail as k, type OrderAccessRequestResponse as l, type OrderAccessVerifyResponse as m, type CheckoutInput as n, type PageDetail as o, type Page as p, type ShopScripts as q, type ShopSeo as r, type Bundle as s, type CrossSellItem as t, type ActivePromotion as u, type ProductReviewsResponse as v, type SubmitReviewInput as w, type ReturnableOrder as x, type ReturnStatus as y, type ReturnRequest as z };
@@ -342,6 +342,17 @@ interface AuthTokens {
342
342
  accessToken: string;
343
343
  refreshToken: string;
344
344
  }
345
+ /**
346
+ * Result of a registration. When the eshop requires admin approval,
347
+ * `pendingApproval` is true and the tokens are null (the account is created but
348
+ * inactive and can't log in until approved) — the storefront should show a
349
+ * "waiting for approval" message instead of a logged-in session.
350
+ */
351
+ interface RegisterResult {
352
+ pendingApproval: boolean;
353
+ accessToken: string | null;
354
+ refreshToken: string | null;
355
+ }
345
356
  interface RegisterInput {
346
357
  email: string;
347
358
  password: string;
@@ -1158,7 +1169,7 @@ declare class AuthModule {
1158
1169
  private client;
1159
1170
  constructor(client: BehioStorefront);
1160
1171
  /** Register a new customer */
1161
- register(input: RegisterInput): Promise<SdkResult<AuthTokens>>;
1172
+ register(input: RegisterInput): Promise<SdkResult<RegisterResult>>;
1162
1173
  /** Login with email and password */
1163
1174
  login(input: LoginInput): Promise<SdkResult<AuthTokens>>;
1164
1175
  /** Refresh access token using refresh token */
@@ -1432,4 +1443,4 @@ declare class ShippingModule {
1432
1443
  }>>;
1433
1444
  }
1434
1445
 
1435
- export { type OrderStatus as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type SubmitReturnInput as D, type CookieConsent as E, type FilterField as F, type GiftCardBalance as G, type CookieConsentInput as H, type SubmitQuoteInput as I, type BackInStockSubscription as J, type AddToCartInput as K, type AuthTokens as L, BehioApiError as M, type BundleItem as N, type OrderListItem as O, type ProductsQuery as P, type QuoteRequest as Q, type RegisterInput as R, type ShopInfo as S, type CartDiscount as T, type CartItem as U, type CheckoutAddress as V, type WishlistItem as W, type FulfillmentStatus as X, type LoginInput as Y, type MessageResponse as Z, type OrderItem as _, BehioStorefront as a, type PaymentStatus as a0, type ProductPrice as a1, type ProductReview as a2, type ProductVariant as a3, type AddressType as a4, AddressTypes as a5, type BehioErrorCode as a6, type BehioEventHandler as a7, type BehioEventType as a8, BehioNetworkError as a9, type SdkResult as aA, type ShippingMethodSummary as aB, type ShippingQuote as aC, type ShippingQuoteInput as aD, type ShopScript as aE, type ShopScriptPlacement as aF, type ShopScriptType as aG, err as aH, ok as aI, toSdkError as aJ, type CartBundleLine as aa, type CartBundleLineItem as ab, type CartItemProduct as ac, type CheckoutPaymentMethod as ad, type DataGroupFieldType as ae, FulfillmentStatuses as af, type GiftCardSummary as ag, type OrderStatusHistory as ah, OrderStatuses as ai, type OrderTracking as aj, type PageAttachment as ak, PaymentStatuses as al, type ProductMedia as am, type ProductMediaVariant as an, ProductSort as ao, type ProductSortValue as ap, type ProductVolumePrice as aq, type QuoteItem as ar, type RequestInterceptor as as, type RequestInterceptorConfig as at, type ResponseInterceptor as au, type ResponseInterceptorData as av, type ReturnRequestItem as aw, type ReturnStatusItem as ax, type ReturnableOrderItem as ay, type SdkError as az, type PaginatedResponse as b, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type OrderDetail as k, type OrderAccessRequestResponse as l, type OrderAccessVerifyResponse as m, type CheckoutInput as n, type PageDetail as o, type Page as p, type ShopScripts as q, type ShopSeo as r, type Bundle as s, type CrossSellItem as t, type ActivePromotion as u, type ProductReviewsResponse as v, type SubmitReviewInput as w, type ReturnableOrder as x, type ReturnStatus as y, type ReturnRequest as z };
1446
+ export { type OrderStatus as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type SubmitReturnInput as D, type CookieConsent as E, type FilterField as F, type GiftCardBalance as G, type CookieConsentInput as H, type SubmitQuoteInput as I, type BackInStockSubscription as J, type AddToCartInput as K, type AuthTokens as L, BehioApiError as M, type BundleItem as N, type OrderListItem as O, type ProductsQuery as P, type QuoteRequest as Q, type RegisterInput as R, type ShopInfo as S, type CartDiscount as T, type CartItem as U, type CheckoutAddress as V, type WishlistItem as W, type FulfillmentStatus as X, type LoginInput as Y, type MessageResponse as Z, type OrderItem as _, BehioStorefront as a, type PaymentStatus as a0, type ProductPrice as a1, type ProductReview as a2, type ProductVariant as a3, type AddressType as a4, AddressTypes as a5, type BehioErrorCode as a6, type BehioEventHandler as a7, type BehioEventType as a8, BehioNetworkError as a9, type SdkError as aA, type SdkResult as aB, type ShippingMethodSummary as aC, type ShippingQuote as aD, type ShippingQuoteInput as aE, type ShopScript as aF, type ShopScriptPlacement as aG, type ShopScriptType as aH, err as aI, ok as aJ, toSdkError as aK, type CartBundleLine as aa, type CartBundleLineItem as ab, type CartItemProduct as ac, type CheckoutPaymentMethod as ad, type DataGroupFieldType as ae, FulfillmentStatuses as af, type GiftCardSummary as ag, type OrderStatusHistory as ah, OrderStatuses as ai, type OrderTracking as aj, type PageAttachment as ak, PaymentStatuses as al, type ProductMedia as am, type ProductMediaVariant as an, ProductSort as ao, type ProductSortValue as ap, type ProductVolumePrice as aq, type QuoteItem as ar, type RegisterResult as as, type RequestInterceptor as at, type RequestInterceptorConfig as au, type ResponseInterceptor as av, type ResponseInterceptorData as aw, type ReturnRequestItem as ax, type ReturnStatusItem as ay, type ReturnableOrderItem as az, type PaginatedResponse as b, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type OrderDetail as k, type OrderAccessRequestResponse as l, type OrderAccessVerifyResponse as m, type CheckoutInput as n, type PageDetail as o, type Page as p, type ShopScripts as q, type ShopSeo as r, type Bundle as s, type CrossSellItem as t, type ActivePromotion as u, type ProductReviewsResponse as v, type SubmitReviewInput as w, type ReturnableOrder as x, type ReturnStatus as y, type ReturnRequest as z };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as AddressSuggestion, a4 as AddressType, a5 as AddressTypes, L as AuthTokens, J as BackInStockSubscription, M as BehioApiError, a6 as BehioErrorCode, a7 as BehioEventHandler, a8 as BehioEventType, a9 as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, s as Bundle, N as BundleItem, g as Cart, aa as CartBundleLine, ab as CartBundleLineItem, T as CartDiscount, U as CartItem, ac as CartItemProduct, C as Category, e as CategoryDetail, V as CheckoutAddress, n as CheckoutInput, ad as CheckoutPaymentMethod, E as CookieConsent, H as CookieConsentInput, t as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ae as DataGroupFieldType, F as FilterField, X as FulfillmentStatus, af as FulfillmentStatuses, G as GiftCardBalance, ag as GiftCardSummary, Y as LoginInput, Z as MessageResponse, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, k as OrderDetail, _ as OrderItem, O as OrderListItem, $ as OrderStatus, ah as OrderStatusHistory, ai as OrderStatuses, aj as OrderTracking, p as Page, ak as PageAttachment, o as PageDetail, b as PaginatedResponse, a0 as PaymentStatus, al as PaymentStatuses, d as ProductDetail, f as ProductLabel, c as ProductListItem, am as ProductMedia, an as ProductMediaVariant, a1 as ProductPrice, a2 as ProductReview, v as ProductReviewsResponse, ao as ProductSort, ap as ProductSortValue, a3 as ProductVariant, aq as ProductVolumePrice, P as ProductsQuery, ar as QuoteItem, Q as QuoteRequest, R as RegisterInput, as as RequestInterceptor, at as RequestInterceptorConfig, au as ResponseInterceptor, av as ResponseInterceptorData, z as ReturnRequest, aw as ReturnRequestItem, y as ReturnStatus, ax as ReturnStatusItem, x as ReturnableOrder, ay as ReturnableOrderItem, az as SdkError, aA as SdkResult, aB as ShippingMethodSummary, aC as ShippingQuote, aD as ShippingQuoteInput, S as ShopInfo, aE as ShopScript, aF as ShopScriptPlacement, aG as ShopScriptType, q as ShopScripts, r as ShopSeo, I as SubmitQuoteInput, D as SubmitReturnInput, w as SubmitReviewInput, W as WishlistItem, aH as err, aI as ok, aJ as toSdkError } from './client-Bc6qvoIu.mjs';
1
+ export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as AddressSuggestion, a4 as AddressType, a5 as AddressTypes, L as AuthTokens, J as BackInStockSubscription, M as BehioApiError, a6 as BehioErrorCode, a7 as BehioEventHandler, a8 as BehioEventType, a9 as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, s as Bundle, N as BundleItem, g as Cart, aa as CartBundleLine, ab as CartBundleLineItem, T as CartDiscount, U as CartItem, ac as CartItemProduct, C as Category, e as CategoryDetail, V as CheckoutAddress, n as CheckoutInput, ad as CheckoutPaymentMethod, E as CookieConsent, H as CookieConsentInput, t as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ae as DataGroupFieldType, F as FilterField, X as FulfillmentStatus, af as FulfillmentStatuses, G as GiftCardBalance, ag as GiftCardSummary, Y as LoginInput, Z as MessageResponse, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, k as OrderDetail, _ as OrderItem, O as OrderListItem, $ as OrderStatus, ah as OrderStatusHistory, ai as OrderStatuses, aj as OrderTracking, p as Page, ak as PageAttachment, o as PageDetail, b as PaginatedResponse, a0 as PaymentStatus, al as PaymentStatuses, d as ProductDetail, f as ProductLabel, c as ProductListItem, am as ProductMedia, an as ProductMediaVariant, a1 as ProductPrice, a2 as ProductReview, v as ProductReviewsResponse, ao as ProductSort, ap as ProductSortValue, a3 as ProductVariant, aq as ProductVolumePrice, P as ProductsQuery, ar as QuoteItem, Q as QuoteRequest, R as RegisterInput, as as RegisterResult, at as RequestInterceptor, au as RequestInterceptorConfig, av as ResponseInterceptor, aw as ResponseInterceptorData, z as ReturnRequest, ax as ReturnRequestItem, y as ReturnStatus, ay as ReturnStatusItem, x as ReturnableOrder, az as ReturnableOrderItem, aA as SdkError, aB as SdkResult, aC as ShippingMethodSummary, aD as ShippingQuote, aE as ShippingQuoteInput, S as ShopInfo, aF as ShopScript, aG as ShopScriptPlacement, aH as ShopScriptType, q as ShopScripts, r as ShopSeo, I as SubmitQuoteInput, D as SubmitReturnInput, w as SubmitReviewInput, W as WishlistItem, aI as err, aJ as ok, aK as toSdkError } from './client-hCuGQERQ.mjs';
2
2
 
3
3
  /**
4
4
  * Format a price amount with currency using Intl.NumberFormat.
@@ -10,4 +10,40 @@ export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as Add
10
10
  */
11
11
  declare function formatPrice(amount: number, currency: string, locale?: string): string;
12
12
 
13
- export { formatPrice };
13
+ /**
14
+ * GA4 e-commerce event helper.
15
+ *
16
+ * Fires standard GA4 ecommerce events (view_item, add_to_cart, begin_checkout,
17
+ * purchase, ...) into whatever analytics runtime the shop has injected via
18
+ * `<StorefrontScripts/>`:
19
+ *
20
+ * - direct GA4 (`gtag` present) -> `gtag("event", name, payload)`
21
+ * - GTM (`dataLayer` array present) -> `dataLayer.push({event, ecommerce})`
22
+ * (with the recommended `ecommerce: null` reset push first)
23
+ * - neither present (no analytics configured, or consent not granted yet so
24
+ * the consent-gated script never loaded) -> silent no-op
25
+ *
26
+ * Consent stays the script layer's job: this helper never loads anything, it
27
+ * only talks to runtimes that already exist on the page.
28
+ */
29
+ type EcommerceEventName = "view_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "purchase";
30
+ type EcommerceItem = {
31
+ item_id: string;
32
+ item_name: string;
33
+ price?: number;
34
+ quantity?: number;
35
+ item_variant?: string;
36
+ item_category?: string;
37
+ };
38
+ type EcommercePayload = {
39
+ currency?: string;
40
+ /** Order / cart total in `currency`. */
41
+ value?: number;
42
+ /** Required for `purchase` — the order number. */
43
+ transaction_id?: string;
44
+ shipping?: number;
45
+ items: EcommerceItem[];
46
+ };
47
+ declare function trackEcommerceEvent(event: EcommerceEventName, payload: EcommercePayload): void;
48
+
49
+ export { type EcommerceEventName, type EcommerceItem, type EcommercePayload, formatPrice, trackEcommerceEvent };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as AddressSuggestion, a4 as AddressType, a5 as AddressTypes, L as AuthTokens, J as BackInStockSubscription, M as BehioApiError, a6 as BehioErrorCode, a7 as BehioEventHandler, a8 as BehioEventType, a9 as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, s as Bundle, N as BundleItem, g as Cart, aa as CartBundleLine, ab as CartBundleLineItem, T as CartDiscount, U as CartItem, ac as CartItemProduct, C as Category, e as CategoryDetail, V as CheckoutAddress, n as CheckoutInput, ad as CheckoutPaymentMethod, E as CookieConsent, H as CookieConsentInput, t as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ae as DataGroupFieldType, F as FilterField, X as FulfillmentStatus, af as FulfillmentStatuses, G as GiftCardBalance, ag as GiftCardSummary, Y as LoginInput, Z as MessageResponse, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, k as OrderDetail, _ as OrderItem, O as OrderListItem, $ as OrderStatus, ah as OrderStatusHistory, ai as OrderStatuses, aj as OrderTracking, p as Page, ak as PageAttachment, o as PageDetail, b as PaginatedResponse, a0 as PaymentStatus, al as PaymentStatuses, d as ProductDetail, f as ProductLabel, c as ProductListItem, am as ProductMedia, an as ProductMediaVariant, a1 as ProductPrice, a2 as ProductReview, v as ProductReviewsResponse, ao as ProductSort, ap as ProductSortValue, a3 as ProductVariant, aq as ProductVolumePrice, P as ProductsQuery, ar as QuoteItem, Q as QuoteRequest, R as RegisterInput, as as RequestInterceptor, at as RequestInterceptorConfig, au as ResponseInterceptor, av as ResponseInterceptorData, z as ReturnRequest, aw as ReturnRequestItem, y as ReturnStatus, ax as ReturnStatusItem, x as ReturnableOrder, ay as ReturnableOrderItem, az as SdkError, aA as SdkResult, aB as ShippingMethodSummary, aC as ShippingQuote, aD as ShippingQuoteInput, S as ShopInfo, aE as ShopScript, aF as ShopScriptPlacement, aG as ShopScriptType, q as ShopScripts, r as ShopSeo, I as SubmitQuoteInput, D as SubmitReturnInput, w as SubmitReviewInput, W as WishlistItem, aH as err, aI as ok, aJ as toSdkError } from './client-Bc6qvoIu.js';
1
+ export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as AddressSuggestion, a4 as AddressType, a5 as AddressTypes, L as AuthTokens, J as BackInStockSubscription, M as BehioApiError, a6 as BehioErrorCode, a7 as BehioEventHandler, a8 as BehioEventType, a9 as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, s as Bundle, N as BundleItem, g as Cart, aa as CartBundleLine, ab as CartBundleLineItem, T as CartDiscount, U as CartItem, ac as CartItemProduct, C as Category, e as CategoryDetail, V as CheckoutAddress, n as CheckoutInput, ad as CheckoutPaymentMethod, E as CookieConsent, H as CookieConsentInput, t as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ae as DataGroupFieldType, F as FilterField, X as FulfillmentStatus, af as FulfillmentStatuses, G as GiftCardBalance, ag as GiftCardSummary, Y as LoginInput, Z as MessageResponse, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, k as OrderDetail, _ as OrderItem, O as OrderListItem, $ as OrderStatus, ah as OrderStatusHistory, ai as OrderStatuses, aj as OrderTracking, p as Page, ak as PageAttachment, o as PageDetail, b as PaginatedResponse, a0 as PaymentStatus, al as PaymentStatuses, d as ProductDetail, f as ProductLabel, c as ProductListItem, am as ProductMedia, an as ProductMediaVariant, a1 as ProductPrice, a2 as ProductReview, v as ProductReviewsResponse, ao as ProductSort, ap as ProductSortValue, a3 as ProductVariant, aq as ProductVolumePrice, P as ProductsQuery, ar as QuoteItem, Q as QuoteRequest, R as RegisterInput, as as RegisterResult, at as RequestInterceptor, au as RequestInterceptorConfig, av as ResponseInterceptor, aw as ResponseInterceptorData, z as ReturnRequest, ax as ReturnRequestItem, y as ReturnStatus, ay as ReturnStatusItem, x as ReturnableOrder, az as ReturnableOrderItem, aA as SdkError, aB as SdkResult, aC as ShippingMethodSummary, aD as ShippingQuote, aE as ShippingQuoteInput, S as ShopInfo, aF as ShopScript, aG as ShopScriptPlacement, aH as ShopScriptType, q as ShopScripts, r as ShopSeo, I as SubmitQuoteInput, D as SubmitReturnInput, w as SubmitReviewInput, W as WishlistItem, aI as err, aJ as ok, aK as toSdkError } from './client-hCuGQERQ.js';
2
2
 
3
3
  /**
4
4
  * Format a price amount with currency using Intl.NumberFormat.
@@ -10,4 +10,40 @@ export { u as ActivePromotion, K as AddToCartInput, j as AddressDetail, A as Add
10
10
  */
11
11
  declare function formatPrice(amount: number, currency: string, locale?: string): string;
12
12
 
13
- export { formatPrice };
13
+ /**
14
+ * GA4 e-commerce event helper.
15
+ *
16
+ * Fires standard GA4 ecommerce events (view_item, add_to_cart, begin_checkout,
17
+ * purchase, ...) into whatever analytics runtime the shop has injected via
18
+ * `<StorefrontScripts/>`:
19
+ *
20
+ * - direct GA4 (`gtag` present) -> `gtag("event", name, payload)`
21
+ * - GTM (`dataLayer` array present) -> `dataLayer.push({event, ecommerce})`
22
+ * (with the recommended `ecommerce: null` reset push first)
23
+ * - neither present (no analytics configured, or consent not granted yet so
24
+ * the consent-gated script never loaded) -> silent no-op
25
+ *
26
+ * Consent stays the script layer's job: this helper never loads anything, it
27
+ * only talks to runtimes that already exist on the page.
28
+ */
29
+ type EcommerceEventName = "view_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "purchase";
30
+ type EcommerceItem = {
31
+ item_id: string;
32
+ item_name: string;
33
+ price?: number;
34
+ quantity?: number;
35
+ item_variant?: string;
36
+ item_category?: string;
37
+ };
38
+ type EcommercePayload = {
39
+ currency?: string;
40
+ /** Order / cart total in `currency`. */
41
+ value?: number;
42
+ /** Required for `purchase` — the order number. */
43
+ transaction_id?: string;
44
+ shipping?: number;
45
+ items: EcommerceItem[];
46
+ };
47
+ declare function trackEcommerceEvent(event: EcommerceEventName, payload: EcommercePayload): void;
48
+
49
+ export { type EcommerceEventName, type EcommerceItem, type EcommercePayload, formatPrice, trackEcommerceEvent };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkXWYDXBLGjs = require('./chunk-XWYDXBLG.js');
4
3
 
4
+ var _chunkBFF5BKR2js = require('./chunk-BFF5BKR2.js');
5
5
 
6
6
 
7
7
 
@@ -13,8 +13,8 @@ var _chunkXWYDXBLGjs = require('./chunk-XWYDXBLG.js');
13
13
 
14
14
 
15
15
 
16
- var _chunkS7YSZHHDjs = require('./chunk-S7YSZHHD.js');
17
16
 
17
+ var _chunkBF4YVFHXjs = require('./chunk-BF4YVFHX.js');
18
18
 
19
19
 
20
20
 
@@ -27,4 +27,6 @@ var _chunkS7YSZHHDjs = require('./chunk-S7YSZHHD.js');
27
27
 
28
28
 
29
29
 
30
- exports.AddressTypes = _chunkS7YSZHHDjs.AddressTypes; exports.BehioApiError = _chunkS7YSZHHDjs.BehioApiError; exports.BehioNetworkError = _chunkS7YSZHHDjs.BehioNetworkError; exports.BehioStorefront = _chunkS7YSZHHDjs.BehioStorefront; exports.FulfillmentStatuses = _chunkS7YSZHHDjs.FulfillmentStatuses; exports.OrderStatuses = _chunkS7YSZHHDjs.OrderStatuses; exports.PaymentStatuses = _chunkS7YSZHHDjs.PaymentStatuses; exports.ProductSort = _chunkS7YSZHHDjs.ProductSort; exports.err = _chunkS7YSZHHDjs.err; exports.formatPrice = _chunkXWYDXBLGjs.formatPrice; exports.ok = _chunkS7YSZHHDjs.ok; exports.toSdkError = _chunkS7YSZHHDjs.toSdkError;
30
+
31
+
32
+ exports.AddressTypes = _chunkBF4YVFHXjs.AddressTypes; exports.BehioApiError = _chunkBF4YVFHXjs.BehioApiError; exports.BehioNetworkError = _chunkBF4YVFHXjs.BehioNetworkError; exports.BehioStorefront = _chunkBF4YVFHXjs.BehioStorefront; exports.FulfillmentStatuses = _chunkBF4YVFHXjs.FulfillmentStatuses; exports.OrderStatuses = _chunkBF4YVFHXjs.OrderStatuses; exports.PaymentStatuses = _chunkBF4YVFHXjs.PaymentStatuses; exports.ProductSort = _chunkBF4YVFHXjs.ProductSort; exports.err = _chunkBF4YVFHXjs.err; exports.formatPrice = _chunkBFF5BKR2js.formatPrice; exports.ok = _chunkBF4YVFHXjs.ok; exports.toSdkError = _chunkBF4YVFHXjs.toSdkError; exports.trackEcommerceEvent = _chunkBFF5BKR2js.trackEcommerceEvent;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
- formatPrice
3
- } from "./chunk-YJ45WIQZ.mjs";
2
+ formatPrice,
3
+ trackEcommerceEvent
4
+ } from "./chunk-AN3QTDNM.mjs";
4
5
  import {
5
6
  AddressTypes,
6
7
  BehioApiError,
@@ -13,7 +14,7 @@ import {
13
14
  err,
14
15
  ok,
15
16
  toSdkError
16
- } from "./chunk-L62FH6WI.mjs";
17
+ } from "./chunk-PZED7VMQ.mjs";
17
18
  export {
18
19
  AddressTypes,
19
20
  BehioApiError,
@@ -26,5 +27,6 @@ export {
26
27
  err,
27
28
  formatPrice,
28
29
  ok,
29
- toSdkError
30
+ toSdkError,
31
+ trackEcommerceEvent
30
32
  };
package/dist/next.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-Bc6qvoIu.mjs';
1
+ import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-hCuGQERQ.mjs';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-Bc6qvoIu.js';
1
+ import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-hCuGQERQ.js';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkS7YSZHHDjs = require('./chunk-S7YSZHHD.js');
3
+ var _chunkBF4YVFHXjs = require('./chunk-BF4YVFHX.js');
4
4
 
5
5
  // src/next.ts
6
6
  var _headers = require('next/headers');
@@ -18,7 +18,7 @@ async function getBehio(options = {}) {
18
18
  const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
19
19
  const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
20
20
  const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
21
- const client = new (0, _chunkS7YSZHHDjs.BehioStorefront)({
21
+ const client = new (0, _chunkBF4YVFHXjs.BehioStorefront)({
22
22
  apiKey,
23
23
  ...baseUrl ? { baseUrl } : {},
24
24
  ...locale ? { locale } : {},
package/dist/next.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-L62FH6WI.mjs";
3
+ } from "./chunk-PZED7VMQ.mjs";
4
4
 
5
5
  // src/next.ts
6
6
  import { cookies } from "next/headers";
package/dist/react.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as ShopScripts, r as ShopSeo, s as Bundle, t as CrossSellItem, u as ActivePromotion, G as GiftCardBalance, W as WishlistItem, v as ProductReviewsResponse, w as SubmitReviewInput, x as ReturnableOrder, y as ReturnStatus, z as ReturnRequest, D as SubmitReturnInput, E as CookieConsent, H as CookieConsentInput, Q as QuoteRequest, I as SubmitQuoteInput, J as BackInStockSubscription } from './client-Bc6qvoIu.mjs';
5
- export { K as AddToCartInput, L as AuthTokens, M as BehioApiError, N as BundleItem, T as CartDiscount, U as CartItem, V as CheckoutAddress, X as FulfillmentStatus, Y as LoginInput, Z as MessageResponse, _ as OrderItem, $ as OrderStatus, a0 as PaymentStatus, a1 as ProductPrice, a2 as ProductReview, a3 as ProductVariant } from './client-Bc6qvoIu.mjs';
4
+ import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as ShopScripts, r as ShopSeo, s as Bundle, t as CrossSellItem, u as ActivePromotion, G as GiftCardBalance, W as WishlistItem, v as ProductReviewsResponse, w as SubmitReviewInput, x as ReturnableOrder, y as ReturnStatus, z as ReturnRequest, D as SubmitReturnInput, E as CookieConsent, H as CookieConsentInput, Q as QuoteRequest, I as SubmitQuoteInput, J as BackInStockSubscription } from './client-hCuGQERQ.mjs';
5
+ export { K as AddToCartInput, L as AuthTokens, M as BehioApiError, N as BundleItem, T as CartDiscount, U as CartItem, V as CheckoutAddress, X as FulfillmentStatus, Y as LoginInput, Z as MessageResponse, _ as OrderItem, $ as OrderStatus, a0 as PaymentStatus, a1 as ProductPrice, a2 as ProductReview, a3 as ProductVariant } from './client-hCuGQERQ.mjs';
6
6
  import * as _tanstack_query_core from '@tanstack/query-core';
7
- export { formatPrice } from './index.mjs';
7
+ export { EcommerceEventName, EcommerceItem, EcommercePayload, formatPrice, trackEcommerceEvent } from './index.mjs';
8
8
 
9
9
  interface StorageAdapter {
10
10
  get(key: string): string | null;
package/dist/react.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as ShopScripts, r as ShopSeo, s as Bundle, t as CrossSellItem, u as ActivePromotion, G as GiftCardBalance, W as WishlistItem, v as ProductReviewsResponse, w as SubmitReviewInput, x as ReturnableOrder, y as ReturnStatus, z as ReturnRequest, D as SubmitReturnInput, E as CookieConsent, H as CookieConsentInput, Q as QuoteRequest, I as SubmitQuoteInput, J as BackInStockSubscription } from './client-Bc6qvoIu.js';
5
- export { K as AddToCartInput, L as AuthTokens, M as BehioApiError, N as BundleItem, T as CartDiscount, U as CartItem, V as CheckoutAddress, X as FulfillmentStatus, Y as LoginInput, Z as MessageResponse, _ as OrderItem, $ as OrderStatus, a0 as PaymentStatus, a1 as ProductPrice, a2 as ProductReview, a3 as ProductVariant } from './client-Bc6qvoIu.js';
4
+ import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, O as OrderListItem, k as OrderDetail, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, n as CheckoutInput, o as PageDetail, p as Page, S as ShopInfo, q as ShopScripts, r as ShopSeo, s as Bundle, t as CrossSellItem, u as ActivePromotion, G as GiftCardBalance, W as WishlistItem, v as ProductReviewsResponse, w as SubmitReviewInput, x as ReturnableOrder, y as ReturnStatus, z as ReturnRequest, D as SubmitReturnInput, E as CookieConsent, H as CookieConsentInput, Q as QuoteRequest, I as SubmitQuoteInput, J as BackInStockSubscription } from './client-hCuGQERQ.js';
5
+ export { K as AddToCartInput, L as AuthTokens, M as BehioApiError, N as BundleItem, T as CartDiscount, U as CartItem, V as CheckoutAddress, X as FulfillmentStatus, Y as LoginInput, Z as MessageResponse, _ as OrderItem, $ as OrderStatus, a0 as PaymentStatus, a1 as ProductPrice, a2 as ProductReview, a3 as ProductVariant } from './client-hCuGQERQ.js';
6
6
  import * as _tanstack_query_core from '@tanstack/query-core';
7
- export { formatPrice } from './index.js';
7
+ export { EcommerceEventName, EcommerceItem, EcommercePayload, formatPrice, trackEcommerceEvent } from './index.js';
8
8
 
9
9
  interface StorageAdapter {
10
10
  get(key: string): string | null;
package/dist/react.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkXWYDXBLGjs = require('./chunk-XWYDXBLG.js');
4
3
 
4
+ var _chunkBFF5BKR2js = require('./chunk-BFF5BKR2.js');
5
5
 
6
- var _chunkS7YSZHHDjs = require('./chunk-S7YSZHHD.js');
6
+
7
+ var _chunkBF4YVFHXjs = require('./chunk-BF4YVFHX.js');
7
8
 
8
9
  // src/react/provider.tsx
9
10
  var _react = require('react');
@@ -133,7 +134,7 @@ function BehioProvider({
133
134
  const [activeCurrency, setActiveCurrency] = _react.useState.call(void 0, resolveInitialCurrency);
134
135
  const clientRef = _react.useRef.call(void 0, null);
135
136
  if (!clientRef.current) {
136
- clientRef.current = new (0, _chunkS7YSZHHDjs.BehioStorefront)({
137
+ clientRef.current = new (0, _chunkBF4YVFHXjs.BehioStorefront)({
137
138
  apiKey,
138
139
  baseUrl,
139
140
  ...shopDomain ? { shopDomain } : {},
@@ -635,9 +636,11 @@ function useAuth() {
635
636
  mutationFn: async (input) => {
636
637
  return unwrap(client.auth.register(input));
637
638
  },
638
- onSuccess: async (tokens) => {
639
- persistTokens(tokens);
640
- await postAuth();
639
+ onSuccess: async (result) => {
640
+ if (result.accessToken && result.refreshToken) {
641
+ persistTokens({ accessToken: result.accessToken, refreshToken: result.refreshToken });
642
+ await postAuth();
643
+ }
641
644
  }
642
645
  });
643
646
  const logoutMutation = _reactquery.useMutation.call(void 0, {
@@ -1487,4 +1490,5 @@ function useBehioClient() {
1487
1490
 
1488
1491
 
1489
1492
 
1490
- exports.BehioProvider = BehioProvider; exports.CurrencySwitcher = CurrencySwitcher; exports.StorefrontScripts = StorefrontScripts; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = _chunkXWYDXBLGjs.formatPrice; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.useAddressAutocomplete = useAddressAutocomplete; exports.useAddresses = useAddresses; exports.useAuth = useAuth; exports.useBehio = useBehio; exports.useBehioClient = useBehioClient; exports.useBundle = useBundle; exports.useBundles = useBundles; exports.useCart = useCart; exports.useCartCount = useCartCount; exports.useCategories = useCategories; exports.useCategory = useCategory; exports.useCheckout = useCheckout; exports.useCookieConsent = useCookieConsent; exports.useCrossSell = useCrossSell; exports.useCurrency = useCurrency; exports.useCustomer = useCustomer; exports.useFeatured = useFeatured; exports.useFilters = useFilters; exports.useGiftCardBalance = useGiftCardBalance; exports.useIsInWishlist = useIsInWishlist; exports.useLabels = useLabels; exports.useLookupReturnableOrder = useLookupReturnableOrder; exports.useNotifyWhenAvailable = useNotifyWhenAvailable; exports.useOrder = useOrder; exports.useOrderAccess = useOrderAccess; exports.useOrders = useOrders; exports.usePage = usePage; exports.usePages = usePages; exports.useProduct = useProduct; exports.useProductPromotions = useProductPromotions; exports.useProductReviews = useProductReviews; exports.useProducts = useProducts; exports.useQuoteStatus = useQuoteStatus; exports.useReturnStatus = useReturnStatus; exports.useSearch = useSearch; exports.useShopInfo = useShopInfo; exports.useShopScripts = useShopScripts; exports.useShopSeo = useShopSeo; exports.useSubmitQuote = useSubmitQuote; exports.useSubmitReturn = useSubmitReturn; exports.useSubmitReview = useSubmitReview; exports.useWishlist = useWishlist;
1493
+
1494
+ exports.BehioProvider = BehioProvider; exports.CurrencySwitcher = CurrencySwitcher; exports.StorefrontScripts = StorefrontScripts; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = _chunkBFF5BKR2js.formatPrice; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.trackEcommerceEvent = _chunkBFF5BKR2js.trackEcommerceEvent; exports.useAddressAutocomplete = useAddressAutocomplete; exports.useAddresses = useAddresses; exports.useAuth = useAuth; exports.useBehio = useBehio; exports.useBehioClient = useBehioClient; exports.useBundle = useBundle; exports.useBundles = useBundles; exports.useCart = useCart; exports.useCartCount = useCartCount; exports.useCategories = useCategories; exports.useCategory = useCategory; exports.useCheckout = useCheckout; exports.useCookieConsent = useCookieConsent; exports.useCrossSell = useCrossSell; exports.useCurrency = useCurrency; exports.useCustomer = useCustomer; exports.useFeatured = useFeatured; exports.useFilters = useFilters; exports.useGiftCardBalance = useGiftCardBalance; exports.useIsInWishlist = useIsInWishlist; exports.useLabels = useLabels; exports.useLookupReturnableOrder = useLookupReturnableOrder; exports.useNotifyWhenAvailable = useNotifyWhenAvailable; exports.useOrder = useOrder; exports.useOrderAccess = useOrderAccess; exports.useOrders = useOrders; exports.usePage = usePage; exports.usePages = usePages; exports.useProduct = useProduct; exports.useProductPromotions = useProductPromotions; exports.useProductReviews = useProductReviews; exports.useProducts = useProducts; exports.useQuoteStatus = useQuoteStatus; exports.useReturnStatus = useReturnStatus; exports.useSearch = useSearch; exports.useShopInfo = useShopInfo; exports.useShopScripts = useShopScripts; exports.useShopSeo = useShopSeo; exports.useSubmitQuote = useSubmitQuote; exports.useSubmitReturn = useSubmitReturn; exports.useSubmitReview = useSubmitReview; exports.useWishlist = useWishlist;
package/dist/react.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
- formatPrice
3
- } from "./chunk-YJ45WIQZ.mjs";
2
+ formatPrice,
3
+ trackEcommerceEvent
4
+ } from "./chunk-AN3QTDNM.mjs";
4
5
  import {
5
6
  BehioStorefront
6
- } from "./chunk-L62FH6WI.mjs";
7
+ } from "./chunk-PZED7VMQ.mjs";
7
8
 
8
9
  // src/react/provider.tsx
9
10
  import { useRef, useEffect, useMemo, useState, useCallback } from "react";
@@ -635,9 +636,11 @@ function useAuth() {
635
636
  mutationFn: async (input) => {
636
637
  return unwrap(client.auth.register(input));
637
638
  },
638
- onSuccess: async (tokens) => {
639
- persistTokens(tokens);
640
- await postAuth();
639
+ onSuccess: async (result) => {
640
+ if (result.accessToken && result.refreshToken) {
641
+ persistTokens({ accessToken: result.accessToken, refreshToken: result.refreshToken });
642
+ await postAuth();
643
+ }
641
644
  }
642
645
  });
643
646
  const logoutMutation = useMutation2({
@@ -1445,6 +1448,7 @@ export {
1445
1448
  formatPrice,
1446
1449
  localStorageAdapter,
1447
1450
  memoryStorage,
1451
+ trackEcommerceEvent,
1448
1452
  useAddressAutocomplete,
1449
1453
  useAddresses,
1450
1454
  useAuth,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "TypeScript SDK for Behio Headless E-Shop — core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",
@@ -1,18 +0,0 @@
1
- // src/react/utils/format-price.ts
2
- function formatPrice(amount, currency, locale) {
3
- const resolvedLocale = locale ?? "cs";
4
- try {
5
- return new Intl.NumberFormat(resolvedLocale, {
6
- style: "currency",
7
- currency,
8
- minimumFractionDigits: Number.isInteger(amount) ? 0 : 2,
9
- maximumFractionDigits: 2
10
- }).format(amount);
11
- } catch {
12
- return `${amount} ${currency}`;
13
- }
14
- }
15
-
16
- export {
17
- formatPrice
18
- };