@moonbase.sh/storefront-api 3.11.0 → 3.12.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/README.md CHANGED
@@ -24,7 +24,8 @@ Configuration notes:
24
24
 
25
25
  - `endpoint`: your Moonbase storefront URL.
26
26
  - `includeManifests`: include downloadable file manifests when available.
27
- - `persistUtm`: store detected UTM values and ad click IDs in localStorage instead of sessionStorage.
27
+ - `persistUtm`: in `@moonbase.sh/vue`, keep the attribution a visitor arrived with in localStorage, across visits, instead of sessionStorage for the tab. Only with the visitor's consent (see `attributionConsent`); a refusal removes it.
28
+ - `attributionConsent`: in `@moonbase.sh/vue`, whether the visitor has agreed to marketing cookies. `false` keeps the UTM tags, referrer and the ad platforms a click came from (`adClicks`) but not the ad click IDs themselves, and records a tagged arrival on the order only with the first thing put in the cart; `true` keeps the click IDs too. Left out, it follows the store's own setting in Moonbase, which the catalog reports for this visitor as `cookieConsentRequired`. Change it later with `setAttributionConsent()`.
28
29
 
29
30
  ## Common usage
30
31
 
@@ -211,6 +212,11 @@ from TikTok) go to the API under those names, and the rest as `utm_*`.
211
212
  in from the tags and click IDs it has already picked up, unless you pass your own
212
213
  `utm`.
213
214
 
215
+ A click ID identifies the visitor's click, so only send one once the visitor has
216
+ agreed to marketing cookies, where the law asks for that. `withoutClickIds(utm)`
217
+ drops their values and keeps the platforms they came from in `adClicks` (sent as
218
+ `utm_ad_click`), which still counts the visit as an ad click.
219
+
214
220
  ## Inventory flow
215
221
 
216
222
  Most inventory endpoints require an authenticated user:
package/dist/index.cjs CHANGED
@@ -54,6 +54,7 @@ __export(index_exports, {
54
54
  SubscriptionStatus: () => SubscriptionStatus,
55
55
  TokenStore: () => TokenStore,
56
56
  accessTokenLifetime: () => accessTokenLifetime,
57
+ adClicksOf: () => adClicksOf,
57
58
  imageWidths: () => imageWidths,
58
59
  isLocalStorageAvailable: () => isLocalStorageAvailable,
59
60
  isPromotionDisplay: () => isPromotionDisplay,
@@ -66,7 +67,8 @@ __export(index_exports, {
66
67
  promotionDisplays: () => promotionDisplays,
67
68
  resolveUtm: () => resolveUtm,
68
69
  schemas: () => schemas_exports12,
69
- utmToObject: () => utmToObject
70
+ utmToObject: () => utmToObject,
71
+ withoutClickIds: () => withoutClickIds
70
72
  });
71
73
  module.exports = __toCommonJS(index_exports);
72
74
 
@@ -117,6 +119,7 @@ var MarketingConsentType = /* @__PURE__ */ ((MarketingConsentType2) => {
117
119
  return MarketingConsentType2;
118
120
  })(MarketingConsentType || {});
119
121
  function utmToObject(utm) {
122
+ var _a;
120
123
  return Object.entries({
121
124
  utm_source: utm == null ? void 0 : utm.source,
122
125
  utm_medium: utm == null ? void 0 : utm.medium,
@@ -129,7 +132,8 @@ function utmToObject(utm) {
129
132
  wbraid: utm == null ? void 0 : utm.wbraid,
130
133
  fbclid: utm == null ? void 0 : utm.fbclid,
131
134
  msclkid: utm == null ? void 0 : utm.msclkid,
132
- ttclid: utm == null ? void 0 : utm.ttclid
135
+ ttclid: utm == null ? void 0 : utm.ttclid,
136
+ utm_ad_click: ((_a = utm == null ? void 0 : utm.adClicks) == null ? void 0 : _a.length) ? utm.adClicks.join(",") : void 0
133
137
  }).filter(([_, value]) => value !== void 0).reduce((obj, [key, value]) => ({
134
138
  ...obj,
135
139
  [key]: value
@@ -500,7 +504,11 @@ var storefrontSchema = import_zod3.z.object({
500
504
  // Promotions need to be optional since we may still have old, cached representations in browsers
501
505
  promotions: storefrontPromotionsSchema.optional(),
502
506
  // Depending on circumstances, we may have a tax estimate available
503
- estimatedTax: taxEstimateSchema.optional()
507
+ estimatedTax: taxEstimateSchema.optional(),
508
+ // Whether the storefront has to wait for this visitor's cookie consent before it keeps ad click
509
+ // IDs or remembers their visit: the store's setting, for the country the visit comes from.
510
+ // Optional for older backends and cached catalogs, which count as asking.
511
+ cookieConsentRequired: import_zod3.z.boolean().optional()
504
512
  });
505
513
 
506
514
  // src/activationRequests/models.ts
@@ -1295,7 +1303,7 @@ var ProductEndpoints = class {
1295
1303
  var import_zod15 = require("zod");
1296
1304
 
1297
1305
  // package.json
1298
- var version = "3.11.0";
1306
+ var version = "3.12.0";
1299
1307
 
1300
1308
  // src/utils/client.ts
1301
1309
  function buildClientHeader(sdk) {
@@ -3056,6 +3064,31 @@ var ImageUtils = class _ImageUtils {
3056
3064
  };
3057
3065
 
3058
3066
  // src/utils/utm.ts
3067
+ var clickIdPlatforms = [
3068
+ ["gclid", "google"],
3069
+ ["gbraid", "google"],
3070
+ ["wbraid", "google"],
3071
+ ["msclkid", "microsoft"],
3072
+ ["fbclid", "meta"],
3073
+ ["ttclid", "tiktok"]
3074
+ ];
3075
+ var adPlatformOrder = ["google", "microsoft", "meta", "tiktok"];
3076
+ function adClicksOf(utm) {
3077
+ var _a;
3078
+ if (!utm)
3079
+ return void 0;
3080
+ const platforms = new Set((_a = utm.adClicks) != null ? _a : []);
3081
+ for (const [key, platform] of clickIdPlatforms) {
3082
+ if (utm[key])
3083
+ platforms.add(platform);
3084
+ }
3085
+ const ordered = adPlatformOrder.filter((platform) => platforms.has(platform));
3086
+ return ordered.length > 0 ? ordered : void 0;
3087
+ }
3088
+ function withoutClickIds(utm) {
3089
+ const { gclid: _gclid, gbraid: _gbraid, wbraid: _wbraid, msclkid: _msclkid, fbclid: _fbclid, ttclid: _ttclid, ...rest } = utm;
3090
+ return { ...rest, adClicks: adClicksOf(utm) };
3091
+ }
3059
3092
  function parseOffSiteReferrer(rawReferrer, currentOrigin) {
3060
3093
  if (!rawReferrer)
3061
3094
  return void 0;
@@ -3070,7 +3103,7 @@ function parseOffSiteReferrer(rawReferrer, currentOrigin) {
3070
3103
  }
3071
3104
  function resolveUtm(cached, fresh) {
3072
3105
  const freshHasUtm = !!(fresh.source || fresh.medium || fresh.campaign || fresh.term || fresh.content);
3073
- const freshHasClickId = !!(fresh.gclid || fresh.gbraid || fresh.wbraid || fresh.fbclid || fresh.msclkid || fresh.ttclid);
3106
+ const freshHasClickId = !!adClicksOf(fresh);
3074
3107
  const freshIsExternalArrival = freshHasUtm || freshHasClickId || !!fresh.referrer;
3075
3108
  if (freshIsExternalArrival)
3076
3109
  return fresh;
@@ -3133,6 +3166,7 @@ var MoonbaseClient = class {
3133
3166
  SubscriptionStatus,
3134
3167
  TokenStore,
3135
3168
  accessTokenLifetime,
3169
+ adClicksOf,
3136
3170
  imageWidths,
3137
3171
  isLocalStorageAvailable,
3138
3172
  isPromotionDisplay,
@@ -3145,5 +3179,6 @@ var MoonbaseClient = class {
3145
3179
  promotionDisplays,
3146
3180
  resolveUtm,
3147
3181
  schemas,
3148
- utmToObject
3182
+ utmToObject,
3183
+ withoutClickIds
3149
3184
  });
package/dist/index.d.cts CHANGED
@@ -1773,12 +1773,21 @@ interface UrchinTrackingModule {
1773
1773
  msclkid?: string;
1774
1774
  /** TikTok Ads click ID, added to the landing page URL of a TikTok ad. */
1775
1775
  ttclid?: string;
1776
+ /**
1777
+ * The platforms whose click IDs were on the link. A click ID identifies the
1778
+ * visitor's click, so the storefront only passes one on once the visitor has
1779
+ * agreed to marketing cookies (`attributionConsent`). Until then it sends
1780
+ * these instead, which still tell Moonbase the visit came from an ad.
1781
+ */
1782
+ adClicks?: AdPlatform[];
1776
1783
  }
1784
+ /** An ad platform whose click IDs Moonbase recognises on a link. */
1785
+ type AdPlatform = 'google' | 'microsoft' | 'meta' | 'tiktok';
1777
1786
  /**
1778
- * The query parameters for `utm`: the tags and referrer as `utm_*`, and the ad
1787
+ * The query parameters for `utm`: the tags and referrer as `utm_*`, the ad
1779
1788
  * click IDs under their own names (`gclid`, `gbraid`, `wbraid`, `fbclid`,
1780
- * `msclkid`, `ttclid`), as they appear on the landing page URL. Fields left out
1781
- * are not sent.
1789
+ * `msclkid`, `ttclid`), as they appear on the landing page URL, and the
1790
+ * platforms they came from as `utm_ad_click`. Fields left out are not sent.
1782
1791
  */
1783
1792
  declare function utmToObject(utm?: UrchinTrackingModule): Record<string, string>;
1784
1793
 
@@ -27252,6 +27261,7 @@ declare class StorefrontEndpoints {
27252
27261
  rate: number;
27253
27262
  region?: string | undefined;
27254
27263
  } | undefined;
27264
+ cookieConsentRequired?: boolean | undefined;
27255
27265
  }>;
27256
27266
  }
27257
27267
 
@@ -51381,6 +51391,7 @@ declare const storefrontSchema: z.ZodObject<{
51381
51391
  rate: number;
51382
51392
  region?: string | undefined;
51383
51393
  }>>;
51394
+ cookieConsentRequired: z.ZodOptional<z.ZodBoolean>;
51384
51395
  }, "strip", z.ZodTypeAny, {
51385
51396
  products: {
51386
51397
  id: string;
@@ -51875,6 +51886,7 @@ declare const storefrontSchema: z.ZodObject<{
51875
51886
  rate: number;
51876
51887
  region?: string | undefined;
51877
51888
  } | undefined;
51889
+ cookieConsentRequired?: boolean | undefined;
51878
51890
  }, {
51879
51891
  products: {
51880
51892
  id: string;
@@ -52195,6 +52207,7 @@ declare const storefrontSchema: z.ZodObject<{
52195
52207
  rate: number;
52196
52208
  region?: string | undefined;
52197
52209
  } | undefined;
52210
+ cookieConsentRequired?: boolean | undefined;
52198
52211
  }>;
52199
52212
 
52200
52213
  declare const schemas$1_offerConditionSchema: typeof offerConditionSchema;
@@ -52579,6 +52592,20 @@ declare const problemDetailsSchema: z.ZodObject<{
52579
52592
  }>;
52580
52593
  type ProblemDetails = z.infer<typeof problemDetailsSchema>;
52581
52594
 
52595
+ /**
52596
+ * The platforms the click IDs in `utm` came from, together with any it already
52597
+ * names in `adClicks`, each once; undefined when there are none, so a visit
52598
+ * without an ad click carries no empty list.
52599
+ */
52600
+ declare function adClicksOf(utm: UrchinTrackingModule | undefined): AdPlatform[] | undefined;
52601
+ /**
52602
+ * `utm` without the values of its ad click IDs, which identify the visitor's
52603
+ * click, but still naming in `adClicks` the platforms they came from, which
52604
+ * identify no one. This is what the storefront keeps and sends until the
52605
+ * visitor has agreed to marketing cookies: the visit still counts as an ad
52606
+ * click, and a sale from it is still put down to the ad's tags.
52607
+ */
52608
+ declare function withoutClickIds(utm: UrchinTrackingModule): UrchinTrackingModule;
52582
52609
  /**
52583
52610
  * Returns the host of `rawReferrer` if it parses as a URL with a different
52584
52611
  * origin from `currentOrigin`. Returns `undefined` for same-origin (internal
@@ -52611,7 +52638,25 @@ declare function resolveUtm(cached: UrchinTrackingModule | undefined, fresh: Urc
52611
52638
 
52612
52639
  interface MoonbaseConfiguration {
52613
52640
  endpoint: string;
52641
+ /**
52642
+ * Keep the attribution a visitor arrived with in localStorage, across visits,
52643
+ * rather than in sessionStorage for the tab. Only with the visitor's consent
52644
+ * (see `attributionConsent`), as it remembers them beyond the visit; a refusal
52645
+ * removes it.
52646
+ */
52614
52647
  persistUtm?: boolean;
52648
+ /**
52649
+ * Whether the visitor has agreed to marketing cookies, as your cookie banner
52650
+ * reports it, so `@moonbase.sh/vue` may keep and send the ad click IDs on the
52651
+ * landing page URL (`gclid`, `fbclid` and the rest) and record a tagged arrival
52652
+ * before they put anything in the cart. Without them it keeps only the UTM
52653
+ * tags, the referring site and which ad platforms the click IDs came from, for
52654
+ * the tab. Left out, the storefront follows the store's own setting in Moonbase
52655
+ * (always, per country, or only with cookie consent), which the catalog
52656
+ * reports for this visitor as `cookieConsentRequired`. Change it later with
52657
+ * `setAttributionConsent()`.
52658
+ */
52659
+ attributionConsent?: boolean;
52615
52660
  includeManifests?: boolean;
52616
52661
  store?: IStore;
52617
52662
  logger?: ILogger;
@@ -52641,4 +52686,4 @@ declare class MoonbaseClient {
52641
52686
  orders: OrderEndpoints;
52642
52687
  }
52643
52688
 
52644
- export { type Activation, ActivationMethod, type ActivationReleaseNotCovered, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, Architecture, type BundleLineItem, CaptchaRequiredError, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, type LicenseReleaseAccess, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, PasswordSetupRequiredError, type PendingPlanChange, Platform, type PricingOption, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type ProductRelease, type ProductReleaseAccess, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, ReleaseNotCoveredError, type SignUpOptions, type SignUpResult, type SingleOrMultiple, StoreClosedError, type Storefront, type StorefrontBundle, type StorefrontLicenseUpgrade, type StorefrontLicenseUpgradeReleaseAccess, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, type SubscriptionCancellationFeedback, SubscriptionCancellationReason, type SubscriptionPlanOption, type SubscriptionPlanOptions, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type VendorCaptcha, type VendorFeatures, type Voucher, accessTokenLifetime, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject };
52689
+ export { type Activation, ActivationMethod, type ActivationReleaseNotCovered, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type AdPlatform, type Address, Architecture, type BundleLineItem, CaptchaRequiredError, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, type LicenseReleaseAccess, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, PasswordSetupRequiredError, type PendingPlanChange, Platform, type PricingOption, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type ProductRelease, type ProductReleaseAccess, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, ReleaseNotCoveredError, type SignUpOptions, type SignUpResult, type SingleOrMultiple, StoreClosedError, type Storefront, type StorefrontBundle, type StorefrontLicenseUpgrade, type StorefrontLicenseUpgradeReleaseAccess, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, type SubscriptionCancellationFeedback, SubscriptionCancellationReason, type SubscriptionPlanOption, type SubscriptionPlanOptions, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type VendorCaptcha, type VendorFeatures, type Voucher, accessTokenLifetime, adClicksOf, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject, withoutClickIds };
package/dist/index.d.ts CHANGED
@@ -1773,12 +1773,21 @@ interface UrchinTrackingModule {
1773
1773
  msclkid?: string;
1774
1774
  /** TikTok Ads click ID, added to the landing page URL of a TikTok ad. */
1775
1775
  ttclid?: string;
1776
+ /**
1777
+ * The platforms whose click IDs were on the link. A click ID identifies the
1778
+ * visitor's click, so the storefront only passes one on once the visitor has
1779
+ * agreed to marketing cookies (`attributionConsent`). Until then it sends
1780
+ * these instead, which still tell Moonbase the visit came from an ad.
1781
+ */
1782
+ adClicks?: AdPlatform[];
1776
1783
  }
1784
+ /** An ad platform whose click IDs Moonbase recognises on a link. */
1785
+ type AdPlatform = 'google' | 'microsoft' | 'meta' | 'tiktok';
1777
1786
  /**
1778
- * The query parameters for `utm`: the tags and referrer as `utm_*`, and the ad
1787
+ * The query parameters for `utm`: the tags and referrer as `utm_*`, the ad
1779
1788
  * click IDs under their own names (`gclid`, `gbraid`, `wbraid`, `fbclid`,
1780
- * `msclkid`, `ttclid`), as they appear on the landing page URL. Fields left out
1781
- * are not sent.
1789
+ * `msclkid`, `ttclid`), as they appear on the landing page URL, and the
1790
+ * platforms they came from as `utm_ad_click`. Fields left out are not sent.
1782
1791
  */
1783
1792
  declare function utmToObject(utm?: UrchinTrackingModule): Record<string, string>;
1784
1793
 
@@ -27252,6 +27261,7 @@ declare class StorefrontEndpoints {
27252
27261
  rate: number;
27253
27262
  region?: string | undefined;
27254
27263
  } | undefined;
27264
+ cookieConsentRequired?: boolean | undefined;
27255
27265
  }>;
27256
27266
  }
27257
27267
 
@@ -51381,6 +51391,7 @@ declare const storefrontSchema: z.ZodObject<{
51381
51391
  rate: number;
51382
51392
  region?: string | undefined;
51383
51393
  }>>;
51394
+ cookieConsentRequired: z.ZodOptional<z.ZodBoolean>;
51384
51395
  }, "strip", z.ZodTypeAny, {
51385
51396
  products: {
51386
51397
  id: string;
@@ -51875,6 +51886,7 @@ declare const storefrontSchema: z.ZodObject<{
51875
51886
  rate: number;
51876
51887
  region?: string | undefined;
51877
51888
  } | undefined;
51889
+ cookieConsentRequired?: boolean | undefined;
51878
51890
  }, {
51879
51891
  products: {
51880
51892
  id: string;
@@ -52195,6 +52207,7 @@ declare const storefrontSchema: z.ZodObject<{
52195
52207
  rate: number;
52196
52208
  region?: string | undefined;
52197
52209
  } | undefined;
52210
+ cookieConsentRequired?: boolean | undefined;
52198
52211
  }>;
52199
52212
 
52200
52213
  declare const schemas$1_offerConditionSchema: typeof offerConditionSchema;
@@ -52579,6 +52592,20 @@ declare const problemDetailsSchema: z.ZodObject<{
52579
52592
  }>;
52580
52593
  type ProblemDetails = z.infer<typeof problemDetailsSchema>;
52581
52594
 
52595
+ /**
52596
+ * The platforms the click IDs in `utm` came from, together with any it already
52597
+ * names in `adClicks`, each once; undefined when there are none, so a visit
52598
+ * without an ad click carries no empty list.
52599
+ */
52600
+ declare function adClicksOf(utm: UrchinTrackingModule | undefined): AdPlatform[] | undefined;
52601
+ /**
52602
+ * `utm` without the values of its ad click IDs, which identify the visitor's
52603
+ * click, but still naming in `adClicks` the platforms they came from, which
52604
+ * identify no one. This is what the storefront keeps and sends until the
52605
+ * visitor has agreed to marketing cookies: the visit still counts as an ad
52606
+ * click, and a sale from it is still put down to the ad's tags.
52607
+ */
52608
+ declare function withoutClickIds(utm: UrchinTrackingModule): UrchinTrackingModule;
52582
52609
  /**
52583
52610
  * Returns the host of `rawReferrer` if it parses as a URL with a different
52584
52611
  * origin from `currentOrigin`. Returns `undefined` for same-origin (internal
@@ -52611,7 +52638,25 @@ declare function resolveUtm(cached: UrchinTrackingModule | undefined, fresh: Urc
52611
52638
 
52612
52639
  interface MoonbaseConfiguration {
52613
52640
  endpoint: string;
52641
+ /**
52642
+ * Keep the attribution a visitor arrived with in localStorage, across visits,
52643
+ * rather than in sessionStorage for the tab. Only with the visitor's consent
52644
+ * (see `attributionConsent`), as it remembers them beyond the visit; a refusal
52645
+ * removes it.
52646
+ */
52614
52647
  persistUtm?: boolean;
52648
+ /**
52649
+ * Whether the visitor has agreed to marketing cookies, as your cookie banner
52650
+ * reports it, so `@moonbase.sh/vue` may keep and send the ad click IDs on the
52651
+ * landing page URL (`gclid`, `fbclid` and the rest) and record a tagged arrival
52652
+ * before they put anything in the cart. Without them it keeps only the UTM
52653
+ * tags, the referring site and which ad platforms the click IDs came from, for
52654
+ * the tab. Left out, the storefront follows the store's own setting in Moonbase
52655
+ * (always, per country, or only with cookie consent), which the catalog
52656
+ * reports for this visitor as `cookieConsentRequired`. Change it later with
52657
+ * `setAttributionConsent()`.
52658
+ */
52659
+ attributionConsent?: boolean;
52615
52660
  includeManifests?: boolean;
52616
52661
  store?: IStore;
52617
52662
  logger?: ILogger;
@@ -52641,4 +52686,4 @@ declare class MoonbaseClient {
52641
52686
  orders: OrderEndpoints;
52642
52687
  }
52643
52688
 
52644
- export { type Activation, ActivationMethod, type ActivationReleaseNotCovered, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, Architecture, type BundleLineItem, CaptchaRequiredError, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, type LicenseReleaseAccess, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, PasswordSetupRequiredError, type PendingPlanChange, Platform, type PricingOption, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type ProductRelease, type ProductReleaseAccess, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, ReleaseNotCoveredError, type SignUpOptions, type SignUpResult, type SingleOrMultiple, StoreClosedError, type Storefront, type StorefrontBundle, type StorefrontLicenseUpgrade, type StorefrontLicenseUpgradeReleaseAccess, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, type SubscriptionCancellationFeedback, SubscriptionCancellationReason, type SubscriptionPlanOption, type SubscriptionPlanOptions, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type VendorCaptcha, type VendorFeatures, type Voucher, accessTokenLifetime, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject };
52689
+ export { type Activation, ActivationMethod, type ActivationReleaseNotCovered, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type AdPlatform, type Address, Architecture, type BundleLineItem, CaptchaRequiredError, type CartCatalog, type CartOrder, type CartTotal, type CartTotalCondition, CartUtils, type CommunicationPreferences, type CommunicationPreferencesInput, type CommunicationPreferencesView, type CompletedOrder, ConnectableAccountProvider, type ConnectedAccount, ConsoleLogger, CycleLength, type Discount, DiscountUtils, type Download, type DownloadManifest, type ILogger, type IRecurrence, type IStore, type ITokenStore, type Identity, type ImageFit, type ImageFormat, type ImageTransform, ImageUtils, InMemoryStore, type License, type LicenseReleaseAccess, LicenseStatus, type LineItem, type LineItemTotal, LocalStorageStore, LogLevel, MarketingConsentType, type MilestoneProgress, type Money, type MoneyCollection, MoneyCollectionUtils, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OfferCondition, type OfferConditionContext, type OfferProgress, type OfferScope, OfferUtils, type OpenOrder, type Order, OrderStatus, type OrderTotal, type OwnedProduct, type Page, PasswordSetupRequiredError, type PendingPlanChange, Platform, type PricingOption, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type ProductRelease, type ProductReleaseAccess, type PromotionDisplay, type Quantifiable, type RawPropertyArray, type RawPropertyObject, type RawPropertyValue, ReleaseNotCoveredError, type SignUpOptions, type SignUpResult, type SingleOrMultiple, StoreClosedError, type Storefront, type StorefrontBundle, type StorefrontLicenseUpgrade, type StorefrontLicenseUpgradeReleaseAccess, type StorefrontOffer, type StorefrontOfferTarget, type StorefrontProduct, type StorefrontPromotion, type StorefrontPromotionCta, type StorefrontPromotionTarget, type SubscribeInput, type SubscribeResponse, type Subscription, type SubscriptionCancellationFeedback, SubscriptionCancellationReason, type SubscriptionPlanOption, type SubscriptionPlanOptions, SubscriptionStatus, type TaxEstimate, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type UserAccountConfirmedStatus, type Vendor, type VendorCaptcha, type VendorFeatures, type Voucher, accessTokenLifetime, adClicksOf, imageWidths, isLocalStorageAvailable, isPromotionDisplay, isTransformableImageUrl, maxImageDimension, normalizeGroupIds, objectToQuery, parseOffSiteReferrer, problemDetailsSchema, promotionDisplays, resolveUtm, schemas, utmToObject, withoutClickIds };
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ var MarketingConsentType = /* @__PURE__ */ ((MarketingConsentType2) => {
51
51
  return MarketingConsentType2;
52
52
  })(MarketingConsentType || {});
53
53
  function utmToObject(utm) {
54
+ var _a;
54
55
  return Object.entries({
55
56
  utm_source: utm == null ? void 0 : utm.source,
56
57
  utm_medium: utm == null ? void 0 : utm.medium,
@@ -63,7 +64,8 @@ function utmToObject(utm) {
63
64
  wbraid: utm == null ? void 0 : utm.wbraid,
64
65
  fbclid: utm == null ? void 0 : utm.fbclid,
65
66
  msclkid: utm == null ? void 0 : utm.msclkid,
66
- ttclid: utm == null ? void 0 : utm.ttclid
67
+ ttclid: utm == null ? void 0 : utm.ttclid,
68
+ utm_ad_click: ((_a = utm == null ? void 0 : utm.adClicks) == null ? void 0 : _a.length) ? utm.adClicks.join(",") : void 0
67
69
  }).filter(([_, value]) => value !== void 0).reduce((obj, [key, value]) => ({
68
70
  ...obj,
69
71
  [key]: value
@@ -434,7 +436,11 @@ var storefrontSchema = z3.object({
434
436
  // Promotions need to be optional since we may still have old, cached representations in browsers
435
437
  promotions: storefrontPromotionsSchema.optional(),
436
438
  // Depending on circumstances, we may have a tax estimate available
437
- estimatedTax: taxEstimateSchema.optional()
439
+ estimatedTax: taxEstimateSchema.optional(),
440
+ // Whether the storefront has to wait for this visitor's cookie consent before it keeps ad click
441
+ // IDs or remembers their visit: the store's setting, for the country the visit comes from.
442
+ // Optional for older backends and cached catalogs, which count as asking.
443
+ cookieConsentRequired: z3.boolean().optional()
438
444
  });
439
445
 
440
446
  // src/activationRequests/models.ts
@@ -1229,7 +1235,7 @@ var ProductEndpoints = class {
1229
1235
  import { z as z15 } from "zod";
1230
1236
 
1231
1237
  // package.json
1232
- var version = "3.11.0";
1238
+ var version = "3.12.0";
1233
1239
 
1234
1240
  // src/utils/client.ts
1235
1241
  function buildClientHeader(sdk) {
@@ -2990,6 +2996,31 @@ var ImageUtils = class _ImageUtils {
2990
2996
  };
2991
2997
 
2992
2998
  // src/utils/utm.ts
2999
+ var clickIdPlatforms = [
3000
+ ["gclid", "google"],
3001
+ ["gbraid", "google"],
3002
+ ["wbraid", "google"],
3003
+ ["msclkid", "microsoft"],
3004
+ ["fbclid", "meta"],
3005
+ ["ttclid", "tiktok"]
3006
+ ];
3007
+ var adPlatformOrder = ["google", "microsoft", "meta", "tiktok"];
3008
+ function adClicksOf(utm) {
3009
+ var _a;
3010
+ if (!utm)
3011
+ return void 0;
3012
+ const platforms = new Set((_a = utm.adClicks) != null ? _a : []);
3013
+ for (const [key, platform] of clickIdPlatforms) {
3014
+ if (utm[key])
3015
+ platforms.add(platform);
3016
+ }
3017
+ const ordered = adPlatformOrder.filter((platform) => platforms.has(platform));
3018
+ return ordered.length > 0 ? ordered : void 0;
3019
+ }
3020
+ function withoutClickIds(utm) {
3021
+ const { gclid: _gclid, gbraid: _gbraid, wbraid: _wbraid, msclkid: _msclkid, fbclid: _fbclid, ttclid: _ttclid, ...rest } = utm;
3022
+ return { ...rest, adClicks: adClicksOf(utm) };
3023
+ }
2993
3024
  function parseOffSiteReferrer(rawReferrer, currentOrigin) {
2994
3025
  if (!rawReferrer)
2995
3026
  return void 0;
@@ -3004,7 +3035,7 @@ function parseOffSiteReferrer(rawReferrer, currentOrigin) {
3004
3035
  }
3005
3036
  function resolveUtm(cached, fresh) {
3006
3037
  const freshHasUtm = !!(fresh.source || fresh.medium || fresh.campaign || fresh.term || fresh.content);
3007
- const freshHasClickId = !!(fresh.gclid || fresh.gbraid || fresh.wbraid || fresh.fbclid || fresh.msclkid || fresh.ttclid);
3038
+ const freshHasClickId = !!adClicksOf(fresh);
3008
3039
  const freshIsExternalArrival = freshHasUtm || freshHasClickId || !!fresh.referrer;
3009
3040
  if (freshIsExternalArrival)
3010
3041
  return fresh;
@@ -3066,6 +3097,7 @@ export {
3066
3097
  SubscriptionStatus,
3067
3098
  TokenStore,
3068
3099
  accessTokenLifetime,
3100
+ adClicksOf,
3069
3101
  imageWidths,
3070
3102
  isLocalStorageAvailable,
3071
3103
  isPromotionDisplay,
@@ -3078,5 +3110,6 @@ export {
3078
3110
  promotionDisplays,
3079
3111
  resolveUtm,
3080
3112
  schemas_exports12 as schemas,
3081
- utmToObject
3113
+ utmToObject,
3114
+ withoutClickIds
3082
3115
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/storefront-api",
3
3
  "type": "module",
4
- "version": "3.11.0",
4
+ "version": "3.12.0",
5
5
  "description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",