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