@vio-live/web-sdk 0.36.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=chunk-6HBX7GBJ.js.map
3
+ //# sourceMappingURL=chunk-6HBX7GBJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-3YFJFDSN.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-6HBX7GBJ.js"}
@@ -3969,7 +3969,7 @@ async function prepareApplePay(config) {
3969
3969
  }
3970
3970
 
3971
3971
  // src/core/version.ts
3972
- var SDK_VERSION = "0.36.0";
3972
+ var SDK_VERSION = "0.37.1";
3973
3973
 
3974
3974
  // src/core/checkout/payments/stripe-embedded.ts
3975
3975
  var CREATE_PAYMENT_INTENT_STRIPE_MUTATION = `
@@ -6298,9 +6298,17 @@ var CheckoutManager = class _CheckoutManager extends EventTarget {
6298
6298
  resumeKustom();
6299
6299
  }
6300
6300
  }
6301
- /** Re-read a Kustom order — used on the confirmation return trip. */
6302
- async getKustomOrder(orderId, sponsorId) {
6303
- const opts = await this.gqlOptions(sponsorId ?? this.state?.sponsorId);
6301
+ /**
6302
+ * Re-read a Kustom order — used on the confirmation return trip. The order
6303
+ * id is Kustom's, so it says nothing of whose it is: `checkoutId` (Vio's,
6304
+ * from the return URL) does. The sponsor and channel this tab remembered for
6305
+ * that checkout win over the open checkout's, as for Qliro and Walley —
6306
+ * without them a return with no cart left (the order already completed it)
6307
+ * read with the platform key and was refused (QA, 2026-10-29).
6308
+ */
6309
+ async getKustomOrder(orderId, sponsorId, checkoutId) {
6310
+ const checkout = checkoutId || void 0;
6311
+ const opts = await this.gqlOptions(this.sponsorIdOfCheckout(checkout) ?? sponsorId ?? this.state?.sponsorId, checkout);
6304
6312
  return getKustomOrder(orderId, opts);
6305
6313
  }
6306
6314
  /** Render a Kustom html_snippet (e.g. the confirmation receipt) into a container. */
@@ -7908,6 +7916,91 @@ function localStorageOrNull() {
7908
7916
  }
7909
7917
  }
7910
7918
 
7919
+ // src/core/analytics/cta.ts
7920
+ var CTA_LOCATIONS = ["detail", "cart", "card", "checkout", "host", "block"];
7921
+ var CTA_ID_PATTERN = /^[a-z0-9_.:-]{1,64}$/;
7922
+ var CTA_VARIANT_PATTERN = /^[A-Za-z0-9._:-]{1,64}$/;
7923
+ var CTA_TEXT_MAX_LENGTH = 64;
7924
+ var ID_MAX_LENGTH = 128;
7925
+ function isCtaId(value) {
7926
+ return typeof value === "string" && CTA_ID_PATTERN.test(value);
7927
+ }
7928
+ function ctaText(value, max = CTA_TEXT_MAX_LENGTH) {
7929
+ if (typeof value !== "string" && typeof value !== "number") return void 0;
7930
+ const clean = String(value).replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim();
7931
+ if (!clean) return void 0;
7932
+ if (clean.length <= max) return clean;
7933
+ let cut4 = clean.slice(0, max);
7934
+ const last = cut4.charCodeAt(cut4.length - 1);
7935
+ if (last >= 55296 && last <= 56319) cut4 = cut4.slice(0, -1);
7936
+ return cut4.trimEnd() || void 0;
7937
+ }
7938
+ function idOf(value) {
7939
+ if (typeof value === "number") return Number.isFinite(value) ? String(value) : void 0;
7940
+ if (typeof value !== "string") return void 0;
7941
+ const v = value.trim();
7942
+ return v && v.length <= ID_MAX_LENGTH ? v : void 0;
7943
+ }
7944
+ function positive(value) {
7945
+ const n = toNumber(value);
7946
+ return n !== void 0 && Number.isInteger(n) && n > 0 ? n : void 0;
7947
+ }
7948
+ function warn(message) {
7949
+ try {
7950
+ console.warn(`[Vio.trackCta] ${message}`);
7951
+ } catch {
7952
+ }
7953
+ }
7954
+ function ctaContextOf(input) {
7955
+ const cta = input?.cta;
7956
+ if (!isCtaId(cta)) {
7957
+ warn(`ignored: cta must be 1\u201364 chars of [a-z0-9_.:-], got ${JSON.stringify(cta)}`);
7958
+ return null;
7959
+ }
7960
+ let location2 = "host";
7961
+ if (input.location !== void 0 && input.location !== null && input.location !== "") {
7962
+ if (CTA_LOCATIONS.includes(String(input.location))) {
7963
+ location2 = input.location;
7964
+ } else {
7965
+ warn(`unknown location ${JSON.stringify(input.location)} \u2014 sent as 'host' (${CTA_LOCATIONS.join(" | ")})`);
7966
+ }
7967
+ }
7968
+ let variant;
7969
+ if (input.variant !== void 0 && input.variant !== null && input.variant !== "") {
7970
+ if (typeof input.variant === "string" && CTA_VARIANT_PATTERN.test(input.variant)) variant = input.variant;
7971
+ else warn(`variant left out: 1\u201364 chars of [A-Za-z0-9._:-], got ${JSON.stringify(input.variant)}`);
7972
+ }
7973
+ const i = input;
7974
+ const layout = normalizeLayoutOrigin(i.layout);
7975
+ const contentId = typeof i.contentId === "number" ? Number.isFinite(i.contentId) ? i.contentId : void 0 : idOf(i.contentId);
7976
+ const slot = typeof i.slot === "string" && i.slot.trim() ? i.slot.trim() : void 0;
7977
+ const ctx = {
7978
+ cta,
7979
+ ctaLocation: location2,
7980
+ ctaLabel: ctaText(i.label),
7981
+ ctaVariant: variant,
7982
+ optionValue: ctaText(i.optionValue),
7983
+ productId: idOf(i.productId),
7984
+ productVariantId: idOf(i.productVariantId),
7985
+ sponsorId: positive(i.sponsorId),
7986
+ campaignId: positive(i.campaignId),
7987
+ slot,
7988
+ contentId,
7989
+ contentTitle: typeof i.contentTitle === "string" && i.contentTitle.trim() ? i.contentTitle.trim() : void 0,
7990
+ componentTemplateId: idOf(i.componentTemplateId),
7991
+ ...layout.layoutId ? {
7992
+ layoutId: layout.layoutId,
7993
+ layoutRevision: layout.layoutRevision ?? "",
7994
+ experimentId: layout.experimentId,
7995
+ variantId: layout.variantId
7996
+ } : {}
7997
+ };
7998
+ for (const key of Object.keys(ctx)) {
7999
+ if (ctx[key] === void 0) delete ctx[key];
8000
+ }
8001
+ return ctx;
8002
+ }
8003
+
7911
8004
  // src/core/cart/slices.ts
7912
8005
  function cartSlicesFrom(lines, resolveCampaign, fallbackCurrency) {
7913
8006
  if (!Array.isArray(lines) || lines.length === 0) return [];
@@ -8222,6 +8315,20 @@ var AnalyticsManager = class extends EventTarget {
8222
8315
  if (this.queue.length > MAX_QUEUE) this.queue.splice(0, this.queue.length - MAX_QUEUE);
8223
8316
  if (this.queue.length >= FLUSH_AT_COUNT) void this.flush();
8224
8317
  }
8318
+ /**
8319
+ * One `cta_click` — a tap on a button (README «Button tracking»). What
8320
+ * `Vio.trackCta()` calls for a host's own buttons; the SDK's elements reach
8321
+ * it through `vio:cta-click`. Only once `start()` ran — like the funnel
8322
+ * events of the elements, never queued before. An invalid `cta` is ignored
8323
+ * with one `console.warn`; consent, `privateContent`, internal traffic,
8324
+ * batching and attribution are those of every event.
8325
+ */
8326
+ trackCta(input) {
8327
+ if (!hasDom() || !this.started) return;
8328
+ const context = ctaContextOf(input);
8329
+ if (!context) return;
8330
+ this.track("cta_click", { context });
8331
+ }
8225
8332
  /**
8226
8333
  * Impression helper: observes an element and tracks ONE
8227
8334
  * `component_impression` per (session, campaignComponentId) when the
@@ -8344,7 +8451,16 @@ var AnalyticsManager = class extends EventTarget {
8344
8451
  layout_id: ctx.layoutId,
8345
8452
  layout_revision: ctx.layoutRevision,
8346
8453
  experiment_id: ctx.experimentId,
8347
- variant_id: ctx.variantId
8454
+ variant_id: ctx.variantId,
8455
+ // `cta_click` (./cta.ts). Con `privateContent` el texto del botón y el
8456
+ // valor elegido no salen del dispositivo: pueden nombrar el producto.
8457
+ cta: ctx.cta,
8458
+ cta_location: ctx.ctaLocation,
8459
+ cta_label: this.options.privateContent ? void 0 : ctx.ctaLabel,
8460
+ cta_variant: ctx.ctaVariant,
8461
+ option_value: this.options.privateContent ? void 0 : ctx.optionValue,
8462
+ product_id: ctx.productId,
8463
+ product_variant_id: ctx.productVariantId
8348
8464
  });
8349
8465
  const com = opts.commerce;
8350
8466
  const commerce = com ? compact({
@@ -8581,6 +8697,10 @@ var AnalyticsManager = class extends EventTarget {
8581
8697
  }
8582
8698
  });
8583
8699
  });
8700
+ on("vio:cta-click", (ev) => {
8701
+ const d = ev.detail;
8702
+ if (d) this.trackCta(d);
8703
+ });
8584
8704
  on("vio:open-cart", () => {
8585
8705
  const snap = this.cartCommerce();
8586
8706
  this.track("view_cart", snap ? { commerce: snap } : {});
@@ -9350,6 +9470,22 @@ var VioFacade = class {
9350
9470
  detailLayout() {
9351
9471
  return copyAppliedLayout(resolveDetailLayout(null));
9352
9472
  }
9473
+ /**
9474
+ * Report a tap on one of the host's own buttons (its cards, its article
9475
+ * blocks) as `cta_click`, the event the SDK's own buttons send — so the
9476
+ * dashboard compares them on one scale. `{ cta, location?, label?,
9477
+ * variant?, optionValue?, productId?, productVariantId?, sponsorId?,
9478
+ * campaignId?, slot?, contentId?, layout? }`; `location` is `host` by
9479
+ * default (`card` / `block` for the host's cards and article blocks). An
9480
+ * invalid `cta` is ignored with one `console.warn`. Nothing is sent before
9481
+ * `Vio.analytics.start()`. Never throws. See README «Button tracking».
9482
+ */
9483
+ trackCta(input) {
9484
+ try {
9485
+ this.analytics.trackCta(input);
9486
+ } catch {
9487
+ }
9488
+ }
9353
9489
  get isInitialized() {
9354
9490
  return Configuration.isInitialized;
9355
9491
  }
@@ -9677,7 +9813,7 @@ var VioFacade = class {
9677
9813
  const all = normalizeSlotLocations(slots);
9678
9814
  if (all.length === 0) return null;
9679
9815
  if (!Configuration.isInitialized) {
9680
- warn("declareSlots() before Vio.init() \u2014 nothing declared");
9816
+ warn2("declareSlots() before Vio.init() \u2014 nothing declared");
9681
9817
  return null;
9682
9818
  }
9683
9819
  const cfg = Configuration.get();
@@ -9695,7 +9831,7 @@ var VioFacade = class {
9695
9831
  if (locations.length > MAX_LOCATIONS_PER_DECLARATION) {
9696
9832
  if (!this.warnedLocationCap) {
9697
9833
  this.warnedLocationCap = true;
9698
- warn(
9834
+ warn2(
9699
9835
  `declareSlots(): ${locations.length} slots on one page \u2014 only the first ${MAX_LOCATIONS_PER_DECLARATION} are declared`
9700
9836
  );
9701
9837
  }
@@ -9705,7 +9841,7 @@ var VioFacade = class {
9705
9841
  if (!opts.force && this.declarationsThisLoad >= MAX_DECLARATIONS_PER_LOAD) {
9706
9842
  if (!this.warnedDeclarationCap) {
9707
9843
  this.warnedDeclarationCap = true;
9708
- warn(
9844
+ warn2(
9709
9845
  `declareSlots(): already ${MAX_DECLARATIONS_PER_LOAD} manifests this page load \u2014 further ones are skipped (force: true to override)`
9710
9846
  );
9711
9847
  }
@@ -9727,7 +9863,7 @@ var VioFacade = class {
9727
9863
  writeSlotDeclaration(storageKey, next);
9728
9864
  } else {
9729
9865
  writeSlotDeclaration(storageKey, rememberSlotKeys(memory2, keys, failedAt(now)));
9730
- warn(
9866
+ warn2(
9731
9867
  "slots declared but the server ignored mode=merge (old server); not caching, will retry next load"
9732
9868
  );
9733
9869
  }
@@ -9736,7 +9872,7 @@ var VioFacade = class {
9736
9872
  if (storageKey && keys.length > 0) {
9737
9873
  writeSlotDeclaration(storageKey, rememberSlotKeys(readSlotDeclaration(storageKey), keys, failedAt(now)));
9738
9874
  }
9739
- warn("declareSlots() failed \u2014", err);
9875
+ warn2("declareSlots() failed \u2014", err);
9740
9876
  return null;
9741
9877
  }
9742
9878
  }
@@ -10098,11 +10234,11 @@ var VioFacade = class {
10098
10234
  if (sentCampaign === void 0) continue;
10099
10235
  if (l.assignment === "dashboard" && !this.warnedDashboardSlots.has(l.locationId)) {
10100
10236
  this.warnedDashboardSlots.add(l.locationId);
10101
- warn(`slot ${l.locationId} is assigned from the dashboard; the page's campaign is ignored there`);
10237
+ warn2(`slot ${l.locationId} is assigned from the dashboard; the page's campaign is ignored there`);
10102
10238
  }
10103
10239
  if (l.assignment === "replaced" && !this.warnedReplacedSlots.has(l.locationId)) {
10104
10240
  this.warnedReplacedSlots.add(l.locationId);
10105
- warn(`slot ${l.locationId} moved to campaign ${sentCampaign} by this page (it replaced an earlier page assignment)`);
10241
+ warn2(`slot ${l.locationId} moved to campaign ${sentCampaign} by this page (it replaced an earlier page assignment)`);
10106
10242
  }
10107
10243
  }
10108
10244
  }
@@ -10174,7 +10310,7 @@ function documentCampaignHints() {
10174
10310
  return [];
10175
10311
  }
10176
10312
  }
10177
- function warn(...args) {
10313
+ function warn2(...args) {
10178
10314
  if (typeof console !== "undefined") console.warn("[Vio]", ...args);
10179
10315
  }
10180
10316
  function failedAt(now) {
@@ -10232,6 +10368,6 @@ function vippsButtonAttributes(verb = "buy", opts = {}) {
10232
10368
  };
10233
10369
  }
10234
10370
 
10235
- export { ADD_ITEM_MUTATION, ADYEN_RETURN_METHOD, ADYEN_RETURN_QUERY_KEYS, AdyenOriginError, AnalyticsManager, BUYER_REF_MAX_LENGTH, CHECKOUT_ATTRIBUTION_CAPS, CHECKOUT_SPONSOR_STORAGE_KEY, CLIENT_LANDING_URL_MAX_LENGTH, CONTENT_URL_MAX_LENGTH, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, CartManager, CheckoutManager, CommerceClient, Configuration, DELETE_ITEM_MUTATION, DETAIL_SECTION_IDS, ESSENTIAL_DETAIL_SECTIONS, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, GRAPHQL_INT_MAX, INTERNAL_KEY, INTERNAL_PARAM, KUSTOM_RETURN_QUERY_KEYS, LINE_ORIGIN_CAPS, SDK_VERSION, UPDATE_CHECKOUT_MUTATION, UPDATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_ITEM_WITH_ORIGIN_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, __decorateClass, activeCampaignEntry, addItem, adyenReturnOutcome, adyenReturnParams, autoSlotDisplayName, autoSlotId, buyerRefOf, campaignCandidates, capContentUrl, cartSlicesFrom, checkApplePayAvailability, checkoutAttributionOf, checkoutSponsorOf, componentKindOf, copyAppliedLayout, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, currentGlobalDescriptionLabel, defaultDetailLayout, deleteItem, displayPrice, dominantCampaignOf, effectiveDetailSections, ensureVippsButton, entryContextOf, executeCartGraphQL, formatPrice, gatewayHas, gatewayHasBuyerRef, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCheckoutReference, getCustomerSessionId, getGlobalCountryCode, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, isUnknownFeatureError, isUnknownTokenError, isValidPhone, kustomReturnOutcome, landingUrl, layoutOriginOf, layoutSignature, lineOriginWire, lineOrigins, nexiReturnPaymentId, normalizeBuyerRef, normalizeDetailLayout, normalizeOrigin, normalizeScope, normalizeSlotId, normalizeSlotKind, onGlobalDetailLayoutChange, originAndPath, primaryImageUrl, purchaseFromPaymentSuccess, purchaseIdsOf, readInternal, readNexiPending, rememberedCheckoutSponsor, resetGatewayFeatures, resolveCampaignId, resolveClientContext, resolveContent, resolveDetailLayout, resolveInternal, resolveLanding, resolveSlotCampaign, sameOrigin, shippingDescriptionOf, showApplePaySheet, sponsorCampaignEntry, sponsorIdentityFrom, storageGet, storedLanding, toCampaignId, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes, withGatewayFeature, writeInternal };
10236
- //# sourceMappingURL=chunk-6PQFXUOW.js.map
10237
- //# sourceMappingURL=chunk-6PQFXUOW.js.map
10371
+ export { ADD_ITEM_MUTATION, ADYEN_RETURN_METHOD, ADYEN_RETURN_QUERY_KEYS, AdyenOriginError, AnalyticsManager, BUYER_REF_MAX_LENGTH, CHECKOUT_ATTRIBUTION_CAPS, CHECKOUT_SPONSOR_STORAGE_KEY, CLIENT_LANDING_URL_MAX_LENGTH, CONTENT_URL_MAX_LENGTH, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, CTA_ID_PATTERN, CTA_LOCATIONS, CTA_TEXT_MAX_LENGTH, CTA_VARIANT_PATTERN, CartManager, CheckoutManager, CommerceClient, Configuration, DELETE_ITEM_MUTATION, DETAIL_SECTION_IDS, ESSENTIAL_DETAIL_SECTIONS, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, GRAPHQL_INT_MAX, INTERNAL_KEY, INTERNAL_PARAM, KUSTOM_RETURN_QUERY_KEYS, LINE_ORIGIN_CAPS, SDK_VERSION, UPDATE_CHECKOUT_MUTATION, UPDATE_CHECKOUT_WITH_ATTRIBUTION_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_ITEM_WITH_ORIGIN_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, __decorateClass, activeCampaignEntry, addItem, adyenReturnOutcome, adyenReturnParams, autoSlotDisplayName, autoSlotId, buyerRefOf, campaignCandidates, capContentUrl, cartSlicesFrom, checkApplePayAvailability, checkoutAttributionOf, checkoutSponsorOf, componentKindOf, copyAppliedLayout, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, ctaContextOf, ctaText, currentGlobalDescriptionLabel, defaultDetailLayout, deleteItem, displayPrice, dominantCampaignOf, effectiveDetailSections, ensureVippsButton, entryContextOf, executeCartGraphQL, formatPrice, gatewayHas, gatewayHasBuyerRef, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCheckoutReference, getCustomerSessionId, getGlobalCountryCode, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, isCtaId, isUnknownFeatureError, isUnknownTokenError, isValidPhone, kustomReturnOutcome, landingUrl, layoutOriginOf, layoutSignature, lineOriginWire, lineOrigins, nexiReturnPaymentId, normalizeBuyerRef, normalizeDetailLayout, normalizeOrigin, normalizeScope, normalizeSlotId, normalizeSlotKind, onGlobalDetailLayoutChange, originAndPath, primaryImageUrl, purchaseFromPaymentSuccess, purchaseIdsOf, readInternal, readNexiPending, rememberedCheckoutSponsor, resetGatewayFeatures, resolveCampaignId, resolveClientContext, resolveContent, resolveDetailLayout, resolveInternal, resolveLanding, resolveSlotCampaign, sameOrigin, shippingDescriptionOf, showApplePaySheet, sponsorCampaignEntry, sponsorIdentityFrom, storageGet, storedLanding, toCampaignId, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes, withGatewayFeature, writeInternal };
10372
+ //# sourceMappingURL=chunk-GUXBD7KR.js.map
10373
+ //# sourceMappingURL=chunk-GUXBD7KR.js.map