@naturalcycles/internal-web-lib 1.2.1 → 1.3.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/bundle/analyticsClient.js.map +1 -1
- package/bundle/conversionClient.js +75 -29
- package/bundle/conversionClient.js.map +1 -1
- package/bundle/cookieMonster.js +4 -0
- package/bundle/cookieMonster.js.map +1 -1
- package/dist/analytics/analyticsClient.d.ts +2 -2
- package/dist/conversion/conversionClient.d.ts +13 -4
- package/dist/conversion/conversionClient.js +37 -11
- package/dist/cookie-monster/cookie-monster-element.js +4 -0
- package/package.json +3 -3
|
@@ -883,11 +883,37 @@ var Y = Symbol("reinitAttempted"), fe = {
|
|
|
883
883
|
timeoutMax: 3e4,
|
|
884
884
|
timeoutMultiplier: 2,
|
|
885
885
|
maxRetryAfter: 6e5
|
|
886
|
-
},
|
|
886
|
+
}, me = {
|
|
887
|
+
"https://www.naturalcycles.com/": [
|
|
888
|
+
"shop",
|
|
889
|
+
"research-library",
|
|
890
|
+
"plan-pregnancy",
|
|
891
|
+
"postpartum",
|
|
892
|
+
"cyclematters/period-calculator",
|
|
893
|
+
"cyclematters/search",
|
|
894
|
+
"cyclematters/perimenopause-quiz"
|
|
895
|
+
],
|
|
896
|
+
"https://www.naturalcycles.me/": [],
|
|
897
|
+
"https://signup.naturalcycles.com/": ["account", "onboarding"],
|
|
898
|
+
"https://se.naturalcycles.com/": [],
|
|
899
|
+
"https://br.naturalcycles.com/": [],
|
|
900
|
+
"https://uk.naturalcycles.com/": []
|
|
901
|
+
}, he = {
|
|
902
|
+
"http://localhost:8000": "https://www.naturalcycles.com/",
|
|
903
|
+
"http://localhost:8001": "https://www.naturalcycles.me/",
|
|
904
|
+
"http://localhost:4200": "https://signup.naturalcycles.com/"
|
|
905
|
+
}, ge = [
|
|
906
|
+
"https://www.naturalcycles.com/",
|
|
907
|
+
"https://www.naturalcycles.me/",
|
|
908
|
+
"https://signup.naturalcycles.com/",
|
|
909
|
+
"https://se.naturalcycles.com/",
|
|
910
|
+
"https://br.naturalcycles.com/",
|
|
911
|
+
"https://uk.naturalcycles.com/"
|
|
912
|
+
], X;
|
|
887
913
|
(function(e) {
|
|
888
914
|
e.flow = "flow", e.code = "code", e.refId = "refId", e.referral = "referral", e.ignoreConfirmation = "ignoreConfirmation", e.ic = "ic", e.measuringDevice = "measuringDevice", e.irclickid = "irclickid", e.fg = "fg", e.sfg = "sfg", e.sq = "sq", e.cbo = "cbo", e.ip = "ip", e.ipv = "ipv", e.appleAuth = "appleAuth", e.googleAuth = "googleAuth", e.od = "od", e.pl = "pl", e.ScCid = "ScCid", e.fbclid = "fbclid", e.ttclid = "ttclid", e.rdt_cid = "rdt_cid", e.epik = "epik", e.adid = "adid", e.wcf = "wcf", e.we = "we", e.werr = "werr", e.wdpm = "wdpm", e.wsc = "wsc", e.ral = "ral";
|
|
889
915
|
})(X ||= {});
|
|
890
|
-
var
|
|
916
|
+
var _e = [
|
|
891
917
|
X.ScCid,
|
|
892
918
|
X.irclickid,
|
|
893
919
|
X.fbclid,
|
|
@@ -896,11 +922,11 @@ var me = [
|
|
|
896
922
|
X.epik
|
|
897
923
|
];
|
|
898
924
|
X.flow, X.code, X.ignoreConfirmation, X.ic, X.fg, X.sfg, X.sq, X.cbo, X.ip, X.ipv, X.od, X.pl, X.wcf, X.we, X.wdpm, X.wsc, X.ral;
|
|
899
|
-
var
|
|
925
|
+
var Z;
|
|
900
926
|
(function(e) {
|
|
901
927
|
e[e.OURA = 1] = "OURA", e[e.APPLE_WATCH = 2] = "APPLE_WATCH", e[e.META_LANDING_PAGE = 3] = "META_LANDING_PAGE", e[e.PAYMENT_REDIRECT_FROM_APP = 4] = "PAYMENT_REDIRECT_FROM_APP", e[e.B1 = 5] = "B1", e[e.EMAIL_VERIFICATION_REDIRECT = 6] = "EMAIL_VERIFICATION_REDIRECT", e[e.WHOOP = 7] = "WHOOP";
|
|
902
|
-
})(
|
|
903
|
-
var
|
|
928
|
+
})(Z ||= {});
|
|
929
|
+
var Q = new class {
|
|
904
930
|
getAllCookies() {
|
|
905
931
|
let e = {}, t = document.cookie.split("; ");
|
|
906
932
|
for (let n of t) {
|
|
@@ -935,10 +961,10 @@ var Z = new class {
|
|
|
935
961
|
}();
|
|
936
962
|
//#endregion
|
|
937
963
|
//#region ../shared/dist/util/metaClickId.util.js
|
|
938
|
-
function
|
|
964
|
+
function $(e) {
|
|
939
965
|
if (e) return e.startsWith("fb.") ? e : `fb.1.${Date.now()}.${e}`;
|
|
940
966
|
}
|
|
941
|
-
function
|
|
967
|
+
function ve(e) {
|
|
942
968
|
if (!e) return;
|
|
943
969
|
e = e.split("?")[0], e.includes("__DOT__") && (e = e.replaceAll("__DOT__", ".")), e = e.split("%")[0], e = e.split("&")[0];
|
|
944
970
|
let t = e.split("."), n = t.lastIndexOf("fb");
|
|
@@ -946,7 +972,7 @@ function ge(e) {
|
|
|
946
972
|
}
|
|
947
973
|
//#endregion
|
|
948
974
|
//#region src/conversion/conversionClient.ts
|
|
949
|
-
var
|
|
975
|
+
var ye = 30, be = 200, xe = 20, Se = class {
|
|
950
976
|
constructor(e) {
|
|
951
977
|
this.cfg = {
|
|
952
978
|
...e,
|
|
@@ -957,14 +983,29 @@ var $ = 30, _e = 200, ve = 20, ye = class {
|
|
|
957
983
|
cfg;
|
|
958
984
|
fetcher;
|
|
959
985
|
lastCapturedHref;
|
|
986
|
+
pendingClickIds = {};
|
|
960
987
|
init() {
|
|
961
988
|
this.cfg.enabled && this.tryOrReport(() => this.captureClickIds(), void 0);
|
|
962
989
|
}
|
|
963
990
|
pageView(e, t = {}) {
|
|
964
|
-
this.cfg.enabled
|
|
991
|
+
if (!this.cfg.enabled) return;
|
|
992
|
+
let n = this.getAllowedPathname(e.pathname);
|
|
993
|
+
n !== null && f(this.send("p", {
|
|
994
|
+
...e,
|
|
995
|
+
pathname: n
|
|
996
|
+
}, t));
|
|
965
997
|
}
|
|
966
998
|
purchase(e, t = {}) {
|
|
967
|
-
this.cfg.enabled
|
|
999
|
+
if (!this.cfg.enabled) return;
|
|
1000
|
+
let n = this.getAllowedPathname(e.pathname);
|
|
1001
|
+
n !== null && f(this.send("purchase", {
|
|
1002
|
+
...e,
|
|
1003
|
+
pathname: n
|
|
1004
|
+
}, t));
|
|
1005
|
+
}
|
|
1006
|
+
getAllowedPathname(e) {
|
|
1007
|
+
let { href: t, origin: n } = globalThis.location, r = ge.find((e) => t.startsWith(e)) || he[n];
|
|
1008
|
+
return r ? me[r].some((t) => e.includes(t)) ? null : e : null;
|
|
968
1009
|
}
|
|
969
1010
|
async send(e, t, n) {
|
|
970
1011
|
try {
|
|
@@ -973,7 +1014,7 @@ var $ = 30, _e = 200, ve = 20, ye = class {
|
|
|
973
1014
|
method: "POST",
|
|
974
1015
|
json: t,
|
|
975
1016
|
headers: {
|
|
976
|
-
...this.getHeaders(),
|
|
1017
|
+
...this.getHeaders({ marketingConsent: t.marketingConsent ?? t.marketingCookie }),
|
|
977
1018
|
...n.extraHeaders
|
|
978
1019
|
},
|
|
979
1020
|
keepalive: !0,
|
|
@@ -984,18 +1025,23 @@ var $ = 30, _e = 200, ve = 20, ye = class {
|
|
|
984
1025
|
this.cfg.onError(T(e));
|
|
985
1026
|
}
|
|
986
1027
|
}
|
|
987
|
-
getHeaders() {
|
|
988
|
-
let
|
|
989
|
-
return this.tryOrReport(() => (this.cfg.enabled && this.
|
|
990
|
-
clientId:
|
|
991
|
-
fbc:
|
|
992
|
-
fbp:
|
|
993
|
-
scCid:
|
|
994
|
-
ttclid:
|
|
995
|
-
rdtCid:
|
|
996
|
-
epik:
|
|
997
|
-
uuid_c1:
|
|
998
|
-
})), { clientId:
|
|
1028
|
+
getHeaders(e) {
|
|
1029
|
+
let t = String(this.cfg.clientId);
|
|
1030
|
+
return e.marketingConsent ? this.tryOrReport(() => (this.cfg.enabled && this.storeClickIds(), re({
|
|
1031
|
+
clientId: t,
|
|
1032
|
+
fbc: Q.getCookie("_fbc") || $(Q.getCookie(X.fbclid)),
|
|
1033
|
+
fbp: Q.getCookie("_fbp"),
|
|
1034
|
+
scCid: Q.getCookie(X.ScCid),
|
|
1035
|
+
ttclid: Q.getCookie(X.ttclid),
|
|
1036
|
+
rdtCid: Q.getCookie(X.rdt_cid),
|
|
1037
|
+
epik: Q.getCookie("_epik") || Q.getCookie(X.epik),
|
|
1038
|
+
uuid_c1: Q.getCookie("_scid") || Q.getCookie("uuid_c1")
|
|
1039
|
+
})), { clientId: t }) : { clientId: t };
|
|
1040
|
+
}
|
|
1041
|
+
storeClickIds() {
|
|
1042
|
+
this.captureClickIds();
|
|
1043
|
+
for (let [e, t] of Object.entries(this.pendingClickIds)) Q.setCookie(e, t, ye, this.cfg.cookieDomain);
|
|
1044
|
+
this.pendingClickIds = {};
|
|
999
1045
|
}
|
|
1000
1046
|
tryOrReport(e, t) {
|
|
1001
1047
|
try {
|
|
@@ -1009,19 +1055,19 @@ var $ = 30, _e = 200, ve = 20, ye = class {
|
|
|
1009
1055
|
if (e === this.lastCapturedHref) return;
|
|
1010
1056
|
this.lastCapturedHref = e;
|
|
1011
1057
|
let n = new URLSearchParams(t);
|
|
1012
|
-
for (let e of
|
|
1058
|
+
for (let e of _e) {
|
|
1013
1059
|
let t = n.get(e) || n.get(e.toLowerCase());
|
|
1014
1060
|
if (!t) continue;
|
|
1015
|
-
let r = e === X.fbclid ? this.toFbc(t) : t.slice(0,
|
|
1016
|
-
r &&
|
|
1061
|
+
let r = e === X.fbclid ? this.toFbc(t) : t.slice(0, be);
|
|
1062
|
+
r && (this.pendingClickIds[e] = r);
|
|
1017
1063
|
}
|
|
1018
1064
|
}
|
|
1019
1065
|
toFbc(e) {
|
|
1020
|
-
let t =
|
|
1021
|
-
if (!(!t || t.length <
|
|
1066
|
+
let t = ve(e);
|
|
1067
|
+
if (!(!t || t.length < xe) && !(this.pendingClickIds[X.fbclid] || Q.getCookie(X.fbclid))?.endsWith(`.${t}`)) return $(t);
|
|
1022
1068
|
}
|
|
1023
1069
|
};
|
|
1024
1070
|
//#endregion
|
|
1025
|
-
export {
|
|
1071
|
+
export { Se as ConversionClient, t as generateConversionEventId };
|
|
1026
1072
|
|
|
1027
1073
|
//# sourceMappingURL=conversionClient.js.map
|