@mparticle/web-rokt-kit 3.2.0 → 3.2.2
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/Rokt-Kit.common.js +1 -1
- package/dist/Rokt-Kit.d.ts +0 -2
- package/dist/Rokt-Kit.esm.js +357 -331
- package/dist/Rokt-Kit.iife.js +1 -1
- package/package.json +1 -1
package/dist/Rokt-Kit.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const we = [
|
|
2
2
|
"active_time_on_site_ms",
|
|
3
3
|
"billingaddress1",
|
|
4
4
|
"billingaddress2",
|
|
@@ -23,31 +23,31 @@ const ve = [
|
|
|
23
23
|
"shippingstate",
|
|
24
24
|
"shippingzipcode",
|
|
25
25
|
"totalprice"
|
|
26
|
-
],
|
|
27
|
-
function
|
|
28
|
-
return
|
|
26
|
+
], Te = new Set(we);
|
|
27
|
+
function fe(i) {
|
|
28
|
+
return Te.has(i.toLowerCase());
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function T(i) {
|
|
31
31
|
const e = {}, t = i || {}, n = Object.keys(t);
|
|
32
32
|
for (let r = 0; r < n.length; r++) {
|
|
33
33
|
const s = n[r];
|
|
34
|
-
|
|
34
|
+
fe(s) || (e[s] = t[s]);
|
|
35
35
|
}
|
|
36
36
|
return e;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function p(i) {
|
|
39
39
|
return typeof i == "object" && i !== null && !Array.isArray(i);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function g(i) {
|
|
42
42
|
return typeof i == "string";
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function L(i) {
|
|
45
45
|
return typeof i == "function";
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function R(i) {
|
|
48
48
|
return i == null ? !0 : typeof i == "string" ? i.length === 0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function W(i) {
|
|
51
51
|
try {
|
|
52
52
|
const e = new URL(i);
|
|
53
53
|
return e.search = "", e.toString();
|
|
@@ -55,21 +55,21 @@ function j(i) {
|
|
|
55
55
|
return i;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function pe(i) {
|
|
59
59
|
let e = 5381;
|
|
60
60
|
for (let t = 0; t < i.length; t++)
|
|
61
61
|
e = (e << 5) + e + i.charCodeAt(t), e = e & e;
|
|
62
62
|
return e;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
function
|
|
64
|
+
const h = "mp-rokt-kit", X = "__rokt_ls_probe__";
|
|
65
|
+
function G() {
|
|
66
66
|
try {
|
|
67
|
-
return window.localStorage.setItem(
|
|
67
|
+
return window.localStorage.setItem(X, "1"), window.localStorage.removeItem(X), !0;
|
|
68
68
|
} catch {
|
|
69
69
|
return !1;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function H(i) {
|
|
73
73
|
try {
|
|
74
74
|
const e = window.localStorage.getItem(i);
|
|
75
75
|
return e === null ? null : JSON.parse(e);
|
|
@@ -77,58 +77,58 @@ function V(i) {
|
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function me(i, e) {
|
|
81
81
|
try {
|
|
82
82
|
return window.localStorage.setItem(i, JSON.stringify(e)), !0;
|
|
83
83
|
} catch {
|
|
84
84
|
return !1;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function Le(i) {
|
|
88
88
|
try {
|
|
89
89
|
window.localStorage.removeItem(i);
|
|
90
90
|
} catch {
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const t =
|
|
95
|
-
return
|
|
93
|
+
function b(i, e) {
|
|
94
|
+
const t = H(i);
|
|
95
|
+
return p(t) ? t[e] : void 0;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const n =
|
|
99
|
-
return r[e] = t,
|
|
97
|
+
function K(i, e, t) {
|
|
98
|
+
const n = H(i), r = p(n) ? { ...n } : {};
|
|
99
|
+
return r[e] = t, me(i, r);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
const t =
|
|
103
|
-
if (!
|
|
101
|
+
function D(i, e) {
|
|
102
|
+
const t = H(i);
|
|
103
|
+
if (!p(t) || !(e in t))
|
|
104
104
|
return;
|
|
105
105
|
const n = { ...t };
|
|
106
|
-
delete n[e], Object.keys(n).length === 0 ?
|
|
106
|
+
delete n[e], Object.keys(n).length === 0 ? Le(i) : me(i, n);
|
|
107
107
|
}
|
|
108
|
-
const
|
|
109
|
-
function
|
|
110
|
-
return i.slice(-
|
|
108
|
+
const z = "pageViews", U = "utmParams", Ee = 25, Oe = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
|
|
109
|
+
function _e(i) {
|
|
110
|
+
return i.slice(-Ee);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
const i =
|
|
112
|
+
function Z() {
|
|
113
|
+
const i = b(h, z);
|
|
114
114
|
return Array.isArray(i) ? i : [];
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
const e =
|
|
116
|
+
function Ne(i) {
|
|
117
|
+
const e = _e(i);
|
|
118
118
|
for (let t = 0; t < e.length; t++) {
|
|
119
119
|
const n = e.slice(t);
|
|
120
|
-
if (
|
|
120
|
+
if (K(h, z, n))
|
|
121
121
|
return n.length;
|
|
122
122
|
}
|
|
123
123
|
return 0;
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
|
|
125
|
+
function ee() {
|
|
126
|
+
D(h, z);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
const e =
|
|
128
|
+
function Ue(i) {
|
|
129
|
+
const e = _e(i);
|
|
130
130
|
return e.map((t, n) => {
|
|
131
|
-
const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r),
|
|
131
|
+
const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), c = e[n + 1]?.activeTimeOnSite, u = c !== void 0 && Number.isFinite(c), l = s && u ? c - r : void 0;
|
|
132
132
|
return {
|
|
133
133
|
pageUrl: t.pageUrl,
|
|
134
134
|
sourceMessageId: t.sourceMessageId,
|
|
@@ -140,19 +140,19 @@ function Te(i) {
|
|
|
140
140
|
};
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
if (
|
|
143
|
+
function Ce(i) {
|
|
144
|
+
if (b(h, U) !== void 0)
|
|
145
145
|
return;
|
|
146
146
|
const e = new URLSearchParams(window.location.search), t = {};
|
|
147
|
-
for (const r of
|
|
147
|
+
for (const r of Oe) {
|
|
148
148
|
const s = e.get(r);
|
|
149
149
|
s && (t[r] = s);
|
|
150
150
|
}
|
|
151
151
|
if (Object.keys(t).length === 0)
|
|
152
152
|
return;
|
|
153
153
|
const n = Object.keys(t).join(", ");
|
|
154
|
-
if (!
|
|
155
|
-
const r =
|
|
154
|
+
if (!K(h, U, t)) {
|
|
155
|
+
const r = G() ? "quota" : "ls_unavailable";
|
|
156
156
|
i?.log({
|
|
157
157
|
message: `Rokt Kit: Failed to persist UTM params [reason: ${r}]`,
|
|
158
158
|
code: "UTM_CAPTURE_FAILED"
|
|
@@ -164,19 +164,19 @@ function we(i) {
|
|
|
164
164
|
code: "UTM_CAPTURE_SUCCESS"
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
const i =
|
|
169
|
-
return
|
|
167
|
+
function Ke() {
|
|
168
|
+
const i = b(h, U);
|
|
169
|
+
return p(i) ? i : null;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
|
|
171
|
+
function te() {
|
|
172
|
+
D(h, U);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function De() {
|
|
175
175
|
const e = document.querySelector('link[rel="canonical"]')?.href;
|
|
176
176
|
if (e)
|
|
177
|
-
return
|
|
177
|
+
return W(e);
|
|
178
178
|
}
|
|
179
|
-
const
|
|
179
|
+
const $ = [
|
|
180
180
|
{
|
|
181
181
|
accountId: "2919171670744024290",
|
|
182
182
|
pathname: "/checkout",
|
|
@@ -189,54 +189,50 @@ const W = [
|
|
|
189
189
|
"eventvenue",
|
|
190
190
|
"firstname",
|
|
191
191
|
"lastname",
|
|
192
|
-
"locale",
|
|
193
192
|
"member_status",
|
|
194
193
|
"billingzipcode",
|
|
195
|
-
"
|
|
196
|
-
"currency",
|
|
197
|
-
"language"
|
|
194
|
+
"currency"
|
|
198
195
|
]
|
|
199
196
|
}
|
|
200
|
-
];
|
|
201
|
-
function
|
|
202
|
-
|
|
203
|
-
return W.find((t) => t.accountId === i && t.pathname === e);
|
|
204
|
-
}
|
|
205
|
-
function Ue(i, e) {
|
|
206
|
-
if (!(!i || !m(e)))
|
|
207
|
-
return W.find((t) => t.accountId === i && t.targetPageIdentifier === e);
|
|
208
|
-
}
|
|
209
|
-
function Ce(i, e) {
|
|
210
|
-
return i ? W.some((t) => t.accountId === i && t.attributeKeys.includes(e)) : !1;
|
|
211
|
-
}
|
|
212
|
-
const De = 6e4;
|
|
213
|
-
function Ke(i) {
|
|
214
|
-
return E(i) && typeof i.expiresAt == "number" && E(i.attributes);
|
|
197
|
+
], Me = 6e4;
|
|
198
|
+
function Fe(i) {
|
|
199
|
+
return p(i) && typeof i.expiresAt == "number" && p(i.attributes);
|
|
215
200
|
}
|
|
216
|
-
function
|
|
201
|
+
function xe(i, e) {
|
|
217
202
|
return `activePreselect:${i}:${e}`;
|
|
218
203
|
}
|
|
219
|
-
function
|
|
220
|
-
const e =
|
|
221
|
-
return
|
|
204
|
+
function Ye(i) {
|
|
205
|
+
const e = b(h, i);
|
|
206
|
+
return Fe(e) ? e : null;
|
|
222
207
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
expiresAt: Date.now() +
|
|
208
|
+
function Ge(i, e) {
|
|
209
|
+
K(h, i, {
|
|
210
|
+
expiresAt: Date.now() + Me,
|
|
226
211
|
attributes: e
|
|
227
212
|
});
|
|
228
213
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
214
|
+
const je = 2 * 6e4;
|
|
215
|
+
function Ve(i) {
|
|
216
|
+
return p(i) && typeof i.expiresAt == "number" && g(i.pathname) && g(i.identifier) && p(i.attributes) && g(i.mpid);
|
|
217
|
+
}
|
|
218
|
+
function q(i) {
|
|
219
|
+
return `pendingPreselect:${i}`;
|
|
220
|
+
}
|
|
221
|
+
function We(i) {
|
|
222
|
+
const e = q(i), t = b(h, e);
|
|
223
|
+
return Ve(t) ? t.expiresAt <= Date.now() ? (D(h, e), null) : t : null;
|
|
224
|
+
}
|
|
225
|
+
function He(i, e, t, n, r) {
|
|
226
|
+
K(h, q(i), {
|
|
227
|
+
expiresAt: Date.now() + je,
|
|
228
|
+
pathname: e,
|
|
229
|
+
identifier: t,
|
|
230
|
+
attributes: n,
|
|
231
|
+
mpid: r
|
|
232
|
+
});
|
|
234
233
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
237
|
-
message: `Rokt Kit: selectPlacements dispatched [placementAttributeKeys=${i.join(",")}]`,
|
|
238
|
-
code: "SELECT_PLACEMENTS_DISPATCHED"
|
|
239
|
-
};
|
|
234
|
+
function x(i) {
|
|
235
|
+
D(h, q(i));
|
|
240
236
|
}
|
|
241
237
|
function k(i, e) {
|
|
242
238
|
const t = {
|
|
@@ -250,10 +246,21 @@ function k(i, e) {
|
|
|
250
246
|
code: t[i]
|
|
251
247
|
};
|
|
252
248
|
}
|
|
253
|
-
function
|
|
249
|
+
function ze(i, e) {
|
|
250
|
+
if (i)
|
|
251
|
+
return $.find((t) => t.accountId === i && t.pathname === e);
|
|
252
|
+
}
|
|
253
|
+
function $e(i, e) {
|
|
254
|
+
if (!(!i || !g(e)))
|
|
255
|
+
return $.find((t) => t.accountId === i && t.targetPageIdentifier === e);
|
|
256
|
+
}
|
|
257
|
+
function qe(i, e) {
|
|
258
|
+
return i ? $.some((t) => t.accountId === i && t.attributeKeys.includes(e)) : !1;
|
|
259
|
+
}
|
|
260
|
+
function Je() {
|
|
254
261
|
return { pending: [] };
|
|
255
262
|
}
|
|
256
|
-
function
|
|
263
|
+
function Y(i, e) {
|
|
257
264
|
const t = i.pending.findIndex((n) => n.pathname === e.pathname);
|
|
258
265
|
if (t >= 0) {
|
|
259
266
|
i.pending[t] = e;
|
|
@@ -261,16 +268,32 @@ function F(i, e) {
|
|
|
261
268
|
}
|
|
262
269
|
i.pending.push(e);
|
|
263
270
|
}
|
|
264
|
-
function
|
|
271
|
+
function j(i) {
|
|
265
272
|
if (!i?.getUserIdentities)
|
|
266
273
|
return !1;
|
|
267
274
|
const e = i.getUserIdentities().userIdentities;
|
|
268
275
|
return e ? Object.keys(e).some((t) => {
|
|
269
276
|
const n = e[t];
|
|
270
|
-
return
|
|
277
|
+
return g(n) && n.length > 0;
|
|
271
278
|
}) : !1;
|
|
272
279
|
}
|
|
273
|
-
function
|
|
280
|
+
function Ie(i) {
|
|
281
|
+
const e = i?.getMPID?.();
|
|
282
|
+
return e == null ? null : String(e);
|
|
283
|
+
}
|
|
284
|
+
function ie(i, e, t) {
|
|
285
|
+
const n = i.filteredUser?.getAllUserAttributes?.() || {}, r = {}, s = [];
|
|
286
|
+
for (const o of t.attributeKeys) {
|
|
287
|
+
const c = i.getEventAttributeValue(e, o), u = R(c) ? i.userAttributes[o] ?? n[o] : c;
|
|
288
|
+
if (R(u)) {
|
|
289
|
+
s.push(o);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
r[o] = u;
|
|
293
|
+
}
|
|
294
|
+
return { collected: r, missingKeys: s };
|
|
295
|
+
}
|
|
296
|
+
function Be(i, e) {
|
|
274
297
|
Promise.resolve(i.selectPlacements(e)).catch((t) => {
|
|
275
298
|
const n = t instanceof Error ? t.message : String(t);
|
|
276
299
|
i.log({
|
|
@@ -279,83 +302,93 @@ function Ge(i, e) {
|
|
|
279
302
|
});
|
|
280
303
|
});
|
|
281
304
|
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
305
|
+
function Se(i, e, t, n, r, s) {
|
|
306
|
+
const o = xe(e, t), c = Ye(o), u = !!c && JSON.stringify(c.attributes) === JSON.stringify(r);
|
|
307
|
+
if (c && c.expiresAt > Date.now() && u) {
|
|
308
|
+
i.logPlacementDiagnostic(k("skipped", "active_preselection"));
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
Ge(o, r), i.logPlacementDiagnostic(k("fired", s)), Be(i, { attributes: r, preselect: !0, identifier: n, omitUrl: !0 });
|
|
312
|
+
}
|
|
313
|
+
function Qe(i, e) {
|
|
314
|
+
if (!e.accountId || !e.isKitReady())
|
|
315
|
+
return;
|
|
316
|
+
const t = We(e.accountId);
|
|
317
|
+
if (t) {
|
|
318
|
+
if (i.pending.some((n) => n.pathname === t.pathname)) {
|
|
319
|
+
x(e.accountId);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (!e.isPreselectionEnabled()) {
|
|
323
|
+
x(e.accountId);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
j(e.filteredUser) && (x(e.accountId), Ie(e.filteredUser) === t.mpid && Se(e, e.accountId, t.pathname, t.identifier, t.attributes, "recovered"));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function ye(i, e, t, n = window.location.pathname) {
|
|
330
|
+
const r = ze(e.accountId, n);
|
|
284
331
|
if (!r)
|
|
285
332
|
return;
|
|
286
333
|
if (!e.isKitReady()) {
|
|
287
|
-
|
|
334
|
+
Y(i, { event: t, pathname: n }), e.logPlacementDiagnostic(k("queued", "not_ready"));
|
|
335
|
+
const c = Ie(e.filteredUser);
|
|
336
|
+
if (e.accountId && c && j(e.filteredUser)) {
|
|
337
|
+
const { collected: u, missingKeys: l } = ie(e, t, r);
|
|
338
|
+
l.length === 0 && He(e.accountId, n, r.targetPageIdentifier, u, c);
|
|
339
|
+
}
|
|
288
340
|
return;
|
|
289
341
|
}
|
|
290
342
|
if (!e.isPreselectionEnabled())
|
|
291
343
|
return;
|
|
292
|
-
if (!
|
|
293
|
-
e.logPlacementDiagnostic(k("missed", "no_valid_identity")),
|
|
344
|
+
if (!j(e.filteredUser)) {
|
|
345
|
+
e.logPlacementDiagnostic(k("missed", "no_valid_identity")), Y(i, { event: t, pathname: n });
|
|
294
346
|
return;
|
|
295
347
|
}
|
|
296
|
-
const s
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
o[h] = p;
|
|
304
|
-
}
|
|
305
|
-
if (a.length > 0) {
|
|
306
|
-
for (const h of a)
|
|
307
|
-
e.logPlacementDiagnostic(k("missed", `missing_attribute:${h}`));
|
|
308
|
-
F(i, { event: t, pathname: n });
|
|
348
|
+
const { collected: s, missingKeys: o } = ie(e, t, r);
|
|
349
|
+
if (o.length > 0) {
|
|
350
|
+
for (const c of o)
|
|
351
|
+
e.logPlacementDiagnostic(k("missed", `missing_attribute:${c}`));
|
|
352
|
+
Y(i, { event: t, pathname: n });
|
|
309
353
|
return;
|
|
310
354
|
}
|
|
311
|
-
|
|
312
|
-
if (l && l.expiresAt > Date.now() && g) {
|
|
313
|
-
e.logPlacementDiagnostic(k("skipped", "active_preselection"));
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
const b = {
|
|
317
|
-
attributes: o,
|
|
318
|
-
preselect: !0,
|
|
319
|
-
identifier: r.targetPageIdentifier,
|
|
320
|
-
omitUrl: !0
|
|
321
|
-
};
|
|
322
|
-
xe(u, o), e.logPlacementDiagnostic(k("fired", "fired")), Ge(e, b);
|
|
355
|
+
Se(e, e.accountId || "", n, r.targetPageIdentifier, s, "fired");
|
|
323
356
|
}
|
|
324
|
-
function
|
|
325
|
-
if (i.pending.length === 0)
|
|
357
|
+
function Xe(i, e, t = window.location.pathname) {
|
|
358
|
+
if (Qe(i, e), i.pending.length === 0)
|
|
326
359
|
return;
|
|
327
360
|
const n = i.pending;
|
|
328
361
|
i.pending = [], n.forEach(({ event: r, pathname: s }) => {
|
|
329
|
-
s === t &&
|
|
362
|
+
s === t && ye(i, e, r, s);
|
|
330
363
|
});
|
|
331
364
|
}
|
|
332
|
-
function
|
|
365
|
+
function Ze() {
|
|
333
366
|
return {
|
|
334
367
|
context: null,
|
|
335
368
|
lifecycle: "idle",
|
|
336
369
|
recreateInFlight: null
|
|
337
370
|
};
|
|
338
371
|
}
|
|
339
|
-
function
|
|
372
|
+
function et(i, e) {
|
|
340
373
|
i.context = {
|
|
341
374
|
accountId: e.accountId,
|
|
342
375
|
launcherOptions: { ...e.launcherOptions },
|
|
343
376
|
legacyRoktExtensions: [...e.legacyRoktExtensions]
|
|
344
377
|
};
|
|
345
378
|
}
|
|
346
|
-
function
|
|
379
|
+
function tt(i) {
|
|
347
380
|
i.lifecycle = "attached";
|
|
348
381
|
}
|
|
349
|
-
function
|
|
382
|
+
function it(i) {
|
|
350
383
|
i.lifecycle !== "idle" && (i.lifecycle = "terminated");
|
|
351
384
|
}
|
|
352
|
-
function
|
|
385
|
+
function nt(i) {
|
|
353
386
|
i.lifecycle = "terminated";
|
|
354
387
|
}
|
|
355
|
-
function
|
|
388
|
+
function rt(i) {
|
|
356
389
|
i.context = null, i.lifecycle = "idle", i.recreateInFlight = null;
|
|
357
390
|
}
|
|
358
|
-
function
|
|
391
|
+
function st(i, e, t) {
|
|
359
392
|
if (i.recreateInFlight)
|
|
360
393
|
return i.recreateInFlight;
|
|
361
394
|
if (i.lifecycle !== "terminated" || !i.context || !e)
|
|
@@ -366,42 +399,42 @@ function Qe(i, e, t) {
|
|
|
366
399
|
i.recreateInFlight = null;
|
|
367
400
|
}), i.recreateInFlight;
|
|
368
401
|
}
|
|
369
|
-
const d = "Rokt",
|
|
402
|
+
const d = "Rokt", O = 181, ot = "selectPlacements", ct = "apps.roktecommerce.com", at = 0.1, lt = "ThankYouPageJourney", ut = "rokt-launcher", dt = "rokt-thank-you-element", ht = "userIdentifiedInWorkspace", gt = 3, ft = 2, pt = "page_events", mt = "page_view_attributes", Et = "mparticle_session_id", _t = "mparticle_device_id", ne = 500, J = {
|
|
370
403
|
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
371
404
|
UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
|
|
372
405
|
IDENTITY_REQUEST: "IDENTITY_REQUEST",
|
|
373
406
|
LOG_DELIVERY_FAILURE: "LOG_DELIVERY_FAILURE"
|
|
374
|
-
},
|
|
407
|
+
}, S = {
|
|
375
408
|
ERROR: "ERROR",
|
|
376
409
|
INFO: "INFO",
|
|
377
410
|
WARNING: "WARNING"
|
|
378
|
-
},
|
|
379
|
-
function
|
|
411
|
+
}, It = "apps.rokt-api.com", St = "/v1/log", yt = "/v1/errors", At = 10;
|
|
412
|
+
function a() {
|
|
380
413
|
return window.mParticle;
|
|
381
414
|
}
|
|
382
|
-
function
|
|
383
|
-
const n = [
|
|
415
|
+
function re(i, e) {
|
|
416
|
+
const n = [M(i), "/wsdk/integrations/launcher.js"].join("");
|
|
384
417
|
return !e || e.length === 0 ? n : n + "?extensions=" + e.join(",");
|
|
385
418
|
}
|
|
386
|
-
function
|
|
387
|
-
return [
|
|
419
|
+
function se(i) {
|
|
420
|
+
return [M(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
|
|
388
421
|
}
|
|
389
|
-
function
|
|
390
|
-
const e = i !== void 0 ? i :
|
|
422
|
+
function M(i) {
|
|
423
|
+
const e = i !== void 0 ? i : It;
|
|
391
424
|
return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
|
|
392
425
|
}
|
|
393
|
-
function
|
|
426
|
+
function Ae(i, e, t) {
|
|
394
427
|
if (i)
|
|
395
428
|
return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
|
|
396
429
|
const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
|
|
397
|
-
return
|
|
430
|
+
return M(r) + t;
|
|
398
431
|
}
|
|
399
|
-
function
|
|
432
|
+
function oe(i, e, t) {
|
|
400
433
|
if (document.getElementById(i)) return;
|
|
401
434
|
const n = document.head || document.body, r = document.createElement("script");
|
|
402
435
|
r.id = i, r.type = "text/javascript", r.src = e, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", t?.onLoad && (r.onload = t.onLoad), t?.onError && (r.onerror = t.onError), n.appendChild(r);
|
|
403
436
|
}
|
|
404
|
-
function
|
|
437
|
+
function N(i) {
|
|
405
438
|
if (!i)
|
|
406
439
|
return [];
|
|
407
440
|
try {
|
|
@@ -411,12 +444,12 @@ function U(i) {
|
|
|
411
444
|
}
|
|
412
445
|
return [];
|
|
413
446
|
}
|
|
414
|
-
function
|
|
415
|
-
const e = i ?
|
|
447
|
+
function ce(i) {
|
|
448
|
+
const e = i ? N(i) : [], t = [], n = [];
|
|
416
449
|
let r = !1;
|
|
417
450
|
for (let s = 0; s < e.length; s++) {
|
|
418
451
|
const o = e[s].value;
|
|
419
|
-
o === "thank-you-journey" ? (r = !0, n.push(
|
|
452
|
+
o === "thank-you-journey" ? (r = !0, n.push(lt)) : t.push(o);
|
|
420
453
|
}
|
|
421
454
|
return {
|
|
422
455
|
roktExtensionsQueryParams: t,
|
|
@@ -424,14 +457,14 @@ function ne(i) {
|
|
|
424
457
|
loadThankYouElement: r
|
|
425
458
|
};
|
|
426
459
|
}
|
|
427
|
-
async function
|
|
460
|
+
async function Pt(i, e) {
|
|
428
461
|
const t = [];
|
|
429
462
|
if (e)
|
|
430
463
|
for (const n of i)
|
|
431
464
|
t.push(e.use(n));
|
|
432
465
|
return Promise.all(t);
|
|
433
466
|
}
|
|
434
|
-
function
|
|
467
|
+
function ae(i) {
|
|
435
468
|
if (!i)
|
|
436
469
|
return {};
|
|
437
470
|
const e = {};
|
|
@@ -441,13 +474,13 @@ function re(i) {
|
|
|
441
474
|
}
|
|
442
475
|
return e;
|
|
443
476
|
}
|
|
444
|
-
function
|
|
477
|
+
function le(i) {
|
|
445
478
|
const e = {};
|
|
446
479
|
if (!Array.isArray(i))
|
|
447
480
|
return e;
|
|
448
481
|
for (let t = 0; t < i.length; t++) {
|
|
449
482
|
const n = i[t];
|
|
450
|
-
if (!n || !
|
|
483
|
+
if (!n || !g(n.value) || !g(n.map))
|
|
451
484
|
continue;
|
|
452
485
|
const r = n.value, s = n.map;
|
|
453
486
|
e[r] || (e[r] = []), e[r].push({
|
|
@@ -457,14 +490,14 @@ function se(i) {
|
|
|
457
490
|
}
|
|
458
491
|
return e;
|
|
459
492
|
}
|
|
460
|
-
function
|
|
461
|
-
return
|
|
493
|
+
function ue(i, e, t) {
|
|
494
|
+
return a().generateHash([i, e, t].join(""));
|
|
462
495
|
}
|
|
463
|
-
function
|
|
464
|
-
let n = "mParticle_wsdkv_" +
|
|
496
|
+
function Rt(i) {
|
|
497
|
+
let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.2.2";
|
|
465
498
|
return i && (n += "_" + i), n;
|
|
466
499
|
}
|
|
467
|
-
function
|
|
500
|
+
function V(i) {
|
|
468
501
|
const e = document.createElement("iframe");
|
|
469
502
|
e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = i, e.onload = function() {
|
|
470
503
|
e.onload = null, e.parentNode && e.parentNode.removeChild(e);
|
|
@@ -472,54 +505,54 @@ function Y(i) {
|
|
|
472
505
|
const t = document.body || document.head;
|
|
473
506
|
t && t.appendChild(e);
|
|
474
507
|
}
|
|
475
|
-
function
|
|
476
|
-
const t =
|
|
477
|
-
if (
|
|
508
|
+
function de(i, e) {
|
|
509
|
+
const t = pe(window.location.origin);
|
|
510
|
+
if (y._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= at)
|
|
478
511
|
return;
|
|
479
512
|
const r = window.__rokt_li_guid__;
|
|
480
513
|
if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
|
|
481
514
|
return;
|
|
482
|
-
const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s),
|
|
483
|
-
|
|
484
|
-
"https://" +
|
|
515
|
+
const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? M(i) : "https://apps.rokt.com";
|
|
516
|
+
V(c + "/v1/wsdk-init/index.html?" + o), V(
|
|
517
|
+
"https://" + ct + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
|
|
485
518
|
);
|
|
486
519
|
}
|
|
487
|
-
function
|
|
520
|
+
function kt() {
|
|
488
521
|
return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
|
|
489
522
|
}
|
|
490
|
-
function
|
|
523
|
+
function bt() {
|
|
491
524
|
return typeof window < "u" ? window.location?.href : void 0;
|
|
492
525
|
}
|
|
493
|
-
function
|
|
526
|
+
function vt() {
|
|
494
527
|
return typeof window < "u" ? window.navigator?.userAgent : void 0;
|
|
495
528
|
}
|
|
496
|
-
class
|
|
529
|
+
class Pe {
|
|
497
530
|
constructor() {
|
|
498
531
|
this._logCount = {};
|
|
499
532
|
}
|
|
500
533
|
incrementAndCheck(e) {
|
|
501
534
|
const n = (this._logCount[e] || 0) + 1;
|
|
502
|
-
return this._logCount[e] = n, n >
|
|
535
|
+
return this._logCount[e] = n, n > At;
|
|
503
536
|
}
|
|
504
537
|
}
|
|
505
|
-
class
|
|
538
|
+
class C {
|
|
506
539
|
constructor(e, t, n, r, s) {
|
|
507
540
|
this._reporter = "mp-wsdk";
|
|
508
541
|
const o = e.isLoggingEnabled;
|
|
509
|
-
this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new
|
|
542
|
+
this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new Pe(), this._isEnabled = kt() || o;
|
|
510
543
|
}
|
|
511
544
|
send(e, t, n, r, s, o) {
|
|
512
545
|
if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
|
|
513
546
|
try {
|
|
514
|
-
const
|
|
547
|
+
const c = {
|
|
515
548
|
additionalInformation: {
|
|
516
549
|
message: n,
|
|
517
550
|
version: this._integrationName
|
|
518
551
|
},
|
|
519
552
|
severity: t,
|
|
520
|
-
code: r ||
|
|
521
|
-
url:
|
|
522
|
-
deviceInfo:
|
|
553
|
+
code: r || J.UNKNOWN_ERROR,
|
|
554
|
+
url: bt(),
|
|
555
|
+
deviceInfo: vt(),
|
|
523
556
|
stackTrace: s,
|
|
524
557
|
reporter: this._reporter,
|
|
525
558
|
integration: this._integrationName
|
|
@@ -532,52 +565,49 @@ class w {
|
|
|
532
565
|
this._launcherInstanceGuid && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(e, {
|
|
533
566
|
method: "POST",
|
|
534
567
|
headers: u,
|
|
535
|
-
body: JSON.stringify(
|
|
568
|
+
body: JSON.stringify(c)
|
|
536
569
|
}).then((l) => {
|
|
537
570
|
if (!l.ok) {
|
|
538
|
-
const
|
|
539
|
-
throw
|
|
571
|
+
const m = new Error("HTTP " + l.status + " from log endpoint");
|
|
572
|
+
throw m.statusCode = l.status, m;
|
|
540
573
|
}
|
|
541
574
|
}).catch((l) => {
|
|
542
575
|
console.error("ReportingTransport: Failed to send log", l), o && o(l);
|
|
543
576
|
});
|
|
544
|
-
} catch (
|
|
545
|
-
console.error("ReportingTransport: Failed to send log",
|
|
577
|
+
} catch (c) {
|
|
578
|
+
console.error("ReportingTransport: Failed to send log", c), o && o(c);
|
|
546
579
|
}
|
|
547
580
|
}
|
|
548
581
|
}
|
|
549
|
-
class
|
|
582
|
+
class he {
|
|
550
583
|
constructor(e, t, n, r, s) {
|
|
551
|
-
this._transport = new
|
|
584
|
+
this._transport = new C(e, t, n, r, s), this._errorUrl = Ae(e?.errorUrl, e?.integrationDomain, yt);
|
|
552
585
|
}
|
|
553
586
|
report(e) {
|
|
554
587
|
if (!e) return;
|
|
555
|
-
const t = e.severity ||
|
|
588
|
+
const t = e.severity || S.ERROR;
|
|
556
589
|
this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
|
|
557
590
|
}
|
|
558
591
|
}
|
|
559
|
-
class
|
|
592
|
+
class ge {
|
|
560
593
|
constructor(e, t, n, r, s, o) {
|
|
561
|
-
this._transport = new
|
|
594
|
+
this._transport = new C(e, n, r, s, o), this._placementDiagnosticTransport = new C(
|
|
562
595
|
e,
|
|
563
596
|
n,
|
|
564
597
|
r,
|
|
565
598
|
s
|
|
566
|
-
), this._loggingUrl =
|
|
599
|
+
), this._loggingUrl = Ae(e?.loggingUrl, e?.integrationDomain, St), this._errorReportingService = t;
|
|
567
600
|
}
|
|
568
601
|
log(e) {
|
|
569
602
|
e && this._send(this._transport, e);
|
|
570
603
|
}
|
|
571
|
-
logDiagnostic(e) {
|
|
572
|
-
e && this._send(this._diagnosticTransport, e);
|
|
573
|
-
}
|
|
574
604
|
logPlacementDiagnostic(e) {
|
|
575
605
|
e && this._send(this._placementDiagnosticTransport, e);
|
|
576
606
|
}
|
|
577
607
|
_send(e, t) {
|
|
578
608
|
e.send(
|
|
579
609
|
this._loggingUrl,
|
|
580
|
-
|
|
610
|
+
S.INFO,
|
|
581
611
|
t.message,
|
|
582
612
|
t.code,
|
|
583
613
|
void 0,
|
|
@@ -586,16 +616,16 @@ class le {
|
|
|
586
616
|
const r = typeof n.statusCode == "number";
|
|
587
617
|
this._errorReportingService.report({
|
|
588
618
|
message: "LoggingService: Failed to send log: " + n.message,
|
|
589
|
-
code:
|
|
590
|
-
severity: r ?
|
|
619
|
+
code: J.LOG_DELIVERY_FAILURE,
|
|
620
|
+
severity: r ? S.ERROR : S.WARNING
|
|
591
621
|
});
|
|
592
622
|
}
|
|
593
623
|
}
|
|
594
624
|
);
|
|
595
625
|
}
|
|
596
626
|
}
|
|
597
|
-
function
|
|
598
|
-
const e =
|
|
627
|
+
function wt(i) {
|
|
628
|
+
const e = W(window.location.href), t = i.EventAttributes?.title || document.title, n = De(), r = i.ActiveTimeOnSite;
|
|
599
629
|
return {
|
|
600
630
|
pageUrl: e,
|
|
601
631
|
sourceMessageId: i.SourceMessageId,
|
|
@@ -605,9 +635,9 @@ function St(i) {
|
|
|
605
635
|
...Number.isFinite(r) ? { activeTimeOnSite: r } : {}
|
|
606
636
|
};
|
|
607
637
|
}
|
|
608
|
-
const
|
|
638
|
+
const _ = class _ {
|
|
609
639
|
constructor() {
|
|
610
|
-
this.name = d, this.id =
|
|
640
|
+
this.name = d, this.id = O, this.moduleId = O, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = Ze(), this.accountId = null, this._preselectState = Je();
|
|
611
641
|
}
|
|
612
642
|
// ---- Private helpers ----
|
|
613
643
|
getEventAttributeValue(e, t) {
|
|
@@ -615,13 +645,13 @@ const I = class I {
|
|
|
615
645
|
return !n || n[t] === void 0 ? null : n[t];
|
|
616
646
|
}
|
|
617
647
|
doesEventAttributeConditionMatch(e, t) {
|
|
618
|
-
if (!e || !
|
|
648
|
+
if (!e || !g(e.operator))
|
|
619
649
|
return !1;
|
|
620
650
|
const n = e.operator.toLowerCase(), r = e.attributeValue;
|
|
621
651
|
return n === "exists" ? t !== null : t == null ? !1 : n === "equals" ? String(t) === String(r) : n === "contains" ? String(t).indexOf(String(r)) !== -1 : !1;
|
|
622
652
|
}
|
|
623
653
|
doesEventMatchRule(e, t) {
|
|
624
|
-
if (!t || !
|
|
654
|
+
if (!t || !g(t.eventAttributeKey))
|
|
625
655
|
return !1;
|
|
626
656
|
const n = t.conditions;
|
|
627
657
|
if (!Array.isArray(n))
|
|
@@ -638,28 +668,28 @@ const I = class I {
|
|
|
638
668
|
const t = Object.keys(this.placementEventAttributeMappingLookup);
|
|
639
669
|
for (let n = 0; n < t.length; n++) {
|
|
640
670
|
const r = t[n], s = this.placementEventAttributeMappingLookup[r];
|
|
641
|
-
if (
|
|
671
|
+
if (R(s))
|
|
642
672
|
continue;
|
|
643
673
|
let o = !0;
|
|
644
|
-
for (let
|
|
645
|
-
if (!this.doesEventMatchRule(e, s[
|
|
674
|
+
for (let c = 0; c < s.length; c++)
|
|
675
|
+
if (!this.doesEventMatchRule(e, s[c])) {
|
|
646
676
|
o = !1;
|
|
647
677
|
break;
|
|
648
678
|
}
|
|
649
|
-
o &&
|
|
679
|
+
o && a().Rokt.setLocalSessionAttribute?.(r, !0);
|
|
650
680
|
}
|
|
651
681
|
}
|
|
652
682
|
capturePageView(e) {
|
|
653
683
|
let t;
|
|
654
684
|
try {
|
|
655
|
-
t =
|
|
656
|
-
const n =
|
|
685
|
+
t = W(window.location.href);
|
|
686
|
+
const n = Z(), r = wt(e);
|
|
657
687
|
n.push(r);
|
|
658
|
-
const s = Math.min(n.length,
|
|
688
|
+
const s = Math.min(n.length, Ee), o = Ne(n);
|
|
659
689
|
if (o === 0) {
|
|
660
|
-
const
|
|
690
|
+
const c = G() ? "quota" : "ls_unavailable";
|
|
661
691
|
this.loggingService?.log({
|
|
662
|
-
message: `Rokt Kit: Failed to persist page view for ${t} [reason: ${
|
|
692
|
+
message: `Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,
|
|
663
693
|
code: "PAGE_VIEW_CAPTURE_FAILED"
|
|
664
694
|
});
|
|
665
695
|
} else o < s && this.loggingService?.log({
|
|
@@ -667,7 +697,7 @@ const I = class I {
|
|
|
667
697
|
code: "PAGE_VIEW_QUOTA_EVICTION"
|
|
668
698
|
});
|
|
669
699
|
} catch (n) {
|
|
670
|
-
const r =
|
|
700
|
+
const r = G() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
|
|
671
701
|
this.loggingService?.log({
|
|
672
702
|
message: `Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,
|
|
673
703
|
code: "PAGE_VIEW_CAPTURE_FAILED"
|
|
@@ -680,7 +710,7 @@ const I = class I {
|
|
|
680
710
|
buildCacheMatchKeys(e) {
|
|
681
711
|
if (!this.isPreselectionEnabled())
|
|
682
712
|
return;
|
|
683
|
-
const t =
|
|
713
|
+
const t = $e(this.accountId, e);
|
|
684
714
|
if (t)
|
|
685
715
|
return t.attributeKeys;
|
|
686
716
|
}
|
|
@@ -698,10 +728,10 @@ const I = class I {
|
|
|
698
728
|
};
|
|
699
729
|
}
|
|
700
730
|
flushPendingPreselectDispatches() {
|
|
701
|
-
|
|
731
|
+
Xe(this._preselectState, this.buildPreselectHost());
|
|
702
732
|
}
|
|
703
733
|
isLauncherReadyToAttach() {
|
|
704
|
-
return !!window.Rokt &&
|
|
734
|
+
return !!window.Rokt && L(window.Rokt.createLauncher);
|
|
705
735
|
}
|
|
706
736
|
/**
|
|
707
737
|
* Returns the user identities from the filtered user, if any.
|
|
@@ -713,38 +743,38 @@ const I = class I {
|
|
|
713
743
|
return this.replaceOtherIdentityWithEmailsha256(t);
|
|
714
744
|
}
|
|
715
745
|
returnLocalSessionAttributes() {
|
|
716
|
-
return !
|
|
746
|
+
return !a().Rokt || typeof a().Rokt.getLocalSessionAttributes != "function" ? {} : a().Rokt.getLocalSessionAttributes();
|
|
717
747
|
}
|
|
718
748
|
replaceOtherIdentityWithEmailsha256(e) {
|
|
719
749
|
const t = { ...e || {} }, n = this._mappedEmailSha256Key;
|
|
720
|
-
return n && e[n] && (t[
|
|
750
|
+
return n && e[n] && (t[_.EMAIL_SHA256_KEY] = e[n]), n && delete t[n], t;
|
|
721
751
|
}
|
|
722
752
|
logSelectPlacementsEvent(e) {
|
|
723
|
-
if (!window.mParticle || typeof
|
|
753
|
+
if (!window.mParticle || typeof a().logEvent != "function" || !p(e))
|
|
724
754
|
return;
|
|
725
|
-
const t =
|
|
726
|
-
|
|
755
|
+
const t = a().EventType.Other;
|
|
756
|
+
a().logEvent(ot, t, e);
|
|
727
757
|
}
|
|
728
758
|
setRoktSessionId(e) {
|
|
729
759
|
if (!(!e || typeof e != "string"))
|
|
730
760
|
try {
|
|
731
|
-
const t =
|
|
732
|
-
t &&
|
|
761
|
+
const t = a().getInstance();
|
|
762
|
+
t && L(t.setIntegrationAttribute) && t.setIntegrationAttribute(O, {
|
|
733
763
|
roktSessionId: e
|
|
734
764
|
});
|
|
735
765
|
} catch {
|
|
736
766
|
}
|
|
737
767
|
}
|
|
738
768
|
readMpSessionId() {
|
|
739
|
-
const e =
|
|
740
|
-
if (
|
|
769
|
+
const e = a()?.sessionManager, t = e?.getSessionId ?? e?.getSession;
|
|
770
|
+
if (L(t))
|
|
741
771
|
return t.call(e) || void 0;
|
|
742
772
|
}
|
|
743
773
|
readMpDeviceId() {
|
|
744
|
-
return
|
|
774
|
+
return a()?.getDeviceId?.() || void 0;
|
|
745
775
|
}
|
|
746
776
|
attachLauncher(e, t, n = []) {
|
|
747
|
-
|
|
777
|
+
et(this._launcherAttachState, {
|
|
748
778
|
accountId: e,
|
|
749
779
|
launcherOptions: t || {},
|
|
750
780
|
legacyRoktExtensions: n
|
|
@@ -755,25 +785,25 @@ const I = class I {
|
|
|
755
785
|
};
|
|
756
786
|
let s;
|
|
757
787
|
return this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
|
|
758
|
-
await
|
|
788
|
+
await Pt([...n], o), this.initRoktLauncher(o);
|
|
759
789
|
}).catch((o) => {
|
|
760
|
-
|
|
790
|
+
nt(this._launcherAttachState), console.error("Error creating Rokt launcher:", o);
|
|
761
791
|
});
|
|
762
792
|
}
|
|
763
793
|
recreateLauncherIfTerminated() {
|
|
764
|
-
return
|
|
794
|
+
return st(
|
|
765
795
|
this._launcherAttachState,
|
|
766
796
|
this.isLauncherReadyToAttach(),
|
|
767
797
|
(e) => this.attachLauncher(e.accountId, e.launcherOptions, e.legacyRoktExtensions)
|
|
768
798
|
);
|
|
769
799
|
}
|
|
770
800
|
initRoktLauncher(e) {
|
|
771
|
-
window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e,
|
|
772
|
-
const t =
|
|
773
|
-
t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0,
|
|
801
|
+
window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, tt(this._launcherAttachState);
|
|
802
|
+
const t = a().Rokt?.filters;
|
|
803
|
+
t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, de(this.domain, this.integrationName), a().Rokt.attachKit(this), this.flushPendingPreselectDispatches();
|
|
774
804
|
}
|
|
775
805
|
fetchOptimizely() {
|
|
776
|
-
const e =
|
|
806
|
+
const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
|
|
777
807
|
try {
|
|
778
808
|
if (e.length > 0 && window.optimizely) {
|
|
779
809
|
const t = window.optimizely.get("state");
|
|
@@ -790,107 +820,107 @@ const I = class I {
|
|
|
790
820
|
// When the partner has opted out of targeting (noTargeting launcher option),
|
|
791
821
|
// the kit must not collect behavioral targeting signals such as page views.
|
|
792
822
|
isTargetingDisabled() {
|
|
793
|
-
return
|
|
823
|
+
return a().Rokt?.launcherOptions?.noTargeting === !0;
|
|
794
824
|
}
|
|
795
825
|
isPartnerInLocalLauncherTestGroup() {
|
|
796
|
-
return !!(
|
|
826
|
+
return !!(a().config && a().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
|
|
797
827
|
}
|
|
798
828
|
isAssignedToSampleGroup() {
|
|
799
829
|
return Math.random() > 0.5;
|
|
800
830
|
}
|
|
801
831
|
captureTiming(e) {
|
|
802
|
-
window &&
|
|
832
|
+
window && a() && a().captureTiming && e && a().captureTiming(e);
|
|
803
833
|
}
|
|
804
834
|
// ---- Public methods (mParticle Kit Callbacks) ----
|
|
805
835
|
/**
|
|
806
836
|
* Initializes the Rokt forwarder with settings from the mParticle server.
|
|
807
837
|
*/
|
|
808
838
|
init(e, t, n, r, s) {
|
|
809
|
-
const o = e,
|
|
810
|
-
this.accountId =
|
|
811
|
-
const u =
|
|
812
|
-
this.placementEventMappingLookup =
|
|
813
|
-
const l =
|
|
839
|
+
const o = e, c = o.accountId;
|
|
840
|
+
this.accountId = c || null, this.userAttributes = T(s), this._onboardingExpProvider = o.onboardingExpProvider;
|
|
841
|
+
const u = N(o.placementEventMapping);
|
|
842
|
+
this.placementEventMappingLookup = ae(u);
|
|
843
|
+
const l = N(
|
|
814
844
|
o.placementEventAttributeMapping
|
|
815
845
|
);
|
|
816
|
-
this.placementEventAttributeMappingLookup =
|
|
817
|
-
const
|
|
846
|
+
this.placementEventAttributeMappingLookup = le(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = g(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
|
|
847
|
+
const m = a().Rokt?.domain, { roktExtensionsQueryParams: F, legacyRoktExtensions: v, loadThankYouElement: w } = ce(
|
|
818
848
|
o.roktExtensions
|
|
819
|
-
),
|
|
820
|
-
...
|
|
849
|
+
), E = {
|
|
850
|
+
...a().Rokt?.launcherOptions || {}
|
|
821
851
|
};
|
|
822
|
-
this.integrationName =
|
|
823
|
-
const
|
|
852
|
+
this.integrationName = Rt(E.integrationName), E.integrationName = this.integrationName, this.domain = m;
|
|
853
|
+
const A = {
|
|
824
854
|
loggingUrl: o.loggingUrl,
|
|
825
855
|
errorUrl: o.errorUrl,
|
|
826
|
-
integrationDomain:
|
|
827
|
-
isLoggingEnabled:
|
|
828
|
-
},
|
|
829
|
-
|
|
856
|
+
integrationDomain: m,
|
|
857
|
+
isLoggingEnabled: a().config?.isLoggingEnabled === !0
|
|
858
|
+
}, I = new he(
|
|
859
|
+
A,
|
|
830
860
|
this.integrationName,
|
|
831
861
|
window.__rokt_li_guid__,
|
|
832
862
|
o.accountId
|
|
833
|
-
),
|
|
834
|
-
|
|
835
|
-
|
|
863
|
+
), P = new ge(
|
|
864
|
+
A,
|
|
865
|
+
I,
|
|
836
866
|
this.integrationName,
|
|
837
867
|
window.__rokt_li_guid__,
|
|
838
868
|
o.accountId
|
|
839
869
|
);
|
|
840
|
-
if (this.errorReportingService =
|
|
870
|
+
if (this.errorReportingService = I, this.loggingService = P, this.isTargetingDisabled())
|
|
841
871
|
try {
|
|
842
|
-
|
|
872
|
+
ee(), te();
|
|
843
873
|
} catch (f) {
|
|
844
874
|
this.errorReportingService?.report({
|
|
845
875
|
message: "Rokt Kit: Failed to clear page views when targeting is disabled",
|
|
846
876
|
code: "PAGE_VIEW_CAPTURE_FAILED",
|
|
847
|
-
severity:
|
|
877
|
+
severity: S.INFO,
|
|
848
878
|
stackTrace: f instanceof Error ? f.stack : void 0
|
|
849
879
|
});
|
|
850
880
|
}
|
|
851
|
-
return
|
|
852
|
-
generateLauncherScript:
|
|
853
|
-
generateThankYouElementScript:
|
|
854
|
-
extractRoktExtensionConfig:
|
|
855
|
-
hashEventMessage:
|
|
856
|
-
parseSettingsString:
|
|
857
|
-
generateMappedEventLookup:
|
|
858
|
-
generateMappedEventAttributeLookup:
|
|
859
|
-
sendAdBlockMeasurementSignals:
|
|
860
|
-
createAutoRemovedIframe:
|
|
861
|
-
djb2:
|
|
881
|
+
return a()._registerErrorReportingService && a()._registerErrorReportingService(I), a()._registerLoggingService && a()._registerLoggingService(P), n ? (this.testHelpers = {
|
|
882
|
+
generateLauncherScript: re,
|
|
883
|
+
generateThankYouElementScript: se,
|
|
884
|
+
extractRoktExtensionConfig: ce,
|
|
885
|
+
hashEventMessage: ue,
|
|
886
|
+
parseSettingsString: N,
|
|
887
|
+
generateMappedEventLookup: ae,
|
|
888
|
+
generateMappedEventAttributeLookup: le,
|
|
889
|
+
sendAdBlockMeasurementSignals: de,
|
|
890
|
+
createAutoRemovedIframe: V,
|
|
891
|
+
djb2: pe,
|
|
862
892
|
setAllowedOriginHashes: (f) => {
|
|
863
|
-
|
|
893
|
+
_._allowedOriginHashes = f;
|
|
864
894
|
},
|
|
865
|
-
ReportingTransport:
|
|
866
|
-
ErrorReportingService:
|
|
867
|
-
LoggingService:
|
|
868
|
-
RateLimiter:
|
|
869
|
-
ErrorCodes:
|
|
870
|
-
WSDKErrorSeverity:
|
|
871
|
-
resetLauncherAttachState: () =>
|
|
872
|
-
}, this.attachLauncher(
|
|
895
|
+
ReportingTransport: C,
|
|
896
|
+
ErrorReportingService: he,
|
|
897
|
+
LoggingService: ge,
|
|
898
|
+
RateLimiter: Pe,
|
|
899
|
+
ErrorCodes: J,
|
|
900
|
+
WSDKErrorSeverity: S,
|
|
901
|
+
resetLauncherAttachState: () => rt(this._launcherAttachState)
|
|
902
|
+
}, this.attachLauncher(c, E), "Successfully initialized: " + d) : (w && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), oe(dt, se(m), {
|
|
873
903
|
onLoad: () => {
|
|
874
904
|
this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
|
|
875
905
|
},
|
|
876
906
|
onError: (f) => {
|
|
877
907
|
console.error("Error loading Rokt Thank You Element script:", f);
|
|
878
908
|
}
|
|
879
|
-
})), this.isLauncherReadyToAttach() ? this.attachLauncher(
|
|
909
|
+
})), this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, v) : (oe(ut, re(m, F), {
|
|
880
910
|
onLoad: () => {
|
|
881
|
-
this.isLauncherReadyToAttach() ? this.attachLauncher(
|
|
911
|
+
this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, v) : console.error("Rokt object is not available after script load.");
|
|
882
912
|
},
|
|
883
913
|
onError: (f) => {
|
|
884
914
|
console.error("Error loading Rokt launcher script:", f);
|
|
885
915
|
}
|
|
886
|
-
}), this.captureTiming(
|
|
916
|
+
}), this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
|
|
887
917
|
}
|
|
888
918
|
process(e) {
|
|
889
|
-
if (this.isTargetingDisabled() || (e.EventDataType ===
|
|
919
|
+
if (this.isTargetingDisabled() || (e.EventDataType === gt && (Ce(this.loggingService), this.capturePageView(e), ye(this._preselectState, this.buildPreselectHost(), e)), e.EventDataType === ft && (ee(), te())), !this.isKitReady())
|
|
890
920
|
return "Kit not ready for forwarder: " + d;
|
|
891
|
-
if (
|
|
892
|
-
const t =
|
|
893
|
-
this.placementEventMappingLookup[String(t)] &&
|
|
921
|
+
if (L(a().Rokt?.setLocalSessionAttribute) && (R(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !R(this.placementEventMappingLookup))) {
|
|
922
|
+
const t = ue(e.EventDataType, e.EventCategory, e.EventName ?? "");
|
|
923
|
+
this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
|
|
894
924
|
}
|
|
895
925
|
return "Successfully sent to forwarder: " + d;
|
|
896
926
|
}
|
|
@@ -902,13 +932,13 @@ const I = class I {
|
|
|
902
932
|
window.Rokt.setExtensionData(e);
|
|
903
933
|
}
|
|
904
934
|
setUserAttribute(e, t) {
|
|
905
|
-
return
|
|
935
|
+
return fe(e) || (this.userAttributes[e] = t), qe(this.accountId, e) && this.flushPendingPreselectDispatches(), "Successfully set user attribute for forwarder: " + d;
|
|
906
936
|
}
|
|
907
937
|
removeUserAttribute(e) {
|
|
908
|
-
return
|
|
938
|
+
return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
|
|
909
939
|
}
|
|
910
940
|
handleIdentityComplete(e, t) {
|
|
911
|
-
return this.userAttributes =
|
|
941
|
+
return this.userAttributes = T(e.getAllUserAttributes()), "Successfully called " + t + " for forwarder: " + d;
|
|
912
942
|
}
|
|
913
943
|
onUserIdentified(e) {
|
|
914
944
|
const t = e;
|
|
@@ -920,20 +950,20 @@ const I = class I {
|
|
|
920
950
|
const t = this._workspaceIdSyncApiKey;
|
|
921
951
|
if (!t)
|
|
922
952
|
return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
|
|
923
|
-
const n =
|
|
953
|
+
const n = a().Identity?.search;
|
|
924
954
|
if (typeof n != "function")
|
|
925
955
|
return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
|
|
926
956
|
const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
|
|
927
957
|
if (r)
|
|
928
958
|
for (const u of Object.keys(r)) {
|
|
929
959
|
const l = r[u];
|
|
930
|
-
|
|
960
|
+
g(l) && l.length > 0 && (s[u] = l);
|
|
931
961
|
}
|
|
932
962
|
const o = Object.keys(s);
|
|
933
963
|
if (o.length === 0)
|
|
934
964
|
return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
|
|
935
|
-
const
|
|
936
|
-
return
|
|
965
|
+
const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
|
|
966
|
+
return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
|
|
937
967
|
try {
|
|
938
968
|
n(t, s, (l) => {
|
|
939
969
|
l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
|
|
@@ -981,7 +1011,7 @@ const I = class I {
|
|
|
981
1011
|
if (t) {
|
|
982
1012
|
const n = this._workspaceSearchInFlightPromise, r = n ? Promise.race([
|
|
983
1013
|
n,
|
|
984
|
-
new Promise((s) => setTimeout(s,
|
|
1014
|
+
new Promise((s) => setTimeout(s, ne))
|
|
985
1015
|
]) : Promise.resolve();
|
|
986
1016
|
return Promise.all([t, r]).then(
|
|
987
1017
|
() => this._dispatchPlacements(e)
|
|
@@ -991,42 +1021,38 @@ const I = class I {
|
|
|
991
1021
|
const n = this._workspaceSearchInFlightPromise;
|
|
992
1022
|
return Promise.race([
|
|
993
1023
|
n,
|
|
994
|
-
new Promise((r) => setTimeout(r,
|
|
1024
|
+
new Promise((r) => setTimeout(r, ne))
|
|
995
1025
|
]).then(() => this._dispatchPlacements(e));
|
|
996
1026
|
}
|
|
997
1027
|
return this._dispatchPlacements(e);
|
|
998
1028
|
}
|
|
999
1029
|
_dispatchPlacements(e) {
|
|
1000
|
-
const t = e && e.attributes || {}, r = { ...
|
|
1030
|
+
const t = e && e.attributes || {}, r = { ...T(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
|
|
1001
1031
|
let l;
|
|
1002
|
-
s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes =
|
|
1003
|
-
const
|
|
1004
|
-
...
|
|
1032
|
+
s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = T(l);
|
|
1033
|
+
const m = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, F = this.returnUserIdentities(c), v = this.returnLocalSessionAttributes(), w = Ue(Z()), E = Ke(), A = this.readMpSessionId(), I = this.readMpDeviceId(), P = {
|
|
1034
|
+
...F,
|
|
1005
1035
|
...l,
|
|
1006
|
-
...
|
|
1007
|
-
...
|
|
1008
|
-
...
|
|
1009
|
-
...
|
|
1010
|
-
...this.userIdentifiedInWorkspace ? { [
|
|
1011
|
-
...
|
|
1012
|
-
...
|
|
1036
|
+
...m,
|
|
1037
|
+
...v,
|
|
1038
|
+
...w.length ? { [pt]: JSON.stringify(w) } : {},
|
|
1039
|
+
...E ? { [mt]: E } : {},
|
|
1040
|
+
...this.userIdentifiedInWorkspace ? { [ht]: !0 } : {},
|
|
1041
|
+
...A ? { [Et]: A } : {},
|
|
1042
|
+
...I ? { [_t]: I } : {},
|
|
1013
1043
|
mpid: u
|
|
1014
|
-
}, f = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0),
|
|
1044
|
+
}, f = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0), Re = {
|
|
1015
1045
|
...e,
|
|
1016
|
-
attributes:
|
|
1046
|
+
attributes: P,
|
|
1017
1047
|
...f !== void 0 ? { cacheMatchKeys: f } : {}
|
|
1048
|
+
}, B = this.launcher.selectPlacements(Re), Q = e.preselect === !0, ke = () => {
|
|
1049
|
+
Q || this.logSelectPlacementsEvent(P);
|
|
1018
1050
|
};
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
const $ = this.launcher.selectPlacements(Ie), q = e.preselect === !0, Se = () => {
|
|
1023
|
-
q || this.logSelectPlacementsEvent(A);
|
|
1024
|
-
};
|
|
1025
|
-
return Promise.resolve($).then((ye) => {
|
|
1026
|
-
if (!q)
|
|
1027
|
-
return ye?.context?.sessionId?.then((Ae) => this.setRoktSessionId(Ae));
|
|
1051
|
+
return Promise.resolve(B).then((be) => {
|
|
1052
|
+
if (!Q)
|
|
1053
|
+
return be?.context?.sessionId?.then((ve) => this.setRoktSessionId(ve));
|
|
1028
1054
|
}).catch(() => {
|
|
1029
|
-
}).finally(
|
|
1055
|
+
}).finally(ke), B;
|
|
1030
1056
|
}
|
|
1031
1057
|
/**
|
|
1032
1058
|
* Passes attributes to the Rokt Web SDK for client-side hashing.
|
|
@@ -1040,7 +1066,7 @@ const I = class I {
|
|
|
1040
1066
|
* @deprecated This functionality has been internalized and will be removed in a future release.
|
|
1041
1067
|
*/
|
|
1042
1068
|
use(e) {
|
|
1043
|
-
return this.isKitReady() ? !e || !
|
|
1069
|
+
return this.isKitReady() ? !e || !g(e) ? Promise.reject(new Error("Rokt Kit: Invalid extension name")) : this.launcher.use(e) : (console.error("Rokt Kit: Not initialized"), Promise.reject(new Error("Rokt Kit: Not initialized")));
|
|
1044
1070
|
}
|
|
1045
1071
|
/**
|
|
1046
1072
|
* Tears down the Rokt launcher and the placements it rendered.
|
|
@@ -1052,7 +1078,7 @@ const I = class I {
|
|
|
1052
1078
|
* here would flip the kit to not-ready with no drain path for queued calls.
|
|
1053
1079
|
*/
|
|
1054
1080
|
terminate() {
|
|
1055
|
-
return this.isKitReady() ? (
|
|
1081
|
+
return this.isKitReady() ? (it(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
|
|
1056
1082
|
}
|
|
1057
1083
|
/**
|
|
1058
1084
|
* Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
|
|
@@ -1061,34 +1087,34 @@ const I = class I {
|
|
|
1061
1087
|
this._isThankYouElementLoaded ? e() : this._thankYouElementOnLoadCallback = e;
|
|
1062
1088
|
}
|
|
1063
1089
|
};
|
|
1064
|
-
|
|
1090
|
+
_._allowedOriginHashes = [-553112570, 549508659], _.PERFORMANCE_MARKS = {
|
|
1065
1091
|
RoktScriptAppended: "mp:RoktScriptAppended"
|
|
1066
|
-
},
|
|
1067
|
-
let
|
|
1068
|
-
function
|
|
1069
|
-
return
|
|
1092
|
+
}, _.EMAIL_SHA256_KEY = "emailsha256";
|
|
1093
|
+
let y = _;
|
|
1094
|
+
function Tt() {
|
|
1095
|
+
return O;
|
|
1070
1096
|
}
|
|
1071
|
-
function
|
|
1097
|
+
function Lt(i) {
|
|
1072
1098
|
if (!i) {
|
|
1073
1099
|
window.console.log("You must pass a config object to register the kit " + d);
|
|
1074
1100
|
return;
|
|
1075
1101
|
}
|
|
1076
|
-
if (!
|
|
1102
|
+
if (!p(i)) {
|
|
1077
1103
|
window.console.log("'config' must be an object. You passed in a " + typeof i);
|
|
1078
1104
|
return;
|
|
1079
1105
|
}
|
|
1080
|
-
|
|
1081
|
-
constructor:
|
|
1106
|
+
p(i.kits) ? i.kits[d] = {
|
|
1107
|
+
constructor: y
|
|
1082
1108
|
} : (i.kits = {}, i.kits[d] = {
|
|
1083
|
-
constructor:
|
|
1109
|
+
constructor: y
|
|
1084
1110
|
}), window.console.log("Successfully registered " + d + " to your mParticle configuration");
|
|
1085
1111
|
}
|
|
1086
|
-
typeof window < "u" && window.mParticle &&
|
|
1112
|
+
typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
|
|
1087
1113
|
name: d,
|
|
1088
|
-
constructor:
|
|
1089
|
-
getId:
|
|
1114
|
+
constructor: y,
|
|
1115
|
+
getId: Tt
|
|
1090
1116
|
});
|
|
1091
1117
|
export {
|
|
1092
|
-
|
|
1118
|
+
Lt as register
|
|
1093
1119
|
};
|
|
1094
1120
|
//# sourceMappingURL=Rokt-Kit.esm.js.map
|