@economist/web-apple-pay 1.12.0 → 1.13.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 +7 -7
- package/dist/index.js +22 -92
- package/dist/src/apple-pay-button.d.ts +8 -18
- package/dist/src/apple-pay-button.js +12 -82
- package/dist/src/apple-pay-button.stories.js +12 -82
- package/dist/src/apple-pay-modal.stories.js +12 -82
- package/dist/src/constants.d.ts +0 -27
- package/dist/src/constants.js +0 -7
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +22 -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,19 @@ 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
|
-
- `PAYWALL`:
|
|
130
|
+
- `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Wallet impression `entry_point` is `free_trial_popup`.
|
|
131
|
+
- `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
|
|
132
132
|
- `REGWALL`: inert — always returns `null`.
|
|
133
133
|
- `ApplePayModal`: modal component class.
|
|
134
134
|
- `ensureApplePayLogoSymbol()`: logo symbol injection helper.
|
|
135
|
-
- `APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY`: Amplitude flag key for paywalls experiment gating / `$exposure`.
|
|
136
135
|
- `Offer`: offer contract type used by component props.
|
|
137
136
|
|
|
138
137
|
### Breaking changes
|
|
139
138
|
|
|
140
|
-
- `
|
|
139
|
+
- `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.
|
|
140
|
+
- `APPLE_PAY_EXPRESS_EXPERIMENT_KEY` (retired banners experiment flag) remains unpublished.
|
|
141
141
|
|
|
142
142
|
## Troubleshooting
|
|
143
143
|
|
|
@@ -147,8 +147,8 @@ Check:
|
|
|
147
147
|
|
|
148
148
|
- `configureApplePay(...)` was called before rendering (with a valid `merchantId` and `walletApiBaseUrl`)
|
|
149
149
|
- 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
|
|
150
|
+
- for paywalls: Safari/Apple placement eligibility (or `?BYPASS_APPLE_PAY_CHECKS=1` for QA)
|
|
151
|
+
- for banners / `FREE_TRIAL_POPUP`: consumer kill switch off (no homepage/Safari gate at `createIfEnabled`)
|
|
152
152
|
- offer variant is not excluded (`bundle`, `insider_print`)
|
|
153
153
|
|
|
154
154
|
### 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,29 @@ 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
|
+
return ApplePayEntryPoint2;
|
|
1956
|
+
})(ApplePayEntryPoint || {});
|
|
1989
1957
|
|
|
1990
1958
|
// src/apple-pay-button.ts
|
|
1991
1959
|
var ENTRY_POINT_CONFIG = {
|
|
1992
1960
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1993
1961
|
isEligible: () => true
|
|
1994
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1995
1962
|
},
|
|
1996
1963
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1997
1964
|
isEligible: () => true
|
|
1998
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1999
1965
|
},
|
|
2000
1966
|
["article_paywall" /* PAYWALL */]: {
|
|
2001
|
-
isEligible:
|
|
2002
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1967
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
2003
1968
|
},
|
|
2004
1969
|
["article_regwall" /* REGWALL */]: {
|
|
2005
1970
|
isEligible: () => true,
|
|
@@ -2009,7 +1974,6 @@ var ENTRY_POINT_CONFIG = {
|
|
|
2009
1974
|
isEligible: () => true
|
|
2010
1975
|
}
|
|
2011
1976
|
};
|
|
2012
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2013
1977
|
var TOTAL_LABEL = "The Economist";
|
|
2014
1978
|
var DEFAULT_CURRENCY = "USD";
|
|
2015
1979
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2028,28 +1992,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2028
1992
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2029
1993
|
*
|
|
2030
1994
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2031
|
-
* no homepage/Safari gate here
|
|
2032
|
-
*
|
|
1995
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1996
|
+
* `isApplePayAvailable()` on mount.
|
|
2033
1997
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2034
1998
|
* 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.
|
|
1999
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
2000
|
+
* `entry_point` (`free_trial_popup`).
|
|
2001
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
2002
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2040
2003
|
* - `REGWALL`: inert — always returns null.
|
|
2041
2004
|
*
|
|
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
|
|
2005
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
2006
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2053
2007
|
*
|
|
2054
2008
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2055
2009
|
* @param country - The user's country code.
|
|
@@ -2062,41 +2016,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2062
2016
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2063
2017
|
return null;
|
|
2064
2018
|
}
|
|
2065
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2066
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2067
|
-
);
|
|
2068
2019
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2069
2020
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2070
2021
|
if (!config) {
|
|
2071
2022
|
return null;
|
|
2072
2023
|
}
|
|
2073
|
-
const { isEligible: eligibilityCheck
|
|
2024
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2074
2025
|
const isEligible = eligibilityCheck();
|
|
2075
2026
|
if (config.enabled === false) {
|
|
2076
2027
|
return null;
|
|
2077
2028
|
}
|
|
2078
|
-
if (!
|
|
2029
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2079
2030
|
return null;
|
|
2080
2031
|
}
|
|
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
2032
|
_ApplePayButton.define();
|
|
2101
2033
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2102
2034
|
button.offer = offer;
|
|
@@ -2423,8 +2355,6 @@ function defineApplePayElements() {
|
|
|
2423
2355
|
}
|
|
2424
2356
|
export {
|
|
2425
2357
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2426
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
2427
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
2428
2358
|
ApplePayButton,
|
|
2429
2359
|
ApplePayEntryPoint,
|
|
2430
2360
|
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,
|
|
@@ -1996,7 +1959,6 @@ var ENTRY_POINT_CONFIG = {
|
|
|
1996
1959
|
isEligible: () => true
|
|
1997
1960
|
}
|
|
1998
1961
|
};
|
|
1999
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2000
1962
|
var TOTAL_LABEL = "The Economist";
|
|
2001
1963
|
var DEFAULT_CURRENCY = "USD";
|
|
2002
1964
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2015,28 +1977,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2015
1977
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2016
1978
|
*
|
|
2017
1979
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2018
|
-
* no homepage/Safari gate here
|
|
2019
|
-
*
|
|
1980
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1981
|
+
* `isApplePayAvailable()` on mount.
|
|
2020
1982
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2021
1983
|
* 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.
|
|
1984
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
1985
|
+
* `entry_point` (`free_trial_popup`).
|
|
1986
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
1987
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2027
1988
|
* - `REGWALL`: inert — always returns null.
|
|
2028
1989
|
*
|
|
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
|
|
1990
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
1991
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2040
1992
|
*
|
|
2041
1993
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2042
1994
|
* @param country - The user's country code.
|
|
@@ -2049,41 +2001,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2049
2001
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2050
2002
|
return null;
|
|
2051
2003
|
}
|
|
2052
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2053
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2054
|
-
);
|
|
2055
2004
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2056
2005
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2057
2006
|
if (!config) {
|
|
2058
2007
|
return null;
|
|
2059
2008
|
}
|
|
2060
|
-
const { isEligible: eligibilityCheck
|
|
2009
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2061
2010
|
const isEligible = eligibilityCheck();
|
|
2062
2011
|
if (config.enabled === false) {
|
|
2063
2012
|
return null;
|
|
2064
2013
|
}
|
|
2065
|
-
if (!
|
|
2014
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2066
2015
|
return null;
|
|
2067
2016
|
}
|
|
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
2017
|
_ApplePayButton.define();
|
|
2088
2018
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2089
2019
|
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,
|
|
@@ -2004,7 +1967,6 @@ var ENTRY_POINT_CONFIG = {
|
|
|
2004
1967
|
isEligible: () => true
|
|
2005
1968
|
}
|
|
2006
1969
|
};
|
|
2007
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2008
1970
|
var TOTAL_LABEL = "The Economist";
|
|
2009
1971
|
var DEFAULT_CURRENCY = "USD";
|
|
2010
1972
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2023,28 +1985,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2023
1985
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2024
1986
|
*
|
|
2025
1987
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2026
|
-
* no homepage/Safari gate here
|
|
2027
|
-
*
|
|
1988
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1989
|
+
* `isApplePayAvailable()` on mount.
|
|
2028
1990
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2029
1991
|
* 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.
|
|
1992
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
1993
|
+
* `entry_point` (`free_trial_popup`).
|
|
1994
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
1995
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2035
1996
|
* - `REGWALL`: inert — always returns null.
|
|
2036
1997
|
*
|
|
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
|
|
1998
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
1999
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2048
2000
|
*
|
|
2049
2001
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2050
2002
|
* @param country - The user's country code.
|
|
@@ -2057,41 +2009,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2057
2009
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2058
2010
|
return null;
|
|
2059
2011
|
}
|
|
2060
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2061
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2062
|
-
);
|
|
2063
2012
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2064
2013
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2065
2014
|
if (!config) {
|
|
2066
2015
|
return null;
|
|
2067
2016
|
}
|
|
2068
|
-
const { isEligible: eligibilityCheck
|
|
2017
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2069
2018
|
const isEligible = eligibilityCheck();
|
|
2070
2019
|
if (config.enabled === false) {
|
|
2071
2020
|
return null;
|
|
2072
2021
|
}
|
|
2073
|
-
if (!
|
|
2022
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2074
2023
|
return null;
|
|
2075
2024
|
}
|
|
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
2025
|
_ApplePayButton.define();
|
|
2096
2026
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2097
2027
|
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,
|
|
@@ -1996,7 +1959,6 @@ var ENTRY_POINT_CONFIG = {
|
|
|
1996
1959
|
isEligible: () => true
|
|
1997
1960
|
}
|
|
1998
1961
|
};
|
|
1999
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2000
1962
|
var TOTAL_LABEL = "The Economist";
|
|
2001
1963
|
var DEFAULT_CURRENCY = "USD";
|
|
2002
1964
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2015,28 +1977,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2015
1977
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2016
1978
|
*
|
|
2017
1979
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2018
|
-
* no homepage/Safari gate here
|
|
2019
|
-
*
|
|
1980
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1981
|
+
* `isApplePayAvailable()` on mount.
|
|
2020
1982
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2021
1983
|
* 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.
|
|
1984
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
1985
|
+
* `entry_point` (`free_trial_popup`).
|
|
1986
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
1987
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2027
1988
|
* - `REGWALL`: inert — always returns null.
|
|
2028
1989
|
*
|
|
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
|
|
1990
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
1991
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2040
1992
|
*
|
|
2041
1993
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2042
1994
|
* @param country - The user's country code.
|
|
@@ -2049,41 +2001,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2049
2001
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2050
2002
|
return null;
|
|
2051
2003
|
}
|
|
2052
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2053
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2054
|
-
);
|
|
2055
2004
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2056
2005
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2057
2006
|
if (!config) {
|
|
2058
2007
|
return null;
|
|
2059
2008
|
}
|
|
2060
|
-
const { isEligible: eligibilityCheck
|
|
2009
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2061
2010
|
const isEligible = eligibilityCheck();
|
|
2062
2011
|
if (config.enabled === false) {
|
|
2063
2012
|
return null;
|
|
2064
2013
|
}
|
|
2065
|
-
if (!
|
|
2014
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2066
2015
|
return null;
|
|
2067
2016
|
}
|
|
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
2017
|
_ApplePayButton.define();
|
|
2088
2018
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2089
2019
|
button.offer = offer;
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -6,30 +6,3 @@ export declare enum ApplePayEntryPoint {
|
|
|
6
6
|
/** Post-registration free-trial popup. Not Amplitude-gated. */
|
|
7
7
|
FREE_TRIAL_POPUP = "free_trial_popup"
|
|
8
8
|
}
|
|
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
|
@@ -7,13 +7,6 @@ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
|
7
7
|
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
8
8
|
return ApplePayEntryPoint2;
|
|
9
9
|
})(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
10
|
export {
|
|
16
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
17
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
18
11
|
ApplePayEntryPoint
|
|
19
12
|
};
|
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,29 @@ 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
|
+
return ApplePayEntryPoint2;
|
|
1956
|
+
})(ApplePayEntryPoint || {});
|
|
1989
1957
|
|
|
1990
1958
|
// src/apple-pay-button.ts
|
|
1991
1959
|
var ENTRY_POINT_CONFIG = {
|
|
1992
1960
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1993
1961
|
isEligible: () => true
|
|
1994
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1995
1962
|
},
|
|
1996
1963
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1997
1964
|
isEligible: () => true
|
|
1998
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1999
1965
|
},
|
|
2000
1966
|
["article_paywall" /* PAYWALL */]: {
|
|
2001
|
-
isEligible:
|
|
2002
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1967
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
2003
1968
|
},
|
|
2004
1969
|
["article_regwall" /* REGWALL */]: {
|
|
2005
1970
|
isEligible: () => true,
|
|
@@ -2009,7 +1974,6 @@ var ENTRY_POINT_CONFIG = {
|
|
|
2009
1974
|
isEligible: () => true
|
|
2010
1975
|
}
|
|
2011
1976
|
};
|
|
2012
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2013
1977
|
var TOTAL_LABEL = "The Economist";
|
|
2014
1978
|
var DEFAULT_CURRENCY = "USD";
|
|
2015
1979
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2028,28 +1992,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2028
1992
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2029
1993
|
*
|
|
2030
1994
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2031
|
-
* no homepage/Safari gate here
|
|
2032
|
-
*
|
|
1995
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1996
|
+
* `isApplePayAvailable()` on mount.
|
|
2033
1997
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2034
1998
|
* 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.
|
|
1999
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
2000
|
+
* `entry_point` (`free_trial_popup`).
|
|
2001
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
2002
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2040
2003
|
* - `REGWALL`: inert — always returns null.
|
|
2041
2004
|
*
|
|
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
|
|
2005
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
2006
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2053
2007
|
*
|
|
2054
2008
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2055
2009
|
* @param country - The user's country code.
|
|
@@ -2062,41 +2016,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2062
2016
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2063
2017
|
return null;
|
|
2064
2018
|
}
|
|
2065
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2066
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2067
|
-
);
|
|
2068
2019
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2069
2020
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2070
2021
|
if (!config) {
|
|
2071
2022
|
return null;
|
|
2072
2023
|
}
|
|
2073
|
-
const { isEligible: eligibilityCheck
|
|
2024
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2074
2025
|
const isEligible = eligibilityCheck();
|
|
2075
2026
|
if (config.enabled === false) {
|
|
2076
2027
|
return null;
|
|
2077
2028
|
}
|
|
2078
|
-
if (!
|
|
2029
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2079
2030
|
return null;
|
|
2080
2031
|
}
|
|
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
2032
|
_ApplePayButton.define();
|
|
2101
2033
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2102
2034
|
button.offer = offer;
|
|
@@ -2423,8 +2355,6 @@ function defineApplePayElements() {
|
|
|
2423
2355
|
}
|
|
2424
2356
|
export {
|
|
2425
2357
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2426
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
2427
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
2428
2358
|
ApplePayButton,
|
|
2429
2359
|
ApplePayEntryPoint,
|
|
2430
2360
|
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
|
-
};
|