@mparticle/web-rokt-kit 1.21.0 → 1.23.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 -1004
- package/dist/Rokt-Kit.d.ts +17 -0
- package/dist/Rokt-Kit.esm.js +515 -0
- package/dist/Rokt-Kit.iife.js +2 -1007
- package/package.json +35 -29
|
@@ -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,515 @@
|
|
|
1
|
+
const g = "Rokt";
|
|
2
|
+
const H = "selectPlacements", j = "apps.roktecommerce.com";
|
|
3
|
+
const L = {
|
|
4
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
5
|
+
UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
|
|
6
|
+
IDENTITY_REQUEST: "IDENTITY_REQUEST"
|
|
7
|
+
}, w = {
|
|
8
|
+
ERROR: "ERROR",
|
|
9
|
+
INFO: "INFO",
|
|
10
|
+
WARNING: "WARNING"
|
|
11
|
+
}, F = "apps.rokt-api.com/v1/log", z = "apps.rokt-api.com/v1/errors", Q = 10;
|
|
12
|
+
function s() {
|
|
13
|
+
return window.mParticle;
|
|
14
|
+
}
|
|
15
|
+
function O(n, t) {
|
|
16
|
+
const o = ["https://", typeof n < "u" ? n : "apps.rokt.com", "/wsdk/integrations/launcher.js"].join("");
|
|
17
|
+
return !t || t.length === 0 ? o : o + "?extensions=" + t.join(",");
|
|
18
|
+
}
|
|
19
|
+
function k(n) {
|
|
20
|
+
return n != null && typeof n == "object" && Array.isArray(n) === !1;
|
|
21
|
+
}
|
|
22
|
+
function y(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 M(n) {
|
|
33
|
+
const t = n ? y(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 U(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 || !v(i.value) || !v(i.map))
|
|
55
|
+
continue;
|
|
56
|
+
const r = i.value, o = i.map;
|
|
57
|
+
t[r] || (t[r] = []), t[r].push({
|
|
58
|
+
eventAttributeKey: o,
|
|
59
|
+
conditions: Array.isArray(i.conditions) ? i.conditions : []
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
}
|
|
64
|
+
function P(n, t, e) {
|
|
65
|
+
return s().generateHash([n, t, e].join(""));
|
|
66
|
+
}
|
|
67
|
+
function R(n) {
|
|
68
|
+
return n == null ? !0 : typeof n == "object" ? Object.keys(n).length === 0 : Array.isArray(n) ? n.length === 0 : !1;
|
|
69
|
+
}
|
|
70
|
+
function v(n) {
|
|
71
|
+
return typeof n == "string";
|
|
72
|
+
}
|
|
73
|
+
function V(n) {
|
|
74
|
+
let i = "mParticle_wsdkv_" + s().getVersion() + "_kitv_" + "1.23.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 S(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 (f._allowedOriginHashes.indexOf(e) === -1 || Math.random() >= 0.1)
|
|
94
|
+
return;
|
|
95
|
+
const r = window.__rokt_li_guid__;
|
|
96
|
+
if (!r)
|
|
97
|
+
return;
|
|
98
|
+
const o = window.location.href.split("?")[0].split("#")[0], a = "version=" + encodeURIComponent(t ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(o);
|
|
99
|
+
S("https://" + (n || "apps.rokt.com") + "/v1/wsdk-init/index.html?" + a), S(
|
|
100
|
+
"https://" + j + "/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 B() {
|
|
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 > Q;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
class N {
|
|
125
|
+
constructor(t, e, i, r, o) {
|
|
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 = o || new G(), this._isEnabled = W() || Y() && a;
|
|
129
|
+
}
|
|
130
|
+
send(t, e, i, r, o, a) {
|
|
131
|
+
if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(e)))
|
|
132
|
+
try {
|
|
133
|
+
const c = {
|
|
134
|
+
additionalInformation: {
|
|
135
|
+
message: i,
|
|
136
|
+
version: this._integrationName
|
|
137
|
+
},
|
|
138
|
+
severity: e,
|
|
139
|
+
code: r || L.UNKNOWN_ERROR,
|
|
140
|
+
url: q(),
|
|
141
|
+
deviceInfo: B(),
|
|
142
|
+
stackTrace: o,
|
|
143
|
+
reporter: this._reporter,
|
|
144
|
+
integration: this._integrationName
|
|
145
|
+
}, u = {
|
|
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 && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(t, {
|
|
152
|
+
method: "POST",
|
|
153
|
+
headers: u,
|
|
154
|
+
body: JSON.stringify(c)
|
|
155
|
+
}).catch((p) => {
|
|
156
|
+
console.error("ReportingTransport: Failed to send log", p), a && a(p);
|
|
157
|
+
});
|
|
158
|
+
} catch (c) {
|
|
159
|
+
console.error("ReportingTransport: Failed to send log", c), a && a(c);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
class D {
|
|
164
|
+
constructor(t, e, i, r, o) {
|
|
165
|
+
this._transport = new N(t, e, i, r, o), this._errorUrl = "https://" + (t?.errorUrl || z);
|
|
166
|
+
}
|
|
167
|
+
report(t) {
|
|
168
|
+
if (!t) return;
|
|
169
|
+
const e = t.severity || w.ERROR;
|
|
170
|
+
this._transport.send(this._errorUrl, e, t.message, t.code, t.stackTrace);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
class K {
|
|
174
|
+
constructor(t, e, i, r, o, a) {
|
|
175
|
+
this._transport = new N(t, i, r, o, a), this._loggingUrl = "https://" + (t?.loggingUrl || F), this._errorReportingService = e;
|
|
176
|
+
}
|
|
177
|
+
log(t) {
|
|
178
|
+
t && this._transport.send(
|
|
179
|
+
this._loggingUrl,
|
|
180
|
+
w.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: w.ERROR
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const d = class d {
|
|
195
|
+
constructor() {
|
|
196
|
+
this.name = g, this.moduleId = 181, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.eventQueue = [], this.eventStreamQueue = [], 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 || !v(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 || !v(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 o = 0; o < i.length; o++)
|
|
219
|
+
if (!this.doesEventAttributeConditionMatch(i[o], 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], o = this.placementEventAttributeMappingLookup[r];
|
|
227
|
+
if (R(o))
|
|
228
|
+
continue;
|
|
229
|
+
let a = !0;
|
|
230
|
+
for (let c = 0; c < o.length; c++)
|
|
231
|
+
if (!this.doesEventMatchRule(t, o[c])) {
|
|
232
|
+
a = !1;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
a && s().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 !s().Rokt || typeof s().Rokt.getLocalSessionAttributes != "function" ? {} : R(this.placementEventMappingLookup) && R(this.placementEventAttributeMappingLookup) ? {} : s().Rokt.getLocalSessionAttributes();
|
|
252
|
+
}
|
|
253
|
+
replaceOtherIdentityWithEmailsha256(t) {
|
|
254
|
+
const e = { ...t || {} }, i = this._mappedEmailSha256Key;
|
|
255
|
+
return i && t[i] && (e[d.EMAIL_SHA256_KEY] = t[i]), i && delete e[i], e;
|
|
256
|
+
}
|
|
257
|
+
logSelectPlacementsEvent(t) {
|
|
258
|
+
if (!window.mParticle || typeof s().logEvent != "function" || !k(t))
|
|
259
|
+
return;
|
|
260
|
+
const e = s().EventType.Other;
|
|
261
|
+
s().logEvent(H, e, t);
|
|
262
|
+
}
|
|
263
|
+
processEventQueue() {
|
|
264
|
+
this.eventQueue.forEach((t) => {
|
|
265
|
+
this.process(t);
|
|
266
|
+
}), this.eventQueue = [];
|
|
267
|
+
}
|
|
268
|
+
enrichEvent(t) {
|
|
269
|
+
return { ...t, UserAttributes: this.userAttributes };
|
|
270
|
+
}
|
|
271
|
+
sendEventStream(t) {
|
|
272
|
+
if (window.Rokt && typeof window.Rokt.__event_stream__ == "function") {
|
|
273
|
+
if (this.eventStreamQueue.length) {
|
|
274
|
+
const e = this.eventStreamQueue;
|
|
275
|
+
this.eventStreamQueue = [];
|
|
276
|
+
for (let i = 0; i < e.length; i++)
|
|
277
|
+
window.Rokt.__event_stream__(this.enrichEvent(e[i]));
|
|
278
|
+
}
|
|
279
|
+
window.Rokt.__event_stream__(this.enrichEvent(t));
|
|
280
|
+
} else
|
|
281
|
+
this.eventStreamQueue.push(t);
|
|
282
|
+
}
|
|
283
|
+
setRoktSessionId(t) {
|
|
284
|
+
if (!(!t || typeof t != "string"))
|
|
285
|
+
try {
|
|
286
|
+
const e = s().getInstance();
|
|
287
|
+
e && typeof e.setIntegrationAttribute == "function" && e.setIntegrationAttribute(181, {
|
|
288
|
+
roktSessionId: t
|
|
289
|
+
});
|
|
290
|
+
} catch {
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
buildIdentityEvent(t, e) {
|
|
294
|
+
const i = e.getMPID && typeof e.getMPID == "function" ? e.getMPID() : null, r = s() && s().sessionManager && typeof s().sessionManager.getSession == "function" ? s().sessionManager.getSession() : null, o = e.getUserIdentities && typeof e.getUserIdentities == "function" ? e.getUserIdentities().userIdentities : null;
|
|
295
|
+
return {
|
|
296
|
+
EventName: t,
|
|
297
|
+
EventDataType: 14,
|
|
298
|
+
EventCategory: 0,
|
|
299
|
+
Timestamp: Date.now(),
|
|
300
|
+
MPID: i,
|
|
301
|
+
SessionId: r,
|
|
302
|
+
UserIdentities: o
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
attachLauncher(t, e) {
|
|
306
|
+
const i = s() && s().sessionManager && typeof s().sessionManager.getSession == "function" ? s().sessionManager.getSession() : void 0, r = {
|
|
307
|
+
accountId: t,
|
|
308
|
+
...e || {},
|
|
309
|
+
...i ? { mpSessionId: i } : {}
|
|
310
|
+
};
|
|
311
|
+
if (this.isPartnerInLocalLauncherTestGroup()) {
|
|
312
|
+
const o = window.Rokt.createLocalLauncher(r);
|
|
313
|
+
this.initRoktLauncher(o);
|
|
314
|
+
} else
|
|
315
|
+
window.Rokt.createLauncher(r).then((o) => this.initRoktLauncher(o)).catch((o) => {
|
|
316
|
+
console.error("Error creating Rokt launcher:", o);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
initRoktLauncher(t) {
|
|
320
|
+
window.Rokt && (window.Rokt.currentLauncher = t), this.launcher = t;
|
|
321
|
+
const e = s().Rokt?.filters;
|
|
322
|
+
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), s().Rokt.attachKit(this), this.processEventQueue();
|
|
323
|
+
}
|
|
324
|
+
fetchOptimizely() {
|
|
325
|
+
const t = s()._getActiveForwarders().filter((e) => e.name === "Optimizely");
|
|
326
|
+
try {
|
|
327
|
+
if (t.length > 0 && window.optimizely) {
|
|
328
|
+
const e = window.optimizely.get("state");
|
|
329
|
+
return !e || !e.getActiveExperimentIds ? {} : e.getActiveExperimentIds().reduce((o, a) => (o["rokt.custom.optimizely.experiment." + a + ".variationId"] = e.getVariationMap()[a].id, o), {});
|
|
330
|
+
}
|
|
331
|
+
} catch (e) {
|
|
332
|
+
console.error("Error fetching Optimizely attributes:", e);
|
|
333
|
+
}
|
|
334
|
+
return {};
|
|
335
|
+
}
|
|
336
|
+
isKitReady() {
|
|
337
|
+
return !!(this.isInitialized && this.launcher);
|
|
338
|
+
}
|
|
339
|
+
isPartnerInLocalLauncherTestGroup() {
|
|
340
|
+
return !!(s().config && s().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
|
|
341
|
+
}
|
|
342
|
+
isAssignedToSampleGroup() {
|
|
343
|
+
return Math.random() > 0.5;
|
|
344
|
+
}
|
|
345
|
+
captureTiming(t) {
|
|
346
|
+
window && s() && s().captureTiming && t && s().captureTiming(t);
|
|
347
|
+
}
|
|
348
|
+
// ---- Public methods (mParticle Kit Callbacks) ----
|
|
349
|
+
/**
|
|
350
|
+
* Initializes the Rokt forwarder with settings from the mParticle server.
|
|
351
|
+
*/
|
|
352
|
+
init(t, e, i, r, o) {
|
|
353
|
+
const a = t.accountId, c = M(t.roktExtensions);
|
|
354
|
+
this.userAttributes = o || {}, this._onboardingExpProvider = t.onboardingExpProvider;
|
|
355
|
+
const u = y(t.placementEventMapping);
|
|
356
|
+
this.placementEventMappingLookup = T(u);
|
|
357
|
+
const p = y(
|
|
358
|
+
t.placementEventAttributeMapping
|
|
359
|
+
);
|
|
360
|
+
this.placementEventAttributeMappingLookup = U(p), t.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = t.hashedEmailUserIdentityType.toLowerCase());
|
|
361
|
+
const b = s().Rokt?.domain, h = {
|
|
362
|
+
...s().Rokt?.launcherOptions || {}
|
|
363
|
+
};
|
|
364
|
+
this.integrationName = V(h.integrationName), h.integrationName = this.integrationName, this.domain = b;
|
|
365
|
+
const m = {
|
|
366
|
+
loggingUrl: t.loggingUrl,
|
|
367
|
+
errorUrl: t.errorUrl,
|
|
368
|
+
isLoggingEnabled: t.isLoggingEnabled === "true" || t.isLoggingEnabled === !0
|
|
369
|
+
}, E = new D(
|
|
370
|
+
m,
|
|
371
|
+
this.integrationName,
|
|
372
|
+
window.__rokt_li_guid__,
|
|
373
|
+
t.accountId
|
|
374
|
+
), _ = new K(
|
|
375
|
+
m,
|
|
376
|
+
E,
|
|
377
|
+
this.integrationName,
|
|
378
|
+
window.__rokt_li_guid__,
|
|
379
|
+
t.accountId
|
|
380
|
+
);
|
|
381
|
+
if (this.errorReportingService = E, this.loggingService = _, s()._registerErrorReportingService && s()._registerErrorReportingService(E), s()._registerLoggingService && s()._registerLoggingService(_), i) {
|
|
382
|
+
this.testHelpers = {
|
|
383
|
+
generateLauncherScript: O,
|
|
384
|
+
extractRoktExtensions: M,
|
|
385
|
+
hashEventMessage: P,
|
|
386
|
+
parseSettingsString: y,
|
|
387
|
+
generateMappedEventLookup: T,
|
|
388
|
+
generateMappedEventAttributeLookup: U,
|
|
389
|
+
sendAdBlockMeasurementSignals: C,
|
|
390
|
+
createAutoRemovedIframe: S,
|
|
391
|
+
djb2: x,
|
|
392
|
+
setAllowedOriginHashes: (A) => {
|
|
393
|
+
d._allowedOriginHashes = A;
|
|
394
|
+
},
|
|
395
|
+
ReportingTransport: N,
|
|
396
|
+
ErrorReportingService: D,
|
|
397
|
+
LoggingService: K,
|
|
398
|
+
RateLimiter: G,
|
|
399
|
+
ErrorCodes: L,
|
|
400
|
+
WSDKErrorSeverity: w
|
|
401
|
+
}, this.attachLauncher(a, h);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (this.isLauncherReadyToAttach())
|
|
405
|
+
this.attachLauncher(a, h);
|
|
406
|
+
else {
|
|
407
|
+
const A = document.head || document.body, l = document.createElement("script");
|
|
408
|
+
l.type = "text/javascript", l.src = O(b, c), l.async = !0, l.crossOrigin = "anonymous", l.fetchPriority = "high", l.id = "rokt-launcher", l.onload = () => {
|
|
409
|
+
this.isLauncherReadyToAttach() ? this.attachLauncher(a, h) : console.error("Rokt object is not available after script load.");
|
|
410
|
+
}, l.onerror = (I) => {
|
|
411
|
+
console.error("Error loading Rokt launcher script:", I);
|
|
412
|
+
}, A.appendChild(l), this.captureTiming(d.PERFORMANCE_MARKS.RoktScriptAppended);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
process(t) {
|
|
416
|
+
if (!this.isKitReady()) {
|
|
417
|
+
this.eventQueue.push(t);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
if (this.sendEventStream(t), typeof s().Rokt?.setLocalSessionAttribute != "function" || (R(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(t), R(this.placementEventMappingLookup)))
|
|
421
|
+
return;
|
|
422
|
+
const e = P(t.EventDataType, t.EventCategory, t.EventName ?? "");
|
|
423
|
+
if (this.placementEventMappingLookup[String(e)]) {
|
|
424
|
+
const i = this.placementEventMappingLookup[String(e)];
|
|
425
|
+
s().Rokt.setLocalSessionAttribute?.(i, !0);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
setExtensionData(t) {
|
|
429
|
+
if (!this.isKitReady()) {
|
|
430
|
+
console.error("Rokt Kit: Not initialized");
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
window.Rokt.setExtensionData(t);
|
|
434
|
+
}
|
|
435
|
+
setUserAttribute(t, e) {
|
|
436
|
+
this.userAttributes[t] = e, this.sendEventStream(
|
|
437
|
+
this.buildIdentityEvent("set_user_attributes", this.filters.filteredUser ?? {})
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
removeUserAttribute(t) {
|
|
441
|
+
delete this.userAttributes[t];
|
|
442
|
+
}
|
|
443
|
+
onUserIdentified(t) {
|
|
444
|
+
this.filters.filteredUser = t, this.userAttributes = t.getAllUserAttributes(), this.sendEventStream(this.buildIdentityEvent("identify", t));
|
|
445
|
+
}
|
|
446
|
+
onLoginComplete(t) {
|
|
447
|
+
this.userAttributes = t.getAllUserAttributes(), this.sendEventStream(this.buildIdentityEvent("login", t));
|
|
448
|
+
}
|
|
449
|
+
onLogoutComplete(t) {
|
|
450
|
+
this.userAttributes = t.getAllUserAttributes(), this.sendEventStream(this.buildIdentityEvent("logout", t));
|
|
451
|
+
}
|
|
452
|
+
onModifyComplete(t) {
|
|
453
|
+
this.userAttributes = t.getAllUserAttributes(), this.sendEventStream(this.buildIdentityEvent("modify_user", t));
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options.
|
|
457
|
+
*/
|
|
458
|
+
selectPlacements(t) {
|
|
459
|
+
const e = t && t.attributes || {}, i = { ...this.userAttributes, ...e }, r = this.filters || {}, o = r.userAttributeFilters || [], a = r.filteredUser || null, c = a && a.getMPID && typeof a.getMPID == "function" ? a.getMPID() : null;
|
|
460
|
+
let u;
|
|
461
|
+
r ? r.filterUserAttributes ? u = r.filterUserAttributes(i, o) : u = i : (console.warn("Rokt Kit: No filters available, using user attributes"), u = i), this.userAttributes = u;
|
|
462
|
+
const p = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, b = this.returnUserIdentities(a), h = this.returnLocalSessionAttributes(), m = {
|
|
463
|
+
...b,
|
|
464
|
+
...u,
|
|
465
|
+
...p,
|
|
466
|
+
...h,
|
|
467
|
+
mpid: c
|
|
468
|
+
}, E = { ...t, attributes: m }, _ = this.launcher.selectPlacements(E), A = () => this.logSelectPlacementsEvent(m);
|
|
469
|
+
return Promise.resolve(_).then((l) => l?.context?.sessionId?.then((I) => this.setRoktSessionId(I))).catch(() => {
|
|
470
|
+
}).finally(A), _;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Passes attributes to the Rokt Web SDK for client-side hashing.
|
|
474
|
+
*/
|
|
475
|
+
hashAttributes(t) {
|
|
476
|
+
return this.isKitReady() ? this.launcher.hashAttributes(t) : (console.error("Rokt Kit: Not initialized"), null);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Enables optional Integration Launcher extensions before selecting placements.
|
|
480
|
+
*/
|
|
481
|
+
use(t) {
|
|
482
|
+
return this.isKitReady() ? !t || !v(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")));
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
d._allowedOriginHashes = [-553112570, 549508659], d.PERFORMANCE_MARKS = {
|
|
486
|
+
RoktScriptAppended: "mp:RoktScriptAppended"
|
|
487
|
+
}, d.EMAIL_SHA256_KEY = "emailsha256";
|
|
488
|
+
let f = d;
|
|
489
|
+
function J() {
|
|
490
|
+
return 181;
|
|
491
|
+
}
|
|
492
|
+
function X(n) {
|
|
493
|
+
if (!n) {
|
|
494
|
+
window.console.log("You must pass a config object to register the kit " + g);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (!k(n)) {
|
|
498
|
+
window.console.log("'config' must be an object. You passed in a " + typeof n);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
k(n.kits) ? n.kits[g] = {
|
|
502
|
+
constructor: f
|
|
503
|
+
} : (n.kits = {}, n.kits[g] = {
|
|
504
|
+
constructor: f
|
|
505
|
+
}), window.console.log("Successfully registered " + g + " to your mParticle configuration");
|
|
506
|
+
}
|
|
507
|
+
typeof window < "u" && window.mParticle && s().addForwarder && s().addForwarder({
|
|
508
|
+
name: g,
|
|
509
|
+
constructor: f,
|
|
510
|
+
getId: J
|
|
511
|
+
});
|
|
512
|
+
export {
|
|
513
|
+
X as register
|
|
514
|
+
};
|
|
515
|
+
//# sourceMappingURL=Rokt-Kit.esm.js.map
|