@economist/web-apple-pay 1.11.2 → 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 -6
- package/dist/index.js +25 -89
- package/dist/src/apple-pay-button.d.ts +8 -16
- package/dist/src/apple-pay-button.js +15 -80
- package/dist/src/apple-pay-button.stories.js +15 -80
- package/dist/src/apple-pay-modal.stories.js +15 -80
- 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 +25 -89
- 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,18 +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
|
-
- `
|
|
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`.
|
|
131
132
|
- `REGWALL`: inert — always returns `null`.
|
|
132
133
|
- `ApplePayModal`: modal component class.
|
|
133
134
|
- `ensureApplePayLogoSymbol()`: logo symbol injection helper.
|
|
134
|
-
- `APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY`: Amplitude flag key for paywalls experiment gating / `$exposure`.
|
|
135
135
|
- `Offer`: offer contract type used by component props.
|
|
136
136
|
|
|
137
137
|
### Breaking changes
|
|
138
138
|
|
|
139
|
-
- `
|
|
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.
|
|
140
141
|
|
|
141
142
|
## Troubleshooting
|
|
142
143
|
|
|
@@ -146,8 +147,8 @@ Check:
|
|
|
146
147
|
|
|
147
148
|
- `configureApplePay(...)` was called before rendering (with a valid `merchantId` and `walletApiBaseUrl`)
|
|
148
149
|
- device/browser supports Apple Pay (Safari on Apple device required — enforced by `isApplePayAvailable` on mount)
|
|
149
|
-
- for paywalls:
|
|
150
|
-
- for banners
|
|
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`)
|
|
151
152
|
- offer variant is not excluded (`bundle`, `insider_print`)
|
|
152
153
|
|
|
153
154
|
### Logged-in checkbox copy looks wrong
|
package/dist/index.js
CHANGED
|
@@ -1305,20 +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
|
-
return ApplePayEntryPoint2;
|
|
1315
|
-
})(ApplePayEntryPoint || {});
|
|
1316
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1317
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1318
|
-
CONTROL: "control",
|
|
1319
|
-
TREATMENT: "treatment"
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
1308
|
// src/utils/expressCheckoutTracking.ts
|
|
1323
1309
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1324
1310
|
/** Wallet button displayed */
|
|
@@ -1356,26 +1342,6 @@ var track = (action, extra) => {
|
|
|
1356
1342
|
...extra
|
|
1357
1343
|
});
|
|
1358
1344
|
};
|
|
1359
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1360
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1361
|
-
if (!isActiveVariant) {
|
|
1362
|
-
return;
|
|
1363
|
-
}
|
|
1364
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1365
|
-
window.__applePayExperimentExposures = exposures;
|
|
1366
|
-
const pathname = window.location?.pathname ?? "";
|
|
1367
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1368
|
-
if (exposures[dedupeKey]) {
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
exposures[dedupeKey] = true;
|
|
1372
|
-
emitTedlEvent({
|
|
1373
|
-
name: "$exposure",
|
|
1374
|
-
flag_key: flagKey,
|
|
1375
|
-
variant,
|
|
1376
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1377
|
-
});
|
|
1378
|
-
};
|
|
1379
1345
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1380
1346
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1381
1347
|
wallet_type: "apple_pay",
|
|
@@ -1976,36 +1942,38 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1976
1942
|
return [...zoneCountries];
|
|
1977
1943
|
};
|
|
1978
1944
|
|
|
1979
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
1980
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1981
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1982
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1983
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1984
|
-
};
|
|
1985
|
-
|
|
1986
1945
|
// src/utils/applePayExpressEligibility.ts
|
|
1987
|
-
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 || {});
|
|
1988
1957
|
|
|
1989
1958
|
// src/apple-pay-button.ts
|
|
1990
1959
|
var ENTRY_POINT_CONFIG = {
|
|
1991
1960
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1992
1961
|
isEligible: () => true
|
|
1993
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1994
1962
|
},
|
|
1995
1963
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1996
1964
|
isEligible: () => true
|
|
1997
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1998
1965
|
},
|
|
1999
1966
|
["article_paywall" /* PAYWALL */]: {
|
|
2000
|
-
isEligible:
|
|
2001
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1967
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
2002
1968
|
},
|
|
2003
1969
|
["article_regwall" /* REGWALL */]: {
|
|
2004
1970
|
isEligible: () => true,
|
|
2005
1971
|
enabled: false
|
|
1972
|
+
},
|
|
1973
|
+
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
1974
|
+
isEligible: () => true
|
|
2006
1975
|
}
|
|
2007
1976
|
};
|
|
2008
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2009
1977
|
var TOTAL_LABEL = "The Economist";
|
|
2010
1978
|
var DEFAULT_CURRENCY = "USD";
|
|
2011
1979
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2024,26 +1992,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2024
1992
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2025
1993
|
*
|
|
2026
1994
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2027
|
-
* no homepage/Safari gate here
|
|
2028
|
-
*
|
|
1995
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1996
|
+
* `isApplePayAvailable()` on mount.
|
|
2029
1997
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2030
1998
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2031
|
-
* - `
|
|
2032
|
-
* (`
|
|
2033
|
-
*
|
|
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`.
|
|
2034
2003
|
* - `REGWALL`: inert — always returns null.
|
|
2035
2004
|
*
|
|
2036
|
-
*
|
|
2037
|
-
* `
|
|
2038
|
-
* treatment (and without inflating `$exposure`). For banners there is no
|
|
2039
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2040
|
-
* `isApplePayAvailable()` on mount.
|
|
2041
|
-
*
|
|
2042
|
-
* **Eligibility:**
|
|
2043
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` (or omitted): always eligible at
|
|
2044
|
-
* this gate (homepage placement is host-owned; Safari/Apple is enforced
|
|
2045
|
-
* later by `isApplePayAvailable()` on mount)
|
|
2046
|
-
* - `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).
|
|
2047
2007
|
*
|
|
2048
2008
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2049
2009
|
* @param country - The user's country code.
|
|
@@ -2056,41 +2016,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2056
2016
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2057
2017
|
return null;
|
|
2058
2018
|
}
|
|
2059
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2060
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2061
|
-
);
|
|
2062
2019
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2063
2020
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2064
2021
|
if (!config) {
|
|
2065
2022
|
return null;
|
|
2066
2023
|
}
|
|
2067
|
-
const { isEligible: eligibilityCheck
|
|
2024
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2068
2025
|
const isEligible = eligibilityCheck();
|
|
2069
2026
|
if (config.enabled === false) {
|
|
2070
2027
|
return null;
|
|
2071
2028
|
}
|
|
2072
|
-
if (!
|
|
2029
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2073
2030
|
return null;
|
|
2074
2031
|
}
|
|
2075
|
-
if (experimentFlagKey) {
|
|
2076
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2077
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2078
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2079
|
-
void isApplePayAvailable().then((available) => {
|
|
2080
|
-
if (available) {
|
|
2081
|
-
trackApplePayExperimentExposure(
|
|
2082
|
-
experimentValue,
|
|
2083
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2084
|
-
experimentFlagKey
|
|
2085
|
-
);
|
|
2086
|
-
}
|
|
2087
|
-
});
|
|
2088
|
-
}
|
|
2089
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2090
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2091
|
-
return null;
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
2032
|
_ApplePayButton.define();
|
|
2095
2033
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2096
2034
|
button.offer = offer;
|
|
@@ -2417,8 +2355,6 @@ function defineApplePayElements() {
|
|
|
2417
2355
|
}
|
|
2418
2356
|
export {
|
|
2419
2357
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2420
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
2421
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
2422
2358
|
ApplePayButton,
|
|
2423
2359
|
ApplePayEntryPoint,
|
|
2424
2360
|
ApplePayModal,
|
|
@@ -9,26 +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
|
-
* - `
|
|
17
|
-
* (`
|
|
18
|
-
*
|
|
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`.
|
|
19
20
|
* - `REGWALL`: inert — always returns null.
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
-
* `
|
|
23
|
-
* treatment (and without inflating `$exposure`). For banners there is no
|
|
24
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
25
|
-
* `isApplePayAvailable()` on mount.
|
|
26
|
-
*
|
|
27
|
-
* **Eligibility:**
|
|
28
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` (or omitted): always eligible at
|
|
29
|
-
* this gate (homepage placement is host-owned; Safari/Apple is enforced
|
|
30
|
-
* later by `isApplePayAvailable()` on mount)
|
|
31
|
-
* - `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).
|
|
32
24
|
*
|
|
33
25
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
34
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,36 +1937,28 @@ 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,
|
|
1993
1956
|
enabled: false
|
|
1957
|
+
},
|
|
1958
|
+
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
1959
|
+
isEligible: () => true
|
|
1994
1960
|
}
|
|
1995
1961
|
};
|
|
1996
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
1997
1962
|
var TOTAL_LABEL = "The Economist";
|
|
1998
1963
|
var DEFAULT_CURRENCY = "USD";
|
|
1999
1964
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2012,26 +1977,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2012
1977
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2013
1978
|
*
|
|
2014
1979
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2015
|
-
* no homepage/Safari gate here
|
|
2016
|
-
*
|
|
1980
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1981
|
+
* `isApplePayAvailable()` on mount.
|
|
2017
1982
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2018
1983
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2019
|
-
* - `
|
|
2020
|
-
* (`
|
|
2021
|
-
*
|
|
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`.
|
|
2022
1988
|
* - `REGWALL`: inert — always returns null.
|
|
2023
1989
|
*
|
|
2024
|
-
*
|
|
2025
|
-
* `
|
|
2026
|
-
* treatment (and without inflating `$exposure`). For banners there is no
|
|
2027
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2028
|
-
* `isApplePayAvailable()` on mount.
|
|
2029
|
-
*
|
|
2030
|
-
* **Eligibility:**
|
|
2031
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` (or omitted): always eligible at
|
|
2032
|
-
* this gate (homepage placement is host-owned; Safari/Apple is enforced
|
|
2033
|
-
* later by `isApplePayAvailable()` on mount)
|
|
2034
|
-
* - `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).
|
|
2035
1992
|
*
|
|
2036
1993
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2037
1994
|
* @param country - The user's country code.
|
|
@@ -2044,41 +2001,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2044
2001
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2045
2002
|
return null;
|
|
2046
2003
|
}
|
|
2047
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2048
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2049
|
-
);
|
|
2050
2004
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2051
2005
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2052
2006
|
if (!config) {
|
|
2053
2007
|
return null;
|
|
2054
2008
|
}
|
|
2055
|
-
const { isEligible: eligibilityCheck
|
|
2009
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2056
2010
|
const isEligible = eligibilityCheck();
|
|
2057
2011
|
if (config.enabled === false) {
|
|
2058
2012
|
return null;
|
|
2059
2013
|
}
|
|
2060
|
-
if (!
|
|
2014
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2061
2015
|
return null;
|
|
2062
2016
|
}
|
|
2063
|
-
if (experimentFlagKey) {
|
|
2064
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2065
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2066
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2067
|
-
void isApplePayAvailable().then((available) => {
|
|
2068
|
-
if (available) {
|
|
2069
|
-
trackApplePayExperimentExposure(
|
|
2070
|
-
experimentValue,
|
|
2071
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2072
|
-
experimentFlagKey
|
|
2073
|
-
);
|
|
2074
|
-
}
|
|
2075
|
-
});
|
|
2076
|
-
}
|
|
2077
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2078
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2079
|
-
return null;
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
2017
|
_ApplePayButton.define();
|
|
2083
2018
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2084
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,36 +1945,28 @@ 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,
|
|
2001
1964
|
enabled: false
|
|
1965
|
+
},
|
|
1966
|
+
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
1967
|
+
isEligible: () => true
|
|
2002
1968
|
}
|
|
2003
1969
|
};
|
|
2004
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2005
1970
|
var TOTAL_LABEL = "The Economist";
|
|
2006
1971
|
var DEFAULT_CURRENCY = "USD";
|
|
2007
1972
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2020,26 +1985,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2020
1985
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2021
1986
|
*
|
|
2022
1987
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2023
|
-
* no homepage/Safari gate here
|
|
2024
|
-
*
|
|
1988
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1989
|
+
* `isApplePayAvailable()` on mount.
|
|
2025
1990
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2026
1991
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2027
|
-
* - `
|
|
2028
|
-
* (`
|
|
2029
|
-
*
|
|
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`.
|
|
2030
1996
|
* - `REGWALL`: inert — always returns null.
|
|
2031
1997
|
*
|
|
2032
|
-
*
|
|
2033
|
-
* `
|
|
2034
|
-
* treatment (and without inflating `$exposure`). For banners there is no
|
|
2035
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2036
|
-
* `isApplePayAvailable()` on mount.
|
|
2037
|
-
*
|
|
2038
|
-
* **Eligibility:**
|
|
2039
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` (or omitted): always eligible at
|
|
2040
|
-
* this gate (homepage placement is host-owned; Safari/Apple is enforced
|
|
2041
|
-
* later by `isApplePayAvailable()` on mount)
|
|
2042
|
-
* - `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).
|
|
2043
2000
|
*
|
|
2044
2001
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2045
2002
|
* @param country - The user's country code.
|
|
@@ -2052,41 +2009,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2052
2009
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2053
2010
|
return null;
|
|
2054
2011
|
}
|
|
2055
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2056
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2057
|
-
);
|
|
2058
2012
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2059
2013
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2060
2014
|
if (!config) {
|
|
2061
2015
|
return null;
|
|
2062
2016
|
}
|
|
2063
|
-
const { isEligible: eligibilityCheck
|
|
2017
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2064
2018
|
const isEligible = eligibilityCheck();
|
|
2065
2019
|
if (config.enabled === false) {
|
|
2066
2020
|
return null;
|
|
2067
2021
|
}
|
|
2068
|
-
if (!
|
|
2022
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2069
2023
|
return null;
|
|
2070
2024
|
}
|
|
2071
|
-
if (experimentFlagKey) {
|
|
2072
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2073
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2074
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2075
|
-
void isApplePayAvailable().then((available) => {
|
|
2076
|
-
if (available) {
|
|
2077
|
-
trackApplePayExperimentExposure(
|
|
2078
|
-
experimentValue,
|
|
2079
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2080
|
-
experimentFlagKey
|
|
2081
|
-
);
|
|
2082
|
-
}
|
|
2083
|
-
});
|
|
2084
|
-
}
|
|
2085
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2086
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2087
|
-
return null;
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
2025
|
_ApplePayButton.define();
|
|
2091
2026
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2092
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,36 +1937,28 @@ 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,
|
|
1993
1956
|
enabled: false
|
|
1957
|
+
},
|
|
1958
|
+
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
1959
|
+
isEligible: () => true
|
|
1994
1960
|
}
|
|
1995
1961
|
};
|
|
1996
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
1997
1962
|
var TOTAL_LABEL = "The Economist";
|
|
1998
1963
|
var DEFAULT_CURRENCY = "USD";
|
|
1999
1964
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2012,26 +1977,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2012
1977
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2013
1978
|
*
|
|
2014
1979
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2015
|
-
* no homepage/Safari gate here
|
|
2016
|
-
*
|
|
1980
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1981
|
+
* `isApplePayAvailable()` on mount.
|
|
2017
1982
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2018
1983
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2019
|
-
* - `
|
|
2020
|
-
* (`
|
|
2021
|
-
*
|
|
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`.
|
|
2022
1988
|
* - `REGWALL`: inert — always returns null.
|
|
2023
1989
|
*
|
|
2024
|
-
*
|
|
2025
|
-
* `
|
|
2026
|
-
* treatment (and without inflating `$exposure`). For banners there is no
|
|
2027
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2028
|
-
* `isApplePayAvailable()` on mount.
|
|
2029
|
-
*
|
|
2030
|
-
* **Eligibility:**
|
|
2031
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` (or omitted): always eligible at
|
|
2032
|
-
* this gate (homepage placement is host-owned; Safari/Apple is enforced
|
|
2033
|
-
* later by `isApplePayAvailable()` on mount)
|
|
2034
|
-
* - `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).
|
|
2035
1992
|
*
|
|
2036
1993
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2037
1994
|
* @param country - The user's country code.
|
|
@@ -2044,41 +2001,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2044
2001
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2045
2002
|
return null;
|
|
2046
2003
|
}
|
|
2047
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2048
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2049
|
-
);
|
|
2050
2004
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2051
2005
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2052
2006
|
if (!config) {
|
|
2053
2007
|
return null;
|
|
2054
2008
|
}
|
|
2055
|
-
const { isEligible: eligibilityCheck
|
|
2009
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2056
2010
|
const isEligible = eligibilityCheck();
|
|
2057
2011
|
if (config.enabled === false) {
|
|
2058
2012
|
return null;
|
|
2059
2013
|
}
|
|
2060
|
-
if (!
|
|
2014
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2061
2015
|
return null;
|
|
2062
2016
|
}
|
|
2063
|
-
if (experimentFlagKey) {
|
|
2064
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2065
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2066
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2067
|
-
void isApplePayAvailable().then((available) => {
|
|
2068
|
-
if (available) {
|
|
2069
|
-
trackApplePayExperimentExposure(
|
|
2070
|
-
experimentValue,
|
|
2071
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2072
|
-
experimentFlagKey
|
|
2073
|
-
);
|
|
2074
|
-
}
|
|
2075
|
-
});
|
|
2076
|
-
}
|
|
2077
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2078
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2079
|
-
return null;
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
2017
|
_ApplePayButton.define();
|
|
2083
2018
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2084
2019
|
button.offer = offer;
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -2,32 +2,7 @@ export declare enum ApplePayEntryPoint {
|
|
|
2
2
|
PAYWALL = "article_paywall",
|
|
3
3
|
REGWALL = "article_regwall",
|
|
4
4
|
DUAL_OFFER_BANNER = "dual_offer_banner",
|
|
5
|
-
FREE_TRIAL_BANNER = "free_trial_banner"
|
|
5
|
+
FREE_TRIAL_BANNER = "free_trial_banner",
|
|
6
|
+
/** Post-registration free-trial popup. Not Amplitude-gated. */
|
|
7
|
+
FREE_TRIAL_POPUP = "free_trial_popup"
|
|
6
8
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Amplitude experiment key for Apple Pay Express Checkout on article paywalls
|
|
9
|
-
* (`ApplePayEntryPoint.PAYWALL`, e.g. single-offer-paywall / multi-offer paywall).
|
|
10
|
-
*
|
|
11
|
-
* Fail-closed when the variant is missing or not `treatment`; the QA URL param
|
|
12
|
-
* `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` can show the button without treatment.
|
|
13
|
-
* Eligibility for this flag ignores homepage and requires Safari/Apple device
|
|
14
|
-
* (plus `isApplePayAvailable` before `$exposure`).
|
|
15
|
-
*
|
|
16
|
-
* Must match the Feature experiment key in Amplitude and host app constants
|
|
17
|
-
* (Engagement / Insider / Podcasts) while those still bridge the experiment.
|
|
18
|
-
*/
|
|
19
|
-
export declare const APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
20
|
-
/**
|
|
21
|
-
* Known Amplitude experiment flag keys for Apple Pay Express Checkout.
|
|
22
|
-
* Narrowed so callers cannot pass an arbitrary typo'd string.
|
|
23
|
-
*/
|
|
24
|
-
export type ApplePayExperimentFlagKey = typeof APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY;
|
|
25
|
-
/**
|
|
26
|
-
* Amplitude variant values for the Apple Pay Express Checkout experiment.
|
|
27
|
-
* CONTROL → button hidden (baseline)
|
|
28
|
-
* TREATMENT → button shown
|
|
29
|
-
*/
|
|
30
|
-
export declare const APPLE_PAY_EXPRESS_VARIANTS: {
|
|
31
|
-
readonly CONTROL: "control";
|
|
32
|
-
readonly TREATMENT: "treatment";
|
|
33
|
-
};
|
package/dist/src/constants.js
CHANGED
|
@@ -4,15 +4,9 @@ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
|
4
4
|
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
5
5
|
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
6
6
|
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
7
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
7
8
|
return ApplePayEntryPoint2;
|
|
8
9
|
})(ApplePayEntryPoint || {});
|
|
9
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
10
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
11
|
-
CONTROL: "control",
|
|
12
|
-
TREATMENT: "treatment"
|
|
13
|
-
};
|
|
14
10
|
export {
|
|
15
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
16
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
17
11
|
ApplePayEntryPoint
|
|
18
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,20 +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
|
-
return ApplePayEntryPoint2;
|
|
1315
|
-
})(ApplePayEntryPoint || {});
|
|
1316
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1317
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1318
|
-
CONTROL: "control",
|
|
1319
|
-
TREATMENT: "treatment"
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
1308
|
// src/utils/expressCheckoutTracking.ts
|
|
1323
1309
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1324
1310
|
/** Wallet button displayed */
|
|
@@ -1356,26 +1342,6 @@ var track = (action, extra) => {
|
|
|
1356
1342
|
...extra
|
|
1357
1343
|
});
|
|
1358
1344
|
};
|
|
1359
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1360
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1361
|
-
if (!isActiveVariant) {
|
|
1362
|
-
return;
|
|
1363
|
-
}
|
|
1364
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1365
|
-
window.__applePayExperimentExposures = exposures;
|
|
1366
|
-
const pathname = window.location?.pathname ?? "";
|
|
1367
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1368
|
-
if (exposures[dedupeKey]) {
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
exposures[dedupeKey] = true;
|
|
1372
|
-
emitTedlEvent({
|
|
1373
|
-
name: "$exposure",
|
|
1374
|
-
flag_key: flagKey,
|
|
1375
|
-
variant,
|
|
1376
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1377
|
-
});
|
|
1378
|
-
};
|
|
1379
1345
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1380
1346
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1381
1347
|
wallet_type: "apple_pay",
|
|
@@ -1976,36 +1942,38 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1976
1942
|
return [...zoneCountries];
|
|
1977
1943
|
};
|
|
1978
1944
|
|
|
1979
|
-
// src/utils/getExperimentKeyFromNextData.ts
|
|
1980
|
-
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1981
|
-
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1982
|
-
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1983
|
-
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1984
|
-
};
|
|
1985
|
-
|
|
1986
1945
|
// src/utils/applePayExpressEligibility.ts
|
|
1987
|
-
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 || {});
|
|
1988
1957
|
|
|
1989
1958
|
// src/apple-pay-button.ts
|
|
1990
1959
|
var ENTRY_POINT_CONFIG = {
|
|
1991
1960
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
1992
1961
|
isEligible: () => true
|
|
1993
|
-
// no experimentFlagKey → always-on after offer exclusions
|
|
1994
1962
|
},
|
|
1995
1963
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
1996
1964
|
isEligible: () => true
|
|
1997
|
-
// Dual parity — no experimentFlagKey, no homepage gate here
|
|
1998
1965
|
},
|
|
1999
1966
|
["article_paywall" /* PAYWALL */]: {
|
|
2000
|
-
isEligible:
|
|
2001
|
-
experimentFlagKey: APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY
|
|
1967
|
+
isEligible: isEligibleForApplePayExpressPaywall
|
|
2002
1968
|
},
|
|
2003
1969
|
["article_regwall" /* REGWALL */]: {
|
|
2004
1970
|
isEligible: () => true,
|
|
2005
1971
|
enabled: false
|
|
1972
|
+
},
|
|
1973
|
+
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
1974
|
+
isEligible: () => true
|
|
2006
1975
|
}
|
|
2007
1976
|
};
|
|
2008
|
-
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
2009
1977
|
var TOTAL_LABEL = "The Economist";
|
|
2010
1978
|
var DEFAULT_CURRENCY = "USD";
|
|
2011
1979
|
var DEFAULT_TOTAL = "0.00";
|
|
@@ -2024,26 +1992,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2024
1992
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2025
1993
|
*
|
|
2026
1994
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2027
|
-
* no homepage/Safari gate here
|
|
2028
|
-
*
|
|
1995
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
1996
|
+
* `isApplePayAvailable()` on mount.
|
|
2029
1997
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2030
1998
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2031
|
-
* - `
|
|
2032
|
-
* (`
|
|
2033
|
-
*
|
|
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`.
|
|
2034
2003
|
* - `REGWALL`: inert — always returns null.
|
|
2035
2004
|
*
|
|
2036
|
-
*
|
|
2037
|
-
* `
|
|
2038
|
-
* treatment (and without inflating `$exposure`). For banners there is no
|
|
2039
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2040
|
-
* `isApplePayAvailable()` on mount.
|
|
2041
|
-
*
|
|
2042
|
-
* **Eligibility:**
|
|
2043
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` (or omitted): always eligible at
|
|
2044
|
-
* this gate (homepage placement is host-owned; Safari/Apple is enforced
|
|
2045
|
-
* later by `isApplePayAvailable()` on mount)
|
|
2046
|
-
* - `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).
|
|
2047
2007
|
*
|
|
2048
2008
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2049
2009
|
* @param country - The user's country code.
|
|
@@ -2056,41 +2016,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2056
2016
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
2057
2017
|
return null;
|
|
2058
2018
|
}
|
|
2059
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2060
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2061
|
-
);
|
|
2062
2019
|
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2063
2020
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2064
2021
|
if (!config) {
|
|
2065
2022
|
return null;
|
|
2066
2023
|
}
|
|
2067
|
-
const { isEligible: eligibilityCheck
|
|
2024
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2068
2025
|
const isEligible = eligibilityCheck();
|
|
2069
2026
|
if (config.enabled === false) {
|
|
2070
2027
|
return null;
|
|
2071
2028
|
}
|
|
2072
|
-
if (!
|
|
2029
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2073
2030
|
return null;
|
|
2074
2031
|
}
|
|
2075
|
-
if (experimentFlagKey) {
|
|
2076
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2077
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2078
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2079
|
-
void isApplePayAvailable().then((available) => {
|
|
2080
|
-
if (available) {
|
|
2081
|
-
trackApplePayExperimentExposure(
|
|
2082
|
-
experimentValue,
|
|
2083
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2084
|
-
experimentFlagKey
|
|
2085
|
-
);
|
|
2086
|
-
}
|
|
2087
|
-
});
|
|
2088
|
-
}
|
|
2089
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2090
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2091
|
-
return null;
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
2032
|
_ApplePayButton.define();
|
|
2095
2033
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2096
2034
|
button.offer = offer;
|
|
@@ -2417,8 +2355,6 @@ function defineApplePayElements() {
|
|
|
2417
2355
|
}
|
|
2418
2356
|
export {
|
|
2419
2357
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2420
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
2421
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
2422
2358
|
ApplePayButton,
|
|
2423
2359
|
ApplePayEntryPoint,
|
|
2424
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
|
-
};
|