@mparticle/web-rokt-kit 3.1.0 → 3.2.1

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