@economist/web-apple-pay 1.9.2 → 1.9.4
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/dist/index.js +44 -11
- package/dist/src/apple-pay-button.js +38 -5
- package/dist/src/apple-pay-button.stories.js +38 -5
- package/dist/src/apple-pay-modal.stories.js +38 -5
- package/dist/src/index.js +44 -11
- package/dist/src/utils/expressCheckoutTracking.d.ts +10 -0
- package/dist/src/utils/expressCheckoutTracking.js +28 -0
- package/dist/src/utils/getExperimentKeyFromNextData.d.ts +8 -0
- package/dist/src/utils/getExperimentKeyFromNextData.js +9 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1303,6 +1303,19 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1303
1303
|
return url.pathname + url.search;
|
|
1304
1304
|
};
|
|
1305
1305
|
|
|
1306
|
+
// src/constants.ts
|
|
1307
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
|
|
1308
|
+
ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
|
|
1309
|
+
ApplePayEntryPoint3["REGWALL"] = "article_regwall";
|
|
1310
|
+
ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1311
|
+
return ApplePayEntryPoint3;
|
|
1312
|
+
})(ApplePayEntryPoint || {});
|
|
1313
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
1314
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1315
|
+
CONTROL: "control",
|
|
1316
|
+
TREATMENT: "treatment"
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1306
1319
|
// src/utils/expressCheckoutTracking.ts
|
|
1307
1320
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1308
1321
|
/** Wallet button displayed */
|
|
@@ -1340,6 +1353,26 @@ var track = (action, extra) => {
|
|
|
1340
1353
|
...extra
|
|
1341
1354
|
});
|
|
1342
1355
|
};
|
|
1356
|
+
var trackApplePayExperimentExposure = (variant, experimentKey) => {
|
|
1357
|
+
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1358
|
+
if (!isActiveVariant) {
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1362
|
+
window.__applePayExperimentExposures = exposures;
|
|
1363
|
+
const pathname = window.location?.pathname ?? "";
|
|
1364
|
+
const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
|
|
1365
|
+
if (exposures[dedupeKey]) {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
exposures[dedupeKey] = true;
|
|
1369
|
+
emitTedlEvent({
|
|
1370
|
+
name: "$exposure",
|
|
1371
|
+
flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
|
|
1372
|
+
variant,
|
|
1373
|
+
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1374
|
+
});
|
|
1375
|
+
};
|
|
1343
1376
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1344
1377
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1345
1378
|
wallet_type: "apple_pay",
|
|
@@ -1963,17 +1996,11 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1963
1996
|
return [...zoneCountries];
|
|
1964
1997
|
};
|
|
1965
1998
|
|
|
1966
|
-
// src/
|
|
1967
|
-
var
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
return ApplePayEntryPoint3;
|
|
1972
|
-
})(ApplePayEntryPoint || {});
|
|
1973
|
-
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
1974
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1975
|
-
CONTROL: "control",
|
|
1976
|
-
TREATMENT: "treatment"
|
|
1999
|
+
// src/utils/getExperimentKeyFromNextData.ts
|
|
2000
|
+
var getExperimentKeyFromNextData = (flagKey) => {
|
|
2001
|
+
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
2002
|
+
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
2003
|
+
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1977
2004
|
};
|
|
1978
2005
|
|
|
1979
2006
|
// src/apple-pay-button.ts
|
|
@@ -2021,6 +2048,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2021
2048
|
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
2022
2049
|
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
2023
2050
|
);
|
|
2051
|
+
if (experimentValue) {
|
|
2052
|
+
trackApplePayExperimentExposure(
|
|
2053
|
+
experimentValue,
|
|
2054
|
+
getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2024
2057
|
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2025
2058
|
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2026
2059
|
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
@@ -1298,6 +1298,13 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1298
1298
|
return url.pathname + url.search;
|
|
1299
1299
|
};
|
|
1300
1300
|
|
|
1301
|
+
// src/constants.ts
|
|
1302
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
1303
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1304
|
+
CONTROL: "control",
|
|
1305
|
+
TREATMENT: "treatment"
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1301
1308
|
// src/utils/expressCheckoutTracking.ts
|
|
1302
1309
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1303
1310
|
/** Wallet button displayed */
|
|
@@ -1335,6 +1342,26 @@ var track = (action, extra) => {
|
|
|
1335
1342
|
...extra
|
|
1336
1343
|
});
|
|
1337
1344
|
};
|
|
1345
|
+
var trackApplePayExperimentExposure = (variant, experimentKey) => {
|
|
1346
|
+
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1347
|
+
if (!isActiveVariant) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1351
|
+
window.__applePayExperimentExposures = exposures;
|
|
1352
|
+
const pathname = window.location?.pathname ?? "";
|
|
1353
|
+
const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
|
|
1354
|
+
if (exposures[dedupeKey]) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
exposures[dedupeKey] = true;
|
|
1358
|
+
emitTedlEvent({
|
|
1359
|
+
name: "$exposure",
|
|
1360
|
+
flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
|
|
1361
|
+
variant,
|
|
1362
|
+
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1363
|
+
});
|
|
1364
|
+
};
|
|
1338
1365
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1339
1366
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1340
1367
|
wallet_type: "apple_pay",
|
|
@@ -1958,11 +1985,11 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1958
1985
|
return [...zoneCountries];
|
|
1959
1986
|
};
|
|
1960
1987
|
|
|
1961
|
-
// src/
|
|
1962
|
-
var
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1988
|
+
// src/utils/getExperimentKeyFromNextData.ts
|
|
1989
|
+
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1990
|
+
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1991
|
+
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1992
|
+
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1966
1993
|
};
|
|
1967
1994
|
|
|
1968
1995
|
// src/apple-pay-button.ts
|
|
@@ -2010,6 +2037,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2010
2037
|
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
2011
2038
|
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
2012
2039
|
);
|
|
2040
|
+
if (experimentValue) {
|
|
2041
|
+
trackApplePayExperimentExposure(
|
|
2042
|
+
experimentValue,
|
|
2043
|
+
getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2013
2046
|
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2014
2047
|
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2015
2048
|
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
@@ -1306,6 +1306,13 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1306
1306
|
return url.pathname + url.search;
|
|
1307
1307
|
};
|
|
1308
1308
|
|
|
1309
|
+
// src/constants.ts
|
|
1310
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
1311
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1312
|
+
CONTROL: "control",
|
|
1313
|
+
TREATMENT: "treatment"
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1309
1316
|
// src/utils/expressCheckoutTracking.ts
|
|
1310
1317
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1311
1318
|
/** Wallet button displayed */
|
|
@@ -1343,6 +1350,26 @@ var track = (action, extra) => {
|
|
|
1343
1350
|
...extra
|
|
1344
1351
|
});
|
|
1345
1352
|
};
|
|
1353
|
+
var trackApplePayExperimentExposure = (variant, experimentKey) => {
|
|
1354
|
+
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1355
|
+
if (!isActiveVariant) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1359
|
+
window.__applePayExperimentExposures = exposures;
|
|
1360
|
+
const pathname = window.location?.pathname ?? "";
|
|
1361
|
+
const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
|
|
1362
|
+
if (exposures[dedupeKey]) {
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
exposures[dedupeKey] = true;
|
|
1366
|
+
emitTedlEvent({
|
|
1367
|
+
name: "$exposure",
|
|
1368
|
+
flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
|
|
1369
|
+
variant,
|
|
1370
|
+
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1371
|
+
});
|
|
1372
|
+
};
|
|
1346
1373
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1347
1374
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1348
1375
|
wallet_type: "apple_pay",
|
|
@@ -1966,11 +1993,11 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1966
1993
|
return [...zoneCountries];
|
|
1967
1994
|
};
|
|
1968
1995
|
|
|
1969
|
-
// src/
|
|
1970
|
-
var
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1996
|
+
// src/utils/getExperimentKeyFromNextData.ts
|
|
1997
|
+
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1998
|
+
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1999
|
+
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
2000
|
+
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1974
2001
|
};
|
|
1975
2002
|
|
|
1976
2003
|
// src/apple-pay-button.ts
|
|
@@ -2018,6 +2045,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2018
2045
|
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
2019
2046
|
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
2020
2047
|
);
|
|
2048
|
+
if (experimentValue) {
|
|
2049
|
+
trackApplePayExperimentExposure(
|
|
2050
|
+
experimentValue,
|
|
2051
|
+
getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
|
|
2052
|
+
);
|
|
2053
|
+
}
|
|
2021
2054
|
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2022
2055
|
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2023
2056
|
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
@@ -1298,6 +1298,13 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1298
1298
|
return url.pathname + url.search;
|
|
1299
1299
|
};
|
|
1300
1300
|
|
|
1301
|
+
// src/constants.ts
|
|
1302
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
1303
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1304
|
+
CONTROL: "control",
|
|
1305
|
+
TREATMENT: "treatment"
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1301
1308
|
// src/utils/expressCheckoutTracking.ts
|
|
1302
1309
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1303
1310
|
/** Wallet button displayed */
|
|
@@ -1335,6 +1342,26 @@ var track = (action, extra) => {
|
|
|
1335
1342
|
...extra
|
|
1336
1343
|
});
|
|
1337
1344
|
};
|
|
1345
|
+
var trackApplePayExperimentExposure = (variant, experimentKey) => {
|
|
1346
|
+
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1347
|
+
if (!isActiveVariant) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1351
|
+
window.__applePayExperimentExposures = exposures;
|
|
1352
|
+
const pathname = window.location?.pathname ?? "";
|
|
1353
|
+
const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
|
|
1354
|
+
if (exposures[dedupeKey]) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
exposures[dedupeKey] = true;
|
|
1358
|
+
emitTedlEvent({
|
|
1359
|
+
name: "$exposure",
|
|
1360
|
+
flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
|
|
1361
|
+
variant,
|
|
1362
|
+
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1363
|
+
});
|
|
1364
|
+
};
|
|
1338
1365
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1339
1366
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1340
1367
|
wallet_type: "apple_pay",
|
|
@@ -1958,11 +1985,11 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1958
1985
|
return [...zoneCountries];
|
|
1959
1986
|
};
|
|
1960
1987
|
|
|
1961
|
-
// src/
|
|
1962
|
-
var
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1988
|
+
// src/utils/getExperimentKeyFromNextData.ts
|
|
1989
|
+
var getExperimentKeyFromNextData = (flagKey) => {
|
|
1990
|
+
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
1991
|
+
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
1992
|
+
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1966
1993
|
};
|
|
1967
1994
|
|
|
1968
1995
|
// src/apple-pay-button.ts
|
|
@@ -2010,6 +2037,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2010
2037
|
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
2011
2038
|
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
2012
2039
|
);
|
|
2040
|
+
if (experimentValue) {
|
|
2041
|
+
trackApplePayExperimentExposure(
|
|
2042
|
+
experimentValue,
|
|
2043
|
+
getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2013
2046
|
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2014
2047
|
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2015
2048
|
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
package/dist/src/index.js
CHANGED
|
@@ -1303,6 +1303,19 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1303
1303
|
return url.pathname + url.search;
|
|
1304
1304
|
};
|
|
1305
1305
|
|
|
1306
|
+
// src/constants.ts
|
|
1307
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
|
|
1308
|
+
ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
|
|
1309
|
+
ApplePayEntryPoint3["REGWALL"] = "article_regwall";
|
|
1310
|
+
ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1311
|
+
return ApplePayEntryPoint3;
|
|
1312
|
+
})(ApplePayEntryPoint || {});
|
|
1313
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
1314
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1315
|
+
CONTROL: "control",
|
|
1316
|
+
TREATMENT: "treatment"
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1306
1319
|
// src/utils/expressCheckoutTracking.ts
|
|
1307
1320
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1308
1321
|
/** Wallet button displayed */
|
|
@@ -1340,6 +1353,26 @@ var track = (action, extra) => {
|
|
|
1340
1353
|
...extra
|
|
1341
1354
|
});
|
|
1342
1355
|
};
|
|
1356
|
+
var trackApplePayExperimentExposure = (variant, experimentKey) => {
|
|
1357
|
+
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1358
|
+
if (!isActiveVariant) {
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1362
|
+
window.__applePayExperimentExposures = exposures;
|
|
1363
|
+
const pathname = window.location?.pathname ?? "";
|
|
1364
|
+
const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
|
|
1365
|
+
if (exposures[dedupeKey]) {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
exposures[dedupeKey] = true;
|
|
1369
|
+
emitTedlEvent({
|
|
1370
|
+
name: "$exposure",
|
|
1371
|
+
flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
|
|
1372
|
+
variant,
|
|
1373
|
+
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1374
|
+
});
|
|
1375
|
+
};
|
|
1343
1376
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1344
1377
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1345
1378
|
wallet_type: "apple_pay",
|
|
@@ -1963,17 +1996,11 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1963
1996
|
return [...zoneCountries];
|
|
1964
1997
|
};
|
|
1965
1998
|
|
|
1966
|
-
// src/
|
|
1967
|
-
var
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
return ApplePayEntryPoint3;
|
|
1972
|
-
})(ApplePayEntryPoint || {});
|
|
1973
|
-
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
1974
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1975
|
-
CONTROL: "control",
|
|
1976
|
-
TREATMENT: "treatment"
|
|
1999
|
+
// src/utils/getExperimentKeyFromNextData.ts
|
|
2000
|
+
var getExperimentKeyFromNextData = (flagKey) => {
|
|
2001
|
+
const experiments = window.__NEXT_DATA__?.props?.pageProps?.experiments;
|
|
2002
|
+
const experimentKey = experiments?.[flagKey]?.metadata?.experimentKey;
|
|
2003
|
+
return typeof experimentKey === "string" ? experimentKey : void 0;
|
|
1977
2004
|
};
|
|
1978
2005
|
|
|
1979
2006
|
// src/apple-pay-button.ts
|
|
@@ -2021,6 +2048,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2021
2048
|
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
2022
2049
|
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
2023
2050
|
);
|
|
2051
|
+
if (experimentValue) {
|
|
2052
|
+
trackApplePayExperimentExposure(
|
|
2053
|
+
experimentValue,
|
|
2054
|
+
getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2024
2057
|
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2025
2058
|
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2026
2059
|
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
@@ -17,6 +17,7 @@ declare global {
|
|
|
17
17
|
events?: Record<string, unknown>[];
|
|
18
18
|
[key: string]: unknown;
|
|
19
19
|
};
|
|
20
|
+
__applePayExperimentExposures?: Record<string, boolean>;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
export declare const EXPRESS_CHECKOUT_EVENTS: {
|
|
@@ -46,6 +47,15 @@ export type ImpressionMetadata = {
|
|
|
46
47
|
/** ISO 3166-1 alpha-2 country code of the offer (e.g. 'GB', 'US'). */
|
|
47
48
|
country: string;
|
|
48
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Amplitude Experiment exposure for Apple Pay Express (SMA-3301).
|
|
52
|
+
*
|
|
53
|
+
* Fired when createIfEnabled evaluates an assigned variant (control or
|
|
54
|
+
* treatment). Deduped per pathname + variant so repeated banner renders on
|
|
55
|
+
* the same page do not over-count. Includes experiment_key from Engagement
|
|
56
|
+
* SSR (__NEXT_DATA__) when present for Feature Experiment run attribution.
|
|
57
|
+
*/
|
|
58
|
+
export declare const trackApplePayExperimentExposure: (variant: string, experimentKey?: string) => void;
|
|
49
59
|
/** Wallet button displayed — emits all 5 required analytics dimensions. */
|
|
50
60
|
export declare const trackExpressWalletImpression: (skuId: string, { entryPoint, country }: ImpressionMetadata) => void;
|
|
51
61
|
/** Wallet button clicked */
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
|
|
3
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
4
|
+
CONTROL: "control",
|
|
5
|
+
TREATMENT: "treatment"
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
// src/utils/expressCheckoutTracking.ts
|
|
2
9
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
3
10
|
/** Wallet button displayed */
|
|
@@ -35,6 +42,26 @@ var track = (action, extra) => {
|
|
|
35
42
|
...extra
|
|
36
43
|
});
|
|
37
44
|
};
|
|
45
|
+
var trackApplePayExperimentExposure = (variant, experimentKey) => {
|
|
46
|
+
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
47
|
+
if (!isActiveVariant) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const exposures = window.__applePayExperimentExposures ?? {};
|
|
51
|
+
window.__applePayExperimentExposures = exposures;
|
|
52
|
+
const pathname = window.location?.pathname ?? "";
|
|
53
|
+
const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
|
|
54
|
+
if (exposures[dedupeKey]) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
exposures[dedupeKey] = true;
|
|
58
|
+
emitTedlEvent({
|
|
59
|
+
name: "$exposure",
|
|
60
|
+
flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
|
|
61
|
+
variant,
|
|
62
|
+
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
38
65
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
39
66
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
40
67
|
wallet_type: "apple_pay",
|
|
@@ -73,6 +100,7 @@ var trackValidationFieldError = (field, errorType) => {
|
|
|
73
100
|
};
|
|
74
101
|
export {
|
|
75
102
|
EXPRESS_CHECKOUT_EVENTS,
|
|
103
|
+
trackApplePayExperimentExposure,
|
|
76
104
|
trackExpressWalletClick,
|
|
77
105
|
trackExpressWalletImpression,
|
|
78
106
|
trackFallbackCheckout,
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
};
|