@adv-re/segment-wrapper 4.36.0-beta.0 → 4.36.0-beta.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/README.md +15 -1
- package/dist/index.js +46 -19
- package/dist/index.mjs +46 -9
- package/package.json +5 -3
- package/umd/index.global.js +1 -0
package/README.md
CHANGED
|
@@ -56,7 +56,8 @@ await analytics.identify('user-123', {
|
|
|
56
56
|
|
|
57
57
|
```html
|
|
58
58
|
<script src="https://cdn.segment.com/analytics.js/v1/YOUR_WRITE_KEY/analytics.min.js"></script>
|
|
59
|
-
|
|
59
|
+
<!-- Use specific version (recommended for production) -->
|
|
60
|
+
<script src="https://unpkg.com/@adv-re/segment-wrapper@4.36.0"></script>
|
|
60
61
|
|
|
61
62
|
<script>
|
|
62
63
|
// Access via window.sui.analytics
|
|
@@ -66,6 +67,19 @@ await analytics.identify('user-123', {
|
|
|
66
67
|
</script>
|
|
67
68
|
```
|
|
68
69
|
|
|
70
|
+
**Version Options:**
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<!-- Specific version (recommended for production) -->
|
|
74
|
+
<script src="https://unpkg.com/@adv-re/segment-wrapper@4.36.0"></script>
|
|
75
|
+
|
|
76
|
+
<!-- Latest version (use only for development) -->
|
|
77
|
+
<script src="https://unpkg.com/@adv-re/segment-wrapper"></script>
|
|
78
|
+
|
|
79
|
+
<!-- Direct path to UMD file -->
|
|
80
|
+
<script src="https://unpkg.com/@adv-re/segment-wrapper@4.36.0/umd/index.global.js"></script>
|
|
81
|
+
```
|
|
82
|
+
|
|
69
83
|
## Configuration
|
|
70
84
|
|
|
71
85
|
```typescript
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -483,8 +473,8 @@ var getConsentsFromCookie = () => {
|
|
|
483
473
|
const { purpose } = JSON.parse(window.atob(cookieValue));
|
|
484
474
|
const { consents } = purpose;
|
|
485
475
|
return consents;
|
|
486
|
-
} catch (
|
|
487
|
-
console.error(
|
|
476
|
+
} catch (e2) {
|
|
477
|
+
console.error(e2);
|
|
488
478
|
return void 0;
|
|
489
479
|
}
|
|
490
480
|
};
|
|
@@ -727,7 +717,7 @@ var decorateContextWithNeededData = async ({
|
|
|
727
717
|
...!isGdprAccepted && { ip: "0.0.0.0" },
|
|
728
718
|
...getExternalIds({ context, xandrId }),
|
|
729
719
|
analytics_storage: getConsentState(),
|
|
730
|
-
clientVersion: `segment-wrapper@${"4.36.0-beta.
|
|
720
|
+
clientVersion: `segment-wrapper@${"4.36.0-beta.4"}`,
|
|
731
721
|
gdpr_privacy: gdprPrivacyValueAnalytics,
|
|
732
722
|
gdpr_privacy_advertising: gdprPrivacyValueAdvertising,
|
|
733
723
|
google_consents,
|
|
@@ -931,9 +921,46 @@ var userTraits = async ({ payload, next }) => {
|
|
|
931
921
|
next(payload);
|
|
932
922
|
};
|
|
933
923
|
|
|
924
|
+
// ../../node_modules/tiny-hashes/md5/index.mjs
|
|
925
|
+
for (r = [], o = 0; o < 64; ) r[o] = 0 | 4294967296 * Math.sin(++o % Math.PI);
|
|
926
|
+
var r;
|
|
927
|
+
var o;
|
|
928
|
+
function md5_default(t) {
|
|
929
|
+
var e2, f2, n, a = [e2 = 1732584193, f2 = 4023233417, ~e2, ~f2], c = [], h = unescape(encodeURI(t)) + "\x80", u = h.length;
|
|
930
|
+
for (t = --u / 4 + 2 | 15, c[--t] = 8 * u; ~u; ) c[u >> 2] |= h.charCodeAt(u) << 8 * u--;
|
|
931
|
+
for (o = h = 0; o < t; o += 16) {
|
|
932
|
+
for (u = a; h < 64; u = [n = u[3], e2 + ((n = u[0] + [e2 & f2 | ~e2 & n, n & e2 | ~n & f2, e2 ^ f2 ^ n, f2 ^ (e2 | ~n)][u = h >> 4] + r[h] + ~~c[o | 15 & [h, 5 * h + 1, 3 * h + 5, 7 * h][u]]) << (u = [7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21][4 * u + h++ % 4]) | n >>> -u), e2, f2]) e2 = 0 | u[1], f2 = u[2];
|
|
933
|
+
for (h = 4; h; ) a[--h] += u[h];
|
|
934
|
+
}
|
|
935
|
+
for (t = ""; h < 32; ) t += (a[h >> 3] >> 4 * (1 ^ h++) & 15).toString(16);
|
|
936
|
+
return t;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// ../../node_modules/tiny-hashes/sha256/index.mjs
|
|
940
|
+
for (o = 18, n = [], t = []; o > 1; o--) for (r = o; r < 320; ) n[r += o] = 1;
|
|
941
|
+
var r;
|
|
942
|
+
var o;
|
|
943
|
+
var n;
|
|
944
|
+
var t;
|
|
945
|
+
function e(r, o) {
|
|
946
|
+
return 4294967296 * Math.pow(r, 1 / o) | 0;
|
|
947
|
+
}
|
|
948
|
+
for (r = 0; r < 64; ) n[++o] || (t[r] = e(o, 2), n[r++] = e(o, 3));
|
|
949
|
+
function f(r, o) {
|
|
950
|
+
return r >>> o | r << -o;
|
|
951
|
+
}
|
|
952
|
+
function sha256_default(u) {
|
|
953
|
+
var c = t.slice(o = r = 0, 8), i = [], a = unescape(encodeURI(u)) + "\x80", p = a.length;
|
|
954
|
+
for (i[u = --p / 4 + 2 | 15] = 8 * p; ~p; ) i[p >> 2] |= a.charCodeAt(p) << 8 * ~p--;
|
|
955
|
+
for (p = []; o < u; o += 16) {
|
|
956
|
+
for (e = c.slice(); r < 64; e.unshift(a + (f(a = e[0], 2) ^ f(a, 13) ^ f(a, 22)) + (a & e[1] ^ e[1] & e[2] ^ e[2] & a))) e[3] += a = 0 | (p[r] = r < 16 ? ~~i[r + o] : (f(a = p[r - 2], 17) ^ f(a, 19) ^ a >>> 10) + p[r - 7] + (f(a = p[r - 15], 7) ^ f(a, 18) ^ a >>> 3) + p[r - 16]) + e.pop() + (f(a = e[4], 6) ^ f(a, 11) ^ f(a, 25)) + (a & e[5] ^ ~a & e[6]) + n[r++];
|
|
957
|
+
for (r = 8; r; ) c[--r] += e[r];
|
|
958
|
+
}
|
|
959
|
+
for (a = ""; r < 64; ) a += (c[r >> 3] >> 4 * (7 - r++) & 15).toString(16);
|
|
960
|
+
return a;
|
|
961
|
+
}
|
|
962
|
+
|
|
934
963
|
// src/utils/hashEmail.ts
|
|
935
|
-
var import_md5 = __toESM(require("tiny-hashes/md5"));
|
|
936
|
-
var import_sha256 = __toESM(require("tiny-hashes/sha256"));
|
|
937
964
|
var PLUS_AND_DOT = /\.|\+.*$/g;
|
|
938
965
|
function normalizeEmail(email) {
|
|
939
966
|
if (typeof email !== "string") return "";
|
|
@@ -946,11 +973,11 @@ function normalizeEmail(email) {
|
|
|
946
973
|
}
|
|
947
974
|
function createUniversalId(email) {
|
|
948
975
|
const normalizedEmail = normalizeEmail(email);
|
|
949
|
-
return normalizedEmail ? (
|
|
976
|
+
return normalizedEmail ? sha256_default(normalizedEmail) : "";
|
|
950
977
|
}
|
|
951
978
|
function hashEmail(email) {
|
|
952
979
|
const normalizedEmail = normalizeEmail(email);
|
|
953
|
-
return normalizedEmail ? (
|
|
980
|
+
return normalizedEmail ? md5_default(normalizedEmail) : "";
|
|
954
981
|
}
|
|
955
982
|
|
|
956
983
|
// src/universalId.ts
|
|
@@ -1054,8 +1081,8 @@ var storage = ({
|
|
|
1054
1081
|
storageObj.removeItem(key);
|
|
1055
1082
|
return;
|
|
1056
1083
|
}
|
|
1057
|
-
} catch (
|
|
1058
|
-
console.error("[segment-wrapper] Storage error:",
|
|
1084
|
+
} catch (e2) {
|
|
1085
|
+
console.error("[segment-wrapper] Storage error:", e2);
|
|
1059
1086
|
return null;
|
|
1060
1087
|
}
|
|
1061
1088
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -423,8 +423,8 @@ var getConsentsFromCookie = () => {
|
|
|
423
423
|
const { purpose } = JSON.parse(window.atob(cookieValue));
|
|
424
424
|
const { consents } = purpose;
|
|
425
425
|
return consents;
|
|
426
|
-
} catch (
|
|
427
|
-
console.error(
|
|
426
|
+
} catch (e2) {
|
|
427
|
+
console.error(e2);
|
|
428
428
|
return void 0;
|
|
429
429
|
}
|
|
430
430
|
};
|
|
@@ -667,7 +667,7 @@ var decorateContextWithNeededData = async ({
|
|
|
667
667
|
...!isGdprAccepted && { ip: "0.0.0.0" },
|
|
668
668
|
...getExternalIds({ context, xandrId }),
|
|
669
669
|
analytics_storage: getConsentState(),
|
|
670
|
-
clientVersion: `segment-wrapper@${"4.36.0-beta.
|
|
670
|
+
clientVersion: `segment-wrapper@${"4.36.0-beta.4"}`,
|
|
671
671
|
gdpr_privacy: gdprPrivacyValueAnalytics,
|
|
672
672
|
gdpr_privacy_advertising: gdprPrivacyValueAdvertising,
|
|
673
673
|
google_consents,
|
|
@@ -871,9 +871,46 @@ var userTraits = async ({ payload, next }) => {
|
|
|
871
871
|
next(payload);
|
|
872
872
|
};
|
|
873
873
|
|
|
874
|
+
// ../../node_modules/tiny-hashes/md5/index.mjs
|
|
875
|
+
for (r = [], o = 0; o < 64; ) r[o] = 0 | 4294967296 * Math.sin(++o % Math.PI);
|
|
876
|
+
var r;
|
|
877
|
+
var o;
|
|
878
|
+
function md5_default(t) {
|
|
879
|
+
var e2, f2, n, a = [e2 = 1732584193, f2 = 4023233417, ~e2, ~f2], c = [], h = unescape(encodeURI(t)) + "\x80", u = h.length;
|
|
880
|
+
for (t = --u / 4 + 2 | 15, c[--t] = 8 * u; ~u; ) c[u >> 2] |= h.charCodeAt(u) << 8 * u--;
|
|
881
|
+
for (o = h = 0; o < t; o += 16) {
|
|
882
|
+
for (u = a; h < 64; u = [n = u[3], e2 + ((n = u[0] + [e2 & f2 | ~e2 & n, n & e2 | ~n & f2, e2 ^ f2 ^ n, f2 ^ (e2 | ~n)][u = h >> 4] + r[h] + ~~c[o | 15 & [h, 5 * h + 1, 3 * h + 5, 7 * h][u]]) << (u = [7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21][4 * u + h++ % 4]) | n >>> -u), e2, f2]) e2 = 0 | u[1], f2 = u[2];
|
|
883
|
+
for (h = 4; h; ) a[--h] += u[h];
|
|
884
|
+
}
|
|
885
|
+
for (t = ""; h < 32; ) t += (a[h >> 3] >> 4 * (1 ^ h++) & 15).toString(16);
|
|
886
|
+
return t;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// ../../node_modules/tiny-hashes/sha256/index.mjs
|
|
890
|
+
for (o = 18, n = [], t = []; o > 1; o--) for (r = o; r < 320; ) n[r += o] = 1;
|
|
891
|
+
var r;
|
|
892
|
+
var o;
|
|
893
|
+
var n;
|
|
894
|
+
var t;
|
|
895
|
+
function e(r, o) {
|
|
896
|
+
return 4294967296 * Math.pow(r, 1 / o) | 0;
|
|
897
|
+
}
|
|
898
|
+
for (r = 0; r < 64; ) n[++o] || (t[r] = e(o, 2), n[r++] = e(o, 3));
|
|
899
|
+
function f(r, o) {
|
|
900
|
+
return r >>> o | r << -o;
|
|
901
|
+
}
|
|
902
|
+
function sha256_default(u) {
|
|
903
|
+
var c = t.slice(o = r = 0, 8), i = [], a = unescape(encodeURI(u)) + "\x80", p = a.length;
|
|
904
|
+
for (i[u = --p / 4 + 2 | 15] = 8 * p; ~p; ) i[p >> 2] |= a.charCodeAt(p) << 8 * ~p--;
|
|
905
|
+
for (p = []; o < u; o += 16) {
|
|
906
|
+
for (e = c.slice(); r < 64; e.unshift(a + (f(a = e[0], 2) ^ f(a, 13) ^ f(a, 22)) + (a & e[1] ^ e[1] & e[2] ^ e[2] & a))) e[3] += a = 0 | (p[r] = r < 16 ? ~~i[r + o] : (f(a = p[r - 2], 17) ^ f(a, 19) ^ a >>> 10) + p[r - 7] + (f(a = p[r - 15], 7) ^ f(a, 18) ^ a >>> 3) + p[r - 16]) + e.pop() + (f(a = e[4], 6) ^ f(a, 11) ^ f(a, 25)) + (a & e[5] ^ ~a & e[6]) + n[r++];
|
|
907
|
+
for (r = 8; r; ) c[--r] += e[r];
|
|
908
|
+
}
|
|
909
|
+
for (a = ""; r < 64; ) a += (c[r >> 3] >> 4 * (7 - r++) & 15).toString(16);
|
|
910
|
+
return a;
|
|
911
|
+
}
|
|
912
|
+
|
|
874
913
|
// src/utils/hashEmail.ts
|
|
875
|
-
import md5 from "tiny-hashes/md5";
|
|
876
|
-
import sha256 from "tiny-hashes/sha256";
|
|
877
914
|
var PLUS_AND_DOT = /\.|\+.*$/g;
|
|
878
915
|
function normalizeEmail(email) {
|
|
879
916
|
if (typeof email !== "string") return "";
|
|
@@ -886,11 +923,11 @@ function normalizeEmail(email) {
|
|
|
886
923
|
}
|
|
887
924
|
function createUniversalId(email) {
|
|
888
925
|
const normalizedEmail = normalizeEmail(email);
|
|
889
|
-
return normalizedEmail ?
|
|
926
|
+
return normalizedEmail ? sha256_default(normalizedEmail) : "";
|
|
890
927
|
}
|
|
891
928
|
function hashEmail(email) {
|
|
892
929
|
const normalizedEmail = normalizeEmail(email);
|
|
893
|
-
return normalizedEmail ?
|
|
930
|
+
return normalizedEmail ? md5_default(normalizedEmail) : "";
|
|
894
931
|
}
|
|
895
932
|
|
|
896
933
|
// src/universalId.ts
|
|
@@ -994,8 +1031,8 @@ var storage = ({
|
|
|
994
1031
|
storageObj.removeItem(key);
|
|
995
1032
|
return;
|
|
996
1033
|
}
|
|
997
|
-
} catch (
|
|
998
|
-
console.error("[segment-wrapper] Storage error:",
|
|
1034
|
+
} catch (e2) {
|
|
1035
|
+
console.error("[segment-wrapper] Storage error:", e2);
|
|
999
1036
|
return null;
|
|
1000
1037
|
}
|
|
1001
1038
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adv-re/segment-wrapper",
|
|
3
|
-
"version": "4.36.0-beta.
|
|
3
|
+
"version": "4.36.0-beta.4",
|
|
4
4
|
"description": "Modern TypeScript abstraction layer on top of the Segment library",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./src/utils/patchAnalytics.ts",
|
|
@@ -46,15 +46,17 @@
|
|
|
46
46
|
"@adv-re/jest-presets": "*",
|
|
47
47
|
"@adv-re/typescript-config": "*",
|
|
48
48
|
"@types/node": "^22.10.7",
|
|
49
|
-
"eslint": "^8.57.
|
|
49
|
+
"eslint": "^8.57.1",
|
|
50
50
|
"tsup": "^8.4.0",
|
|
51
51
|
"typescript": "5.8.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"tiny-hashes": "1.0.1"
|
|
55
55
|
},
|
|
56
|
+
"unpkg": "umd/index.global.js",
|
|
56
57
|
"files": [
|
|
57
|
-
"dist"
|
|
58
|
+
"dist",
|
|
59
|
+
"umd"
|
|
58
60
|
],
|
|
59
61
|
"author": "",
|
|
60
62
|
"license": "ISC"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(()=>{var A="__mpi",g=typeof window<"u",Q=()=>g?window:void 0;function r(e){let t=Q()?.[A]?.segmentWrapper||{};return e?t[e]:t}var _=(e,n)=>{let t=Q();if(!t){console.warn("[segment-wrapper] Cannot set config in non-browser environment");return}t[A]=t[A]||{},t[A].segmentWrapper=t[A].segmentWrapper||{},t[A].segmentWrapper[e]=n};var R,U=()=>({ADOBE_ORG_ID:window.__SEGMENT_WRAPPER?.ADOBE_ORG_ID,DEFAULT_DEMDEX_VERSION:window.__SEGMENT_WRAPPER?.DEFAULT_DEMDEX_VERSION??"3.3.0",TIME_BETWEEN_RETRIES:window.__SEGMENT_WRAPPER?.TIME_BETWEEN_RETRIES??15,TIMES_TO_RETRY:window.__SEGMENT_WRAPPER?.TIMES_TO_RETRY??80,SERVERS:{trackingServer:window.__SEGMENT_WRAPPER?.TRACKING_SERVER,trackingServerSecure:window.__SEGMENT_WRAPPER?.TRACKING_SERVER}}),q=()=>{let e=U();if(window.Visitor&&e.ADOBE_ORG_ID)return window.Visitor.getInstance(e.ADOBE_ORG_ID,e.SERVERS)},Ve=e=>e?.getMarketingCloudVisitorID(),J=()=>{let e=q(),n=U(),t=e?.version??n.DEFAULT_DEMDEX_VERSION,{trackingServer:o}=n.SERVERS;return Promise.resolve({trackingServer:o,version:t})},Z=()=>{if(R)return Promise.resolve(R);let e=U();return new Promise(n=>{function t(o){if(o===0)return n("");let i=q();R=Ve(i),R?n(R):window.setTimeout(()=>t(--o),e.TIME_BETWEEN_RETRIES)}t(e.TIMES_TO_RETRY)})},ke=async()=>Z(),N=async()=>{let e=r("getCustomAdobeVisitorId");return typeof e=="function"?e():r("importAdobeVisitorId")===!0?ke():Z()};var ee={GA4_INIT_EVENT_SENT:"ga4InitEventSent"};var L={spaReferrer:"",referrer:""},x={getDocumentReferrer:()=>document.referrer,getActualLocation:()=>{let{origin:e,pathname:n}=window.location;return`${e}${n}`},getActualQueryString:()=>{let{search:e}=window.location;return e}},ne=({isPageTrack:e=!1}={})=>{let{referrer:n,spaReferrer:t}=L;return(e?n:t)||x.getDocumentReferrer()},he=()=>{L.spaReferrer=ne({isPageTrack:!0}),L.referrer=x.getActualLocation()},te=({payload:e,next:n})=>{let{obj:{context:t}}=e,{isPageTrack:o}=t,i=ne({isPageTrack:o});e.obj.context={...t,page:{...t.page,referrer:i}},o&&he(),n(e)};var oe={clientId:"client_id",sessionId:"session_id"},W="dataLayer",m={granted:"granted",denied:"denied"},Ue=1,Le=2,D={QUERY:"stc",SPLIT_SYMBOL:"-",CAMPAIGN_SPLIT_SYMBOL:":"},We="utm_campaign",Fe="utm_medium",Ke="utm_source",$e="utm_content",je="utm_id",Ye="utm_term",Be={aff:"affiliate",dis:"display",em:"email",met:"paid-metasearch",sem:"paid-search",rt:"display",sm:"social-media",sp:"paid-social",pn:"push-notification",cs:"cross-sites"},ze="na",Xe="sui",He={medium:null,source:null,campaign:null},Qe=async e=>new Promise(function(n,t){let o=document.createElement("script");o.src=e,o.onload=()=>n(),o.onerror=t,document.head.appendChild(o)}),ie=async()=>{let e=r("googleAnalyticsMeasurementId"),n=r("googleAnalyticsDataLayer")||W;if(!e)return Promise.resolve(!1);let t=`https://www.googletagmanager.com/gtag/js?id=${e}&l=${n}`;return Qe(t).then(()=>!0)},qe=e=>{let n=r("googleAnalyticsInitEvent")??Xe,t=`ga_event_${n}_`,o=`${t}${e}`;if(!(typeof window.gtag>"u")){if(!localStorage.getItem(o)&&(window.gtag("event",n),console.log(`Sending GA4 event "${n}" for the session "${e}"`),localStorage.setItem(o,"true"),typeof window.dispatchEvent=="function")){let i=new CustomEvent(ee.GA4_INIT_EVENT_SENT,{detail:{eventName:n,sessionId:e}});window.dispatchEvent(i)}Object.keys(localStorage).forEach(i=>{i.startsWith(t)&&i!==o&&localStorage.removeItem(i)})}},re=async e=>{let n=r("googleAnalyticsMeasurementId");return n?new Promise(t=>{window.gtag?.("get",n,e,t)}):Promise.resolve(void 0)},Je={STC:"stc",UTM:"utm"},G=({needsTransformation:e=!0}={})=>{let{medium:n,source:t,campaign:o,content:i,term:s}=Ze();if(!n||!t||!o)return null;let[c,d]=o.split(D.CAMPAIGN_SPLIT_SYMBOL);if(!c&&!d)return null;let f=typeof i<"u"&&i!==ze;return{campaign:{medium:e&&Be[n]||n,...typeof d<"u"&&{id:c},name:d??c,source:t,...f&&{content:i},...typeof s<"u"&&{term:s}}}};function Ze(){let e=x.getActualQueryString(),n=new URLSearchParams(e);return r("trackingTagsType")===Je.UTM?en(n):se(n)}function se(e){if(!ae(e))return He;let n=e.get(D.QUERY),[t,o,i,s,c]=n?.split(D.SPLIT_SYMBOL)||[];return{medium:t,source:o,campaign:i,content:s,term:c}}function ae(e){return e.has(D.QUERY)}function en(e){let n=e.get(je),t=e.get(We),o=e.get(Fe),i=e.get(Ke),s=e.get($e),c=e.get(Ye),d=n?`${n}${D.CAMPAIGN_SPLIT_SYMBOL}${t}`:t;return(!o||!i||!d)&&ae(e)?se(e):{campaign:d,medium:o,source:i,content:s??void 0,term:c??void 0}}var ce=async()=>re(oe.clientId),de=async()=>{let e=await re(oe.sessionId);return e&&qe(e),e};function S(e="analytics_storage"){try{let n=window.google_tag_data?.ics?.getConsentState?.(e);return n===Ue?m.granted:n===Le?m.denied:void 0}catch{return}}var le=()=>S()??m.denied,ge=e=>{!r("googleAnalyticsMeasurementId")||!e||window.gtag?.("set","user_id",e)},b=(e="default",n)=>{window.gtag?.("consent",e,n||{analytics_storage:m.denied,ad_user_data:m.denied,ad_personalization:m.denied,ad_storage:m.denied})};var nn="borosTcf",tn=2,on={channel:"GDPR"},ue={analytics:[1,8,10],advertising:[3]},F={LOADED:"tcloaded",USER_ACTION_COMPLETE:"useractioncomplete"},K="CMP Submitted",p={ACCEPTED:"accepted",DECLINED:"declined",UNKNOWN:"unknown"},E={listeners:[],value:void 0,addListener:e=>E.listeners.push(e),get:()=>E.value,set:e=>{let{analytics:n,advertising:t}=e||{};E.value={analytics:n,advertising:t},E.listeners.forEach(o=>o(e)),E.listeners=[]}};function rn(e){if(!g)return null;let t=new RegExp(e+"=([^;]+)").exec(document.cookie);return t!==null?unescape(t[1]):null}var sn=()=>{if(r("initialized"))return!1;let e=!!window.__tcfapi;return e||console.warn("[tcfTracking] window.__tcfapi is not available on client and TCF won't be tracked."),e},an=e=>ue.analytics.every(n=>e[`${n}`]),cn=e=>ue.advertising.every(n=>e[`${n}`]),dn=({gdprPrivacy:e})=>O.track(K,{...on,...r("tcfTrackDefaultProperties")||{}},{gdpr_privacy:e.analytics,gdpr_privacy_advertising:e.advertising}),I=()=>{let e=E.get();return e!==void 0?Promise.resolve(e):new Promise(n=>{E.addListener(t=>n(t))})},T=e=>e?.analytics===p.ACCEPTED,pe=e=>{let n=an(e),t=cn(e),o=n?p.ACCEPTED:p.DECLINED,i=t?p.ACCEPTED:p.DECLINED;return E.set({analytics:o,advertising:i}),{analytics:o,advertising:i}},fe=()=>{let e=rn(nn);if(e)try{let{purpose:n}=JSON.parse(window.atob(e)),{consents:t}=n;return t}catch(n){console.error(n);return}},ln=()=>{let e=fe();e&&pe(e)},gn=()=>{let e=fe();_("isFirstVisit",!e)};function $(){if(g){if(ln(),gn(),!sn()){E.get()?.analytics===void 0&&E.set({analytics:p.UNKNOWN,advertising:p.UNKNOWN});return}_("initialized",!0),window.__tcfapi?.("addEventListener",tn,({eventStatus:e,purpose:n},t)=>{if(!t)return Promise.resolve();if(e===F.USER_ACTION_COMPLETE||e===F.LOADED){let{consents:o}=n,i=pe(o);if(e===F.USER_ACTION_COMPLETE){let{analytics:s,advertising:c}=i,d={analytics:s,advertising:c};return!(g&&window.sessionStorage.getItem("didomi-migration"))&&dn({gdprPrivacy:d})}}})}}function me(e){if(typeof document>"u")return null;let t=new RegExp(`${e}=([^;]+)`).exec(document.cookie);return t!==null?unescape(t[1]):null}function Ee(e,n,t={}){if(typeof document>"u"||typeof window>"u")return;let{maxAge:o=31536e3,path:i="/",reduceDomain:s=!0,sameSite:c="Lax"}=t,d=s?_e():window.location.hostname,f=[`${e}=${n}`,`domain=${d}`,`path=${i}`,`max-age=${o}`,`SameSite=${c}`].join(";");document.cookie=f}function ye(e,n={}){if(typeof document>"u"||typeof window>"u")return;let{path:t="/",reduceDomain:o=!0}=n,i=o?_e():window.location.hostname;document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${t}; domain=${i}`}var _e=e=>{let n=e!==void 0?e:typeof window<"u"?window.location.hostname:"",t=".",o=n.split(t).reverse();if(o.length===1)return o[0];let i=[];for(let s of o)if(i.push(s),s.length>3)break;return`${t}${i.reverse().join(t)}`};var un="https://secure.adnxs.com/getuidj?consent=1",j="adit-xandr-id",pn=0;function fn(){return g?window.fetch(un,{credentials:"include"}).then(e=>e.json()).then(e=>e?.uid).catch(()=>null):Promise.resolve(null)}function we({gdprPrivacyValueAdvertising:e}){if(!g)return null;if(e!==p.ACCEPTED)return ye(j),null;let n=i=>i!==null&&Number(i)>pn,t=me(j),o=n(t);return o||fn().then(i=>{typeof i=="string"&&Ee(j,i)}),_("xandrId",t),o?t:null}var mn={platform:"web"},En={All:!1},yn={All:!0},_n=e=>{let n=r("userIdPrefix");return n&&(typeof e=="number"||typeof e=="string"&&!e.startsWith(n))?`${n}${e}`:e},Y=()=>({...mn,...r("defaultProperties")}),wn=async({gdprPrivacyValue:e,event:n})=>{let t=T(e),o,i,s;try{t&&(o=await N()),i=await de(),s=await ce()}catch(d){console.error(d)}return{...Tn({isGdprAccepted:t,event:n}),"Adobe Analytics":o?{marketingCloudVisitorId:o}:!0,"Google Analytics 4":s&&i?{clientId:s,sessionId:i}:!0}},Tn=({isGdprAccepted:e,event:n})=>n==="CMP Submitted"?yn:e?{}:En,An=({context:e,xandrId:n})=>{let t=r("sendXandrId")!==!1,o=n&&parseInt(n)!==0;if(!t||!o)return{};let d=[...Array.isArray(e?.externalIds)?e.externalIds:[],{collection:"users",encoding:"none",id:n,type:"xandr_id"}];return{externalIds:d.filter(({id:C,type:P},v)=>v===d.findIndex(({id:h,type:Oe})=>C===h&&P===Oe))}},V=e=>e===p.ACCEPTED?m.granted:m.denied,B=async({event:e="",context:n={}})=>{let t=await I(),{analytics:o,advertising:i}=t||{},s=T(t),[c,d]=await Promise.all([wn({gdprPrivacyValue:t,event:e}),we({gdprPrivacyValueAdvertising:i})]),f=S("analytics_storage")??V(o),C=S("ad_user_data")??V(i),P=S("ad_personalization")??V(i),v=S("ad_storage")??V(i);s||(n.integrations={...n.integrations??{},Personas:!1,Webhooks:!0,Webhook:!0});let h={analytics_storage:f,ad_user_data:C,ad_personalization:P,ad_storage:v};return{...n,...!s&&{ip:"0.0.0.0"},...An({context:n,xandrId:d}),analytics_storage:le(),clientVersion:"segment-wrapper@4.36.0-beta.4",gdpr_privacy:o,gdpr_privacy_advertising:i,google_consents:h,integrations:{...n.integrations,...c}}},Te=(e,n,t={},o)=>new Promise(i=>{(async()=>{let c=await B({context:t,event:e}),d={...Y(),...n},f=async(...P)=>{o&&o(...P);let[v]=await Promise.all([I()]);T(v),i()};r("googleAnalyticsConsentManagement")&&e===K&&b("update",c.google_consents),window.analytics.track(e,d,{...c,context:{integrations:{...c.integrations}}},f)})()}),Sn=async(e,n,t,o)=>{let i=await I(),s=_n(e);return ge(s),window.analytics.identify(s,T(i)?n:{},t,o)},In=(e,n,t={},o)=>(t.isPageTrack=!0,Te(e??"",n,t,o)),Cn=()=>Promise.resolve(window.analytics.reset()),O={page:In,identify:Sn,track:Te,reset:Cn};var Se="__mpi_patch";function Ae(){let{track:e}=window.analytics;window.analytics.track=(...n)=>{let[t,o,i,s]=n,c={...Y(),...o};return B({context:i,event:t}).then(d=>{e.call(window.analytics,t,c,d,s)}),window.analytics},window.analytics[Se]=!0}g&&(window.analytics?window.analytics[Se]||(window.analytics.initialized?Ae():window.analytics.ready(Ae)):console.warn("[segment-wrapper] Segment Analytics is not loaded so patch is not applied."));var Ie=({payload:e,next:n})=>{if(r("googleAnalyticsMeasurementId")){let o=G();e.obj.context={...e.obj.context,...o}}n(e)};var Pn={platform:"web"},Ce=({payload:e,next:n})=>{let t=r("defaultContext")||{};e.obj.context={...Pn,...t,...e.obj.context},n(e)};var vn=()=>{let e=null;return({payload:n,next:t})=>{try{let{obj:o}=n,{event:i,type:s}=o;if(s!=="track"){t(n);return}if(typeof i=="string"&&i.endsWith("Viewed")){let{page_name:c,page_type:d}=o.properties||{};e={name:c,type:d},t(n);return}if(!e){t(n);return}t({...n,obj:{...o,properties:{...o.properties,page_name_origin:e.name,page_type:o.properties?.page_type||e.type}}})}catch(o){console.error(o),t(n)}}},Pe=vn();var ve=({payload:e,next:n})=>{e.obj.context={...e.obj.context,screen:{height:window.innerHeight,width:window.innerWidth,density:window.devicePixelRatio}},n(e)};var Rn=e=>{let n=r("isUserTraitsEnabled"),t=window.analytics.user?.(),o=T(e),i=t?.id();return{anonymousId:t?.anonymousId(),...i&&{userId:i},...o&&n&&t?.traits()||{}}},Re=async({payload:e,next:n})=>{let t=await I(),o;try{o=Rn(t)}catch(i){console.error(i)}e.obj.context={...e.obj.context,traits:{...e.obj.context.traits||{},...o}},n(e)};for(De=[],k=0;k<64;)De[k]=0|4294967296*Math.sin(++k%Math.PI);var De,k;for(u=18,M=[],z=[];u>1;u--)for(a=u;a<320;)M[a+=u]=1;var a,u,M,z;function l(e,n){return 4294967296*Math.pow(e,1/n)|0}for(a=0;a<64;)M[++u]||(z[a]=l(u,2),M[a++]=l(u,3));function y(e,n){return e>>>n|e<<-n}function Me(e){var n=z.slice(u=a=0,8),t=[],o=unescape(encodeURI(e))+"\x80",i=o.length;for(t[e=--i/4+2|15]=8*i;~i;)t[i>>2]|=o.charCodeAt(i)<<8*~i--;for(i=[];u<e;u+=16){for(l=n.slice();a<64;l.unshift(o+(y(o=l[0],2)^y(o,13)^y(o,22))+(o&l[1]^l[1]&l[2]^l[2]&o)))l[3]+=o=0|(i[a]=a<16?~~t[a+u]:(y(o=i[a-2],17)^y(o,19)^o>>>10)+i[a-7]+(y(o=i[a-15],7)^y(o,18)^o>>>3)+i[a-16])+l.pop()+(y(o=l[4],6)^y(o,11)^y(o,25))+(o&l[5]^~o&l[6])+M[a++];for(a=8;a;)n[--a]+=l[a]}for(o="";a<64;)o+=(n[a>>3]>>4*(7-a++)&15).toString(16);return o}var Dn=/\.|\+.*$/g;function Mn(e){if(typeof e!="string")return"";let t=e.toLowerCase().split(/@/);if(t.length!==2)return"";let[o,i]=t;return`${o.replace(Dn,"")}@${i}`}function Ne(e){let n=Mn(e);return n?Me(n):""}var Nn="USER_DATA_READY",xn=()=>r("universalId"),Gn=()=>{let e=xn();if(e)return X(),e;let n=r("userEmail");if(n)return e=Ne(n),bn(e),X(),e;X()},xe=()=>{if(!g)return;let e=Gn(),n=r("userEmail");if(typeof window<"u"&&typeof window.dispatchEvent=="function"){let t=new CustomEvent(Nn,{detail:{universalId:e,userEmail:n}});window.dispatchEvent(t)}return{universalId:e,userEmail:n}},X=()=>{_("universalIdInitialized",!0)},bn=e=>{_("universalId",e)};var Ge=()=>{if(typeof window>"u")return;let e=window,n=e.analytics;if(!n){console.warn("[segment-wrapper] Analytics is not available");return}let t=e.__SEGMENT_WRAPPER?.SEGMENT_ID_USER_WITHOUT_CONSENTS??"anonymous_user";n.user?.()?.anonymousId()===t&&"setAnonymousId"in n&&typeof n.setAnonymousId=="function"&&n.setAnonymousId(null)};$();try{xe()}catch(e){console.error("[segment-wrapper] UniversalID could not be initialized",e)}var be=()=>{let e=r("experimentalPageDataMiddleware");window.analytics.addSourceMiddleware?.(Re),window.analytics.addSourceMiddleware?.(Ce),window.analytics.addSourceMiddleware?.(Ie),window.analytics.addSourceMiddleware?.(ve),window.analytics.addSourceMiddleware?.(te),e&&window.analytics.addSourceMiddleware?.(Pe)};if(g&&window.analytics){let e=r("googleAnalyticsMeasurementId"),n=r("googleAnalyticsDataLayer")||W,t=r("googleAnalyticsConsentManagement");if(e){let o=r("googleAnalyticsConfig");window[n]=window[n]||[],window.gtag=window.gtag||function(){window[n].push(arguments)},window.gtag("js",new Date),t&&b(),window.gtag("config",e,{cookie_prefix:"segment",send_page_view:!1,...o,...G()}),ie().catch(i=>{console.error("[segment-wrapper] Failed to load Google Analytics",i)})}window.analytics.ready(Ge),window.analytics.addSourceMiddleware?be():window.analytics.ready(be)}var H=O;var w=window;w.sui=w.sui||{};w.sui.analytics=w.sui.analytics||H;w.sui.analytics.getAdobeVisitorData=w.sui.analytics.getAdobeVisitorData||J;w.sui.analytics.getAdobeMCVisitorID=w.sui.analytics.getAdobeMCVisitorID||N;var $t=H;})();
|