@behio/storefront-sdk 0.33.0 → 0.34.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.
- package/dist/chunk-CZRSJULD.js +118 -0
- package/dist/chunk-QUU76QUB.mjs +118 -0
- package/dist/{client-BQlF_Vn9.d.mts → client-DdaC0_6x.d.mts} +5 -1
- package/dist/{client-BQlF_Vn9.d.ts → client-DdaC0_6x.d.ts} +5 -1
- package/dist/index.d.mts +86 -8
- package/dist/index.d.ts +86 -8
- package/dist/index.js +10 -2
- package/dist/index.mjs +9 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +69 -34
- package/dist/react.mjs +46 -11
- package/package.json +1 -1
- package/dist/chunk-JIAOZ5YW.js +0 -40
- package/dist/chunk-ZOZAJG6T.mjs +0 -40
|
@@ -0,0 +1,118 @@
|
|
|
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; }// src/react/utils/format-price.ts
|
|
2
|
+
function formatPrice(amount, currency, locale) {
|
|
3
|
+
const resolvedLocale = _nullishCoalesce(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 (e) {
|
|
12
|
+
return `${amount} ${currency}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/analytics.ts
|
|
17
|
+
var GA4_NAME_MAP = {
|
|
18
|
+
newsletter_signup: "generate_lead"
|
|
19
|
+
};
|
|
20
|
+
function trackEcommerceEvent(event, payload) {
|
|
21
|
+
if (typeof window === "undefined") return;
|
|
22
|
+
const w = window;
|
|
23
|
+
try {
|
|
24
|
+
_optionalChain([w, 'access', _ => _.__behioEcommerceSink, 'optionalCall', _2 => _2(event, payload)]);
|
|
25
|
+
} catch (e2) {
|
|
26
|
+
}
|
|
27
|
+
const gaName = _nullishCoalesce(GA4_NAME_MAP[event], () => ( event));
|
|
28
|
+
try {
|
|
29
|
+
if (typeof w.gtag === "function") {
|
|
30
|
+
w.gtag("event", gaName, payload);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(w.dataLayer)) {
|
|
34
|
+
w.dataLayer.push({ ecommerce: null });
|
|
35
|
+
w.dataLayer.push({ event: gaName, ecommerce: payload });
|
|
36
|
+
}
|
|
37
|
+
} catch (e3) {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/consent-visitor.ts
|
|
42
|
+
var VISITOR_KEY = "behio_visitor_id";
|
|
43
|
+
var COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
|
|
44
|
+
function getStoredVisitorId() {
|
|
45
|
+
if (typeof window === "undefined") return null;
|
|
46
|
+
try {
|
|
47
|
+
const ls = localStorage.getItem(VISITOR_KEY);
|
|
48
|
+
if (ls) return ls;
|
|
49
|
+
} catch (e4) {
|
|
50
|
+
}
|
|
51
|
+
return readCookie(VISITOR_KEY);
|
|
52
|
+
}
|
|
53
|
+
function generateVisitorId() {
|
|
54
|
+
const bytes = new Uint8Array(18);
|
|
55
|
+
try {
|
|
56
|
+
_optionalChain([globalThis, 'access', _3 => _3.crypto, 'optionalAccess', _4 => _4.getRandomValues, 'optionalCall', _5 => _5(bytes)]);
|
|
57
|
+
} catch (e5) {
|
|
58
|
+
}
|
|
59
|
+
let filled = false;
|
|
60
|
+
for (const b of bytes) if (b !== 0) filled = true;
|
|
61
|
+
if (!filled) for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
62
|
+
let bin = "";
|
|
63
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
64
|
+
const b64 = typeof btoa === "function" ? btoa(bin) : Buffer.from(bytes).toString("base64");
|
|
65
|
+
return `v${b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}`.slice(0, 40);
|
|
66
|
+
}
|
|
67
|
+
function writeVisitorId(id) {
|
|
68
|
+
if (typeof window === "undefined") return;
|
|
69
|
+
try {
|
|
70
|
+
localStorage.setItem(VISITOR_KEY, id);
|
|
71
|
+
} catch (e6) {
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
document.cookie = `${VISITOR_KEY}=${encodeURIComponent(id)}; path=/; max-age=${COOKIE_MAX_AGE}; SameSite=Lax`;
|
|
75
|
+
} catch (e7) {
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function readCookie(name) {
|
|
79
|
+
if (typeof document === "undefined") return null;
|
|
80
|
+
const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
|
|
81
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
82
|
+
}
|
|
83
|
+
function emitConsentChanged() {
|
|
84
|
+
if (typeof window === "undefined") return;
|
|
85
|
+
try {
|
|
86
|
+
window.dispatchEvent(new Event("behio:consent-changed"));
|
|
87
|
+
} catch (e8) {
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function grantAnalyticsConsent(client, categories) {
|
|
91
|
+
const id = _nullishCoalesce(getStoredVisitorId(), () => ( generateVisitorId()));
|
|
92
|
+
writeVisitorId(id);
|
|
93
|
+
client.setAnalyticsVisitorId(id);
|
|
94
|
+
const res = await client.consent.record({
|
|
95
|
+
visitorId: id,
|
|
96
|
+
analytics: true,
|
|
97
|
+
marketing: _nullishCoalesce(_optionalChain([categories, 'optionalAccess', _6 => _6.marketing]), () => ( false)),
|
|
98
|
+
preferences: _nullishCoalesce(_optionalChain([categories, 'optionalAccess', _7 => _7.preferences]), () => ( false))
|
|
99
|
+
});
|
|
100
|
+
emitConsentChanged();
|
|
101
|
+
return res;
|
|
102
|
+
}
|
|
103
|
+
async function revokeAnalyticsConsent(client) {
|
|
104
|
+
const id = getStoredVisitorId();
|
|
105
|
+
client.setAnalyticsVisitorId(null);
|
|
106
|
+
emitConsentChanged();
|
|
107
|
+
if (!id) return { data: { success: true }, error: null };
|
|
108
|
+
return client.consent.revoke(id);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
exports.formatPrice = formatPrice; exports.trackEcommerceEvent = trackEcommerceEvent; exports.getStoredVisitorId = getStoredVisitorId; exports.generateVisitorId = generateVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent;
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
var GA4_NAME_MAP = {
|
|
18
|
+
newsletter_signup: "generate_lead"
|
|
19
|
+
};
|
|
20
|
+
function trackEcommerceEvent(event, payload) {
|
|
21
|
+
if (typeof window === "undefined") return;
|
|
22
|
+
const w = window;
|
|
23
|
+
try {
|
|
24
|
+
w.__behioEcommerceSink?.(event, payload);
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
const gaName = GA4_NAME_MAP[event] ?? event;
|
|
28
|
+
try {
|
|
29
|
+
if (typeof w.gtag === "function") {
|
|
30
|
+
w.gtag("event", gaName, payload);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(w.dataLayer)) {
|
|
34
|
+
w.dataLayer.push({ ecommerce: null });
|
|
35
|
+
w.dataLayer.push({ event: gaName, ecommerce: payload });
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/consent-visitor.ts
|
|
42
|
+
var VISITOR_KEY = "behio_visitor_id";
|
|
43
|
+
var COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
|
|
44
|
+
function getStoredVisitorId() {
|
|
45
|
+
if (typeof window === "undefined") return null;
|
|
46
|
+
try {
|
|
47
|
+
const ls = localStorage.getItem(VISITOR_KEY);
|
|
48
|
+
if (ls) return ls;
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
return readCookie(VISITOR_KEY);
|
|
52
|
+
}
|
|
53
|
+
function generateVisitorId() {
|
|
54
|
+
const bytes = new Uint8Array(18);
|
|
55
|
+
try {
|
|
56
|
+
globalThis.crypto?.getRandomValues?.(bytes);
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
let filled = false;
|
|
60
|
+
for (const b of bytes) if (b !== 0) filled = true;
|
|
61
|
+
if (!filled) for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
62
|
+
let bin = "";
|
|
63
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
64
|
+
const b64 = typeof btoa === "function" ? btoa(bin) : Buffer.from(bytes).toString("base64");
|
|
65
|
+
return `v${b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}`.slice(0, 40);
|
|
66
|
+
}
|
|
67
|
+
function writeVisitorId(id) {
|
|
68
|
+
if (typeof window === "undefined") return;
|
|
69
|
+
try {
|
|
70
|
+
localStorage.setItem(VISITOR_KEY, id);
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
document.cookie = `${VISITOR_KEY}=${encodeURIComponent(id)}; path=/; max-age=${COOKIE_MAX_AGE}; SameSite=Lax`;
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function readCookie(name) {
|
|
79
|
+
if (typeof document === "undefined") return null;
|
|
80
|
+
const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
|
|
81
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
82
|
+
}
|
|
83
|
+
function emitConsentChanged() {
|
|
84
|
+
if (typeof window === "undefined") return;
|
|
85
|
+
try {
|
|
86
|
+
window.dispatchEvent(new Event("behio:consent-changed"));
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function grantAnalyticsConsent(client, categories) {
|
|
91
|
+
const id = getStoredVisitorId() ?? generateVisitorId();
|
|
92
|
+
writeVisitorId(id);
|
|
93
|
+
client.setAnalyticsVisitorId(id);
|
|
94
|
+
const res = await client.consent.record({
|
|
95
|
+
visitorId: id,
|
|
96
|
+
analytics: true,
|
|
97
|
+
marketing: categories?.marketing ?? false,
|
|
98
|
+
preferences: categories?.preferences ?? false
|
|
99
|
+
});
|
|
100
|
+
emitConsentChanged();
|
|
101
|
+
return res;
|
|
102
|
+
}
|
|
103
|
+
async function revokeAnalyticsConsent(client) {
|
|
104
|
+
const id = getStoredVisitorId();
|
|
105
|
+
client.setAnalyticsVisitorId(null);
|
|
106
|
+
emitConsentChanged();
|
|
107
|
+
if (!id) return { data: { success: true }, error: null };
|
|
108
|
+
return client.consent.revoke(id);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
formatPrice,
|
|
113
|
+
trackEcommerceEvent,
|
|
114
|
+
getStoredVisitorId,
|
|
115
|
+
generateVisitorId,
|
|
116
|
+
grantAnalyticsConsent,
|
|
117
|
+
revokeAnalyticsConsent
|
|
118
|
+
};
|
|
@@ -1754,6 +1754,10 @@ declare class BehioStorefront {
|
|
|
1754
1754
|
utmSource?: string;
|
|
1755
1755
|
utmMedium?: string;
|
|
1756
1756
|
utmCampaign?: string;
|
|
1757
|
+
utmTerm?: string;
|
|
1758
|
+
utmContent?: string;
|
|
1759
|
+
gclid?: string;
|
|
1760
|
+
fbclid?: string;
|
|
1757
1761
|
dwellMs?: number;
|
|
1758
1762
|
value?: number;
|
|
1759
1763
|
currency?: string;
|
|
@@ -2310,4 +2314,4 @@ declare class NewsletterModule {
|
|
|
2310
2314
|
unsubscribe(email: string): Promise<SdkResult<NewsletterUnsubscribeResult>>;
|
|
2311
2315
|
}
|
|
2312
2316
|
|
|
2313
|
-
export { type QuoteRequest as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type ShopScripts as D, type ShopSeo as E, type FilterField as F, type Bundle as G, type ProductGroup as H, type CrossSellItem as I, type ActivePromotion as J, type GiftCardBalance as K, type LoyaltySummary as L, type Menu as M, type NewsletterSubscribeResult as N, type OrderListItem as O, type ProductsQuery as P, type ProductReviewsResponse as Q, type RegisterInput as R, type Subscription as S, type SubmitReviewInput as T, type ReturnableOrder as U, type ReturnStatus as V, type WishlistItem as W, type ReturnRequest as X, type SubmitReturnInput as Y, type CookieConsent as Z, type CookieConsentInput as _, BehioStorefront as a, type
|
|
2317
|
+
export { type QuoteRequest as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type ShopScripts as D, type ShopSeo as E, type FilterField as F, type Bundle as G, type ProductGroup as H, type CrossSellItem as I, type ActivePromotion as J, type GiftCardBalance as K, type LoyaltySummary as L, type Menu as M, type NewsletterSubscribeResult as N, type OrderListItem as O, type ProductsQuery as P, type ProductReviewsResponse as Q, type RegisterInput as R, type Subscription as S, type SubmitReviewInput as T, type ReturnableOrder as U, type ReturnStatus as V, type WishlistItem as W, type ReturnRequest as X, type SubmitReturnInput as Y, type CookieConsent as Z, type CookieConsentInput as _, BehioStorefront as a, type ProductVolumePrice as a$, type SubmitQuoteInput as a0, type BackInStockSubscription as a1, type AddToCartInput as a2, type AuthTokens as a3, BehioApiError as a4, type BundleItem as a5, type CartDiscount as a6, type CartItem as a7, type CheckoutAddress as a8, type FulfillmentStatus as a9, type GiftCardPurchaseResult as aA, type GiftCardSummary as aB, type LoyaltyBalance as aC, type LoyaltyNextTier as aD, type LoyaltyProgram as aE, type LoyaltyTier as aF, type LoyaltyTierPerks as aG, type LoyaltyTransaction as aH, type MenuItem as aI, type MenuItemRef as aJ, type MenuItemType as aK, type NewsletterOptInDefault as aL, type OrderStatusHistory as aM, OrderStatuses as aN, type OrderTracking as aO, type PageAttachment as aP, PaymentStatuses as aQ, type PickupPointHours as aR, type PriceDisplay as aS, type ProductAvailability as aT, type ProductCustomField as aU, type ProductCustomFieldGroup as aV, type ProductMedia as aW, type ProductMediaVariant as aX, type ProductPromotionSummary as aY, ProductSort as aZ, type ProductSortValue as a_, type LoginInput as aa, type MessageResponse as ab, type OrderItem as ac, type OrderStatus as ad, type PaymentStatus as ae, type ProductPrice as af, type ProductReview as ag, type ProductVariant as ah, type SdkResult as ai, type AddressType as aj, AddressTypes as ak, type BadgeTone as al, type BehioErrorCode as am, type BehioEventHandler as an, type BehioEventType as ao, BehioNetworkError as ap, type CartBundleLine as aq, type CartBundleLineItem as ar, type CartItemProduct as as, type CartPromotion as at, type CheckoutSettings as au, type DataGroupFieldType as av, type DigitalDownload as aw, type DownloadUrl as ax, FulfillmentStatuses as ay, type GiftCardPurchaseInput as az, type PaginatedResponse as b, type QuoteItem as b0, type RegisterResult as b1, type RequestInterceptor as b2, type RequestInterceptorConfig as b3, type ResponseInterceptor as b4, type ResponseInterceptorData as b5, type ReturnRequestItem as b6, type ReturnStatusItem as b7, type ReturnableOrderItem as b8, type SdkError as b9, type ShopScript as ba, type ShopScriptPlacement as bb, type ShopScriptType as bc, type ShopSeoIdentity as bd, type StockBehavior as be, type SubscriptionFrequency as bf, type SubscriptionItem as bg, type SubscriptionStatus as bh, type TaxBreakdownLine as bi, type VariantAxis as bj, type VariantAxisValue as bk, err as bl, ok as bm, toSdkError as bn, 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 SubscriptionAction as k, type PickupPointsInput as l, type PickupPoint as m, type ShippingMethodSummary as n, type ShippingQuoteInput as o, type ShippingQuote as p, type CheckoutPaymentMethod as q, type NewsletterSubscribeInput as r, type NewsletterUnsubscribeResult as s, type OrderDetail as t, type OrderAccessRequestResponse as u, type OrderAccessVerifyResponse as v, type CheckoutInput as w, type PageDetail as x, type Page as y, type ShopInfo as z };
|
|
@@ -1754,6 +1754,10 @@ declare class BehioStorefront {
|
|
|
1754
1754
|
utmSource?: string;
|
|
1755
1755
|
utmMedium?: string;
|
|
1756
1756
|
utmCampaign?: string;
|
|
1757
|
+
utmTerm?: string;
|
|
1758
|
+
utmContent?: string;
|
|
1759
|
+
gclid?: string;
|
|
1760
|
+
fbclid?: string;
|
|
1757
1761
|
dwellMs?: number;
|
|
1758
1762
|
value?: number;
|
|
1759
1763
|
currency?: string;
|
|
@@ -2310,4 +2314,4 @@ declare class NewsletterModule {
|
|
|
2310
2314
|
unsubscribe(email: string): Promise<SdkResult<NewsletterUnsubscribeResult>>;
|
|
2311
2315
|
}
|
|
2312
2316
|
|
|
2313
|
-
export { type QuoteRequest as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type ShopScripts as D, type ShopSeo as E, type FilterField as F, type Bundle as G, type ProductGroup as H, type CrossSellItem as I, type ActivePromotion as J, type GiftCardBalance as K, type LoyaltySummary as L, type Menu as M, type NewsletterSubscribeResult as N, type OrderListItem as O, type ProductsQuery as P, type ProductReviewsResponse as Q, type RegisterInput as R, type Subscription as S, type SubmitReviewInput as T, type ReturnableOrder as U, type ReturnStatus as V, type WishlistItem as W, type ReturnRequest as X, type SubmitReturnInput as Y, type CookieConsent as Z, type CookieConsentInput as _, BehioStorefront as a, type
|
|
2317
|
+
export { type QuoteRequest as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type ShopScripts as D, type ShopSeo as E, type FilterField as F, type Bundle as G, type ProductGroup as H, type CrossSellItem as I, type ActivePromotion as J, type GiftCardBalance as K, type LoyaltySummary as L, type Menu as M, type NewsletterSubscribeResult as N, type OrderListItem as O, type ProductsQuery as P, type ProductReviewsResponse as Q, type RegisterInput as R, type Subscription as S, type SubmitReviewInput as T, type ReturnableOrder as U, type ReturnStatus as V, type WishlistItem as W, type ReturnRequest as X, type SubmitReturnInput as Y, type CookieConsent as Z, type CookieConsentInput as _, BehioStorefront as a, type ProductVolumePrice as a$, type SubmitQuoteInput as a0, type BackInStockSubscription as a1, type AddToCartInput as a2, type AuthTokens as a3, BehioApiError as a4, type BundleItem as a5, type CartDiscount as a6, type CartItem as a7, type CheckoutAddress as a8, type FulfillmentStatus as a9, type GiftCardPurchaseResult as aA, type GiftCardSummary as aB, type LoyaltyBalance as aC, type LoyaltyNextTier as aD, type LoyaltyProgram as aE, type LoyaltyTier as aF, type LoyaltyTierPerks as aG, type LoyaltyTransaction as aH, type MenuItem as aI, type MenuItemRef as aJ, type MenuItemType as aK, type NewsletterOptInDefault as aL, type OrderStatusHistory as aM, OrderStatuses as aN, type OrderTracking as aO, type PageAttachment as aP, PaymentStatuses as aQ, type PickupPointHours as aR, type PriceDisplay as aS, type ProductAvailability as aT, type ProductCustomField as aU, type ProductCustomFieldGroup as aV, type ProductMedia as aW, type ProductMediaVariant as aX, type ProductPromotionSummary as aY, ProductSort as aZ, type ProductSortValue as a_, type LoginInput as aa, type MessageResponse as ab, type OrderItem as ac, type OrderStatus as ad, type PaymentStatus as ae, type ProductPrice as af, type ProductReview as ag, type ProductVariant as ah, type SdkResult as ai, type AddressType as aj, AddressTypes as ak, type BadgeTone as al, type BehioErrorCode as am, type BehioEventHandler as an, type BehioEventType as ao, BehioNetworkError as ap, type CartBundleLine as aq, type CartBundleLineItem as ar, type CartItemProduct as as, type CartPromotion as at, type CheckoutSettings as au, type DataGroupFieldType as av, type DigitalDownload as aw, type DownloadUrl as ax, FulfillmentStatuses as ay, type GiftCardPurchaseInput as az, type PaginatedResponse as b, type QuoteItem as b0, type RegisterResult as b1, type RequestInterceptor as b2, type RequestInterceptorConfig as b3, type ResponseInterceptor as b4, type ResponseInterceptorData as b5, type ReturnRequestItem as b6, type ReturnStatusItem as b7, type ReturnableOrderItem as b8, type SdkError as b9, type ShopScript as ba, type ShopScriptPlacement as bb, type ShopScriptType as bc, type ShopSeoIdentity as bd, type StockBehavior as be, type SubscriptionFrequency as bf, type SubscriptionItem as bg, type SubscriptionStatus as bh, type TaxBreakdownLine as bi, type VariantAxis as bj, type VariantAxisValue as bk, err as bl, ok as bm, toSdkError as bn, 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 SubscriptionAction as k, type PickupPointsInput as l, type PickupPoint as m, type ShippingMethodSummary as n, type ShippingQuoteInput as o, type ShippingQuote as p, type CheckoutPaymentMethod as q, type NewsletterSubscribeInput as r, type NewsletterUnsubscribeResult as s, type OrderDetail as t, type OrderAccessRequestResponse as u, type OrderAccessVerifyResponse as v, type CheckoutInput as w, type PageDetail as x, type Page as y, type ShopInfo as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as BehioStorefront, ai as SdkResult, Z as CookieConsent } from './client-DdaC0_6x.mjs';
|
|
2
|
+
export { J as ActivePromotion, a2 as AddToCartInput, j as AddressDetail, A as AddressSuggestion, aj as AddressType, ak as AddressTypes, a3 as AuthTokens, a1 as BackInStockSubscription, al as BadgeTone, a4 as BehioApiError, am as BehioErrorCode, an as BehioEventHandler, ao as BehioEventType, ap as BehioNetworkError, B as BehioStorefrontConfig, G as Bundle, a5 as BundleItem, g as Cart, aq as CartBundleLine, ar as CartBundleLineItem, a6 as CartDiscount, a7 as CartItem, as as CartItemProduct, at as CartPromotion, C as Category, e as CategoryDetail, a8 as CheckoutAddress, w as CheckoutInput, q as CheckoutPaymentMethod, au as CheckoutSettings, _ as CookieConsentInput, I as CrossSellItem, i as CustomerAddress, h as CustomerProfile, av as DataGroupFieldType, aw as DigitalDownload, ax as DownloadUrl, F as FilterField, a9 as FulfillmentStatus, ay as FulfillmentStatuses, K as GiftCardBalance, az as GiftCardPurchaseInput, aA as GiftCardPurchaseResult, aB as GiftCardSummary, aa as LoginInput, aC as LoyaltyBalance, aD as LoyaltyNextTier, aE as LoyaltyProgram, L as LoyaltySummary, aF as LoyaltyTier, aG as LoyaltyTierPerks, aH as LoyaltyTransaction, M as Menu, aI as MenuItem, aJ as MenuItemRef, aK as MenuItemType, ab as MessageResponse, aL as NewsletterOptInDefault, r as NewsletterSubscribeInput, N as NewsletterSubscribeResult, s as NewsletterUnsubscribeResult, u as OrderAccessRequestResponse, v as OrderAccessVerifyResponse, t as OrderDetail, ac as OrderItem, O as OrderListItem, ad as OrderStatus, aM as OrderStatusHistory, aN as OrderStatuses, aO as OrderTracking, y as Page, aP as PageAttachment, x as PageDetail, b as PaginatedResponse, ae as PaymentStatus, aQ as PaymentStatuses, m as PickupPoint, aR as PickupPointHours, l as PickupPointsInput, aS as PriceDisplay, aT as ProductAvailability, aU as ProductCustomField, aV as ProductCustomFieldGroup, d as ProductDetail, H as ProductGroup, f as ProductLabel, c as ProductListItem, aW as ProductMedia, aX as ProductMediaVariant, af as ProductPrice, aY as ProductPromotionSummary, ag as ProductReview, Q as ProductReviewsResponse, aZ as ProductSort, a_ as ProductSortValue, ah as ProductVariant, a$ as ProductVolumePrice, P as ProductsQuery, b0 as QuoteItem, $ as QuoteRequest, R as RegisterInput, b1 as RegisterResult, b2 as RequestInterceptor, b3 as RequestInterceptorConfig, b4 as ResponseInterceptor, b5 as ResponseInterceptorData, X as ReturnRequest, b6 as ReturnRequestItem, V as ReturnStatus, b7 as ReturnStatusItem, U as ReturnableOrder, b8 as ReturnableOrderItem, b9 as SdkError, n as ShippingMethodSummary, p as ShippingQuote, o as ShippingQuoteInput, z as ShopInfo, ba as ShopScript, bb as ShopScriptPlacement, bc as ShopScriptType, D as ShopScripts, E as ShopSeo, bd as ShopSeoIdentity, be as StockBehavior, a0 as SubmitQuoteInput, Y as SubmitReturnInput, T as SubmitReviewInput, S as Subscription, k as SubscriptionAction, bf as SubscriptionFrequency, bg as SubscriptionItem, bh as SubscriptionStatus, bi as TaxBreakdownLine, bj as VariantAxis, bk as VariantAxisValue, W as WishlistItem, bl as err, bm as ok, bn as toSdkError } from './client-DdaC0_6x.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Format a price amount with currency using Intl.NumberFormat.
|
|
@@ -13,20 +14,29 @@ declare function formatPrice(amount: number, currency: string, locale?: string):
|
|
|
13
14
|
/**
|
|
14
15
|
* GA4 e-commerce event helper.
|
|
15
16
|
*
|
|
16
|
-
* Fires standard GA4 ecommerce events (view_item, add_to_cart,
|
|
17
|
-
* purchase, ...) into whatever analytics runtime the
|
|
18
|
-
* `<StorefrontScripts
|
|
17
|
+
* Fires standard GA4 ecommerce/engagement events (view_item, add_to_cart,
|
|
18
|
+
* begin_checkout, purchase, search, ...) into whatever analytics runtime the
|
|
19
|
+
* shop has injected via `<StorefrontScripts/>`, and — crucially — into Behio
|
|
20
|
+
* Analytics via the sink the tracker registers. One call, both systems.
|
|
19
21
|
*
|
|
22
|
+
* Sinks:
|
|
23
|
+
* - Behio Analytics (`__behioEcommerceSink`) — always, when the tracker is
|
|
24
|
+
* mounted. Records the ORIGINAL event name so Behio-exclusive signals
|
|
25
|
+
* (variant_selected, newsletter_signup) stay distinct.
|
|
20
26
|
* - direct GA4 (`gtag` present) -> `gtag("event", name, payload)`
|
|
21
27
|
* - GTM (`dataLayer` array present) -> `dataLayer.push({event, ecommerce})`
|
|
22
28
|
* (with the recommended `ecommerce: null` reset push first)
|
|
23
29
|
* - neither present (no analytics configured, or consent not granted yet so
|
|
24
|
-
* the consent-gated script never loaded) -> silent no-op
|
|
30
|
+
* the consent-gated script never loaded) -> silent no-op for the GA path
|
|
31
|
+
*
|
|
32
|
+
* Behio-only signal names that have a GA4 recommended equivalent are remapped
|
|
33
|
+
* for the GA path only (see `GA4_NAME_MAP`), so merchants keep clean GA4
|
|
34
|
+
* reports while Behio keeps the richer signal.
|
|
25
35
|
*
|
|
26
36
|
* Consent stays the script layer's job: this helper never loads anything, it
|
|
27
37
|
* only talks to runtimes that already exist on the page.
|
|
28
38
|
*/
|
|
29
|
-
type EcommerceEventName = "view_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "purchase";
|
|
39
|
+
type EcommerceEventName = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "add_to_wishlist" | "view_promotion" | "select_promotion" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "search" | "generate_lead" | "purchase" | "variant_selected" | "newsletter_signup";
|
|
30
40
|
type EcommerceItem = {
|
|
31
41
|
item_id: string;
|
|
32
42
|
item_name: string;
|
|
@@ -34,6 +44,8 @@ type EcommerceItem = {
|
|
|
34
44
|
quantity?: number;
|
|
35
45
|
item_variant?: string;
|
|
36
46
|
item_category?: string;
|
|
47
|
+
/** Position in the list (1-based) — for select_item rail/list attribution. */
|
|
48
|
+
index?: number;
|
|
37
49
|
};
|
|
38
50
|
type EcommercePayload = {
|
|
39
51
|
currency?: string;
|
|
@@ -42,8 +54,74 @@ type EcommercePayload = {
|
|
|
42
54
|
/** Required for `purchase` — the order number. */
|
|
43
55
|
transaction_id?: string;
|
|
44
56
|
shipping?: number;
|
|
45
|
-
|
|
57
|
+
/** Optional for non-item events (search, add_shipping_info, newsletter). */
|
|
58
|
+
items?: EcommerceItem[];
|
|
59
|
+
/** search event: the query string. */
|
|
60
|
+
search_term?: string;
|
|
61
|
+
/** add_shipping_info: the selected shipping method label. */
|
|
62
|
+
shipping_tier?: string;
|
|
63
|
+
/** add_payment_info: the selected payment method type. */
|
|
64
|
+
payment_type?: string;
|
|
65
|
+
/** view_item_list / select_item: the list id (shop|category|search|rail:*). */
|
|
66
|
+
item_list_id?: string;
|
|
67
|
+
/** view_item_list / select_item: human-readable list name. */
|
|
68
|
+
item_list_name?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Behio-only extra props forwarded verbatim into the Behio event `props`
|
|
71
|
+
* (ignored by GA4). Use for signals GA4 can't model: resultsCount,
|
|
72
|
+
* zeroResults, variantId, listId, position, source, ...
|
|
73
|
+
*/
|
|
74
|
+
props?: Record<string, unknown>;
|
|
46
75
|
};
|
|
47
76
|
declare function trackEcommerceEvent(event: EcommerceEventName, payload: EcommercePayload): void;
|
|
48
77
|
|
|
49
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Consent-gated visitor identity helpers.
|
|
80
|
+
*
|
|
81
|
+
* Behio Analytics has three identity tiers (see BehioAnalyticsTracker):
|
|
82
|
+
* anonymous (cookieless server hash), consented (persistent behio_visitor_id),
|
|
83
|
+
* and customer-linked (server stitches at checkout/login). The persistent
|
|
84
|
+
* `behio_visitor_id` is what unlocks returning-visitor metrics, the customer
|
|
85
|
+
* journey and Smart Offers.
|
|
86
|
+
*
|
|
87
|
+
* Historically the SDK only READ that id and left generation/writing to each
|
|
88
|
+
* shop's consent banner — so any storefront that forgot the write stayed 100%
|
|
89
|
+
* anonymous. These helpers move the write into the SDK: the consent banner just
|
|
90
|
+
* calls `grantAnalyticsConsent(client)` / `revokeAnalyticsConsent(client)` and
|
|
91
|
+
* everything (id generation, storage, server record, tracker refresh) is
|
|
92
|
+
* handled here, identically for every template and AI-generated shop.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/** Read the persistent visitor id (localStorage first, cookie fallback for SSR-set ids). */
|
|
96
|
+
declare function getStoredVisitorId(): string | null;
|
|
97
|
+
/**
|
|
98
|
+
* Generate a fresh, URL-safe visitor id in the range the ingest DTO accepts
|
|
99
|
+
* (8..64 chars, [A-Za-z0-9_-]). Uses crypto when available, falling back to
|
|
100
|
+
* Math.random so it never throws in a locked-down runtime.
|
|
101
|
+
*/
|
|
102
|
+
declare function generateVisitorId(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Grant analytics consent: ensure a persistent `behio_visitor_id` exists, store
|
|
105
|
+
* it, record the consent server-side, wire the id into the client (so orders /
|
|
106
|
+
* logins can be attributed) and notify the tracker to start sending it.
|
|
107
|
+
*
|
|
108
|
+
* Returns the visitor id (or an SdkResult error if the server record failed —
|
|
109
|
+
* the id is still stored locally so tracking works and can retry later).
|
|
110
|
+
*
|
|
111
|
+
* @param categories optional marketing/preferences flags (default false); the
|
|
112
|
+
* analytics flag is always true here.
|
|
113
|
+
*/
|
|
114
|
+
declare function grantAnalyticsConsent(client: BehioStorefront, categories?: {
|
|
115
|
+
marketing?: boolean;
|
|
116
|
+
preferences?: boolean;
|
|
117
|
+
}): Promise<SdkResult<CookieConsent>>;
|
|
118
|
+
/**
|
|
119
|
+
* Revoke analytics consent: tell the server, stop sending the id and notify the
|
|
120
|
+
* tracker. The stored id is kept (consent record now says analytics=false) so a
|
|
121
|
+
* later re-grant reuses the same visitor rather than fragmenting the journey.
|
|
122
|
+
*/
|
|
123
|
+
declare function revokeAnalyticsConsent(client: BehioStorefront): Promise<SdkResult<{
|
|
124
|
+
success: boolean;
|
|
125
|
+
}>>;
|
|
126
|
+
|
|
127
|
+
export { BehioStorefront, CookieConsent, type EcommerceEventName, type EcommerceItem, type EcommercePayload, SdkResult, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, revokeAnalyticsConsent, trackEcommerceEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as BehioStorefront, ai as SdkResult, Z as CookieConsent } from './client-DdaC0_6x.js';
|
|
2
|
+
export { J as ActivePromotion, a2 as AddToCartInput, j as AddressDetail, A as AddressSuggestion, aj as AddressType, ak as AddressTypes, a3 as AuthTokens, a1 as BackInStockSubscription, al as BadgeTone, a4 as BehioApiError, am as BehioErrorCode, an as BehioEventHandler, ao as BehioEventType, ap as BehioNetworkError, B as BehioStorefrontConfig, G as Bundle, a5 as BundleItem, g as Cart, aq as CartBundleLine, ar as CartBundleLineItem, a6 as CartDiscount, a7 as CartItem, as as CartItemProduct, at as CartPromotion, C as Category, e as CategoryDetail, a8 as CheckoutAddress, w as CheckoutInput, q as CheckoutPaymentMethod, au as CheckoutSettings, _ as CookieConsentInput, I as CrossSellItem, i as CustomerAddress, h as CustomerProfile, av as DataGroupFieldType, aw as DigitalDownload, ax as DownloadUrl, F as FilterField, a9 as FulfillmentStatus, ay as FulfillmentStatuses, K as GiftCardBalance, az as GiftCardPurchaseInput, aA as GiftCardPurchaseResult, aB as GiftCardSummary, aa as LoginInput, aC as LoyaltyBalance, aD as LoyaltyNextTier, aE as LoyaltyProgram, L as LoyaltySummary, aF as LoyaltyTier, aG as LoyaltyTierPerks, aH as LoyaltyTransaction, M as Menu, aI as MenuItem, aJ as MenuItemRef, aK as MenuItemType, ab as MessageResponse, aL as NewsletterOptInDefault, r as NewsletterSubscribeInput, N as NewsletterSubscribeResult, s as NewsletterUnsubscribeResult, u as OrderAccessRequestResponse, v as OrderAccessVerifyResponse, t as OrderDetail, ac as OrderItem, O as OrderListItem, ad as OrderStatus, aM as OrderStatusHistory, aN as OrderStatuses, aO as OrderTracking, y as Page, aP as PageAttachment, x as PageDetail, b as PaginatedResponse, ae as PaymentStatus, aQ as PaymentStatuses, m as PickupPoint, aR as PickupPointHours, l as PickupPointsInput, aS as PriceDisplay, aT as ProductAvailability, aU as ProductCustomField, aV as ProductCustomFieldGroup, d as ProductDetail, H as ProductGroup, f as ProductLabel, c as ProductListItem, aW as ProductMedia, aX as ProductMediaVariant, af as ProductPrice, aY as ProductPromotionSummary, ag as ProductReview, Q as ProductReviewsResponse, aZ as ProductSort, a_ as ProductSortValue, ah as ProductVariant, a$ as ProductVolumePrice, P as ProductsQuery, b0 as QuoteItem, $ as QuoteRequest, R as RegisterInput, b1 as RegisterResult, b2 as RequestInterceptor, b3 as RequestInterceptorConfig, b4 as ResponseInterceptor, b5 as ResponseInterceptorData, X as ReturnRequest, b6 as ReturnRequestItem, V as ReturnStatus, b7 as ReturnStatusItem, U as ReturnableOrder, b8 as ReturnableOrderItem, b9 as SdkError, n as ShippingMethodSummary, p as ShippingQuote, o as ShippingQuoteInput, z as ShopInfo, ba as ShopScript, bb as ShopScriptPlacement, bc as ShopScriptType, D as ShopScripts, E as ShopSeo, bd as ShopSeoIdentity, be as StockBehavior, a0 as SubmitQuoteInput, Y as SubmitReturnInput, T as SubmitReviewInput, S as Subscription, k as SubscriptionAction, bf as SubscriptionFrequency, bg as SubscriptionItem, bh as SubscriptionStatus, bi as TaxBreakdownLine, bj as VariantAxis, bk as VariantAxisValue, W as WishlistItem, bl as err, bm as ok, bn as toSdkError } from './client-DdaC0_6x.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Format a price amount with currency using Intl.NumberFormat.
|
|
@@ -13,20 +14,29 @@ declare function formatPrice(amount: number, currency: string, locale?: string):
|
|
|
13
14
|
/**
|
|
14
15
|
* GA4 e-commerce event helper.
|
|
15
16
|
*
|
|
16
|
-
* Fires standard GA4 ecommerce events (view_item, add_to_cart,
|
|
17
|
-
* purchase, ...) into whatever analytics runtime the
|
|
18
|
-
* `<StorefrontScripts
|
|
17
|
+
* Fires standard GA4 ecommerce/engagement events (view_item, add_to_cart,
|
|
18
|
+
* begin_checkout, purchase, search, ...) into whatever analytics runtime the
|
|
19
|
+
* shop has injected via `<StorefrontScripts/>`, and — crucially — into Behio
|
|
20
|
+
* Analytics via the sink the tracker registers. One call, both systems.
|
|
19
21
|
*
|
|
22
|
+
* Sinks:
|
|
23
|
+
* - Behio Analytics (`__behioEcommerceSink`) — always, when the tracker is
|
|
24
|
+
* mounted. Records the ORIGINAL event name so Behio-exclusive signals
|
|
25
|
+
* (variant_selected, newsletter_signup) stay distinct.
|
|
20
26
|
* - direct GA4 (`gtag` present) -> `gtag("event", name, payload)`
|
|
21
27
|
* - GTM (`dataLayer` array present) -> `dataLayer.push({event, ecommerce})`
|
|
22
28
|
* (with the recommended `ecommerce: null` reset push first)
|
|
23
29
|
* - neither present (no analytics configured, or consent not granted yet so
|
|
24
|
-
* the consent-gated script never loaded) -> silent no-op
|
|
30
|
+
* the consent-gated script never loaded) -> silent no-op for the GA path
|
|
31
|
+
*
|
|
32
|
+
* Behio-only signal names that have a GA4 recommended equivalent are remapped
|
|
33
|
+
* for the GA path only (see `GA4_NAME_MAP`), so merchants keep clean GA4
|
|
34
|
+
* reports while Behio keeps the richer signal.
|
|
25
35
|
*
|
|
26
36
|
* Consent stays the script layer's job: this helper never loads anything, it
|
|
27
37
|
* only talks to runtimes that already exist on the page.
|
|
28
38
|
*/
|
|
29
|
-
type EcommerceEventName = "view_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "purchase";
|
|
39
|
+
type EcommerceEventName = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "add_to_wishlist" | "view_promotion" | "select_promotion" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "search" | "generate_lead" | "purchase" | "variant_selected" | "newsletter_signup";
|
|
30
40
|
type EcommerceItem = {
|
|
31
41
|
item_id: string;
|
|
32
42
|
item_name: string;
|
|
@@ -34,6 +44,8 @@ type EcommerceItem = {
|
|
|
34
44
|
quantity?: number;
|
|
35
45
|
item_variant?: string;
|
|
36
46
|
item_category?: string;
|
|
47
|
+
/** Position in the list (1-based) — for select_item rail/list attribution. */
|
|
48
|
+
index?: number;
|
|
37
49
|
};
|
|
38
50
|
type EcommercePayload = {
|
|
39
51
|
currency?: string;
|
|
@@ -42,8 +54,74 @@ type EcommercePayload = {
|
|
|
42
54
|
/** Required for `purchase` — the order number. */
|
|
43
55
|
transaction_id?: string;
|
|
44
56
|
shipping?: number;
|
|
45
|
-
|
|
57
|
+
/** Optional for non-item events (search, add_shipping_info, newsletter). */
|
|
58
|
+
items?: EcommerceItem[];
|
|
59
|
+
/** search event: the query string. */
|
|
60
|
+
search_term?: string;
|
|
61
|
+
/** add_shipping_info: the selected shipping method label. */
|
|
62
|
+
shipping_tier?: string;
|
|
63
|
+
/** add_payment_info: the selected payment method type. */
|
|
64
|
+
payment_type?: string;
|
|
65
|
+
/** view_item_list / select_item: the list id (shop|category|search|rail:*). */
|
|
66
|
+
item_list_id?: string;
|
|
67
|
+
/** view_item_list / select_item: human-readable list name. */
|
|
68
|
+
item_list_name?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Behio-only extra props forwarded verbatim into the Behio event `props`
|
|
71
|
+
* (ignored by GA4). Use for signals GA4 can't model: resultsCount,
|
|
72
|
+
* zeroResults, variantId, listId, position, source, ...
|
|
73
|
+
*/
|
|
74
|
+
props?: Record<string, unknown>;
|
|
46
75
|
};
|
|
47
76
|
declare function trackEcommerceEvent(event: EcommerceEventName, payload: EcommercePayload): void;
|
|
48
77
|
|
|
49
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Consent-gated visitor identity helpers.
|
|
80
|
+
*
|
|
81
|
+
* Behio Analytics has three identity tiers (see BehioAnalyticsTracker):
|
|
82
|
+
* anonymous (cookieless server hash), consented (persistent behio_visitor_id),
|
|
83
|
+
* and customer-linked (server stitches at checkout/login). The persistent
|
|
84
|
+
* `behio_visitor_id` is what unlocks returning-visitor metrics, the customer
|
|
85
|
+
* journey and Smart Offers.
|
|
86
|
+
*
|
|
87
|
+
* Historically the SDK only READ that id and left generation/writing to each
|
|
88
|
+
* shop's consent banner — so any storefront that forgot the write stayed 100%
|
|
89
|
+
* anonymous. These helpers move the write into the SDK: the consent banner just
|
|
90
|
+
* calls `grantAnalyticsConsent(client)` / `revokeAnalyticsConsent(client)` and
|
|
91
|
+
* everything (id generation, storage, server record, tracker refresh) is
|
|
92
|
+
* handled here, identically for every template and AI-generated shop.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/** Read the persistent visitor id (localStorage first, cookie fallback for SSR-set ids). */
|
|
96
|
+
declare function getStoredVisitorId(): string | null;
|
|
97
|
+
/**
|
|
98
|
+
* Generate a fresh, URL-safe visitor id in the range the ingest DTO accepts
|
|
99
|
+
* (8..64 chars, [A-Za-z0-9_-]). Uses crypto when available, falling back to
|
|
100
|
+
* Math.random so it never throws in a locked-down runtime.
|
|
101
|
+
*/
|
|
102
|
+
declare function generateVisitorId(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Grant analytics consent: ensure a persistent `behio_visitor_id` exists, store
|
|
105
|
+
* it, record the consent server-side, wire the id into the client (so orders /
|
|
106
|
+
* logins can be attributed) and notify the tracker to start sending it.
|
|
107
|
+
*
|
|
108
|
+
* Returns the visitor id (or an SdkResult error if the server record failed —
|
|
109
|
+
* the id is still stored locally so tracking works and can retry later).
|
|
110
|
+
*
|
|
111
|
+
* @param categories optional marketing/preferences flags (default false); the
|
|
112
|
+
* analytics flag is always true here.
|
|
113
|
+
*/
|
|
114
|
+
declare function grantAnalyticsConsent(client: BehioStorefront, categories?: {
|
|
115
|
+
marketing?: boolean;
|
|
116
|
+
preferences?: boolean;
|
|
117
|
+
}): Promise<SdkResult<CookieConsent>>;
|
|
118
|
+
/**
|
|
119
|
+
* Revoke analytics consent: tell the server, stop sending the id and notify the
|
|
120
|
+
* tracker. The stored id is kept (consent record now says analytics=false) so a
|
|
121
|
+
* later re-grant reuses the same visitor rather than fragmenting the journey.
|
|
122
|
+
*/
|
|
123
|
+
declare function revokeAnalyticsConsent(client: BehioStorefront): Promise<SdkResult<{
|
|
124
|
+
success: boolean;
|
|
125
|
+
}>>;
|
|
126
|
+
|
|
127
|
+
export { BehioStorefront, CookieConsent, type EcommerceEventName, type EcommerceItem, type EcommercePayload, SdkResult, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, revokeAnalyticsConsent, trackEcommerceEvent };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkCZRSJULDjs = require('./chunk-CZRSJULD.js');
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
|
|
@@ -29,4 +33,8 @@ var _chunkY4ZCK5HDjs = require('./chunk-Y4ZCK5HD.js');
|
|
|
29
33
|
|
|
30
34
|
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.AddressTypes = _chunkY4ZCK5HDjs.AddressTypes; exports.BehioApiError = _chunkY4ZCK5HDjs.BehioApiError; exports.BehioNetworkError = _chunkY4ZCK5HDjs.BehioNetworkError; exports.BehioStorefront = _chunkY4ZCK5HDjs.BehioStorefront; exports.FulfillmentStatuses = _chunkY4ZCK5HDjs.FulfillmentStatuses; exports.OrderStatuses = _chunkY4ZCK5HDjs.OrderStatuses; exports.PaymentStatuses = _chunkY4ZCK5HDjs.PaymentStatuses; exports.ProductSort = _chunkY4ZCK5HDjs.ProductSort; exports.err = _chunkY4ZCK5HDjs.err; exports.formatPrice = _chunkCZRSJULDjs.formatPrice; exports.generateVisitorId = _chunkCZRSJULDjs.generateVisitorId; exports.getStoredVisitorId = _chunkCZRSJULDjs.getStoredVisitorId; exports.grantAnalyticsConsent = _chunkCZRSJULDjs.grantAnalyticsConsent; exports.ok = _chunkY4ZCK5HDjs.ok; exports.revokeAnalyticsConsent = _chunkCZRSJULDjs.revokeAnalyticsConsent; exports.toSdkError = _chunkY4ZCK5HDjs.toSdkError; exports.trackEcommerceEvent = _chunkCZRSJULDjs.trackEcommerceEvent;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatPrice,
|
|
3
|
+
generateVisitorId,
|
|
4
|
+
getStoredVisitorId,
|
|
5
|
+
grantAnalyticsConsent,
|
|
6
|
+
revokeAnalyticsConsent,
|
|
3
7
|
trackEcommerceEvent
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QUU76QUB.mjs";
|
|
5
9
|
import {
|
|
6
10
|
AddressTypes,
|
|
7
11
|
BehioApiError,
|
|
@@ -26,7 +30,11 @@ export {
|
|
|
26
30
|
ProductSort,
|
|
27
31
|
err,
|
|
28
32
|
formatPrice,
|
|
33
|
+
generateVisitorId,
|
|
34
|
+
getStoredVisitorId,
|
|
35
|
+
grantAnalyticsConsent,
|
|
29
36
|
ok,
|
|
37
|
+
revokeAnalyticsConsent,
|
|
30
38
|
toSdkError,
|
|
31
39
|
trackEcommerceEvent
|
|
32
40
|
};
|
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-
|
|
1
|
+
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-DdaC0_6x.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-
|
|
1
|
+
import { B as BehioStorefrontConfig, a as BehioStorefront } from './client-DdaC0_6x.js';
|
|
2
2
|
|
|
3
3
|
interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
|
|
4
4
|
/** Override the cart session cookie name (default: "behio_cart_session"). */
|
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, M as Menu, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, L as LoyaltySummary, S as Subscription, k as SubscriptionAction, l as PickupPointsInput, m as PickupPoint, n as ShippingMethodSummary, o as ShippingQuoteInput, p as ShippingQuote, q as CheckoutPaymentMethod, N as NewsletterSubscribeResult, r as NewsletterSubscribeInput, s as NewsletterUnsubscribeResult, O as OrderListItem, t as OrderDetail, u as OrderAccessRequestResponse, v as OrderAccessVerifyResponse, w as CheckoutInput, x as PageDetail, y as Page, z as ShopInfo, D as ShopScripts, E as ShopSeo, G as Bundle, H as ProductGroup, I as CrossSellItem, J as ActivePromotion, K as GiftCardBalance, W as WishlistItem, Q as ProductReviewsResponse, T as SubmitReviewInput, U as ReturnableOrder, V as ReturnStatus, X as ReturnRequest, Y as SubmitReturnInput, Z as CookieConsent, _ as CookieConsentInput, $ as QuoteRequest, a0 as SubmitQuoteInput, a1 as BackInStockSubscription } from './client-
|
|
5
|
-
export { a2 as AddToCartInput, a3 as AuthTokens, a4 as BehioApiError, a5 as BundleItem, a6 as CartDiscount, a7 as CartItem, a8 as CheckoutAddress, a9 as FulfillmentStatus, aa as LoginInput, ab as MessageResponse, ac as OrderItem, ad as OrderStatus, ae as PaymentStatus, af as ProductPrice, ag as ProductReview, ah as ProductVariant } from './client-
|
|
4
|
+
import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, M as Menu, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, L as LoyaltySummary, S as Subscription, k as SubscriptionAction, l as PickupPointsInput, m as PickupPoint, n as ShippingMethodSummary, o as ShippingQuoteInput, p as ShippingQuote, q as CheckoutPaymentMethod, N as NewsletterSubscribeResult, r as NewsletterSubscribeInput, s as NewsletterUnsubscribeResult, O as OrderListItem, t as OrderDetail, u as OrderAccessRequestResponse, v as OrderAccessVerifyResponse, w as CheckoutInput, x as PageDetail, y as Page, z as ShopInfo, D as ShopScripts, E as ShopSeo, G as Bundle, H as ProductGroup, I as CrossSellItem, J as ActivePromotion, K as GiftCardBalance, W as WishlistItem, Q as ProductReviewsResponse, T as SubmitReviewInput, U as ReturnableOrder, V as ReturnStatus, X as ReturnRequest, Y as SubmitReturnInput, Z as CookieConsent, _ as CookieConsentInput, $ as QuoteRequest, a0 as SubmitQuoteInput, a1 as BackInStockSubscription } from './client-DdaC0_6x.mjs';
|
|
5
|
+
export { a2 as AddToCartInput, a3 as AuthTokens, a4 as BehioApiError, a5 as BundleItem, a6 as CartDiscount, a7 as CartItem, a8 as CheckoutAddress, a9 as FulfillmentStatus, aa as LoginInput, ab as MessageResponse, ac as OrderItem, ad as OrderStatus, ae as PaymentStatus, af as ProductPrice, ag as ProductReview, ah as ProductVariant } from './client-DdaC0_6x.mjs';
|
|
6
6
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
7
|
-
export { EcommerceEventName, EcommerceItem, EcommercePayload, formatPrice, trackEcommerceEvent } from './index.mjs';
|
|
7
|
+
export { EcommerceEventName, EcommerceItem, EcommercePayload, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, revokeAnalyticsConsent, 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, M as Menu, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, L as LoyaltySummary, S as Subscription, k as SubscriptionAction, l as PickupPointsInput, m as PickupPoint, n as ShippingMethodSummary, o as ShippingQuoteInput, p as ShippingQuote, q as CheckoutPaymentMethod, N as NewsletterSubscribeResult, r as NewsletterSubscribeInput, s as NewsletterUnsubscribeResult, O as OrderListItem, t as OrderDetail, u as OrderAccessRequestResponse, v as OrderAccessVerifyResponse, w as CheckoutInput, x as PageDetail, y as Page, z as ShopInfo, D as ShopScripts, E as ShopSeo, G as Bundle, H as ProductGroup, I as CrossSellItem, J as ActivePromotion, K as GiftCardBalance, W as WishlistItem, Q as ProductReviewsResponse, T as SubmitReviewInput, U as ReturnableOrder, V as ReturnStatus, X as ReturnRequest, Y as SubmitReturnInput, Z as CookieConsent, _ as CookieConsentInput, $ as QuoteRequest, a0 as SubmitQuoteInput, a1 as BackInStockSubscription } from './client-
|
|
5
|
-
export { a2 as AddToCartInput, a3 as AuthTokens, a4 as BehioApiError, a5 as BundleItem, a6 as CartDiscount, a7 as CartItem, a8 as CheckoutAddress, a9 as FulfillmentStatus, aa as LoginInput, ab as MessageResponse, ac as OrderItem, ad as OrderStatus, ae as PaymentStatus, af as ProductPrice, ag as ProductReview, ah as ProductVariant } from './client-
|
|
4
|
+
import { a as BehioStorefront, P as ProductsQuery, b as PaginatedResponse, c as ProductListItem, d as ProductDetail, C as Category, e as CategoryDetail, M as Menu, f as ProductLabel, F as FilterField, g as Cart, h as CustomerProfile, R as RegisterInput, i as CustomerAddress, A as AddressSuggestion, j as AddressDetail, L as LoyaltySummary, S as Subscription, k as SubscriptionAction, l as PickupPointsInput, m as PickupPoint, n as ShippingMethodSummary, o as ShippingQuoteInput, p as ShippingQuote, q as CheckoutPaymentMethod, N as NewsletterSubscribeResult, r as NewsletterSubscribeInput, s as NewsletterUnsubscribeResult, O as OrderListItem, t as OrderDetail, u as OrderAccessRequestResponse, v as OrderAccessVerifyResponse, w as CheckoutInput, x as PageDetail, y as Page, z as ShopInfo, D as ShopScripts, E as ShopSeo, G as Bundle, H as ProductGroup, I as CrossSellItem, J as ActivePromotion, K as GiftCardBalance, W as WishlistItem, Q as ProductReviewsResponse, T as SubmitReviewInput, U as ReturnableOrder, V as ReturnStatus, X as ReturnRequest, Y as SubmitReturnInput, Z as CookieConsent, _ as CookieConsentInput, $ as QuoteRequest, a0 as SubmitQuoteInput, a1 as BackInStockSubscription } from './client-DdaC0_6x.js';
|
|
5
|
+
export { a2 as AddToCartInput, a3 as AuthTokens, a4 as BehioApiError, a5 as BundleItem, a6 as CartDiscount, a7 as CartItem, a8 as CheckoutAddress, a9 as FulfillmentStatus, aa as LoginInput, ab as MessageResponse, ac as OrderItem, ad as OrderStatus, ae as PaymentStatus, af as ProductPrice, ag as ProductReview, ah as ProductVariant } from './client-DdaC0_6x.js';
|
|
6
6
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
7
|
-
export { EcommerceEventName, EcommerceItem, EcommercePayload, formatPrice, trackEcommerceEvent } from './index.js';
|
|
7
|
+
export { EcommerceEventName, EcommerceItem, EcommercePayload, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, revokeAnalyticsConsent, trackEcommerceEvent } from './index.js';
|
|
8
8
|
|
|
9
9
|
interface StorageAdapter {
|
|
10
10
|
get(key: string): string | null;
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
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
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkCZRSJULDjs = require('./chunk-CZRSJULD.js');
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
var _chunkY4ZCK5HDjs = require('./chunk-Y4ZCK5HD.js');
|
|
@@ -1662,6 +1666,18 @@ function initTracker(client) {
|
|
|
1662
1666
|
href = void 0;
|
|
1663
1667
|
}
|
|
1664
1668
|
}
|
|
1669
|
+
const dataProps = {};
|
|
1670
|
+
const dataset = el.dataset;
|
|
1671
|
+
if (dataset) {
|
|
1672
|
+
for (const k of Object.keys(dataset)) {
|
|
1673
|
+
if (k.startsWith("behio") && k !== "behioEvent") {
|
|
1674
|
+
const short = k.slice("behio".length);
|
|
1675
|
+
const propKey = short.charAt(0).toLowerCase() + short.slice(1);
|
|
1676
|
+
const v = dataset[k];
|
|
1677
|
+
if (v != null) dataProps[propKey] = String(v).slice(0, 120);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1665
1681
|
enqueue({
|
|
1666
1682
|
type: "custom",
|
|
1667
1683
|
name: explicit || "click",
|
|
@@ -1670,13 +1686,29 @@ function initTracker(client) {
|
|
|
1670
1686
|
props: {
|
|
1671
1687
|
tag: el.tagName.toLowerCase(),
|
|
1672
1688
|
...text ? { text } : {},
|
|
1673
|
-
...href ? { href } : {}
|
|
1689
|
+
...href ? { href } : {},
|
|
1690
|
+
...dataProps
|
|
1674
1691
|
}
|
|
1675
1692
|
});
|
|
1676
1693
|
};
|
|
1677
1694
|
const w = window;
|
|
1678
1695
|
w.__behioEcommerceSink = (event, payload) => {
|
|
1679
1696
|
if (event === "purchase") return;
|
|
1697
|
+
const items = Array.isArray(payload.items) ? payload.items : [];
|
|
1698
|
+
const props = {
|
|
1699
|
+
..._nullishCoalesce(payload.props, () => ( {})),
|
|
1700
|
+
...payload.search_term != null ? { query: payload.search_term } : {},
|
|
1701
|
+
...payload.shipping_tier != null ? { shippingTier: payload.shipping_tier } : {},
|
|
1702
|
+
...payload.payment_type != null ? { paymentType: payload.payment_type } : {},
|
|
1703
|
+
...payload.item_list_id != null ? { listId: payload.item_list_id } : {},
|
|
1704
|
+
...payload.item_list_name != null ? { listName: payload.item_list_name } : {},
|
|
1705
|
+
...items.length > 0 ? {
|
|
1706
|
+
items: items.length,
|
|
1707
|
+
// First item id = the product (view_item/add_to_cart are
|
|
1708
|
+
// single-product in practice) - Behavioral Offers count on it.
|
|
1709
|
+
itemId: _optionalChain([items, 'access', _95 => _95[0], 'optionalAccess', _96 => _96.item_id])
|
|
1710
|
+
} : {}
|
|
1711
|
+
};
|
|
1680
1712
|
enqueue({
|
|
1681
1713
|
type: "ecommerce",
|
|
1682
1714
|
name: event,
|
|
@@ -1684,14 +1716,7 @@ function initTracker(client) {
|
|
|
1684
1716
|
ts: Date.now(),
|
|
1685
1717
|
...payload.value != null ? { value: payload.value } : {},
|
|
1686
1718
|
...payload.currency ? { currency: payload.currency } : {},
|
|
1687
|
-
...
|
|
1688
|
-
props: {
|
|
1689
|
-
items: payload.items.length,
|
|
1690
|
-
// First item id = the product (view_item/add_to_cart are
|
|
1691
|
-
// single-product in practice) - Behavioral Offers count on it.
|
|
1692
|
-
itemId: _optionalChain([payload, 'access', _95 => _95.items, 'access', _96 => _96[0], 'optionalAccess', _97 => _97.item_id])
|
|
1693
|
-
}
|
|
1694
|
-
} : {}
|
|
1719
|
+
...Object.keys(props).length > 0 ? { props } : {}
|
|
1695
1720
|
});
|
|
1696
1721
|
};
|
|
1697
1722
|
const origPush = history.pushState.bind(history);
|
|
@@ -1737,7 +1762,13 @@ function utmFromSearch(search) {
|
|
|
1737
1762
|
return {
|
|
1738
1763
|
utmSource: _nullishCoalesce(p.get("utm_source"), () => ( void 0)),
|
|
1739
1764
|
utmMedium: _nullishCoalesce(p.get("utm_medium"), () => ( void 0)),
|
|
1740
|
-
utmCampaign: _nullishCoalesce(p.get("utm_campaign"), () => ( void 0))
|
|
1765
|
+
utmCampaign: _nullishCoalesce(p.get("utm_campaign"), () => ( void 0)),
|
|
1766
|
+
// Extended attribution: paid-search term/content + click ids. The
|
|
1767
|
+
// backend folds these into event props (raw columns unchanged).
|
|
1768
|
+
utmTerm: _nullishCoalesce(p.get("utm_term"), () => ( void 0)),
|
|
1769
|
+
utmContent: _nullishCoalesce(p.get("utm_content"), () => ( void 0)),
|
|
1770
|
+
gclid: _nullishCoalesce(p.get("gclid"), () => ( void 0)),
|
|
1771
|
+
fbclid: _nullishCoalesce(p.get("fbclid"), () => ( void 0))
|
|
1741
1772
|
};
|
|
1742
1773
|
} catch (e10) {
|
|
1743
1774
|
return {};
|
|
@@ -1751,8 +1782,8 @@ function useBundles(options) {
|
|
|
1751
1782
|
return _reactquery.useQuery.call(void 0, {
|
|
1752
1783
|
queryKey: ["behio", "bundles"],
|
|
1753
1784
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
1754
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1755
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1785
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97.enabled]), () => ( true)),
|
|
1786
|
+
initialData: _optionalChain([options, 'optionalAccess', _98 => _98.initialData])
|
|
1756
1787
|
});
|
|
1757
1788
|
}
|
|
1758
1789
|
function useBundle(slug, options) {
|
|
@@ -1760,8 +1791,8 @@ function useBundle(slug, options) {
|
|
|
1760
1791
|
return _reactquery.useQuery.call(void 0, {
|
|
1761
1792
|
queryKey: ["behio", "bundle", slug],
|
|
1762
1793
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
1763
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1764
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1794
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _99 => _99.enabled]), () => ( true))),
|
|
1795
|
+
initialData: _optionalChain([options, 'optionalAccess', _100 => _100.initialData])
|
|
1765
1796
|
});
|
|
1766
1797
|
}
|
|
1767
1798
|
|
|
@@ -1770,15 +1801,15 @@ function useBundle(slug, options) {
|
|
|
1770
1801
|
function useProductGroup(slug, options) {
|
|
1771
1802
|
const { client } = useBehio();
|
|
1772
1803
|
return _reactquery.useQuery.call(void 0, {
|
|
1773
|
-
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess',
|
|
1804
|
+
queryKey: ["behio", "product-group", slug, _optionalChain([options, 'optionalAccess', _101 => _101.locale]), _optionalChain([options, 'optionalAccess', _102 => _102.currency])],
|
|
1774
1805
|
queryFn: () => unwrap(
|
|
1775
1806
|
client.catalog.getProductGroup(slug, {
|
|
1776
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1777
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1807
|
+
locale: _optionalChain([options, 'optionalAccess', _103 => _103.locale]),
|
|
1808
|
+
currency: _optionalChain([options, 'optionalAccess', _104 => _104.currency])
|
|
1778
1809
|
})
|
|
1779
1810
|
),
|
|
1780
|
-
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1781
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1811
|
+
enabled: Boolean(slug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _105 => _105.enabled]), () => ( true))),
|
|
1812
|
+
initialData: _optionalChain([options, 'optionalAccess', _106 => _106.initialData])
|
|
1782
1813
|
});
|
|
1783
1814
|
}
|
|
1784
1815
|
|
|
@@ -1787,15 +1818,15 @@ function useProductGroup(slug, options) {
|
|
|
1787
1818
|
function useCrossSell(productSlug, options) {
|
|
1788
1819
|
const { client } = useBehio();
|
|
1789
1820
|
return _reactquery.useQuery.call(void 0, {
|
|
1790
|
-
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess',
|
|
1821
|
+
queryKey: ["behio", "cross-sell", productSlug, _optionalChain([options, 'optionalAccess', _107 => _107.locale]), _optionalChain([options, 'optionalAccess', _108 => _108.currency])],
|
|
1791
1822
|
queryFn: () => unwrap(
|
|
1792
1823
|
client.catalog.getCrossSell(productSlug, {
|
|
1793
|
-
locale: _optionalChain([options, 'optionalAccess',
|
|
1794
|
-
currency: _optionalChain([options, 'optionalAccess',
|
|
1824
|
+
locale: _optionalChain([options, 'optionalAccess', _109 => _109.locale]),
|
|
1825
|
+
currency: _optionalChain([options, 'optionalAccess', _110 => _110.currency])
|
|
1795
1826
|
})
|
|
1796
1827
|
),
|
|
1797
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1798
|
-
initialData: _optionalChain([options, 'optionalAccess',
|
|
1828
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _111 => _111.enabled]), () => ( true))),
|
|
1829
|
+
initialData: _optionalChain([options, 'optionalAccess', _112 => _112.initialData])
|
|
1799
1830
|
});
|
|
1800
1831
|
}
|
|
1801
1832
|
|
|
@@ -1806,8 +1837,8 @@ function useProductPromotions(productSlug, options) {
|
|
|
1806
1837
|
return _reactquery.useQuery.call(void 0, {
|
|
1807
1838
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
1808
1839
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
1809
|
-
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1810
|
-
refetchInterval: _optionalChain([options, 'optionalAccess',
|
|
1840
|
+
enabled: Boolean(productSlug) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _113 => _113.enabled]), () => ( true))),
|
|
1841
|
+
refetchInterval: _optionalChain([options, 'optionalAccess', _114 => _114.refetchIntervalMs])
|
|
1811
1842
|
});
|
|
1812
1843
|
}
|
|
1813
1844
|
|
|
@@ -1815,11 +1846,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
1815
1846
|
|
|
1816
1847
|
function useGiftCardBalance(code, options) {
|
|
1817
1848
|
const { client } = useBehio();
|
|
1818
|
-
const trimmed = _optionalChain([code, 'optionalAccess',
|
|
1849
|
+
const trimmed = _optionalChain([code, 'optionalAccess', _115 => _115.trim, 'call', _116 => _116()]);
|
|
1819
1850
|
return _reactquery.useQuery.call(void 0, {
|
|
1820
1851
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
1821
1852
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
1822
|
-
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1853
|
+
enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _117 => _117.enabled]), () => ( true)))
|
|
1823
1854
|
});
|
|
1824
1855
|
}
|
|
1825
1856
|
|
|
@@ -1831,7 +1862,7 @@ function useWishlist(options) {
|
|
|
1831
1862
|
const query = _reactquery.useQuery.call(void 0, {
|
|
1832
1863
|
queryKey: ["behio", "wishlist"],
|
|
1833
1864
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
1834
|
-
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1865
|
+
enabled: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _118 => _118.enabled]), () => ( true))
|
|
1835
1866
|
});
|
|
1836
1867
|
const addMutation = _reactquery.useMutation.call(void 0, {
|
|
1837
1868
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
@@ -1863,9 +1894,9 @@ function useIsInWishlist(productId) {
|
|
|
1863
1894
|
function useProductReviews(productId, options) {
|
|
1864
1895
|
const { client } = useBehio();
|
|
1865
1896
|
return _reactquery.useQuery.call(void 0, {
|
|
1866
|
-
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1867
|
-
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess',
|
|
1868
|
-
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1897
|
+
queryKey: ["behio", "reviews", productId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _119 => _119.page]), () => ( 1))],
|
|
1898
|
+
queryFn: () => unwrap(client.reviews.getProductReviews(productId, _optionalChain([options, 'optionalAccess', _120 => _120.page]), _optionalChain([options, 'optionalAccess', _121 => _121.limit]))),
|
|
1899
|
+
enabled: Boolean(productId) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _122 => _122.enabled]), () => ( true)))
|
|
1869
1900
|
});
|
|
1870
1901
|
}
|
|
1871
1902
|
function useSubmitReview() {
|
|
@@ -1991,4 +2022,8 @@ function useNotifyWhenAvailable() {
|
|
|
1991
2022
|
|
|
1992
2023
|
|
|
1993
2024
|
|
|
1994
|
-
|
|
2025
|
+
|
|
2026
|
+
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
exports.BehioAnalyticsTracker = BehioAnalyticsTracker; exports.BehioProvider = BehioProvider; exports.CurrencySwitcher = CurrencySwitcher; exports.StorefrontScripts = StorefrontScripts; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = _chunkCZRSJULDjs.formatPrice; exports.generateVisitorId = _chunkCZRSJULDjs.generateVisitorId; exports.getStoredVisitorId = _chunkCZRSJULDjs.getStoredVisitorId; exports.grantAnalyticsConsent = _chunkCZRSJULDjs.grantAnalyticsConsent; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.revokeAnalyticsConsent = _chunkCZRSJULDjs.revokeAnalyticsConsent; exports.trackEcommerceEvent = _chunkCZRSJULDjs.trackEcommerceEvent; exports.useAddressAutocomplete = useAddressAutocomplete; exports.useAddresses = useAddresses; exports.useAnalyticsEvents = useAnalyticsEvents; 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.useLoyalty = useLoyalty; exports.useMenu = useMenu; exports.useNewsletterSubscribe = useNewsletterSubscribe; exports.useNewsletterUnsubscribe = useNewsletterUnsubscribe; exports.useNotifyWhenAvailable = useNotifyWhenAvailable; exports.useOrder = useOrder; exports.useOrderAccess = useOrderAccess; exports.useOrders = useOrders; exports.usePage = usePage; exports.usePages = usePages; exports.usePaymentMethods = usePaymentMethods; exports.usePersonalOffers = usePersonalOffers; exports.usePickupPoints = usePickupPoints; exports.useProduct = useProduct; exports.useProductGroup = useProductGroup; exports.useProductPromotions = useProductPromotions; exports.useProductReviews = useProductReviews; exports.useProducts = useProducts; exports.useQuoteStatus = useQuoteStatus; exports.useReturnStatus = useReturnStatus; exports.useSearch = useSearch; exports.useShippingMethods = useShippingMethods; exports.useShippingQuote = useShippingQuote; exports.useShopInfo = useShopInfo; exports.useShopScripts = useShopScripts; exports.useShopSeo = useShopSeo; exports.useSubmitQuote = useSubmitQuote; exports.useSubmitReturn = useSubmitReturn; exports.useSubmitReview = useSubmitReview; exports.useSubscriptions = useSubscriptions; exports.useWishlist = useWishlist;
|
package/dist/react.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatPrice,
|
|
3
|
+
generateVisitorId,
|
|
4
|
+
getStoredVisitorId,
|
|
5
|
+
grantAnalyticsConsent,
|
|
6
|
+
revokeAnalyticsConsent,
|
|
3
7
|
trackEcommerceEvent
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QUU76QUB.mjs";
|
|
5
9
|
import {
|
|
6
10
|
BehioStorefront
|
|
7
11
|
} from "./chunk-5KJDVDUM.mjs";
|
|
@@ -1662,6 +1666,18 @@ function initTracker(client) {
|
|
|
1662
1666
|
href = void 0;
|
|
1663
1667
|
}
|
|
1664
1668
|
}
|
|
1669
|
+
const dataProps = {};
|
|
1670
|
+
const dataset = el.dataset;
|
|
1671
|
+
if (dataset) {
|
|
1672
|
+
for (const k of Object.keys(dataset)) {
|
|
1673
|
+
if (k.startsWith("behio") && k !== "behioEvent") {
|
|
1674
|
+
const short = k.slice("behio".length);
|
|
1675
|
+
const propKey = short.charAt(0).toLowerCase() + short.slice(1);
|
|
1676
|
+
const v = dataset[k];
|
|
1677
|
+
if (v != null) dataProps[propKey] = String(v).slice(0, 120);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1665
1681
|
enqueue({
|
|
1666
1682
|
type: "custom",
|
|
1667
1683
|
name: explicit || "click",
|
|
@@ -1670,13 +1686,29 @@ function initTracker(client) {
|
|
|
1670
1686
|
props: {
|
|
1671
1687
|
tag: el.tagName.toLowerCase(),
|
|
1672
1688
|
...text ? { text } : {},
|
|
1673
|
-
...href ? { href } : {}
|
|
1689
|
+
...href ? { href } : {},
|
|
1690
|
+
...dataProps
|
|
1674
1691
|
}
|
|
1675
1692
|
});
|
|
1676
1693
|
};
|
|
1677
1694
|
const w = window;
|
|
1678
1695
|
w.__behioEcommerceSink = (event, payload) => {
|
|
1679
1696
|
if (event === "purchase") return;
|
|
1697
|
+
const items = Array.isArray(payload.items) ? payload.items : [];
|
|
1698
|
+
const props = {
|
|
1699
|
+
...payload.props ?? {},
|
|
1700
|
+
...payload.search_term != null ? { query: payload.search_term } : {},
|
|
1701
|
+
...payload.shipping_tier != null ? { shippingTier: payload.shipping_tier } : {},
|
|
1702
|
+
...payload.payment_type != null ? { paymentType: payload.payment_type } : {},
|
|
1703
|
+
...payload.item_list_id != null ? { listId: payload.item_list_id } : {},
|
|
1704
|
+
...payload.item_list_name != null ? { listName: payload.item_list_name } : {},
|
|
1705
|
+
...items.length > 0 ? {
|
|
1706
|
+
items: items.length,
|
|
1707
|
+
// First item id = the product (view_item/add_to_cart are
|
|
1708
|
+
// single-product in practice) - Behavioral Offers count on it.
|
|
1709
|
+
itemId: items[0]?.item_id
|
|
1710
|
+
} : {}
|
|
1711
|
+
};
|
|
1680
1712
|
enqueue({
|
|
1681
1713
|
type: "ecommerce",
|
|
1682
1714
|
name: event,
|
|
@@ -1684,14 +1716,7 @@ function initTracker(client) {
|
|
|
1684
1716
|
ts: Date.now(),
|
|
1685
1717
|
...payload.value != null ? { value: payload.value } : {},
|
|
1686
1718
|
...payload.currency ? { currency: payload.currency } : {},
|
|
1687
|
-
...
|
|
1688
|
-
props: {
|
|
1689
|
-
items: payload.items.length,
|
|
1690
|
-
// First item id = the product (view_item/add_to_cart are
|
|
1691
|
-
// single-product in practice) - Behavioral Offers count on it.
|
|
1692
|
-
itemId: payload.items[0]?.item_id
|
|
1693
|
-
}
|
|
1694
|
-
} : {}
|
|
1719
|
+
...Object.keys(props).length > 0 ? { props } : {}
|
|
1695
1720
|
});
|
|
1696
1721
|
};
|
|
1697
1722
|
const origPush = history.pushState.bind(history);
|
|
@@ -1737,7 +1762,13 @@ function utmFromSearch(search) {
|
|
|
1737
1762
|
return {
|
|
1738
1763
|
utmSource: p.get("utm_source") ?? void 0,
|
|
1739
1764
|
utmMedium: p.get("utm_medium") ?? void 0,
|
|
1740
|
-
utmCampaign: p.get("utm_campaign") ?? void 0
|
|
1765
|
+
utmCampaign: p.get("utm_campaign") ?? void 0,
|
|
1766
|
+
// Extended attribution: paid-search term/content + click ids. The
|
|
1767
|
+
// backend folds these into event props (raw columns unchanged).
|
|
1768
|
+
utmTerm: p.get("utm_term") ?? void 0,
|
|
1769
|
+
utmContent: p.get("utm_content") ?? void 0,
|
|
1770
|
+
gclid: p.get("gclid") ?? void 0,
|
|
1771
|
+
fbclid: p.get("fbclid") ?? void 0
|
|
1741
1772
|
};
|
|
1742
1773
|
} catch {
|
|
1743
1774
|
return {};
|
|
@@ -1934,8 +1965,12 @@ export {
|
|
|
1934
1965
|
createMemoryStorage,
|
|
1935
1966
|
detectStorage,
|
|
1936
1967
|
formatPrice,
|
|
1968
|
+
generateVisitorId,
|
|
1969
|
+
getStoredVisitorId,
|
|
1970
|
+
grantAnalyticsConsent,
|
|
1937
1971
|
localStorageAdapter,
|
|
1938
1972
|
memoryStorage,
|
|
1973
|
+
revokeAnalyticsConsent,
|
|
1939
1974
|
trackEcommerceEvent,
|
|
1940
1975
|
useAddressAutocomplete,
|
|
1941
1976
|
useAddresses,
|
package/package.json
CHANGED
package/dist/chunk-JIAOZ5YW.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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; }// src/react/utils/format-price.ts
|
|
2
|
-
function formatPrice(amount, currency, locale) {
|
|
3
|
-
const resolvedLocale = _nullishCoalesce(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 (e) {
|
|
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
|
-
_optionalChain([w, 'access', _ => _.__behioEcommerceSink, 'optionalCall', _2 => _2(event, payload)]);
|
|
22
|
-
} catch (e2) {
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
if (typeof w.gtag === "function") {
|
|
26
|
-
w.gtag("event", event, payload);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(w.dataLayer)) {
|
|
30
|
-
w.dataLayer.push({ ecommerce: null });
|
|
31
|
-
w.dataLayer.push({ event, ecommerce: payload });
|
|
32
|
-
}
|
|
33
|
-
} catch (e3) {
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
exports.formatPrice = formatPrice; exports.trackEcommerceEvent = trackEcommerceEvent;
|
package/dist/chunk-ZOZAJG6T.mjs
DELETED
|
@@ -1,40 +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
|
-
// src/analytics.ts
|
|
17
|
-
function trackEcommerceEvent(event, payload) {
|
|
18
|
-
if (typeof window === "undefined") return;
|
|
19
|
-
const w = window;
|
|
20
|
-
try {
|
|
21
|
-
w.__behioEcommerceSink?.(event, payload);
|
|
22
|
-
} catch {
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
if (typeof w.gtag === "function") {
|
|
26
|
-
w.gtag("event", event, payload);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(w.dataLayer)) {
|
|
30
|
-
w.dataLayer.push({ ecommerce: null });
|
|
31
|
-
w.dataLayer.push({ event, ecommerce: payload });
|
|
32
|
-
}
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
formatPrice,
|
|
39
|
-
trackEcommerceEvent
|
|
40
|
-
};
|