@economist/web-apple-pay 1.12.0 → 1.14.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 +8 -7
- package/dist/index.js +27 -92
- package/dist/src/apple-pay-button.d.ts +8 -18
- package/dist/src/apple-pay-button.js +16 -82
- package/dist/src/apple-pay-button.stories.js +16 -82
- package/dist/src/apple-pay-modal.stories.js +16 -82
- package/dist/src/constants.d.ts +3 -28
- package/dist/src/constants.js +1 -7
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +27 -92
- package/dist/src/utils/applePayExpressEligibility.d.ts +5 -6
- package/dist/src/utils/applePayExpressEligibility.js +2 -2
- package/dist/src/utils/expressCheckoutTracking.d.ts +0 -15
- package/dist/src/utils/expressCheckoutTracking.js +0 -27
- package/package.json +1 -1
- package/dist/src/types/experiment-integration.d.js +0 -0
- package/dist/src/utils/getExperimentKeyFromNextData.d.ts +0 -8
- package/dist/src/utils/getExperimentKeyFromNextData.js +0 -9
package/README.md
CHANGED
|
@@ -125,19 +125,20 @@ Consumers should listen for this event and continue payment orchestration.
|
|
|
125
125
|
- `ApplePayButton`: button component class.
|
|
126
126
|
- `whenReady(): Promise<void>` — resolves when the current render lifecycle completes (available or hidden). Resolves immediately if called before the element is connected.
|
|
127
127
|
- `createIfEnabled(offer, country, entryPoint?)`: returns a configured button or `null`.
|
|
128
|
-
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount)
|
|
128
|
+
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount).
|
|
129
129
|
- `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; wallet impression `entry_point` is `free_trial_banner`.
|
|
130
|
-
- `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate
|
|
131
|
-
- `
|
|
130
|
+
- `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Wallet impression `entry_point` is `free_trial_popup`.
|
|
131
|
+
- `SUBSCRIBE`: same always-on-after-exclusions gate for `/subscribe` (sma-checkout); no Amplitude. Wallet impression `entry_point` is `subscribe`.
|
|
132
|
+
- `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
|
|
132
133
|
- `REGWALL`: inert — always returns `null`.
|
|
133
134
|
- `ApplePayModal`: modal component class.
|
|
134
135
|
- `ensureApplePayLogoSymbol()`: logo symbol injection helper.
|
|
135
|
-
- `APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY`: Amplitude flag key for paywalls experiment gating / `$exposure`.
|
|
136
136
|
- `Offer`: offer contract type used by component props.
|
|
137
137
|
|
|
138
138
|
### Breaking changes
|
|
139
139
|
|
|
140
|
-
- `
|
|
140
|
+
- `APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY`, `APPLE_PAY_EXPRESS_VARIANTS`, and `ApplePayExperimentFlagKey` are no longer exported. Paywalls are always-on after Safari/offer checks; drop those imports.
|
|
141
|
+
- `APPLE_PAY_EXPRESS_EXPERIMENT_KEY` (retired banners experiment flag) remains unpublished.
|
|
141
142
|
|
|
142
143
|
## Troubleshooting
|
|
143
144
|
|
|
@@ -147,8 +148,8 @@ Check:
|
|
|
147
148
|
|
|
148
149
|
- `configureApplePay(...)` was called before rendering (with a valid `merchantId` and `walletApiBaseUrl`)
|
|
149
150
|
- device/browser supports Apple Pay (Safari on Apple device required — enforced by `isApplePayAvailable` on mount)
|
|
150
|
-
- for paywalls:
|
|
151
|
-
- for banners / `FREE_TRIAL_POPUP`: consumer kill switch off (no homepage/Safari gate at `createIfEnabled
|
|
151
|
+
- for paywalls: Safari/Apple placement eligibility (or `?BYPASS_APPLE_PAY_CHECKS=1` for QA)
|
|
152
|
+
- for banners / `FREE_TRIAL_POPUP`: consumer kill switch off (no homepage/Safari gate at `createIfEnabled`)
|
|
152
153
|
- offer variant is not excluded (`bundle`, `insider_print`)
|
|
153
154
|
|
|
154
155
|
### Logged-in checkbox copy looks wrong
|
package/dist/index.js
CHANGED
|
@@ -1305,21 +1305,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1305
1305
|
return url.pathname + url.search;
|
|
1306
1306
|
};
|
|
1307
1307
|
|
|
1308
|
-
// src/constants.ts
|
|
1309
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1310
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1311
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1312
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1313
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1314
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1315
|
-
return ApplePayEntryPoint2;
|
|
1316
|
-
})(ApplePayEntryPoint || {});
|
|
1317
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1318
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1319
|
-
CONTROL: "control",
|
|
1320
|
-
TREATMENT: "treatment"
|
|
1321
|
-
};
|
|
1322
|
-
|
|
1323
1308
|
// src/utils/expressCheckoutTracking.ts
|
|
1324
1309
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1325
1310
|
/** Wallet button displayed */
|
|
@@ -1357,26 +1342,6 @@ var track = (action, extra) => {
|
|
|
1357
1342
|
...extra
|
|
1358
1343
|
});
|
|
1359
1344
|
};
|
|
1360
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1361
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1362
|
-
if (!isActiveVariant) {
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1366
|
-
window.__applePayExperimentExposures = exposures;
|
|
1367
|
-
const pathname = window.location?.pathname ?? "";
|
|
1368
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1369
|
-
if (exposures[dedupeKey]) {
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
exposures[dedupeKey] = true;
|
|
1373
|
-
emitTedlEvent({
|
|
1374
|
-
name: "$exposure",
|
|
1375
|
-
flag_key: flagKey,
|
|
1376
|
-
variant,
|
|
1377
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1378
|
-
});
|
|
1379
|
-
};
|
|
1380
1345
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1381
1346
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1382
1347
|
wallet_type: "apple_pay",
|
|
@@ -1977,29 +1942,30 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1977
1942
|
return [...zoneCountries];
|
|
1978
1943
|
};
|
|
1979
1944
|
|
|
1980
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
1981
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1982
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1983
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1984
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1985
|
-
};
|
|
1986
|
-
|
|
1987
1945
|
// src/utils/applePayExpressEligibility.ts
|
|
1988
|
-
var
|
|
1946
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1947
|
+
|
|
1948
|
+
// src/constants.ts
|
|
1949
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1950
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1951
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1952
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1953
|
+
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1954
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1955
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1956
|
+
return ApplePayEntryPoint2;
|
|
1957
|
+
})(ApplePayEntryPoint || {});
|
|
1989
1958
|
|
|
1990
1959
|
// src/apple-pay-button.ts
|
|
1991
1960
|
var ENTRY_POINT_CONFIG = {
|
|
1992
1961
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1993
1962
|
isEligible: () => true
|
|
1994
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1995
1963
|
},
|
|
1996
1964
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1997
1965
|
isEligible: () => true
|
|
1998
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1999
1966
|
},
|
|
2000
1967
|
["article_paywall" /* PAYWALL */]: {
|
|
2001
|
-
isEligible:
|
|
2002
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1968
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
2003
1969
|
},
|
|
2004
1970
|
["article_regwall" /* REGWALL */]: {
|
|
2005
1971
|
isEligible: () => true,
|
|
@@ -2007,9 +1973,12 @@ var ENTRY_POINT_CONFIG = {
|
|
|
2007
1973
|
},
|
|
2008
1974
|
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
2009
1975
|
isEligible: () => true
|
|
1976
|
+
},
|
|
1977
|
+
["subscribe" /* SUBSCRIBE */]: {
|
|
1978
|
+
isEligible: () => true
|
|
1979
|
+
// Always-on after offer exclusions — host (sma-checkout) owns rollout toggle
|
|
2010
1980
|
}
|
|
2011
1981
|
};
|
|
2012
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2013
1982
|
var TOTAL_LABEL = "The Economist";
|
|
2014
1983
|
var DEFAULT_CURRENCY = "USD";
|
|
2015
1984
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2028,28 +1997,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2028
1997
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2029
1998
|
*
|
|
2030
1999
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2031
|
-
* no homepage/Safari gate here
|
|
2032
|
-
*
|
|
2000
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
2001
|
+
* `isApplePayAvailable()` on mount.
|
|
2033
2002
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2034
2003
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2035
|
-
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate
|
|
2036
|
-
* `
|
|
2037
|
-
* - `PAYWALL`:
|
|
2038
|
-
*
|
|
2039
|
-
* `window.experimentIntegration` before calling for this entry point.
|
|
2004
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
2005
|
+
* `entry_point` (`free_trial_popup`).
|
|
2006
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
2007
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2040
2008
|
* - `REGWALL`: inert — always returns null.
|
|
2041
2009
|
*
|
|
2042
|
-
*
|
|
2043
|
-
* `
|
|
2044
|
-
* treatment (and without inflating `$exposure`). For banners / popup there is no
|
|
2045
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2046
|
-
* `isApplePayAvailable()` on mount.
|
|
2047
|
-
*
|
|
2048
|
-
* **Eligibility:**
|
|
2049
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` / `FREE_TRIAL_POPUP` (or omitted):
|
|
2050
|
-
* always eligible at this gate (homepage placement is host-owned; Safari/Apple
|
|
2051
|
-
* is enforced later by `isApplePayAvailable()` on mount)
|
|
2052
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
2010
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
2011
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2053
2012
|
*
|
|
2054
2013
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2055
2014
|
* @param country - The user's country code.
|
|
@@ -2062,41 +2021,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2062
2021
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2063
2022
|
return null;
|
|
2064
2023
|
}
|
|
2065
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2066
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2067
|
-
);
|
|
2068
2024
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2069
2025
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2070
2026
|
if (!config) {
|
|
2071
2027
|
return null;
|
|
2072
2028
|
}
|
|
2073
|
-
const { isEligible: eligibilityCheck
|
|
2029
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2074
2030
|
const isEligible = eligibilityCheck();
|
|
2075
2031
|
if (config.enabled === false) {
|
|
2076
2032
|
return null;
|
|
2077
2033
|
}
|
|
2078
|
-
if (!
|
|
2034
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2079
2035
|
return null;
|
|
2080
2036
|
}
|
|
2081
|
-
if (experimentFlagKey) {
|
|
2082
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2083
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2084
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2085
|
-
void isApplePayAvailable().then((available) => {
|
|
2086
|
-
if (available) {
|
|
2087
|
-
trackApplePayExperimentExposure(
|
|
2088
|
-
experimentValue,
|
|
2089
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2090
|
-
experimentFlagKey
|
|
2091
|
-
);
|
|
2092
|
-
}
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2096
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2097
|
-
return null;
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
2037
|
_ApplePayButton.define();
|
|
2101
2038
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2102
2039
|
button.offer = offer;
|
|
@@ -2423,8 +2360,6 @@ function defineApplePayElements() {
|
|
|
2423
2360
|
}
|
|
2424
2361
|
export {
|
|
2425
2362
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2426
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
2427
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
2428
2363
|
ApplePayButton,
|
|
2429
2364
|
ApplePayEntryPoint,
|
|
2430
2365
|
ApplePayModal,
|
|
@@ -9,28 +9,18 @@ export declare class ApplePayButton extends HTMLElement {
|
|
|
9
9
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
10
10
|
*
|
|
11
11
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
12
|
-
* no homepage/Safari gate here
|
|
13
|
-
*
|
|
12
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
13
|
+
* `isApplePayAvailable()` on mount.
|
|
14
14
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
15
15
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
16
|
-
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate
|
|
17
|
-
* `
|
|
18
|
-
* - `PAYWALL`:
|
|
19
|
-
*
|
|
20
|
-
* `window.experimentIntegration` before calling for this entry point.
|
|
16
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
17
|
+
* `entry_point` (`free_trial_popup`).
|
|
18
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
19
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
21
20
|
* - `REGWALL`: inert — always returns null.
|
|
22
21
|
*
|
|
23
|
-
*
|
|
24
|
-
* `
|
|
25
|
-
* treatment (and without inflating `$exposure`). For banners / popup there is no
|
|
26
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
27
|
-
* `isApplePayAvailable()` on mount.
|
|
28
|
-
*
|
|
29
|
-
* **Eligibility:**
|
|
30
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` / `FREE_TRIAL_POPUP` (or omitted):
|
|
31
|
-
* always eligible at this gate (homepage placement is host-owned; Safari/Apple
|
|
32
|
-
* is enforced later by `isApplePayAvailable()` on mount)
|
|
33
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
22
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
23
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
34
24
|
*
|
|
35
25
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
36
26
|
* @param country - The user's country code.
|
|
@@ -1300,13 +1300,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1300
1300
|
return url.pathname + url.search;
|
|
1301
1301
|
};
|
|
1302
1302
|
|
|
1303
|
-
// src/constants.ts
|
|
1304
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1305
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1306
|
-
CONTROL: "control",
|
|
1307
|
-
TREATMENT: "treatment"
|
|
1308
|
-
};
|
|
1309
|
-
|
|
1310
1303
|
// src/utils/expressCheckoutTracking.ts
|
|
1311
1304
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1312
1305
|
/** Wallet button displayed */
|
|
@@ -1344,26 +1337,6 @@ var track = (action, extra) => {
|
|
|
1344
1337
|
...extra
|
|
1345
1338
|
});
|
|
1346
1339
|
};
|
|
1347
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1348
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1349
|
-
if (!isActiveVariant) {
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1353
|
-
window.__applePayExperimentExposures = exposures;
|
|
1354
|
-
const pathname = window.location?.pathname ?? "";
|
|
1355
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1356
|
-
if (exposures[dedupeKey]) {
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
exposures[dedupeKey] = true;
|
|
1360
|
-
emitTedlEvent({
|
|
1361
|
-
name: "$exposure",
|
|
1362
|
-
flag_key: flagKey,
|
|
1363
|
-
variant,
|
|
1364
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1365
|
-
});
|
|
1366
|
-
};
|
|
1367
1340
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1368
1341
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1369
1342
|
wallet_type: "apple_pay",
|
|
@@ -1964,29 +1937,19 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1964
1937
|
return [...zoneCountries];
|
|
1965
1938
|
};
|
|
1966
1939
|
|
|
1967
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
1968
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1969
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1970
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1971
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1972
|
-
};
|
|
1973
|
-
|
|
1974
1940
|
// src/utils/applePayExpressEligibility.ts
|
|
1975
|
-
var
|
|
1941
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1976
1942
|
|
|
1977
1943
|
// src/apple-pay-button.ts
|
|
1978
1944
|
var ENTRY_POINT_CONFIG = {
|
|
1979
1945
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1980
1946
|
isEligible: () => true
|
|
1981
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1982
1947
|
},
|
|
1983
1948
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1984
1949
|
isEligible: () => true
|
|
1985
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1986
1950
|
},
|
|
1987
1951
|
["article_paywall" /* PAYWALL */]: {
|
|
1988
|
-
isEligible:
|
|
1989
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1952
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
1990
1953
|
},
|
|
1991
1954
|
["article_regwall" /* REGWALL */]: {
|
|
1992
1955
|
isEligible: () => true,
|
|
@@ -1994,9 +1957,12 @@ var ENTRY_POINT_CONFIG = {
|
|
|
1994
1957
|
},
|
|
1995
1958
|
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
1996
1959
|
isEligible: () => true
|
|
1960
|
+
},
|
|
1961
|
+
["subscribe" /* SUBSCRIBE */]: {
|
|
1962
|
+
isEligible: () => true
|
|
1963
|
+
// Always-on after offer exclusions — host (sma-checkout) owns rollout toggle
|
|
1997
1964
|
}
|
|
1998
1965
|
};
|
|
1999
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2000
1966
|
var TOTAL_LABEL = "The Economist";
|
|
2001
1967
|
var DEFAULT_CURRENCY = "USD";
|
|
2002
1968
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2015,28 +1981,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2015
1981
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2016
1982
|
*
|
|
2017
1983
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2018
|
-
* no homepage/Safari gate here
|
|
2019
|
-
*
|
|
1984
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1985
|
+
* `isApplePayAvailable()` on mount.
|
|
2020
1986
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2021
1987
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2022
|
-
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate
|
|
2023
|
-
* `
|
|
2024
|
-
* - `PAYWALL`:
|
|
2025
|
-
*
|
|
2026
|
-
* `window.experimentIntegration` before calling for this entry point.
|
|
1988
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
1989
|
+
* `entry_point` (`free_trial_popup`).
|
|
1990
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
1991
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2027
1992
|
* - `REGWALL`: inert — always returns null.
|
|
2028
1993
|
*
|
|
2029
|
-
*
|
|
2030
|
-
* `
|
|
2031
|
-
* treatment (and without inflating `$exposure`). For banners / popup there is no
|
|
2032
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2033
|
-
* `isApplePayAvailable()` on mount.
|
|
2034
|
-
*
|
|
2035
|
-
* **Eligibility:**
|
|
2036
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` / `FREE_TRIAL_POPUP` (or omitted):
|
|
2037
|
-
* always eligible at this gate (homepage placement is host-owned; Safari/Apple
|
|
2038
|
-
* is enforced later by `isApplePayAvailable()` on mount)
|
|
2039
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
1994
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
1995
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2040
1996
|
*
|
|
2041
1997
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2042
1998
|
* @param country - The user's country code.
|
|
@@ -2049,41 +2005,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2049
2005
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2050
2006
|
return null;
|
|
2051
2007
|
}
|
|
2052
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2053
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2054
|
-
);
|
|
2055
2008
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2056
2009
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2057
2010
|
if (!config) {
|
|
2058
2011
|
return null;
|
|
2059
2012
|
}
|
|
2060
|
-
const { isEligible: eligibilityCheck
|
|
2013
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2061
2014
|
const isEligible = eligibilityCheck();
|
|
2062
2015
|
if (config.enabled === false) {
|
|
2063
2016
|
return null;
|
|
2064
2017
|
}
|
|
2065
|
-
if (!
|
|
2018
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2066
2019
|
return null;
|
|
2067
2020
|
}
|
|
2068
|
-
if (experimentFlagKey) {
|
|
2069
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2070
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2071
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2072
|
-
void isApplePayAvailable().then((available) => {
|
|
2073
|
-
if (available) {
|
|
2074
|
-
trackApplePayExperimentExposure(
|
|
2075
|
-
experimentValue,
|
|
2076
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2077
|
-
experimentFlagKey
|
|
2078
|
-
);
|
|
2079
|
-
}
|
|
2080
|
-
});
|
|
2081
|
-
}
|
|
2082
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2083
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2084
|
-
return null;
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
2021
|
_ApplePayButton.define();
|
|
2088
2022
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2089
2023
|
button.offer = offer;
|
|
@@ -1308,13 +1308,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1308
1308
|
return url.pathname + url.search;
|
|
1309
1309
|
};
|
|
1310
1310
|
|
|
1311
|
-
// src/constants.ts
|
|
1312
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1313
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1314
|
-
CONTROL: "control",
|
|
1315
|
-
TREATMENT: "treatment"
|
|
1316
|
-
};
|
|
1317
|
-
|
|
1318
1311
|
// src/utils/expressCheckoutTracking.ts
|
|
1319
1312
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1320
1313
|
/** Wallet button displayed */
|
|
@@ -1352,26 +1345,6 @@ var track = (action, extra) => {
|
|
|
1352
1345
|
...extra
|
|
1353
1346
|
});
|
|
1354
1347
|
};
|
|
1355
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1356
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1357
|
-
if (!isActiveVariant) {
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1361
|
-
window.__applePayExperimentExposures = exposures;
|
|
1362
|
-
const pathname = window.location?.pathname ?? "";
|
|
1363
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1364
|
-
if (exposures[dedupeKey]) {
|
|
1365
|
-
return;
|
|
1366
|
-
}
|
|
1367
|
-
exposures[dedupeKey] = true;
|
|
1368
|
-
emitTedlEvent({
|
|
1369
|
-
name: "$exposure",
|
|
1370
|
-
flag_key: flagKey,
|
|
1371
|
-
variant,
|
|
1372
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1373
|
-
});
|
|
1374
|
-
};
|
|
1375
1348
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1376
1349
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1377
1350
|
wallet_type: "apple_pay",
|
|
@@ -1972,29 +1945,19 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1972
1945
|
return [...zoneCountries];
|
|
1973
1946
|
};
|
|
1974
1947
|
|
|
1975
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
1976
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1977
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1978
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1979
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1980
|
-
};
|
|
1981
|
-
|
|
1982
1948
|
// src/utils/applePayExpressEligibility.ts
|
|
1983
|
-
var
|
|
1949
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1984
1950
|
|
|
1985
1951
|
// src/apple-pay-button.ts
|
|
1986
1952
|
var ENTRY_POINT_CONFIG = {
|
|
1987
1953
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1988
1954
|
isEligible: () => true
|
|
1989
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1990
1955
|
},
|
|
1991
1956
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1992
1957
|
isEligible: () => true
|
|
1993
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1994
1958
|
},
|
|
1995
1959
|
["article_paywall" /* PAYWALL */]: {
|
|
1996
|
-
isEligible:
|
|
1997
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1960
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
1998
1961
|
},
|
|
1999
1962
|
["article_regwall" /* REGWALL */]: {
|
|
2000
1963
|
isEligible: () => true,
|
|
@@ -2002,9 +1965,12 @@ var ENTRY_POINT_CONFIG = {
|
|
|
2002
1965
|
},
|
|
2003
1966
|
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
2004
1967
|
isEligible: () => true
|
|
1968
|
+
},
|
|
1969
|
+
["subscribe" /* SUBSCRIBE */]: {
|
|
1970
|
+
isEligible: () => true
|
|
1971
|
+
// Always-on after offer exclusions — host (sma-checkout) owns rollout toggle
|
|
2005
1972
|
}
|
|
2006
1973
|
};
|
|
2007
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2008
1974
|
var TOTAL_LABEL = "The Economist";
|
|
2009
1975
|
var DEFAULT_CURRENCY = "USD";
|
|
2010
1976
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2023,28 +1989,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2023
1989
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2024
1990
|
*
|
|
2025
1991
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2026
|
-
* no homepage/Safari gate here
|
|
2027
|
-
*
|
|
1992
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1993
|
+
* `isApplePayAvailable()` on mount.
|
|
2028
1994
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2029
1995
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2030
|
-
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate
|
|
2031
|
-
* `
|
|
2032
|
-
* - `PAYWALL`:
|
|
2033
|
-
*
|
|
2034
|
-
* `window.experimentIntegration` before calling for this entry point.
|
|
1996
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
1997
|
+
* `entry_point` (`free_trial_popup`).
|
|
1998
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
1999
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2035
2000
|
* - `REGWALL`: inert — always returns null.
|
|
2036
2001
|
*
|
|
2037
|
-
*
|
|
2038
|
-
* `
|
|
2039
|
-
* treatment (and without inflating `$exposure`). For banners / popup there is no
|
|
2040
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2041
|
-
* `isApplePayAvailable()` on mount.
|
|
2042
|
-
*
|
|
2043
|
-
* **Eligibility:**
|
|
2044
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` / `FREE_TRIAL_POPUP` (or omitted):
|
|
2045
|
-
* always eligible at this gate (homepage placement is host-owned; Safari/Apple
|
|
2046
|
-
* is enforced later by `isApplePayAvailable()` on mount)
|
|
2047
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
2002
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
2003
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2048
2004
|
*
|
|
2049
2005
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2050
2006
|
* @param country - The user's country code.
|
|
@@ -2057,41 +2013,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2057
2013
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2058
2014
|
return null;
|
|
2059
2015
|
}
|
|
2060
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2061
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2062
|
-
);
|
|
2063
2016
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2064
2017
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2065
2018
|
if (!config) {
|
|
2066
2019
|
return null;
|
|
2067
2020
|
}
|
|
2068
|
-
const { isEligible: eligibilityCheck
|
|
2021
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2069
2022
|
const isEligible = eligibilityCheck();
|
|
2070
2023
|
if (config.enabled === false) {
|
|
2071
2024
|
return null;
|
|
2072
2025
|
}
|
|
2073
|
-
if (!
|
|
2026
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2074
2027
|
return null;
|
|
2075
2028
|
}
|
|
2076
|
-
if (experimentFlagKey) {
|
|
2077
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2078
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2079
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2080
|
-
void isApplePayAvailable().then((available) => {
|
|
2081
|
-
if (available) {
|
|
2082
|
-
trackApplePayExperimentExposure(
|
|
2083
|
-
experimentValue,
|
|
2084
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2085
|
-
experimentFlagKey
|
|
2086
|
-
);
|
|
2087
|
-
}
|
|
2088
|
-
});
|
|
2089
|
-
}
|
|
2090
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2091
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2092
|
-
return null;
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
2029
|
_ApplePayButton.define();
|
|
2096
2030
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2097
2031
|
button.offer = offer;
|
|
@@ -1300,13 +1300,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1300
1300
|
return url.pathname + url.search;
|
|
1301
1301
|
};
|
|
1302
1302
|
|
|
1303
|
-
// src/constants.ts
|
|
1304
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1305
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1306
|
-
CONTROL: "control",
|
|
1307
|
-
TREATMENT: "treatment"
|
|
1308
|
-
};
|
|
1309
|
-
|
|
1310
1303
|
// src/utils/expressCheckoutTracking.ts
|
|
1311
1304
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1312
1305
|
/** Wallet button displayed */
|
|
@@ -1344,26 +1337,6 @@ var track = (action, extra) => {
|
|
|
1344
1337
|
...extra
|
|
1345
1338
|
});
|
|
1346
1339
|
};
|
|
1347
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1348
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1349
|
-
if (!isActiveVariant) {
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1353
|
-
window.__applePayExperimentExposures = exposures;
|
|
1354
|
-
const pathname = window.location?.pathname ?? "";
|
|
1355
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1356
|
-
if (exposures[dedupeKey]) {
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
exposures[dedupeKey] = true;
|
|
1360
|
-
emitTedlEvent({
|
|
1361
|
-
name: "$exposure",
|
|
1362
|
-
flag_key: flagKey,
|
|
1363
|
-
variant,
|
|
1364
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1365
|
-
});
|
|
1366
|
-
};
|
|
1367
1340
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1368
1341
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1369
1342
|
wallet_type: "apple_pay",
|
|
@@ -1964,29 +1937,19 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1964
1937
|
return [...zoneCountries];
|
|
1965
1938
|
};
|
|
1966
1939
|
|
|
1967
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
1968
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1969
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1970
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1971
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1972
|
-
};
|
|
1973
|
-
|
|
1974
1940
|
// src/utils/applePayExpressEligibility.ts
|
|
1975
|
-
var
|
|
1941
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1976
1942
|
|
|
1977
1943
|
// src/apple-pay-button.ts
|
|
1978
1944
|
var ENTRY_POINT_CONFIG = {
|
|
1979
1945
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1980
1946
|
isEligible: () => true
|
|
1981
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1982
1947
|
},
|
|
1983
1948
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1984
1949
|
isEligible: () => true
|
|
1985
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1986
1950
|
},
|
|
1987
1951
|
["article_paywall" /* PAYWALL */]: {
|
|
1988
|
-
isEligible:
|
|
1989
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1952
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
1990
1953
|
},
|
|
1991
1954
|
["article_regwall" /* REGWALL */]: {
|
|
1992
1955
|
isEligible: () => true,
|
|
@@ -1994,9 +1957,12 @@ var ENTRY_POINT_CONFIG = {
|
|
|
1994
1957
|
},
|
|
1995
1958
|
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
1996
1959
|
isEligible: () => true
|
|
1960
|
+
},
|
|
1961
|
+
["subscribe" /* SUBSCRIBE */]: {
|
|
1962
|
+
isEligible: () => true
|
|
1963
|
+
// Always-on after offer exclusions — host (sma-checkout) owns rollout toggle
|
|
1997
1964
|
}
|
|
1998
1965
|
};
|
|
1999
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2000
1966
|
var TOTAL_LABEL = "The Economist";
|
|
2001
1967
|
var DEFAULT_CURRENCY = "USD";
|
|
2002
1968
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2015,28 +1981,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2015
1981
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2016
1982
|
*
|
|
2017
1983
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2018
|
-
* no homepage/Safari gate here
|
|
2019
|
-
*
|
|
1984
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1985
|
+
* `isApplePayAvailable()` on mount.
|
|
2020
1986
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2021
1987
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2022
|
-
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate
|
|
2023
|
-
* `
|
|
2024
|
-
* - `PAYWALL`:
|
|
2025
|
-
*
|
|
2026
|
-
* `window.experimentIntegration` before calling for this entry point.
|
|
1988
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
1989
|
+
* `entry_point` (`free_trial_popup`).
|
|
1990
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
1991
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2027
1992
|
* - `REGWALL`: inert — always returns null.
|
|
2028
1993
|
*
|
|
2029
|
-
*
|
|
2030
|
-
* `
|
|
2031
|
-
* treatment (and without inflating `$exposure`). For banners / popup there is no
|
|
2032
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2033
|
-
* `isApplePayAvailable()` on mount.
|
|
2034
|
-
*
|
|
2035
|
-
* **Eligibility:**
|
|
2036
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` / `FREE_TRIAL_POPUP` (or omitted):
|
|
2037
|
-
* always eligible at this gate (homepage placement is host-owned; Safari/Apple
|
|
2038
|
-
* is enforced later by `isApplePayAvailable()` on mount)
|
|
2039
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
1994
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
1995
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2040
1996
|
*
|
|
2041
1997
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2042
1998
|
* @param country - The user's country code.
|
|
@@ -2049,41 +2005,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2049
2005
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2050
2006
|
return null;
|
|
2051
2007
|
}
|
|
2052
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2053
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2054
|
-
);
|
|
2055
2008
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2056
2009
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2057
2010
|
if (!config) {
|
|
2058
2011
|
return null;
|
|
2059
2012
|
}
|
|
2060
|
-
const { isEligible: eligibilityCheck
|
|
2013
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2061
2014
|
const isEligible = eligibilityCheck();
|
|
2062
2015
|
if (config.enabled === false) {
|
|
2063
2016
|
return null;
|
|
2064
2017
|
}
|
|
2065
|
-
if (!
|
|
2018
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2066
2019
|
return null;
|
|
2067
2020
|
}
|
|
2068
|
-
if (experimentFlagKey) {
|
|
2069
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2070
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2071
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2072
|
-
void isApplePayAvailable().then((available) => {
|
|
2073
|
-
if (available) {
|
|
2074
|
-
trackApplePayExperimentExposure(
|
|
2075
|
-
experimentValue,
|
|
2076
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2077
|
-
experimentFlagKey
|
|
2078
|
-
);
|
|
2079
|
-
}
|
|
2080
|
-
});
|
|
2081
|
-
}
|
|
2082
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2083
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2084
|
-
return null;
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
2021
|
_ApplePayButton.define();
|
|
2088
2022
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2089
2023
|
button.offer = offer;
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -4,32 +4,7 @@ export declare enum ApplePayEntryPoint {
|
|
|
4
4
|
DUAL_OFFER_BANNER = "dual_offer_banner",
|
|
5
5
|
FREE_TRIAL_BANNER = "free_trial_banner",
|
|
6
6
|
/** Post-registration free-trial popup. Not Amplitude-gated. */
|
|
7
|
-
FREE_TRIAL_POPUP = "free_trial_popup"
|
|
7
|
+
FREE_TRIAL_POPUP = "free_trial_popup",
|
|
8
|
+
/** /subscribe offers page (sma-checkout). Not Amplitude-gated. */
|
|
9
|
+
SUBSCRIBE = "subscribe"
|
|
8
10
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Amplitude experiment key for Apple Pay Express Checkout on article paywalls
|
|
11
|
-
* (`ApplePayEntryPoint.PAYWALL`, e.g. single-offer-paywall / multi-offer paywall).
|
|
12
|
-
*
|
|
13
|
-
* Fail-closed when the variant is missing or not `treatment`; the QA URL param
|
|
14
|
-
* `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` can show the button without treatment.
|
|
15
|
-
* Eligibility for this flag ignores homepage and requires Safari/Apple device
|
|
16
|
-
* (plus `isApplePayAvailable` before `$exposure`).
|
|
17
|
-
*
|
|
18
|
-
* Must match the Feature experiment key in Amplitude and host app constants
|
|
19
|
-
* (Engagement / Insider / Podcasts) while those still bridge the experiment.
|
|
20
|
-
*/
|
|
21
|
-
export declare const APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
22
|
-
/**
|
|
23
|
-
* Known Amplitude experiment flag keys for Apple Pay Express Checkout.
|
|
24
|
-
* Narrowed so callers cannot pass an arbitrary typo'd string.
|
|
25
|
-
*/
|
|
26
|
-
export type ApplePayExperimentFlagKey = typeof APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY;
|
|
27
|
-
/**
|
|
28
|
-
* Amplitude variant values for the Apple Pay Express Checkout experiment.
|
|
29
|
-
* CONTROL → button hidden (baseline)
|
|
30
|
-
* TREATMENT → button shown
|
|
31
|
-
*/
|
|
32
|
-
export declare const APPLE_PAY_EXPRESS_VARIANTS: {
|
|
33
|
-
readonly CONTROL: "control";
|
|
34
|
-
readonly TREATMENT: "treatment";
|
|
35
|
-
};
|
package/dist/src/constants.js
CHANGED
|
@@ -5,15 +5,9 @@ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
|
5
5
|
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
6
6
|
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
7
7
|
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
8
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
8
9
|
return ApplePayEntryPoint2;
|
|
9
10
|
})(ApplePayEntryPoint || {});
|
|
10
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
11
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
12
|
-
CONTROL: "control",
|
|
13
|
-
TREATMENT: "treatment"
|
|
14
|
-
};
|
|
15
11
|
export {
|
|
16
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
17
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
18
12
|
ApplePayEntryPoint
|
|
19
13
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ export { ApplePayButton, APPLE_PAY_EXCLUDED_VARIANTS, } from './apple-pay-button
|
|
|
2
2
|
export { ApplePayModal } from './apple-pay-modal';
|
|
3
3
|
export { ensureApplePayLogoSymbol } from './apple-pay-logo';
|
|
4
4
|
export { configureApplePay } from './clients/payment-checkout/config';
|
|
5
|
-
export { ApplePayEntryPoint
|
|
6
|
-
export type { ApplePayExperimentFlagKey } from './constants';
|
|
5
|
+
export { ApplePayEntryPoint } from './constants';
|
|
7
6
|
export type { ApplePayRuntimeConfig } from './clients/payment-checkout/config';
|
|
8
7
|
export type { Offer } from './types/offer.types';
|
|
9
8
|
export declare function defineApplePayElements(): void;
|
package/dist/src/index.js
CHANGED
|
@@ -1305,21 +1305,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1305
1305
|
return url.pathname + url.search;
|
|
1306
1306
|
};
|
|
1307
1307
|
|
|
1308
|
-
// src/constants.ts
|
|
1309
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1310
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1311
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1312
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1313
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1314
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1315
|
-
return ApplePayEntryPoint2;
|
|
1316
|
-
})(ApplePayEntryPoint || {});
|
|
1317
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1318
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1319
|
-
CONTROL: "control",
|
|
1320
|
-
TREATMENT: "treatment"
|
|
1321
|
-
};
|
|
1322
|
-
|
|
1323
1308
|
// src/utils/expressCheckoutTracking.ts
|
|
1324
1309
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1325
1310
|
/** Wallet button displayed */
|
|
@@ -1357,26 +1342,6 @@ var track = (action, extra) => {
|
|
|
1357
1342
|
...extra
|
|
1358
1343
|
});
|
|
1359
1344
|
};
|
|
1360
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1361
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1362
|
-
if (!isActiveVariant) {
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1366
|
-
window.__applePayExperimentExposures = exposures;
|
|
1367
|
-
const pathname = window.location?.pathname ?? "";
|
|
1368
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1369
|
-
if (exposures[dedupeKey]) {
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
exposures[dedupeKey] = true;
|
|
1373
|
-
emitTedlEvent({
|
|
1374
|
-
name: "$exposure",
|
|
1375
|
-
flag_key: flagKey,
|
|
1376
|
-
variant,
|
|
1377
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1378
|
-
});
|
|
1379
|
-
};
|
|
1380
1345
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1381
1346
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1382
1347
|
wallet_type: "apple_pay",
|
|
@@ -1977,29 +1942,30 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1977
1942
|
return [...zoneCountries];
|
|
1978
1943
|
};
|
|
1979
1944
|
|
|
1980
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
1981
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1982
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1983
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1984
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1985
|
-
};
|
|
1986
|
-
|
|
1987
1945
|
// src/utils/applePayExpressEligibility.ts
|
|
1988
|
-
var
|
|
1946
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1947
|
+
|
|
1948
|
+
// src/constants.ts
|
|
1949
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1950
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1951
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1952
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1953
|
+
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1954
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1955
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1956
|
+
return ApplePayEntryPoint2;
|
|
1957
|
+
})(ApplePayEntryPoint || {});
|
|
1989
1958
|
|
|
1990
1959
|
// src/apple-pay-button.ts
|
|
1991
1960
|
var ENTRY_POINT_CONFIG = {
|
|
1992
1961
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1993
1962
|
isEligible: () => true
|
|
1994
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1995
1963
|
},
|
|
1996
1964
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1997
1965
|
isEligible: () => true
|
|
1998
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1999
1966
|
},
|
|
2000
1967
|
["article_paywall" /* PAYWALL */]: {
|
|
2001
|
-
isEligible:
|
|
2002
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1968
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
2003
1969
|
},
|
|
2004
1970
|
["article_regwall" /* REGWALL */]: {
|
|
2005
1971
|
isEligible: () => true,
|
|
@@ -2007,9 +1973,12 @@ var ENTRY_POINT_CONFIG = {
|
|
|
2007
1973
|
},
|
|
2008
1974
|
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
2009
1975
|
isEligible: () => true
|
|
1976
|
+
},
|
|
1977
|
+
["subscribe" /* SUBSCRIBE */]: {
|
|
1978
|
+
isEligible: () => true
|
|
1979
|
+
// Always-on after offer exclusions — host (sma-checkout) owns rollout toggle
|
|
2010
1980
|
}
|
|
2011
1981
|
};
|
|
2012
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2013
1982
|
var TOTAL_LABEL = "The Economist";
|
|
2014
1983
|
var DEFAULT_CURRENCY = "USD";
|
|
2015
1984
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2028,28 +1997,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2028
1997
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2029
1998
|
*
|
|
2030
1999
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2031
|
-
* no homepage/Safari gate here
|
|
2032
|
-
*
|
|
2000
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
2001
|
+
* `isApplePayAvailable()` on mount.
|
|
2033
2002
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2034
2003
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2035
|
-
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate
|
|
2036
|
-
* `
|
|
2037
|
-
* - `PAYWALL`:
|
|
2038
|
-
*
|
|
2039
|
-
* `window.experimentIntegration` before calling for this entry point.
|
|
2004
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
2005
|
+
* `entry_point` (`free_trial_popup`).
|
|
2006
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
2007
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2040
2008
|
* - `REGWALL`: inert — always returns null.
|
|
2041
2009
|
*
|
|
2042
|
-
*
|
|
2043
|
-
* `
|
|
2044
|
-
* treatment (and without inflating `$exposure`). For banners / popup there is no
|
|
2045
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2046
|
-
* `isApplePayAvailable()` on mount.
|
|
2047
|
-
*
|
|
2048
|
-
* **Eligibility:**
|
|
2049
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` / `FREE_TRIAL_POPUP` (or omitted):
|
|
2050
|
-
* always eligible at this gate (homepage placement is host-owned; Safari/Apple
|
|
2051
|
-
* is enforced later by `isApplePayAvailable()` on mount)
|
|
2052
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
2010
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
2011
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2053
2012
|
*
|
|
2054
2013
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2055
2014
|
* @param country - The user's country code.
|
|
@@ -2062,41 +2021,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2062
2021
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2063
2022
|
return null;
|
|
2064
2023
|
}
|
|
2065
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2066
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2067
|
-
);
|
|
2068
2024
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2069
2025
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2070
2026
|
if (!config) {
|
|
2071
2027
|
return null;
|
|
2072
2028
|
}
|
|
2073
|
-
const { isEligible: eligibilityCheck
|
|
2029
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2074
2030
|
const isEligible = eligibilityCheck();
|
|
2075
2031
|
if (config.enabled === false) {
|
|
2076
2032
|
return null;
|
|
2077
2033
|
}
|
|
2078
|
-
if (!
|
|
2034
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2079
2035
|
return null;
|
|
2080
2036
|
}
|
|
2081
|
-
if (experimentFlagKey) {
|
|
2082
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2083
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2084
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2085
|
-
void isApplePayAvailable().then((available) => {
|
|
2086
|
-
if (available) {
|
|
2087
|
-
trackApplePayExperimentExposure(
|
|
2088
|
-
experimentValue,
|
|
2089
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2090
|
-
experimentFlagKey
|
|
2091
|
-
);
|
|
2092
|
-
}
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2096
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2097
|
-
return null;
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
2037
|
_ApplePayButton.define();
|
|
2101
2038
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2102
2039
|
button.offer = offer;
|
|
@@ -2423,8 +2360,6 @@ function defineApplePayElements() {
|
|
|
2423
2360
|
}
|
|
2424
2361
|
export {
|
|
2425
2362
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2426
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
2427
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
2428
2363
|
ApplePayButton,
|
|
2429
2364
|
ApplePayEntryPoint,
|
|
2430
2365
|
ApplePayModal,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host-side placement eligibility helpers for Apple Pay Express.
|
|
3
3
|
*
|
|
4
|
-
* Paywalls: used by createIfEnabled after offer exclusions so
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* further gated on isApplePayAvailable() (BYPASS_APPLE_PAY_CHECKS respected).
|
|
4
|
+
* Paywalls: used by createIfEnabled after offer exclusions so the button is
|
|
5
|
+
* Safari/Apple-gated. Banners: createIfEnabled does not call the banner helper
|
|
6
|
+
* (always-on after offer exclusions); Safari/Apple still runs later via
|
|
7
|
+
* isApplePayAvailable() on mount.
|
|
9
8
|
*/
|
|
10
9
|
export declare const isApplePayExpressHomepage: (pathname?: string) => boolean;
|
|
11
10
|
/**
|
|
@@ -18,4 +17,4 @@ export declare const isEligibleForApplePayExpressBanner: () => boolean;
|
|
|
18
17
|
* Article paywalls (`ApplePayEntryPoint.PAYWALL`): Safari/Apple device only.
|
|
19
18
|
* Homepage targeting does not apply — paywalls render on article pages.
|
|
20
19
|
*/
|
|
21
|
-
export declare const
|
|
20
|
+
export declare const isEligibleForApplePayExpressPaywall: () => boolean;
|
|
@@ -8,9 +8,9 @@ var isAppleDeviceOrSafari = () => {
|
|
|
8
8
|
// src/utils/applePayExpressEligibility.ts
|
|
9
9
|
var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
|
|
10
10
|
var isEligibleForApplePayExpressBanner = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
|
|
11
|
-
var
|
|
11
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
12
12
|
export {
|
|
13
13
|
isApplePayExpressHomepage,
|
|
14
14
|
isEligibleForApplePayExpressBanner,
|
|
15
|
-
|
|
15
|
+
isEligibleForApplePayExpressPaywall
|
|
16
16
|
};
|
|
@@ -11,14 +11,12 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Event names are aligned to the PRD spec (section 10 — Tracking & Analytics).
|
|
13
13
|
*/
|
|
14
|
-
import { type ApplePayExperimentFlagKey } from '../constants';
|
|
15
14
|
declare global {
|
|
16
15
|
interface Window {
|
|
17
16
|
tedl?: {
|
|
18
17
|
events?: Record<string, unknown>[];
|
|
19
18
|
[key: string]: unknown;
|
|
20
19
|
};
|
|
21
|
-
__applePayExperimentExposures?: Record<string, boolean>;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
export declare const EXPRESS_CHECKOUT_EVENTS: {
|
|
@@ -48,19 +46,6 @@ export type ImpressionMetadata = {
|
|
|
48
46
|
/** ISO 3166-1 alpha-2 country code of the offer (e.g. 'GB', 'US'). */
|
|
49
47
|
country: string;
|
|
50
48
|
};
|
|
51
|
-
/**
|
|
52
|
-
* Amplitude Experiment exposure for Apple Pay Express (SMA-3301).
|
|
53
|
-
*
|
|
54
|
-
* Fired from createIfEnabled only after isApplePayAvailable() succeeds
|
|
55
|
-
* (control or treatment). Deduped per pathname + flag_key + variant so
|
|
56
|
-
* repeated renders on the same page do not over-count. Includes
|
|
57
|
-
* experiment_key from Engagement SSR (__NEXT_DATA__) when present for run
|
|
58
|
-
* attribution.
|
|
59
|
-
*
|
|
60
|
-
* @param flagKey - Amplitude flag_key (required). Callers must pass an
|
|
61
|
-
* explicit key such as {@link APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY}.
|
|
62
|
-
*/
|
|
63
|
-
export declare const trackApplePayExperimentExposure: (variant: string, experimentKey: string | undefined, flagKey: ApplePayExperimentFlagKey) => void;
|
|
64
49
|
/** Wallet button displayed — emits all 5 required analytics dimensions. */
|
|
65
50
|
export declare const trackExpressWalletImpression: (skuId: string, { entryPoint, country }: ImpressionMetadata) => void;
|
|
66
51
|
/**
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// src/constants.ts
|
|
2
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
3
|
-
CONTROL: "control",
|
|
4
|
-
TREATMENT: "treatment"
|
|
5
|
-
};
|
|
6
|
-
|
|
7
1
|
// src/utils/expressCheckoutTracking.ts
|
|
8
2
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
9
3
|
/** Wallet button displayed */
|
|
@@ -41,26 +35,6 @@ var track = (action, extra) => {
|
|
|
41
35
|
...extra
|
|
42
36
|
});
|
|
43
37
|
};
|
|
44
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
45
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
46
|
-
if (!isActiveVariant) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
50
|
-
window.__applePayExperimentExposures = exposures;
|
|
51
|
-
const pathname = window.location?.pathname ?? "";
|
|
52
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
53
|
-
if (exposures[dedupeKey]) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
exposures[dedupeKey] = true;
|
|
57
|
-
emitTedlEvent({
|
|
58
|
-
name: "$exposure",
|
|
59
|
-
flag_key: flagKey,
|
|
60
|
-
variant,
|
|
61
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
38
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
65
39
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
66
40
|
wallet_type: "apple_pay",
|
|
@@ -102,7 +76,6 @@ var trackValidationFieldError = (field, errorType) => {
|
|
|
102
76
|
};
|
|
103
77
|
export {
|
|
104
78
|
EXPRESS_CHECKOUT_EVENTS,
|
|
105
|
-
trackApplePayExperimentExposure,
|
|
106
79
|
trackExpressWalletClick,
|
|
107
80
|
trackExpressWalletImpression,
|
|
108
81
|
trackFallbackCheckout,
|
package/package.json
CHANGED
|
File without changes
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads Amplitude experiment run key from Engagement SSR page props.
|
|
3
|
-
*
|
|
4
|
-
* Engagement already stores full fetchVariants entries on
|
|
5
|
-
* `window.__NEXT_DATA__.props.pageProps.experiments` (including
|
|
6
|
-
* `metadata.experimentKey`). Avoids extending the CDN bridge API.
|
|
7
|
-
*/
|
|
8
|
-
export declare const getExperimentKeyFromNextData: (flagKey: string) => string | undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
2
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
3
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
4
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
5
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
6
|
-
};
|
|
7
|
-
export {
|
|
8
|
-
getExperimentKeyFromNextData
|
|
9
|
-
};
|