@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.
@@ -1,1007 +1,2 @@
1
- var RoktKit = (function (exports) {
2
- 'use strict';
3
-
4
- /* eslint-disable no-undef */
5
- // Copyright 2025 mParticle, Inc.
6
- //
7
- // Licensed under the Apache License, Version 2.0 (the "License");
8
- // you may not use this file except in compliance with the License.
9
- // You may obtain a copy of the License at
10
- //
11
- // http://www.apache.org/licenses/LICENSE-2.0
12
- //
13
- // Unless required by applicable law or agreed to in writing, software
14
- // distributed under the License is distributed on an "AS IS" BASIS,
15
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- // See the License for the specific language governing permissions and
17
- // limitations under the License.
18
-
19
- var name = 'Rokt';
20
- var moduleId = 181;
21
- var EVENT_NAME_SELECT_PLACEMENTS = 'selectPlacements';
22
-
23
- var constructor = function () {
24
- var self = this;
25
- var PerformanceMarks = {
26
- RoktScriptAppended: 'mp:RoktScriptAppended',
27
- };
28
-
29
- var EMAIL_SHA256_KEY = 'emailsha256';
30
-
31
- // Dynamic identity type for Rokt's emailsha256 identity value which MP doesn't natively support - will be set during initialization
32
- var mappedEmailSha256Key;
33
-
34
- self.name = name;
35
- self.moduleId = moduleId;
36
- self.isInitialized = false;
37
-
38
- self.launcher = null;
39
- self.filters = {};
40
- self.userAttributes = {};
41
- self.testHelpers = null;
42
- self.placementEventMappingLookup = {};
43
- self.placementEventAttributeMappingLookup = {};
44
- self.eventQueue = [];
45
- self.eventStreamQueue = [];
46
- self.integrationName = null;
47
-
48
- function getEventAttributeValue(event, eventAttributeKey) {
49
- var attributes = event && event.EventAttributes;
50
- if (!attributes) {
51
- return null;
52
- }
53
-
54
- if (typeof attributes[eventAttributeKey] === 'undefined') {
55
- return null;
56
- }
57
-
58
- return attributes[eventAttributeKey];
59
- }
60
-
61
- function doesEventAttributeConditionMatch(condition, actualValue) {
62
- if (!condition || !isString(condition.operator)) {
63
- return false;
64
- }
65
-
66
- var operator = condition.operator.toLowerCase();
67
- var expectedValue = condition.attributeValue;
68
-
69
- if (operator === 'exists') {
70
- return actualValue !== null;
71
- }
72
-
73
- if (actualValue == null) {
74
- return false;
75
- }
76
-
77
- if (operator === 'equals') {
78
- return String(actualValue) === String(expectedValue);
79
- }
80
-
81
- if (operator === 'contains') {
82
- return String(actualValue).indexOf(String(expectedValue)) !== -1;
83
- }
84
-
85
- return false;
86
- }
87
-
88
- function doesEventMatchRule(event, rule) {
89
- if (!rule || !isString(rule.eventAttributeKey)) {
90
- return false;
91
- }
92
-
93
- var conditions = rule.conditions;
94
- if (!Array.isArray(conditions)) {
95
- return false;
96
- }
97
-
98
- var actualValue = getEventAttributeValue(event, rule.eventAttributeKey);
99
-
100
- if (conditions.length === 0) {
101
- return actualValue !== null;
102
- }
103
- for (var i = 0; i < conditions.length; i++) {
104
- if (!doesEventAttributeConditionMatch(conditions[i], actualValue)) {
105
- return false;
106
- }
107
- }
108
-
109
- return true;
110
- }
111
-
112
- function generateMappedEventAttributeLookup(
113
- placementEventAttributeMapping
114
- ) {
115
- var mappedAttributeKeys = {};
116
- if (!Array.isArray(placementEventAttributeMapping)) {
117
- return mappedAttributeKeys;
118
- }
119
- for (var i = 0; i < placementEventAttributeMapping.length; i++) {
120
- var mapping = placementEventAttributeMapping[i];
121
- if (
122
- !mapping ||
123
- !isString(mapping.value) ||
124
- !isString(mapping.map)
125
- ) {
126
- continue;
127
- }
128
-
129
- var mappedAttributeKey = mapping.value;
130
- var eventAttributeKey = mapping.map;
131
-
132
- if (!mappedAttributeKeys[mappedAttributeKey]) {
133
- mappedAttributeKeys[mappedAttributeKey] = [];
134
- }
135
-
136
- mappedAttributeKeys[mappedAttributeKey].push({
137
- eventAttributeKey: eventAttributeKey,
138
- conditions: Array.isArray(mapping.conditions)
139
- ? mapping.conditions
140
- : [],
141
- });
142
- }
143
- return mappedAttributeKeys;
144
- }
145
-
146
- function applyPlacementEventAttributeMapping(event) {
147
- var mappedAttributeKeys = Object.keys(
148
- self.placementEventAttributeMappingLookup
149
- );
150
- for (var i = 0; i < mappedAttributeKeys.length; i++) {
151
- var mappedAttributeKey = mappedAttributeKeys[i];
152
- var rulesForMappedAttributeKey =
153
- self.placementEventAttributeMappingLookup[mappedAttributeKey];
154
- if (isEmpty(rulesForMappedAttributeKey)) {
155
- continue;
156
- }
157
-
158
- // Require ALL rules for the same key to match (AND).
159
- var allMatch = true;
160
- for (var j = 0; j < rulesForMappedAttributeKey.length; j++) {
161
- if (!doesEventMatchRule(event, rulesForMappedAttributeKey[j])) {
162
- allMatch = false;
163
- break;
164
- }
165
- }
166
- if (!allMatch) {
167
- continue;
168
- }
169
-
170
- window.mParticle.Rokt.setLocalSessionAttribute(
171
- mappedAttributeKey,
172
- true
173
- );
174
- }
175
- }
176
-
177
- /**
178
- * Generates the Rokt launcher script URL with optional domain override and extensions
179
- * @param {string} domain - The CNAME domain to use for overriding the launcher url
180
- * @param {Array<string>} extensions - List of extension query parameters to append
181
- * @returns {string} The complete launcher script URL
182
- */
183
- function generateLauncherScript(_domain, extensions) {
184
- // Override domain if a customer is using a CNAME
185
- // If a customer is using a CNAME, a domain will be passed. If not, we use the default domain.
186
- var domain = typeof _domain !== 'undefined' ? _domain : 'apps.rokt.com';
187
- var protocol = 'https://';
188
- var launcherPath = '/wsdk/integrations/launcher.js';
189
- var baseUrl = [protocol, domain, launcherPath].join('');
190
-
191
- if (!extensions || extensions.length === 0) {
192
- return baseUrl;
193
- }
194
- return baseUrl + '?extensions=' + extensions.join(',');
195
- }
196
-
197
- /**
198
- * Checks if Rokt launcher is available and ready to attach
199
- * @returns {boolean} True if launcher can be attached
200
- */
201
- function isLauncherReadyToAttach() {
202
- return window.Rokt && typeof window.Rokt.createLauncher === 'function';
203
- }
204
-
205
- /**
206
- * Passes attributes to the Rokt Web SDK for client-side hashing
207
- * @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
208
- * @param {Object} attributes - The attributes to be hashed
209
- * @returns {Promise<Object|null>} A Promise resolving to the
210
- * hashed attributes from the launcher, or `null` if the kit is not initialized
211
- */
212
- function hashAttributes(attributes) {
213
- if (!isKitReady()) {
214
- console.error('Rokt Kit: Not initialized');
215
- return null;
216
- }
217
- return self.launcher.hashAttributes(attributes);
218
- }
219
-
220
- function initForwarder(
221
- settings,
222
- _service,
223
- testMode,
224
- _trackerId,
225
- filteredUserAttributes
226
- ) {
227
- var accountId = settings.accountId;
228
- var roktExtensions = extractRoktExtensions(settings.roktExtensions);
229
- self.userAttributes = filteredUserAttributes || {};
230
- self.onboardingExpProvider = settings.onboardingExpProvider;
231
-
232
- var placementEventMapping = parseSettingsString(
233
- settings.placementEventMapping
234
- );
235
- self.placementEventMappingLookup = generateMappedEventLookup(
236
- placementEventMapping
237
- );
238
-
239
- var placementEventAttributeMapping = parseSettingsString(
240
- settings.placementEventAttributeMapping
241
- );
242
- self.placementEventAttributeMappingLookup =
243
- generateMappedEventAttributeLookup(placementEventAttributeMapping);
244
-
245
- // Set dynamic OTHER_IDENTITY based on server settings
246
- // Convert to lowercase since server sends TitleCase (e.g., 'Other' -> 'other')
247
- if (settings.hashedEmailUserIdentityType) {
248
- mappedEmailSha256Key =
249
- settings.hashedEmailUserIdentityType.toLowerCase();
250
- }
251
-
252
- var domain = window.mParticle.Rokt.domain;
253
- var launcherOptions = mergeObjects(
254
- {},
255
- window.mParticle.Rokt.launcherOptions || {}
256
- );
257
- self.integrationName = generateIntegrationName(
258
- launcherOptions.integrationName
259
- );
260
- launcherOptions.integrationName = self.integrationName;
261
-
262
- self.domain = domain;
263
-
264
- if (testMode) {
265
- self.testHelpers = {
266
- generateLauncherScript: generateLauncherScript,
267
- extractRoktExtensions: extractRoktExtensions,
268
- hashEventMessage: hashEventMessage,
269
- parseSettingsString: parseSettingsString,
270
- generateMappedEventLookup: generateMappedEventLookup,
271
- generateMappedEventAttributeLookup:
272
- generateMappedEventAttributeLookup,
273
- sendAdBlockMeasurementSignals: sendAdBlockMeasurementSignals,
274
- createAutoRemovedIframe: createAutoRemovedIframe,
275
- djb2: djb2,
276
- setAllowedOriginHashes: function (hashes) {
277
- _allowedOriginHashes = hashes;
278
- },
279
- };
280
- attachLauncher(accountId, launcherOptions);
281
- return;
282
- }
283
-
284
- if (isLauncherReadyToAttach()) {
285
- attachLauncher(accountId, launcherOptions);
286
- } else {
287
- var target = document.head || document.body;
288
- var script = document.createElement('script');
289
- script.type = 'text/javascript';
290
- script.src = generateLauncherScript(domain, roktExtensions);
291
- script.async = true;
292
- script.crossOrigin = 'anonymous';
293
- script.fetchPriority = 'high';
294
- script.id = 'rokt-launcher';
295
-
296
- script.onload = function () {
297
- if (isLauncherReadyToAttach()) {
298
- attachLauncher(accountId, launcherOptions);
299
- } else {
300
- console.error(
301
- 'Rokt object is not available after script load.'
302
- );
303
- }
304
- };
305
-
306
- script.onerror = function (error) {
307
- console.error('Error loading Rokt launcher script:', error);
308
- };
309
-
310
- target.appendChild(script);
311
- captureTiming(PerformanceMarks.RoktScriptAppended);
312
- }
313
- }
314
- /**
315
- * Returns the user identities from the filtered user, if any
316
- * @param {Object} filteredUser - The filtered user object containing identities
317
- * @returns {Object} The user identities from the filtered user
318
- */
319
- function returnUserIdentities(filteredUser) {
320
- if (!filteredUser || !filteredUser.getUserIdentities) {
321
- return {};
322
- }
323
-
324
- var userIdentities = filteredUser.getUserIdentities().userIdentities;
325
-
326
- return replaceOtherIdentityWithEmailsha256(userIdentities);
327
- }
328
-
329
- function returnLocalSessionAttributes() {
330
- if (
331
- !window.mParticle.Rokt ||
332
- typeof window.mParticle.Rokt.getLocalSessionAttributes !==
333
- 'function'
334
- ) {
335
- return {};
336
- }
337
- if (
338
- isEmpty(self.placementEventMappingLookup) &&
339
- isEmpty(self.placementEventAttributeMappingLookup)
340
- ) {
341
- return {};
342
- }
343
- return window.mParticle.Rokt.getLocalSessionAttributes();
344
- }
345
-
346
- function replaceOtherIdentityWithEmailsha256(userIdentities) {
347
- var newUserIdentities = mergeObjects({}, userIdentities || {});
348
- if (userIdentities[mappedEmailSha256Key]) {
349
- newUserIdentities[EMAIL_SHA256_KEY] =
350
- userIdentities[mappedEmailSha256Key];
351
- }
352
- delete newUserIdentities[mappedEmailSha256Key];
353
-
354
- return newUserIdentities;
355
- }
356
-
357
- /**
358
- * Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options
359
- * @see https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options/
360
- * @param {Object} options - The options object for selecting placements containing:
361
- * - identifier {string}: The placement identifier
362
- * - attributes {Object}: Optional attributes to merge with existing attributes
363
- * @returns {Promise<void>} A Promise resolving to the Rokt launcher's selectPlacements method with processed attributes
364
- */
365
- function selectPlacements(options) {
366
- var attributes = (options && options.attributes) || {};
367
- var placementAttributes = mergeObjects(self.userAttributes, attributes);
368
-
369
- var filters = self.filters || {};
370
- var userAttributeFilters = filters.userAttributeFilters || [];
371
- var filteredUser = filters.filteredUser || {};
372
- var mpid =
373
- filteredUser &&
374
- filteredUser.getMPID &&
375
- typeof filteredUser.getMPID === 'function'
376
- ? filteredUser.getMPID()
377
- : null;
378
-
379
- var filteredAttributes;
380
-
381
- if (!filters) {
382
- console.warn(
383
- 'Rokt Kit: No filters available, using user attributes'
384
- );
385
-
386
- filteredAttributes = placementAttributes;
387
- } else if (filters.filterUserAttributes) {
388
- filteredAttributes = filters.filterUserAttributes(
389
- placementAttributes,
390
- userAttributeFilters
391
- );
392
- }
393
-
394
- self.userAttributes = filteredAttributes;
395
-
396
- var optimizelyAttributes =
397
- self.onboardingExpProvider === 'Optimizely'
398
- ? fetchOptimizely()
399
- : {};
400
-
401
- var filteredUserIdentities = returnUserIdentities(filteredUser);
402
-
403
- var localSessionAttributes = returnLocalSessionAttributes();
404
-
405
- var selectPlacementsAttributes = mergeObjects(
406
- filteredUserIdentities,
407
- filteredAttributes,
408
- optimizelyAttributes,
409
- localSessionAttributes,
410
- {
411
- mpid: mpid,
412
- }
413
- );
414
-
415
- var selectPlacementsOptions = mergeObjects(options, {
416
- attributes: selectPlacementsAttributes,
417
- });
418
-
419
- var selection = self.launcher.selectPlacements(selectPlacementsOptions);
420
-
421
- // After selection resolves, sync the Rokt session ID back to mParticle
422
- // as an integration attribute so server-side integrations can link events.
423
- // We log the custom event AFTER setting the attribute because
424
- // setIntegrationAttribute alone doesn't fire a network request —
425
- // if the user closes the page before another event fires, the server
426
- // would never receive the session ID.
427
- if (selection && typeof selection.then === 'function') {
428
- selection
429
- .then(function (sel) {
430
- if (sel && sel.context && sel.context.sessionId) {
431
- sel.context.sessionId
432
- .then(function (sessionId) {
433
- _setRoktSessionId(sessionId);
434
- logSelectPlacementsEvent(
435
- selectPlacementsAttributes
436
- );
437
- })
438
- .catch(function () {
439
- logSelectPlacementsEvent(
440
- selectPlacementsAttributes
441
- );
442
- });
443
- } else {
444
- logSelectPlacementsEvent(selectPlacementsAttributes);
445
- }
446
- })
447
- .catch(function () {
448
- logSelectPlacementsEvent(selectPlacementsAttributes);
449
- });
450
- } else {
451
- logSelectPlacementsEvent(selectPlacementsAttributes);
452
- }
453
-
454
- return selection;
455
- }
456
-
457
- /**
458
- * Logs a custom event when selectPlacements is called
459
- * This enables visibility and troubleshooting
460
- * @param {Object} attributes - The attributes sent to Rokt
461
- */
462
- function logSelectPlacementsEvent(attributes) {
463
- if (
464
- !window.mParticle ||
465
- typeof window.mParticle.logEvent !== 'function'
466
- ) {
467
- return;
468
- }
469
-
470
- if (!isObject(attributes)) {
471
- return;
472
- }
473
-
474
- var EVENT_TYPE_OTHER = window.mParticle.EventType.Other;
475
-
476
- window.mParticle.logEvent(
477
- EVENT_NAME_SELECT_PLACEMENTS,
478
- EVENT_TYPE_OTHER,
479
- attributes
480
- );
481
- }
482
-
483
- /**
484
- * Enables optional Integration Launcher extensions before selecting placements
485
- * @param {string} extensionName - Name of the extension to enable
486
- * @returns {Promise<*>} A Promise resolving to the extension API if available
487
- */
488
- function use(extensionName) {
489
- if (!isKitReady()) {
490
- console.error('Rokt Kit: Not initialized');
491
- return Promise.reject(new Error('Rokt Kit: Not initialized'));
492
- }
493
- if (!extensionName || !isString(extensionName)) {
494
- return Promise.reject(
495
- new Error('Rokt Kit: Invalid extension name')
496
- );
497
- }
498
- return self.launcher.use(extensionName);
499
- }
500
-
501
- /**
502
- * Sets extension data for Rokt Web SDK
503
- * @param {Object} partnerExtensionData - The extension data object containing:
504
- * - [extensionName] {string}: Name of the extension
505
- * - [extensionName].options {Object}: Key-value pairs of options for the extension
506
- * @returns {void} Nothing is returned
507
- */
508
- function setExtensionData(partnerExtensionData) {
509
- if (!isKitReady()) {
510
- console.error('Rokt Kit: Not initialized');
511
- return;
512
- }
513
-
514
- window.Rokt.setExtensionData(partnerExtensionData);
515
- }
516
-
517
- function processEventQueue() {
518
- self.eventQueue.forEach(function (event) {
519
- processEvent(event);
520
- });
521
- self.eventQueue = [];
522
- }
523
-
524
- function processEvent(event) {
525
- if (!isKitReady()) {
526
- self.eventQueue.push(event);
527
- return;
528
- }
529
-
530
- _sendEventStream(event);
531
-
532
- if (
533
- typeof window.mParticle.Rokt.setLocalSessionAttribute !== 'function'
534
- ) {
535
- return;
536
- }
537
-
538
- if (!isEmpty(self.placementEventAttributeMappingLookup)) {
539
- applyPlacementEventAttributeMapping(event);
540
- }
541
-
542
- if (isEmpty(self.placementEventMappingLookup)) {
543
- return;
544
- }
545
-
546
- var hashedEvent = hashEventMessage(
547
- event.EventDataType,
548
- event.EventCategory,
549
- event.EventName
550
- );
551
-
552
- if (self.placementEventMappingLookup[hashedEvent]) {
553
- var mappedValue = self.placementEventMappingLookup[hashedEvent];
554
- window.mParticle.Rokt.setLocalSessionAttribute(mappedValue, true);
555
- }
556
- }
557
-
558
- function _enrichEvent(event) {
559
- return mergeObjects({}, event, {
560
- UserAttributes: self.userAttributes,
561
- });
562
- }
563
-
564
- function _sendEventStream(event) {
565
- if (window.Rokt && typeof window.Rokt.__event_stream__ === 'function') {
566
- if (self.eventStreamQueue.length) {
567
- var queuedEvents = self.eventStreamQueue;
568
- self.eventStreamQueue = [];
569
- for (var i = 0; i < queuedEvents.length; i++) {
570
- window.Rokt.__event_stream__(_enrichEvent(queuedEvents[i]));
571
- }
572
- }
573
- window.Rokt.__event_stream__(_enrichEvent(event));
574
- } else {
575
- self.eventStreamQueue.push(event);
576
- }
577
- }
578
-
579
- function _setRoktSessionId(sessionId) {
580
- if (!sessionId || typeof sessionId !== 'string') {
581
- return;
582
- }
583
- try {
584
- var mpInstance = window.mParticle.getInstance();
585
- if (
586
- mpInstance &&
587
- typeof mpInstance.setIntegrationAttribute === 'function'
588
- ) {
589
- mpInstance.setIntegrationAttribute(moduleId, {
590
- roktSessionId: sessionId,
591
- });
592
- }
593
- } catch (e) {
594
- // Best effort — never let this break the partner page
595
- }
596
- }
597
-
598
- function onUserIdentified(filteredUser) {
599
- self.filters.filteredUser = filteredUser;
600
- self.userAttributes = filteredUser.getAllUserAttributes();
601
- _sendEventStream(_buildIdentityEvent('identify', filteredUser));
602
- }
603
-
604
- function _buildIdentityEvent(eventName, filteredUser) {
605
- var mpid =
606
- filteredUser.getMPID && typeof filteredUser.getMPID === 'function'
607
- ? filteredUser.getMPID()
608
- : null;
609
- var sessionId =
610
- window.mParticle &&
611
- window.mParticle.sessionManager &&
612
- typeof window.mParticle.sessionManager.getSession === 'function'
613
- ? window.mParticle.sessionManager.getSession()
614
- : null;
615
- var userIdentities =
616
- filteredUser.getUserIdentities &&
617
- typeof filteredUser.getUserIdentities === 'function'
618
- ? filteredUser.getUserIdentities().userIdentities
619
- : null;
620
-
621
- return {
622
- EventName: eventName,
623
- EventDataType: 14, // MessageType.Profile
624
- Timestamp: Date.now(),
625
- MPID: mpid,
626
- SessionId: sessionId,
627
- UserIdentities: userIdentities,
628
- };
629
- }
630
-
631
- function onLoginComplete(filteredUser) {
632
- self.userAttributes = filteredUser.getAllUserAttributes();
633
- _sendEventStream(_buildIdentityEvent('login', filteredUser));
634
- }
635
-
636
- function onLogoutComplete(filteredUser) {
637
- self.userAttributes = filteredUser.getAllUserAttributes();
638
- _sendEventStream(_buildIdentityEvent('logout', filteredUser));
639
- }
640
-
641
- function onModifyComplete(filteredUser) {
642
- self.userAttributes = filteredUser.getAllUserAttributes();
643
- _sendEventStream(_buildIdentityEvent('modify_user', filteredUser));
644
- }
645
-
646
- function setUserAttribute(key, value) {
647
- self.userAttributes[key] = value;
648
- _sendEventStream(
649
- _buildIdentityEvent(
650
- 'set_user_attributes',
651
- self.filters.filteredUser || {}
652
- )
653
- );
654
- }
655
-
656
- function removeUserAttribute(key) {
657
- delete self.userAttributes[key];
658
- }
659
-
660
- function attachLauncher(accountId, launcherOptions) {
661
- var mpSessionId =
662
- window.mParticle &&
663
- window.mParticle.sessionManager &&
664
- typeof window.mParticle.sessionManager.getSession === 'function'
665
- ? window.mParticle.sessionManager.getSession()
666
- : undefined;
667
-
668
- var options = mergeObjects(
669
- {
670
- accountId: accountId,
671
- },
672
- launcherOptions || {},
673
- mpSessionId ? { mpSessionId: mpSessionId } : {}
674
- );
675
-
676
- if (isPartnerInLocalLauncherTestGroup()) {
677
- var localLauncher = window.Rokt.createLocalLauncher(options);
678
- initRoktLauncher(localLauncher);
679
- } else {
680
- window.Rokt.createLauncher(options)
681
- .then(initRoktLauncher)
682
- .catch(function (err) {
683
- console.error('Error creating Rokt launcher:', err);
684
- });
685
- }
686
- }
687
-
688
- function initRoktLauncher(launcher) {
689
- // Assign the launcher to a global variable for later access
690
- window.Rokt.currentLauncher = launcher;
691
- // Locally cache the launcher and filters
692
- self.launcher = launcher;
693
-
694
- var roktFilters = window.mParticle.Rokt.filters;
695
-
696
- if (!roktFilters) {
697
- console.warn('Rokt Kit: No filters have been set.');
698
- } else {
699
- self.filters = roktFilters;
700
- if (!roktFilters.filteredUser) {
701
- console.warn('Rokt Kit: No filtered user has been set.');
702
- }
703
- }
704
-
705
- // Kit must be initialized before attaching to the Rokt manager
706
- self.isInitialized = true;
707
-
708
- sendAdBlockMeasurementSignals(self.domain, self.integrationName);
709
-
710
- // Attaches the kit to the Rokt manager
711
- window.mParticle.Rokt.attachKit(self);
712
- processEventQueue();
713
- }
714
-
715
- // mParticle Kit Callback Methods
716
- function fetchOptimizely() {
717
- var forwarders = window.mParticle
718
- ._getActiveForwarders()
719
- .filter(function (forwarder) {
720
- return forwarder.name === 'Optimizely';
721
- });
722
-
723
- try {
724
- if (forwarders.length > 0 && window.optimizely) {
725
- // Get the state object
726
- var optimizelyState = window.optimizely.get('state');
727
- if (
728
- !optimizelyState ||
729
- !optimizelyState.getActiveExperimentIds
730
- ) {
731
- return {};
732
- }
733
- // Get active experiment IDs
734
- var activeExperimentIds =
735
- optimizelyState.getActiveExperimentIds();
736
- // Get variations for each active experiment
737
- var activeExperiments = activeExperimentIds.reduce(function (
738
- acc,
739
- expId
740
- ) {
741
- acc[
742
- 'rokt.custom.optimizely.experiment.' +
743
- expId +
744
- '.variationId'
745
- ] = optimizelyState.getVariationMap()[expId].id;
746
- return acc;
747
- },
748
- {});
749
- return activeExperiments;
750
- }
751
- } catch (error) {
752
- console.error('Error fetching Optimizely attributes:', error);
753
- }
754
- return {};
755
- }
756
-
757
- // Called by the mParticle Rokt Manager
758
- this.selectPlacements = selectPlacements;
759
- this.hashAttributes = hashAttributes;
760
- this.use = use;
761
-
762
- // Kit Callback Methods
763
- this.init = initForwarder;
764
- this.process = processEvent;
765
- this.setExtensionData = setExtensionData;
766
- this.setUserAttribute = setUserAttribute;
767
- this.onUserIdentified = onUserIdentified;
768
- this.onLoginComplete = onLoginComplete;
769
- this.onLogoutComplete = onLogoutComplete;
770
- this.onModifyComplete = onModifyComplete;
771
- this.removeUserAttribute = removeUserAttribute;
772
-
773
- /**
774
- * Checks if the Rokt kit is ready to use.
775
- * Both conditions must be true:
776
- * 1. self.isInitialized - Set after successful initialization of the kit
777
- * 2. self.launcher - The Rokt launcher instance must be available
778
- * @returns {boolean} Whether the kit is ready for use
779
- */
780
- function isKitReady() {
781
- return !!(self.isInitialized && self.launcher);
782
- }
783
-
784
- function isPartnerInLocalLauncherTestGroup() {
785
- return (
786
- window.mParticle.config &&
787
- window.mParticle.config.isLocalLauncherEnabled &&
788
- _isAssignedToSampleGroup()
789
- );
790
- }
791
-
792
- function _isAssignedToSampleGroup() {
793
- var LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD = 0.5;
794
- return Math.random() > LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD;
795
- }
796
-
797
- function captureTiming(metricName) {
798
- if (
799
- window &&
800
- window.mParticle &&
801
- window.mParticle.captureTiming &&
802
- metricName
803
- ) {
804
- window.mParticle.captureTiming(metricName);
805
- }
806
- }
807
-
808
- function createAutoRemovedIframe(src) {
809
- var iframe = document.createElement('iframe');
810
- iframe.style.display = 'none';
811
- iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
812
- iframe.src = src;
813
- iframe.onload = function () {
814
- iframe.onload = null;
815
- if (iframe.parentNode) {
816
- iframe.parentNode.removeChild(iframe);
817
- }
818
- };
819
- var target = document.body || document.head;
820
- if (target) {
821
- target.appendChild(iframe);
822
- }
823
- }
824
-
825
- var ADBLOCK_CONTROL_DOMAIN = 'apps.roktecommerce.com';
826
- var INIT_LOG_SAMPLING_RATE = 0.1;
827
- var _allowedOriginHashes = [-553112570, 549508659];
828
-
829
- function djb2(str) {
830
- var hash = 5381;
831
- for (var i = 0; i < str.length; i++) {
832
- hash = (hash << 5) + hash + str.charCodeAt(i);
833
- hash = hash & hash;
834
- }
835
- return hash;
836
- }
837
-
838
- function sendAdBlockMeasurementSignals(domain, version) {
839
- var originHash = djb2(window.location.origin);
840
- if (_allowedOriginHashes.indexOf(originHash) === -1) {
841
- return;
842
- }
843
-
844
- if (Math.random() >= INIT_LOG_SAMPLING_RATE) {
845
- return;
846
- }
847
-
848
- var guid = window.__rokt_li_guid__;
849
- if (!guid) {
850
- return;
851
- }
852
-
853
- var pageUrl = window.location.href.split('?')[0].split('#')[0];
854
- var params =
855
- 'version=' +
856
- encodeURIComponent(version) +
857
- '&launcherInstanceGuid=' +
858
- encodeURIComponent(guid) +
859
- '&pageUrl=' +
860
- encodeURIComponent(pageUrl);
861
-
862
- var existingDomain = domain || 'apps.rokt.com';
863
- createAutoRemovedIframe(
864
- 'https://' + existingDomain + '/v1/wsdk-init/index.html?' + params
865
- );
866
-
867
- createAutoRemovedIframe(
868
- 'https://' +
869
- ADBLOCK_CONTROL_DOMAIN +
870
- '/v1/wsdk-init/index.html?' +
871
- params +
872
- '&isControl=true'
873
- );
874
- }
875
- };
876
-
877
- function generateIntegrationName(customIntegrationName) {
878
- var coreSdkVersion = window.mParticle.getVersion();
879
- var kitVersion = "1.21.0";
880
- var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
881
-
882
- if (customIntegrationName) {
883
- name += '_' + customIntegrationName;
884
- }
885
- return name;
886
- }
887
-
888
- function getId() {
889
- return moduleId;
890
- }
891
-
892
- function register(config) {
893
- if (!config) {
894
- window.console.log(
895
- 'You must pass a config object to register the kit ' + name
896
- );
897
- return;
898
- }
899
- if (!isObject(config)) {
900
- window.console.log(
901
- "'config' must be an object. You passed in a " + typeof config
902
- );
903
- return;
904
- }
905
-
906
- if (isObject(config.kits)) {
907
- config.kits[name] = {
908
- constructor: constructor,
909
- };
910
- } else {
911
- config.kits = {};
912
- config.kits[name] = {
913
- constructor: constructor,
914
- };
915
- }
916
- window.console.log(
917
- 'Successfully registered ' + name + ' to your mParticle configuration'
918
- );
919
- }
920
-
921
- function isObject(val) {
922
- return (
923
- val != null && typeof val === 'object' && Array.isArray(val) === false
924
- );
925
- }
926
-
927
- function mergeObjects() {
928
- var resObj = {};
929
- for (var i = 0; i < arguments.length; i += 1) {
930
- var obj = arguments[i],
931
- keys = Object.keys(obj);
932
- for (var j = 0; j < keys.length; j += 1) {
933
- resObj[keys[j]] = obj[keys[j]];
934
- }
935
- }
936
- return resObj;
937
- }
938
-
939
- function parseSettingsString(settingsString) {
940
- if (!settingsString) {
941
- return [];
942
- }
943
- try {
944
- return JSON.parse(settingsString.replace(/&quot;/g, '"'));
945
- } catch (error) {
946
- console.error('Settings string contains invalid JSON');
947
- }
948
- return [];
949
- }
950
-
951
- function extractRoktExtensions(settingsString) {
952
- var settings = settingsString ? parseSettingsString(settingsString) : [];
953
- var roktExtensions = [];
954
-
955
- for (var i = 0; i < settings.length; i++) {
956
- roktExtensions.push(settings[i].value);
957
- }
958
-
959
- return roktExtensions;
960
- }
961
-
962
- function generateMappedEventLookup(placementEventMapping) {
963
- if (!placementEventMapping) {
964
- return {};
965
- }
966
-
967
- var mappedEvents = {};
968
- for (var i = 0; i < placementEventMapping.length; i++) {
969
- var mapping = placementEventMapping[i];
970
- mappedEvents[mapping.jsmap] = mapping.value;
971
- }
972
- return mappedEvents;
973
- }
974
-
975
- function hashEventMessage(messageType, eventType, eventName) {
976
- return window.mParticle.generateHash(
977
- [messageType, eventType, eventName].join('')
978
- );
979
- }
980
-
981
- function isEmpty(value) {
982
- return value == null || !(Object.keys(value) || value).length;
983
- }
984
-
985
- function isString(value) {
986
- return typeof value === 'string';
987
- }
988
-
989
- if (window && window.mParticle && window.mParticle.addForwarder) {
990
- window.mParticle.addForwarder({
991
- name: name,
992
- constructor: constructor,
993
- getId: getId,
994
- });
995
- }
996
-
997
- var RoktKit = {
998
- register: register,
999
- };
1000
- var RoktKit_1 = RoktKit.register;
1001
-
1002
- exports.default = RoktKit;
1003
- exports.register = RoktKit_1;
1004
-
1005
- return exports;
1006
-
1007
- }({}));
1
+ var RoktKit=(function(I){"use strict";const p="Rokt",H="selectPlacements",F="apps.roktecommerce.com",k={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},b={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},z="apps.rokt-api.com/v1/log",Q="apps.rokt-api.com/v1/errors",V=10;function s(){return window.mParticle}function M(n,t){const o=["https://",typeof n<"u"?n:"apps.rokt.com","/wsdk/integrations/launcher.js"].join("");return!t||t.length===0?o:o+"?extensions="+t.join(",")}function S(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function y(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function T(n){const t=n?y(n):[],e=[];for(let i=0;i<t.length;i++)e.push(t[i].value);return e}function P(n){if(!n)return{};const t={};for(let e=0;e<n.length;e++){const i=n[e];t[i.jsmap]=i.value}return t}function U(n){const t={};if(!Array.isArray(n))return t;for(let e=0;e<n.length;e++){const i=n[e];if(!i||!E(i.value)||!E(i.map))continue;const r=i.value,o=i.map;t[r]||(t[r]=[]),t[r].push({eventAttributeKey:o,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return t}function C(n,t,e){return s().generateHash([n,t,e].join(""))}function m(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function E(n){return typeof n=="string"}function Y(n){let i="mParticle_wsdkv_"+s().getVersion()+"_kitv_"+"1.23.0";return n&&(i+="_"+n),i}function D(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e),t=t&t;return t}function L(n){const t=document.createElement("iframe");t.style.display="none",t.setAttribute("sandbox","allow-scripts allow-same-origin"),t.src=n,t.onload=function(){t.onload=null,t.parentNode&&t.parentNode.removeChild(t)};const e=document.body||document.head;e&&e.appendChild(t)}function K(n,t){const e=D(window.location.origin);if(g._allowedOriginHashes.indexOf(e)===-1||Math.random()>=.1)return;const r=window.__rokt_li_guid__;if(!r)return;const o=window.location.href.split("?")[0].split("#")[0],a="version="+encodeURIComponent(t??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o);L("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+a),L("https://"+F+"/v1/wsdk-init/index.html?"+a+"&isControl=true")}function W(){return typeof window<"u"&&!!window.ROKT_DOMAIN}function q(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function B(){return typeof window<"u"?window.location?.href:void 0}function J(){return typeof window<"u"?window.navigator?.userAgent:void 0}class x{constructor(){this._logCount={}}incrementAndCheck(t){const i=(this._logCount[t]||0)+1;return this._logCount[t]=i,i>V}}class N{constructor(t,e,i,r,o){this._reporter="mp-wsdk";const a=t?.isLoggingEnabled===!0||t?.isLoggingEnabled==="true";this._integrationName=e||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=o||new x,this._isEnabled=q()||W()&&a}send(t,e,i,r,o,a){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(e)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:e,code:r||k.UNKNOWN_ERROR,url:B(),deviceInfo:J(),stackTrace:o,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(t,{method:"POST",headers:u,body:JSON.stringify(c)}).catch(f=>{console.error("ReportingTransport: Failed to send log",f),a&&a(f)})}catch(c){console.error("ReportingTransport: Failed to send log",c),a&&a(c)}}}class j{constructor(t,e,i,r,o){this._transport=new N(t,e,i,r,o),this._errorUrl="https://"+(t?.errorUrl||Q)}report(t){if(!t)return;const e=t.severity||b.ERROR;this._transport.send(this._errorUrl,e,t.message,t.code,t.stackTrace)}}class G{constructor(t,e,i,r,o,a){this._transport=new N(t,i,r,o,a),this._loggingUrl="https://"+(t?.loggingUrl||z),this._errorReportingService=e}log(t){t&&this._transport.send(this._loggingUrl,b.INFO,t.message,t.code,void 0,e=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+e.message,code:k.UNKNOWN_ERROR,severity:b.ERROR})})}}const d=class d{constructor(){this.name=p,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}getEventAttributeValue(t,e){const i=t&&t.EventAttributes;return!i||typeof i[e]>"u"?null:i[e]}doesEventAttributeConditionMatch(t,e){if(!t||!E(t.operator))return!1;const i=t.operator.toLowerCase(),r=t.attributeValue;return i==="exists"?e!==null:e==null?!1:i==="equals"?String(e)===String(r):i==="contains"?String(e).indexOf(String(r))!==-1:!1}doesEventMatchRule(t,e){if(!e||!E(e.eventAttributeKey))return!1;const i=e.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(t,e.eventAttributeKey);if(i.length===0)return r!==null;for(let o=0;o<i.length;o++)if(!this.doesEventAttributeConditionMatch(i[o],r))return!1;return!0}applyPlacementEventAttributeMapping(t){const e=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<e.length;i++){const r=e[i],o=this.placementEventAttributeMappingLookup[r];if(m(o))continue;let a=!0;for(let c=0;c<o.length;c++)if(!this.doesEventMatchRule(t,o[c])){a=!1;break}a&&s().Rokt.setLocalSessionAttribute?.(r,!0)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}returnUserIdentities(t){if(!t||!t.getUserIdentities)return{};const e=t.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(e)}returnLocalSessionAttributes(){return!s().Rokt||typeof s().Rokt.getLocalSessionAttributes!="function"?{}:m(this.placementEventMappingLookup)&&m(this.placementEventAttributeMappingLookup)?{}:s().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(t){const e={...t||{}},i=this._mappedEmailSha256Key;return i&&t[i]&&(e[d.EMAIL_SHA256_KEY]=t[i]),i&&delete e[i],e}logSelectPlacementsEvent(t){if(!window.mParticle||typeof s().logEvent!="function"||!S(t))return;const e=s().EventType.Other;s().logEvent(H,e,t)}processEventQueue(){this.eventQueue.forEach(t=>{this.process(t)}),this.eventQueue=[]}enrichEvent(t){return{...t,UserAttributes:this.userAttributes}}sendEventStream(t){if(window.Rokt&&typeof window.Rokt.__event_stream__=="function"){if(this.eventStreamQueue.length){const e=this.eventStreamQueue;this.eventStreamQueue=[];for(let i=0;i<e.length;i++)window.Rokt.__event_stream__(this.enrichEvent(e[i]))}window.Rokt.__event_stream__(this.enrichEvent(t))}else this.eventStreamQueue.push(t)}setRoktSessionId(t){if(!(!t||typeof t!="string"))try{const e=s().getInstance();e&&typeof e.setIntegrationAttribute=="function"&&e.setIntegrationAttribute(181,{roktSessionId:t})}catch{}}buildIdentityEvent(t,e){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;return{EventName:t,EventDataType:14,EventCategory:0,Timestamp:Date.now(),MPID:i,SessionId:r,UserIdentities:o}}attachLauncher(t,e){const i=s()&&s().sessionManager&&typeof s().sessionManager.getSession=="function"?s().sessionManager.getSession():void 0,r={accountId:t,...e||{},...i?{mpSessionId:i}:{}};if(this.isPartnerInLocalLauncherTestGroup()){const o=window.Rokt.createLocalLauncher(r);this.initRoktLauncher(o)}else window.Rokt.createLauncher(r).then(o=>this.initRoktLauncher(o)).catch(o=>{console.error("Error creating Rokt launcher:",o)})}initRoktLauncher(t){window.Rokt&&(window.Rokt.currentLauncher=t),this.launcher=t;const e=s().Rokt?.filters;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,K(this.domain,this.integrationName),s().Rokt.attachKit(this),this.processEventQueue()}fetchOptimizely(){const t=s()._getActiveForwarders().filter(e=>e.name==="Optimizely");try{if(t.length>0&&window.optimizely){const e=window.optimizely.get("state");return!e||!e.getActiveExperimentIds?{}:e.getActiveExperimentIds().reduce((o,a)=>(o["rokt.custom.optimizely.experiment."+a+".variationId"]=e.getVariationMap()[a].id,o),{})}}catch(e){console.error("Error fetching Optimizely attributes:",e)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isPartnerInLocalLauncherTestGroup(){return!!(s().config&&s().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(t){window&&s()&&s().captureTiming&&t&&s().captureTiming(t)}init(t,e,i,r,o){const a=t.accountId,c=T(t.roktExtensions);this.userAttributes=o||{},this._onboardingExpProvider=t.onboardingExpProvider;const u=y(t.placementEventMapping);this.placementEventMappingLookup=P(u);const f=y(t.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=U(f),t.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=t.hashedEmailUserIdentityType.toLowerCase());const w=s().Rokt?.domain,h={...s().Rokt?.launcherOptions||{}};this.integrationName=Y(h.integrationName),h.integrationName=this.integrationName,this.domain=w;const _={loggingUrl:t.loggingUrl,errorUrl:t.errorUrl,isLoggingEnabled:t.isLoggingEnabled==="true"||t.isLoggingEnabled===!0},A=new j(_,this.integrationName,window.__rokt_li_guid__,t.accountId),R=new G(_,A,this.integrationName,window.__rokt_li_guid__,t.accountId);if(this.errorReportingService=A,this.loggingService=R,s()._registerErrorReportingService&&s()._registerErrorReportingService(A),s()._registerLoggingService&&s()._registerLoggingService(R),i){this.testHelpers={generateLauncherScript:M,extractRoktExtensions:T,hashEventMessage:C,parseSettingsString:y,generateMappedEventLookup:P,generateMappedEventAttributeLookup:U,sendAdBlockMeasurementSignals:K,createAutoRemovedIframe:L,djb2:D,setAllowedOriginHashes:v=>{d._allowedOriginHashes=v},ReportingTransport:N,ErrorReportingService:j,LoggingService:G,RateLimiter:x,ErrorCodes:k,WSDKErrorSeverity:b},this.attachLauncher(a,h);return}if(this.isLauncherReadyToAttach())this.attachLauncher(a,h);else{const v=document.head||document.body,l=document.createElement("script");l.type="text/javascript",l.src=M(w,c),l.async=!0,l.crossOrigin="anonymous",l.fetchPriority="high",l.id="rokt-launcher",l.onload=()=>{this.isLauncherReadyToAttach()?this.attachLauncher(a,h):console.error("Rokt object is not available after script load.")},l.onerror=O=>{console.error("Error loading Rokt launcher script:",O)},v.appendChild(l),this.captureTiming(d.PERFORMANCE_MARKS.RoktScriptAppended)}}process(t){if(!this.isKitReady()){this.eventQueue.push(t);return}if(this.sendEventStream(t),typeof s().Rokt?.setLocalSessionAttribute!="function"||(m(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(t),m(this.placementEventMappingLookup)))return;const e=C(t.EventDataType,t.EventCategory,t.EventName??"");if(this.placementEventMappingLookup[String(e)]){const i=this.placementEventMappingLookup[String(e)];s().Rokt.setLocalSessionAttribute?.(i,!0)}}setExtensionData(t){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(t)}setUserAttribute(t,e){this.userAttributes[t]=e,this.sendEventStream(this.buildIdentityEvent("set_user_attributes",this.filters.filteredUser??{}))}removeUserAttribute(t){delete this.userAttributes[t]}onUserIdentified(t){this.filters.filteredUser=t,this.userAttributes=t.getAllUserAttributes(),this.sendEventStream(this.buildIdentityEvent("identify",t))}onLoginComplete(t){this.userAttributes=t.getAllUserAttributes(),this.sendEventStream(this.buildIdentityEvent("login",t))}onLogoutComplete(t){this.userAttributes=t.getAllUserAttributes(),this.sendEventStream(this.buildIdentityEvent("logout",t))}onModifyComplete(t){this.userAttributes=t.getAllUserAttributes(),this.sendEventStream(this.buildIdentityEvent("modify_user",t))}selectPlacements(t){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;let u;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;const f=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},w=this.returnUserIdentities(a),h=this.returnLocalSessionAttributes(),_={...w,...u,...f,...h,mpid:c},A={...t,attributes:_},R=this.launcher.selectPlacements(A),v=()=>this.logSelectPlacementsEvent(_);return Promise.resolve(R).then(l=>l?.context?.sessionId?.then(O=>this.setRoktSessionId(O))).catch(()=>{}).finally(v),R}hashAttributes(t){return this.isKitReady()?this.launcher.hashAttributes(t):(console.error("Rokt Kit: Not initialized"),null)}use(t){return this.isKitReady()?!t||!E(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")))}};d._allowedOriginHashes=[-553112570,549508659],d.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},d.EMAIL_SHA256_KEY="emailsha256";let g=d;function X(){return 181}function Z(n){if(!n){window.console.log("You must pass a config object to register the kit "+p);return}if(!S(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}S(n.kits)?n.kits[p]={constructor:g}:(n.kits={},n.kits[p]={constructor:g}),window.console.log("Successfully registered "+p+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&s().addForwarder&&s().addForwarder({name:p,constructor:g,getId:X}),I.register=Z,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"}),I})({});
2
+ //# sourceMappingURL=Rokt-Kit.iife.js.map