@shoppexio/storefront 1.0.79 → 1.0.80

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.80
4
+
5
+ - Keep an existing affiliate code while the server resolves its attribution policy. Checkout can no longer read a replacement before a first-click decision arrives.
6
+ - Keep the existing code and its expiry when policy resolution fails or rejects the arriving code.
7
+
3
8
  ## 1.0.79
4
9
 
5
10
  - Attribution is now decided by the policy of the code that EARNED the hold, never by the one that just arrived. `captureAffiliateFromUrl()` sends the held code so the server can report its mode, and a first-click hold survives an affiliate on a last-click tier landing afterwards.
package/dist/index.cjs CHANGED
@@ -19516,8 +19516,7 @@ async function captureAffiliateFromUrl(param = "ref") {
19516
19516
  if (!code) return null;
19517
19517
  const held = getStoredAffiliate();
19518
19518
  const holdsOtherCode = held !== null && held.code !== code;
19519
- const mayHoldFirstClick = holdsOtherCode && held.mode === "FIRST_CLICK";
19520
- if (!mayHoldFirstClick) {
19519
+ if (!holdsOtherCode) {
19521
19520
  setAffiliateCode(code, held?.windowDays ?? DEFAULT_TTL_DAYS, held?.mode);
19522
19521
  }
19523
19522
  if (isInitialized()) {
@@ -19540,14 +19539,12 @@ async function captureAffiliateFromUrl(param = "ref") {
19540
19539
  const heldMode = res.success && res.data?.held_attribution_mode ? normalizeMode(res.data.held_attribution_mode) : null;
19541
19540
  const holdsFirstClick = holdsOtherCode && (heldMode ?? held?.mode) === "FIRST_CLICK";
19542
19541
  if (holdsFirstClick && held) {
19543
- if (!mayHoldFirstClick) {
19544
- restoreStoredAffiliate({
19545
- code: held.code,
19546
- expiresAt: held.expiresAt,
19547
- windowDays: held.windowDays,
19548
- mode: heldMode ?? "FIRST_CLICK"
19549
- });
19550
- }
19542
+ restoreStoredAffiliate({
19543
+ code: held.code,
19544
+ expiresAt: held.expiresAt,
19545
+ windowDays: held.windowDays,
19546
+ mode: heldMode ?? held.mode
19547
+ });
19551
19548
  return held.code;
19552
19549
  }
19553
19550
  if (res.success && res.data?.accepted && res.data.affiliate_code) {
@@ -19555,15 +19552,16 @@ async function captureAffiliateFromUrl(param = "ref") {
19555
19552
  return res.data.affiliate_code;
19556
19553
  }
19557
19554
  if (res.success && res.data && res.data.accepted === false) {
19555
+ if (holdsOtherCode) return held.code;
19558
19556
  clearAffiliateCode();
19559
19557
  return null;
19560
19558
  }
19561
- return mayHoldFirstClick ? held.code : code;
19559
+ return holdsOtherCode ? held.code : code;
19562
19560
  } catch {
19563
- return mayHoldFirstClick ? held.code : code;
19561
+ return holdsOtherCode ? held.code : code;
19564
19562
  }
19565
19563
  }
19566
- return mayHoldFirstClick ? held.code : code;
19564
+ return holdsOtherCode ? held.code : code;
19567
19565
  }
19568
19566
 
19569
19567
  // ../sdk/src/utils/cart-line-id.ts