@mparticle/web-rokt-kit 1.22.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Rokt-Kit.common.js +2 -1284
- package/dist/Rokt-Kit.d.ts +17 -0
- package/dist/Rokt-Kit.esm.js +521 -0
- package/dist/Rokt-Kit.iife.js +2 -1287
- package/package.json +37 -30
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function register(config: {
|
|
2
|
+
kits?: Record<string, unknown>;
|
|
3
|
+
}): void;
|
|
4
|
+
|
|
5
|
+
export { }
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
Rokt?: RoktGlobal;
|
|
11
|
+
__rokt_li_guid__?: string;
|
|
12
|
+
optimizely?: OptimizelyGlobal;
|
|
13
|
+
ROKT_DOMAIN?: string;
|
|
14
|
+
mParticle: any;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
const c = "Rokt";
|
|
2
|
+
const j = "selectPlacements", F = "apps.roktecommerce.com";
|
|
3
|
+
const L = {
|
|
4
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
5
|
+
UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
|
|
6
|
+
IDENTITY_REQUEST: "IDENTITY_REQUEST"
|
|
7
|
+
}, v = {
|
|
8
|
+
ERROR: "ERROR",
|
|
9
|
+
INFO: "INFO",
|
|
10
|
+
WARNING: "WARNING"
|
|
11
|
+
}, z = "apps.rokt-api.com/v1/log", Q = "apps.rokt-api.com/v1/errors", B = 10;
|
|
12
|
+
function o() {
|
|
13
|
+
return window.mParticle;
|
|
14
|
+
}
|
|
15
|
+
function O(n, t) {
|
|
16
|
+
const s = ["https://", typeof n < "u" ? n : "apps.rokt.com", "/wsdk/integrations/launcher.js"].join("");
|
|
17
|
+
return !t || t.length === 0 ? s : s + "?extensions=" + t.join(",");
|
|
18
|
+
}
|
|
19
|
+
function S(n) {
|
|
20
|
+
return n != null && typeof n == "object" && Array.isArray(n) === !1;
|
|
21
|
+
}
|
|
22
|
+
function w(n) {
|
|
23
|
+
if (!n)
|
|
24
|
+
return [];
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(n.replace(/"/g, '"'));
|
|
27
|
+
} catch {
|
|
28
|
+
console.error("Settings string contains invalid JSON");
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
function U(n) {
|
|
33
|
+
const t = n ? w(n) : [], e = [];
|
|
34
|
+
for (let i = 0; i < t.length; i++)
|
|
35
|
+
e.push(t[i].value);
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
function T(n) {
|
|
39
|
+
if (!n)
|
|
40
|
+
return {};
|
|
41
|
+
const t = {};
|
|
42
|
+
for (let e = 0; e < n.length; e++) {
|
|
43
|
+
const i = n[e];
|
|
44
|
+
t[i.jsmap] = i.value;
|
|
45
|
+
}
|
|
46
|
+
return t;
|
|
47
|
+
}
|
|
48
|
+
function M(n) {
|
|
49
|
+
const t = {};
|
|
50
|
+
if (!Array.isArray(n))
|
|
51
|
+
return t;
|
|
52
|
+
for (let e = 0; e < n.length; e++) {
|
|
53
|
+
const i = n[e];
|
|
54
|
+
if (!i || !y(i.value) || !y(i.map))
|
|
55
|
+
continue;
|
|
56
|
+
const r = i.value, s = i.map;
|
|
57
|
+
t[r] || (t[r] = []), t[r].push({
|
|
58
|
+
eventAttributeKey: s,
|
|
59
|
+
conditions: Array.isArray(i.conditions) ? i.conditions : []
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
}
|
|
64
|
+
function P(n, t, e) {
|
|
65
|
+
return o().generateHash([n, t, e].join(""));
|
|
66
|
+
}
|
|
67
|
+
function _(n) {
|
|
68
|
+
return n == null ? !0 : typeof n == "object" ? Object.keys(n).length === 0 : Array.isArray(n) ? n.length === 0 : !1;
|
|
69
|
+
}
|
|
70
|
+
function y(n) {
|
|
71
|
+
return typeof n == "string";
|
|
72
|
+
}
|
|
73
|
+
function V(n) {
|
|
74
|
+
let i = "mParticle_wsdkv_" + o().getVersion() + "_kitv_" + "1.24.0";
|
|
75
|
+
return n && (i += "_" + n), i;
|
|
76
|
+
}
|
|
77
|
+
function x(n) {
|
|
78
|
+
let t = 5381;
|
|
79
|
+
for (let e = 0; e < n.length; e++)
|
|
80
|
+
t = (t << 5) + t + n.charCodeAt(e), t = t & t;
|
|
81
|
+
return t;
|
|
82
|
+
}
|
|
83
|
+
function k(n) {
|
|
84
|
+
const t = document.createElement("iframe");
|
|
85
|
+
t.style.display = "none", t.setAttribute("sandbox", "allow-scripts allow-same-origin"), t.src = n, t.onload = function() {
|
|
86
|
+
t.onload = null, t.parentNode && t.parentNode.removeChild(t);
|
|
87
|
+
};
|
|
88
|
+
const e = document.body || document.head;
|
|
89
|
+
e && e.appendChild(t);
|
|
90
|
+
}
|
|
91
|
+
function C(n, t) {
|
|
92
|
+
const e = x(window.location.origin);
|
|
93
|
+
if (m._allowedOriginHashes.indexOf(e) === -1 || Math.random() >= 0.1)
|
|
94
|
+
return;
|
|
95
|
+
const r = window.__rokt_li_guid__;
|
|
96
|
+
if (!r)
|
|
97
|
+
return;
|
|
98
|
+
const s = window.location.href.split("?")[0].split("#")[0], a = "version=" + encodeURIComponent(t ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s);
|
|
99
|
+
k("https://" + (n || "apps.rokt.com") + "/v1/wsdk-init/index.html?" + a), k(
|
|
100
|
+
"https://" + F + "/v1/wsdk-init/index.html?" + a + "&isControl=true"
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function Y() {
|
|
104
|
+
return typeof window < "u" && !!window.ROKT_DOMAIN;
|
|
105
|
+
}
|
|
106
|
+
function W() {
|
|
107
|
+
return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
|
|
108
|
+
}
|
|
109
|
+
function q() {
|
|
110
|
+
return typeof window < "u" ? window.location?.href : void 0;
|
|
111
|
+
}
|
|
112
|
+
function J() {
|
|
113
|
+
return typeof window < "u" ? window.navigator?.userAgent : void 0;
|
|
114
|
+
}
|
|
115
|
+
class G {
|
|
116
|
+
constructor() {
|
|
117
|
+
this._logCount = {};
|
|
118
|
+
}
|
|
119
|
+
incrementAndCheck(t) {
|
|
120
|
+
const i = (this._logCount[t] || 0) + 1;
|
|
121
|
+
return this._logCount[t] = i, i > B;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
class N {
|
|
125
|
+
constructor(t, e, i, r, s) {
|
|
126
|
+
this._reporter = "mp-wsdk";
|
|
127
|
+
const a = t?.isLoggingEnabled === !0 || t?.isLoggingEnabled === "true";
|
|
128
|
+
this._integrationName = e || "", this._launcherInstanceGuid = i, this._accountId = r || null, this._rateLimiter = s || new G(), this._isEnabled = W() || Y() && a;
|
|
129
|
+
}
|
|
130
|
+
send(t, e, i, r, s, a) {
|
|
131
|
+
if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(e)))
|
|
132
|
+
try {
|
|
133
|
+
const u = {
|
|
134
|
+
additionalInformation: {
|
|
135
|
+
message: i,
|
|
136
|
+
version: this._integrationName
|
|
137
|
+
},
|
|
138
|
+
severity: e,
|
|
139
|
+
code: r || L.UNKNOWN_ERROR,
|
|
140
|
+
url: q(),
|
|
141
|
+
deviceInfo: J(),
|
|
142
|
+
stackTrace: s,
|
|
143
|
+
reporter: this._reporter,
|
|
144
|
+
integration: this._integrationName
|
|
145
|
+
}, l = {
|
|
146
|
+
Accept: "text/plain;charset=UTF-8",
|
|
147
|
+
"Content-Type": "application/json",
|
|
148
|
+
"rokt-launcher-version": this._integrationName,
|
|
149
|
+
"rokt-wsdk-version": "joint"
|
|
150
|
+
};
|
|
151
|
+
this._launcherInstanceGuid && (l["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (l["rokt-account-id"] = this._accountId), fetch(t, {
|
|
152
|
+
method: "POST",
|
|
153
|
+
headers: l,
|
|
154
|
+
body: JSON.stringify(u)
|
|
155
|
+
}).catch((g) => {
|
|
156
|
+
console.error("ReportingTransport: Failed to send log", g), a && a(g);
|
|
157
|
+
});
|
|
158
|
+
} catch (u) {
|
|
159
|
+
console.error("ReportingTransport: Failed to send log", u), a && a(u);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
class K {
|
|
164
|
+
constructor(t, e, i, r, s) {
|
|
165
|
+
this._transport = new N(t, e, i, r, s), this._errorUrl = "https://" + (t?.errorUrl || Q);
|
|
166
|
+
}
|
|
167
|
+
report(t) {
|
|
168
|
+
if (!t) return;
|
|
169
|
+
const e = t.severity || v.ERROR;
|
|
170
|
+
this._transport.send(this._errorUrl, e, t.message, t.code, t.stackTrace);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
class D {
|
|
174
|
+
constructor(t, e, i, r, s, a) {
|
|
175
|
+
this._transport = new N(t, i, r, s, a), this._loggingUrl = "https://" + (t?.loggingUrl || z), this._errorReportingService = e;
|
|
176
|
+
}
|
|
177
|
+
log(t) {
|
|
178
|
+
t && this._transport.send(
|
|
179
|
+
this._loggingUrl,
|
|
180
|
+
v.INFO,
|
|
181
|
+
t.message,
|
|
182
|
+
t.code,
|
|
183
|
+
void 0,
|
|
184
|
+
(e) => {
|
|
185
|
+
this._errorReportingService && this._errorReportingService.report({
|
|
186
|
+
message: "LoggingService: Failed to send log: " + e.message,
|
|
187
|
+
code: L.UNKNOWN_ERROR,
|
|
188
|
+
severity: v.ERROR
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const p = class p {
|
|
195
|
+
constructor() {
|
|
196
|
+
this.name = c, this.id = 181, this.moduleId = 181, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.batchQueue = [], this.batchStreamQueue = [], this.pendingIdentityEvents = [], this.integrationName = null, this.errorReportingService = null, this.loggingService = null;
|
|
197
|
+
}
|
|
198
|
+
// ---- Private helpers ----
|
|
199
|
+
getEventAttributeValue(t, e) {
|
|
200
|
+
const i = t && t.EventAttributes;
|
|
201
|
+
return !i || typeof i[e] > "u" ? null : i[e];
|
|
202
|
+
}
|
|
203
|
+
doesEventAttributeConditionMatch(t, e) {
|
|
204
|
+
if (!t || !y(t.operator))
|
|
205
|
+
return !1;
|
|
206
|
+
const i = t.operator.toLowerCase(), r = t.attributeValue;
|
|
207
|
+
return i === "exists" ? e !== null : e == null ? !1 : i === "equals" ? String(e) === String(r) : i === "contains" ? String(e).indexOf(String(r)) !== -1 : !1;
|
|
208
|
+
}
|
|
209
|
+
doesEventMatchRule(t, e) {
|
|
210
|
+
if (!e || !y(e.eventAttributeKey))
|
|
211
|
+
return !1;
|
|
212
|
+
const i = e.conditions;
|
|
213
|
+
if (!Array.isArray(i))
|
|
214
|
+
return !1;
|
|
215
|
+
const r = this.getEventAttributeValue(t, e.eventAttributeKey);
|
|
216
|
+
if (i.length === 0)
|
|
217
|
+
return r !== null;
|
|
218
|
+
for (let s = 0; s < i.length; s++)
|
|
219
|
+
if (!this.doesEventAttributeConditionMatch(i[s], r))
|
|
220
|
+
return !1;
|
|
221
|
+
return !0;
|
|
222
|
+
}
|
|
223
|
+
applyPlacementEventAttributeMapping(t) {
|
|
224
|
+
const e = Object.keys(this.placementEventAttributeMappingLookup);
|
|
225
|
+
for (let i = 0; i < e.length; i++) {
|
|
226
|
+
const r = e[i], s = this.placementEventAttributeMappingLookup[r];
|
|
227
|
+
if (_(s))
|
|
228
|
+
continue;
|
|
229
|
+
let a = !0;
|
|
230
|
+
for (let u = 0; u < s.length; u++)
|
|
231
|
+
if (!this.doesEventMatchRule(t, s[u])) {
|
|
232
|
+
a = !1;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
a && o().Rokt.setLocalSessionAttribute?.(r, !0);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
isLauncherReadyToAttach() {
|
|
239
|
+
return !!window.Rokt && typeof window.Rokt.createLauncher == "function";
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Returns the user identities from the filtered user, if any.
|
|
243
|
+
*/
|
|
244
|
+
returnUserIdentities(t) {
|
|
245
|
+
if (!t || !t.getUserIdentities)
|
|
246
|
+
return {};
|
|
247
|
+
const e = t.getUserIdentities().userIdentities;
|
|
248
|
+
return this.replaceOtherIdentityWithEmailsha256(e);
|
|
249
|
+
}
|
|
250
|
+
returnLocalSessionAttributes() {
|
|
251
|
+
return !o().Rokt || typeof o().Rokt.getLocalSessionAttributes != "function" ? {} : _(this.placementEventMappingLookup) && _(this.placementEventAttributeMappingLookup) ? {} : o().Rokt.getLocalSessionAttributes();
|
|
252
|
+
}
|
|
253
|
+
replaceOtherIdentityWithEmailsha256(t) {
|
|
254
|
+
const e = { ...t || {} }, i = this._mappedEmailSha256Key;
|
|
255
|
+
return i && t[i] && (e[p.EMAIL_SHA256_KEY] = t[i]), i && delete e[i], e;
|
|
256
|
+
}
|
|
257
|
+
logSelectPlacementsEvent(t) {
|
|
258
|
+
if (!window.mParticle || typeof o().logEvent != "function" || !S(t))
|
|
259
|
+
return;
|
|
260
|
+
const e = o().EventType.Other;
|
|
261
|
+
o().logEvent(j, e, t);
|
|
262
|
+
}
|
|
263
|
+
buildIdentityEvent(t, e) {
|
|
264
|
+
const i = e.getMPID(), r = o() && o().sessionManager && typeof o().sessionManager.getSession == "function" ? o().sessionManager.getSession() : null, s = e.getUserIdentities && typeof e.getUserIdentities == "function" ? e.getUserIdentities().userIdentities : null;
|
|
265
|
+
return {
|
|
266
|
+
EventName: t,
|
|
267
|
+
EventDataType: 14,
|
|
268
|
+
EventCategory: 0,
|
|
269
|
+
Timestamp: Date.now(),
|
|
270
|
+
MPID: i,
|
|
271
|
+
SessionId: r,
|
|
272
|
+
UserIdentities: s
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
mergePendingIdentityEvents(t) {
|
|
276
|
+
if (this.pendingIdentityEvents.length === 0)
|
|
277
|
+
return t;
|
|
278
|
+
const e = {
|
|
279
|
+
...t,
|
|
280
|
+
events: [...t.events ?? [], ...this.pendingIdentityEvents]
|
|
281
|
+
};
|
|
282
|
+
return this.pendingIdentityEvents = [], e;
|
|
283
|
+
}
|
|
284
|
+
drainBatchQueue() {
|
|
285
|
+
this.batchQueue.forEach((t) => {
|
|
286
|
+
this.processBatch(t);
|
|
287
|
+
}), this.batchQueue = [];
|
|
288
|
+
}
|
|
289
|
+
processBatch(t) {
|
|
290
|
+
return this.isKitReady() ? (this.sendBatchStream(this.mergePendingIdentityEvents(t)), "Successfully sent batch to forwarder: " + c) : (this.batchQueue.push(t), "Batch queued for forwarder: " + c);
|
|
291
|
+
}
|
|
292
|
+
sendBatchStream(t) {
|
|
293
|
+
if (window.Rokt && typeof window.Rokt.__batch_stream__ == "function") {
|
|
294
|
+
if (this.batchStreamQueue.length) {
|
|
295
|
+
const e = this.batchStreamQueue;
|
|
296
|
+
this.batchStreamQueue = [];
|
|
297
|
+
for (let i = 0; i < e.length; i++)
|
|
298
|
+
window.Rokt.__batch_stream__(e[i]);
|
|
299
|
+
}
|
|
300
|
+
window.Rokt.__batch_stream__(t);
|
|
301
|
+
} else
|
|
302
|
+
this.batchStreamQueue.push(t);
|
|
303
|
+
}
|
|
304
|
+
setRoktSessionId(t) {
|
|
305
|
+
if (!(!t || typeof t != "string"))
|
|
306
|
+
try {
|
|
307
|
+
const e = o().getInstance();
|
|
308
|
+
e && typeof e.setIntegrationAttribute == "function" && e.setIntegrationAttribute(181, {
|
|
309
|
+
roktSessionId: t
|
|
310
|
+
});
|
|
311
|
+
} catch {
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
attachLauncher(t, e) {
|
|
315
|
+
const i = o() && o().sessionManager && typeof o().sessionManager.getSession == "function" ? o().sessionManager.getSession() : void 0, r = {
|
|
316
|
+
accountId: t,
|
|
317
|
+
...e || {},
|
|
318
|
+
...i ? { mpSessionId: i } : {}
|
|
319
|
+
};
|
|
320
|
+
if (this.isPartnerInLocalLauncherTestGroup()) {
|
|
321
|
+
const s = window.Rokt.createLocalLauncher(r);
|
|
322
|
+
this.initRoktLauncher(s);
|
|
323
|
+
} else
|
|
324
|
+
window.Rokt.createLauncher(r).then((s) => this.initRoktLauncher(s)).catch((s) => {
|
|
325
|
+
console.error("Error creating Rokt launcher:", s);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
initRoktLauncher(t) {
|
|
329
|
+
window.Rokt && (window.Rokt.currentLauncher = t), this.launcher = t;
|
|
330
|
+
const e = o().Rokt?.filters;
|
|
331
|
+
e ? (this.filters = e, e.filteredUser || console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, C(this.domain, this.integrationName), o().Rokt.attachKit(this), this.drainBatchQueue();
|
|
332
|
+
}
|
|
333
|
+
fetchOptimizely() {
|
|
334
|
+
const t = o()._getActiveForwarders().filter((e) => e.name === "Optimizely");
|
|
335
|
+
try {
|
|
336
|
+
if (t.length > 0 && window.optimizely) {
|
|
337
|
+
const e = window.optimizely.get("state");
|
|
338
|
+
return !e || !e.getActiveExperimentIds ? {} : e.getActiveExperimentIds().reduce((s, a) => (s["rokt.custom.optimizely.experiment." + a + ".variationId"] = e.getVariationMap()[a].id, s), {});
|
|
339
|
+
}
|
|
340
|
+
} catch (e) {
|
|
341
|
+
console.error("Error fetching Optimizely attributes:", e);
|
|
342
|
+
}
|
|
343
|
+
return {};
|
|
344
|
+
}
|
|
345
|
+
isKitReady() {
|
|
346
|
+
return !!(this.isInitialized && this.launcher);
|
|
347
|
+
}
|
|
348
|
+
isPartnerInLocalLauncherTestGroup() {
|
|
349
|
+
return !!(o().config && o().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
|
|
350
|
+
}
|
|
351
|
+
isAssignedToSampleGroup() {
|
|
352
|
+
return Math.random() > 0.5;
|
|
353
|
+
}
|
|
354
|
+
captureTiming(t) {
|
|
355
|
+
window && o() && o().captureTiming && t && o().captureTiming(t);
|
|
356
|
+
}
|
|
357
|
+
// ---- Public methods (mParticle Kit Callbacks) ----
|
|
358
|
+
/**
|
|
359
|
+
* Initializes the Rokt forwarder with settings from the mParticle server.
|
|
360
|
+
*/
|
|
361
|
+
init(t, e, i, r, s) {
|
|
362
|
+
const a = t, u = a.accountId, l = U(a.roktExtensions);
|
|
363
|
+
this.userAttributes = s || {}, this._onboardingExpProvider = a.onboardingExpProvider;
|
|
364
|
+
const g = w(a.placementEventMapping);
|
|
365
|
+
this.placementEventMappingLookup = T(g);
|
|
366
|
+
const I = w(
|
|
367
|
+
a.placementEventAttributeMapping
|
|
368
|
+
);
|
|
369
|
+
this.placementEventAttributeMappingLookup = M(I), a.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = a.hashedEmailUserIdentityType.toLowerCase());
|
|
370
|
+
const R = o().Rokt?.domain, h = {
|
|
371
|
+
...o().Rokt?.launcherOptions || {}
|
|
372
|
+
};
|
|
373
|
+
this.integrationName = V(h.integrationName), h.integrationName = this.integrationName, this.domain = R;
|
|
374
|
+
const A = {
|
|
375
|
+
loggingUrl: a.loggingUrl,
|
|
376
|
+
errorUrl: a.errorUrl,
|
|
377
|
+
isLoggingEnabled: a.isLoggingEnabled === "true" || a.isLoggingEnabled === !0
|
|
378
|
+
}, f = new K(
|
|
379
|
+
A,
|
|
380
|
+
this.integrationName,
|
|
381
|
+
window.__rokt_li_guid__,
|
|
382
|
+
a.accountId
|
|
383
|
+
), b = new D(
|
|
384
|
+
A,
|
|
385
|
+
f,
|
|
386
|
+
this.integrationName,
|
|
387
|
+
window.__rokt_li_guid__,
|
|
388
|
+
a.accountId
|
|
389
|
+
);
|
|
390
|
+
if (this.errorReportingService = f, this.loggingService = b, o()._registerErrorReportingService && o()._registerErrorReportingService(f), o()._registerLoggingService && o()._registerLoggingService(b), i)
|
|
391
|
+
return this.testHelpers = {
|
|
392
|
+
generateLauncherScript: O,
|
|
393
|
+
extractRoktExtensions: U,
|
|
394
|
+
hashEventMessage: P,
|
|
395
|
+
parseSettingsString: w,
|
|
396
|
+
generateMappedEventLookup: T,
|
|
397
|
+
generateMappedEventAttributeLookup: M,
|
|
398
|
+
sendAdBlockMeasurementSignals: C,
|
|
399
|
+
createAutoRemovedIframe: k,
|
|
400
|
+
djb2: x,
|
|
401
|
+
setAllowedOriginHashes: (E) => {
|
|
402
|
+
p._allowedOriginHashes = E;
|
|
403
|
+
},
|
|
404
|
+
ReportingTransport: N,
|
|
405
|
+
ErrorReportingService: K,
|
|
406
|
+
LoggingService: D,
|
|
407
|
+
RateLimiter: G,
|
|
408
|
+
ErrorCodes: L,
|
|
409
|
+
WSDKErrorSeverity: v
|
|
410
|
+
}, this.attachLauncher(u, h), "Successfully initialized: " + c;
|
|
411
|
+
if (this.isLauncherReadyToAttach())
|
|
412
|
+
this.attachLauncher(u, h);
|
|
413
|
+
else {
|
|
414
|
+
const E = document.head || document.body, d = document.createElement("script");
|
|
415
|
+
d.type = "text/javascript", d.src = O(R, l), d.async = !0, d.crossOrigin = "anonymous", d.fetchPriority = "high", d.id = "rokt-launcher", d.onload = () => {
|
|
416
|
+
this.isLauncherReadyToAttach() ? this.attachLauncher(u, h) : console.error("Rokt object is not available after script load.");
|
|
417
|
+
}, d.onerror = (H) => {
|
|
418
|
+
console.error("Error loading Rokt launcher script:", H);
|
|
419
|
+
}, E.appendChild(d), this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended);
|
|
420
|
+
}
|
|
421
|
+
return "Successfully initialized: " + c;
|
|
422
|
+
}
|
|
423
|
+
process(t) {
|
|
424
|
+
if (!this.isKitReady())
|
|
425
|
+
return "Kit not ready for forwarder: " + c;
|
|
426
|
+
if (typeof o().Rokt?.setLocalSessionAttribute == "function" && (_(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(t), !_(this.placementEventMappingLookup))) {
|
|
427
|
+
const e = P(t.EventDataType, t.EventCategory, t.EventName ?? "");
|
|
428
|
+
this.placementEventMappingLookup[String(e)] && o().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(e)], !0);
|
|
429
|
+
}
|
|
430
|
+
return "Successfully sent to forwarder: " + c;
|
|
431
|
+
}
|
|
432
|
+
setExtensionData(t) {
|
|
433
|
+
if (!this.isKitReady()) {
|
|
434
|
+
console.error("Rokt Kit: Not initialized");
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
window.Rokt.setExtensionData(t);
|
|
438
|
+
}
|
|
439
|
+
setUserAttribute(t, e) {
|
|
440
|
+
return this.userAttributes[t] = e, "Successfully set user attribute for forwarder: " + c;
|
|
441
|
+
}
|
|
442
|
+
removeUserAttribute(t) {
|
|
443
|
+
return delete this.userAttributes[t], "Successfully removed user attribute for forwarder: " + c;
|
|
444
|
+
}
|
|
445
|
+
onUserIdentified(t) {
|
|
446
|
+
const e = t;
|
|
447
|
+
return this.filters.filteredUser = e, this.userAttributes = t.getAllUserAttributes(), this.pendingIdentityEvents.push(this.buildIdentityEvent("identify", e)), "Successfully called onUserIdentified for forwarder: " + c;
|
|
448
|
+
}
|
|
449
|
+
onLoginComplete(t, e) {
|
|
450
|
+
const i = t;
|
|
451
|
+
return this.userAttributes = t.getAllUserAttributes(), this.pendingIdentityEvents.push(this.buildIdentityEvent("login", i)), "Successfully called onLoginComplete for forwarder: " + c;
|
|
452
|
+
}
|
|
453
|
+
onLogoutComplete(t, e) {
|
|
454
|
+
const i = t;
|
|
455
|
+
return this.userAttributes = t.getAllUserAttributes(), this.pendingIdentityEvents.push(this.buildIdentityEvent("logout", i)), "Successfully called onLogoutComplete for forwarder: " + c;
|
|
456
|
+
}
|
|
457
|
+
onModifyComplete(t, e) {
|
|
458
|
+
const i = t;
|
|
459
|
+
return this.userAttributes = t.getAllUserAttributes(), this.pendingIdentityEvents.push(this.buildIdentityEvent("modify", i)), "Successfully called onModifyComplete for forwarder: " + c;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options.
|
|
463
|
+
*/
|
|
464
|
+
selectPlacements(t) {
|
|
465
|
+
const e = t && t.attributes || {}, i = { ...this.userAttributes, ...e }, r = this.filters || {}, s = r.userAttributeFilters || [], a = r.filteredUser || null, u = a ? a.getMPID() : null;
|
|
466
|
+
let l;
|
|
467
|
+
r ? r.filterUserAttributes ? l = r.filterUserAttributes(i, s) : l = i : (console.warn("Rokt Kit: No filters available, using user attributes"), l = i), this.userAttributes = l;
|
|
468
|
+
const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, I = this.returnUserIdentities(a), R = this.returnLocalSessionAttributes(), h = {
|
|
469
|
+
...I,
|
|
470
|
+
...l,
|
|
471
|
+
...g,
|
|
472
|
+
...R,
|
|
473
|
+
mpid: u
|
|
474
|
+
}, A = { ...t, attributes: h }, f = this.launcher.selectPlacements(A), b = () => this.logSelectPlacementsEvent(h);
|
|
475
|
+
return Promise.resolve(f).then((E) => E?.context?.sessionId?.then((d) => this.setRoktSessionId(d))).catch(() => {
|
|
476
|
+
}).finally(b), f;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Passes attributes to the Rokt Web SDK for client-side hashing.
|
|
480
|
+
*/
|
|
481
|
+
hashAttributes(t) {
|
|
482
|
+
return this.isKitReady() ? this.launcher.hashAttributes(t) : (console.error("Rokt Kit: Not initialized"), null);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Enables optional Integration Launcher extensions before selecting placements.
|
|
486
|
+
*/
|
|
487
|
+
use(t) {
|
|
488
|
+
return this.isKitReady() ? !t || !y(t) ? Promise.reject(new Error("Rokt Kit: Invalid extension name")) : this.launcher.use(t) : (console.error("Rokt Kit: Not initialized"), Promise.reject(new Error("Rokt Kit: Not initialized")));
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
p._allowedOriginHashes = [-553112570, 549508659], p.PERFORMANCE_MARKS = {
|
|
492
|
+
RoktScriptAppended: "mp:RoktScriptAppended"
|
|
493
|
+
}, p.EMAIL_SHA256_KEY = "emailsha256";
|
|
494
|
+
let m = p;
|
|
495
|
+
function X() {
|
|
496
|
+
return 181;
|
|
497
|
+
}
|
|
498
|
+
function Z(n) {
|
|
499
|
+
if (!n) {
|
|
500
|
+
window.console.log("You must pass a config object to register the kit " + c);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (!S(n)) {
|
|
504
|
+
window.console.log("'config' must be an object. You passed in a " + typeof n);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
S(n.kits) ? n.kits[c] = {
|
|
508
|
+
constructor: m
|
|
509
|
+
} : (n.kits = {}, n.kits[c] = {
|
|
510
|
+
constructor: m
|
|
511
|
+
}), window.console.log("Successfully registered " + c + " to your mParticle configuration");
|
|
512
|
+
}
|
|
513
|
+
typeof window < "u" && window.mParticle && o().addForwarder && o().addForwarder({
|
|
514
|
+
name: c,
|
|
515
|
+
constructor: m,
|
|
516
|
+
getId: X
|
|
517
|
+
});
|
|
518
|
+
export {
|
|
519
|
+
Z as register
|
|
520
|
+
};
|
|
521
|
+
//# sourceMappingURL=Rokt-Kit.esm.js.map
|