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