@mparticle/web-rokt-kit 1.13.0 → 1.14.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.
@@ -19,6 +19,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
19
19
 
20
20
  var name = 'Rokt';
21
21
  var moduleId = 181;
22
+ var EVENT_NAME_SELECT_PLACEMENTS = 'selectPlacements';
22
23
 
23
24
  var constructor = function () {
24
25
  var self = this;
@@ -27,7 +28,6 @@ var constructor = function () {
27
28
  };
28
29
 
29
30
  var EMAIL_SHA256_KEY = 'emailsha256';
30
- var EMAIL_KEY = 'email';
31
31
 
32
32
  // Dynamic identity type for Rokt's emailsha256 identity value which MP doesn't natively support - will be set during initialization
33
33
  var mappedEmailSha256Key;
@@ -63,6 +63,14 @@ var constructor = function () {
63
63
  return baseUrl + '?extensions=' + extensions.join(',');
64
64
  }
65
65
 
66
+ /**
67
+ * Checks if Rokt launcher is available and ready to attach
68
+ * @returns {boolean} True if launcher can be attached
69
+ */
70
+ function isLauncherReadyToAttach() {
71
+ return window.Rokt && typeof window.Rokt.createLauncher === 'function';
72
+ }
73
+
66
74
  /**
67
75
  * Passes attributes to the Rokt Web SDK for client-side hashing
68
76
  * @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
@@ -125,7 +133,9 @@ var constructor = function () {
125
133
  return;
126
134
  }
127
135
 
128
- if (!window.Rokt || !(window.Rokt && window.Rokt.currentLauncher)) {
136
+ if (isLauncherReadyToAttach()) {
137
+ attachLauncher(accountId, launcherOptions);
138
+ } else {
129
139
  var target = document.head || document.body;
130
140
  var script = document.createElement('script');
131
141
  script.type = 'text/javascript';
@@ -136,12 +146,7 @@ var constructor = function () {
136
146
  script.id = 'rokt-launcher';
137
147
 
138
148
  script.onload = function () {
139
- // Once the script loads, ensure the Rokt object is available
140
- if (
141
- window.Rokt &&
142
- typeof window.Rokt.createLauncher === 'function' &&
143
- window.Rokt.currentLauncher === undefined
144
- ) {
149
+ if (isLauncherReadyToAttach()) {
145
150
  attachLauncher(accountId, launcherOptions);
146
151
  } else {
147
152
  console.error(
@@ -156,8 +161,6 @@ var constructor = function () {
156
161
 
157
162
  target.appendChild(script);
158
163
  captureTiming(PerformanceMarks.RoktScriptAppended);
159
- } else {
160
- console.warn('Unable to find Rokt on the page');
161
164
  }
162
165
  }
163
166
  /**
@@ -189,24 +192,15 @@ var constructor = function () {
189
192
 
190
193
  function replaceOtherIdentityWithEmailsha256(userIdentities) {
191
194
  var newUserIdentities = mergeObjects({}, userIdentities || {});
192
- if (userIdentities.hasOwnProperty(mappedEmailSha256Key)) {
195
+ if (userIdentities[mappedEmailSha256Key]) {
193
196
  newUserIdentities[EMAIL_SHA256_KEY] =
194
197
  userIdentities[mappedEmailSha256Key];
195
- delete newUserIdentities[mappedEmailSha256Key];
196
198
  }
199
+ delete newUserIdentities[mappedEmailSha256Key];
197
200
 
198
201
  return newUserIdentities;
199
202
  }
200
203
 
201
- function sanitizeEmailIdentities(_data) {
202
- var data = mergeObjects({}, _data || {});
203
- if (_data.hasOwnProperty(EMAIL_SHA256_KEY)) {
204
- delete data[EMAIL_KEY];
205
- }
206
-
207
- return data;
208
- }
209
-
210
204
  /**
211
205
  * Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options
212
206
  * @see https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options/
@@ -266,12 +260,41 @@ var constructor = function () {
266
260
  );
267
261
 
268
262
  var selectPlacementsOptions = mergeObjects(options, {
269
- attributes: sanitizeEmailIdentities(selectPlacementsAttributes),
263
+ attributes: selectPlacementsAttributes,
270
264
  });
271
265
 
266
+ // Log custom event for selectPlacements call
267
+ logSelectPlacementsEvent(selectPlacementsAttributes);
268
+
272
269
  return self.launcher.selectPlacements(selectPlacementsOptions);
273
270
  }
274
271
 
272
+ /**
273
+ * Logs a custom event when selectPlacements is called
274
+ * This enables visibility and troubleshooting
275
+ * @param {Object} attributes - The attributes sent to Rokt
276
+ */
277
+ function logSelectPlacementsEvent(attributes) {
278
+ if (
279
+ !window.mParticle ||
280
+ typeof window.mParticle.logEvent !== 'function'
281
+ ) {
282
+ return;
283
+ }
284
+
285
+ if (!isObject(attributes)) {
286
+ return;
287
+ }
288
+
289
+ var EVENT_TYPE_OTHER = window.mParticle.EventType.Other;
290
+
291
+ window.mParticle.logEvent(
292
+ EVENT_NAME_SELECT_PLACEMENTS,
293
+ EVENT_TYPE_OTHER,
294
+ attributes
295
+ );
296
+ }
297
+
275
298
  /**
276
299
  * Enables optional Integration Launcher extensions before selecting placements
277
300
  * @param {string} extensionName - Name of the extension to enable
@@ -488,7 +511,7 @@ var constructor = function () {
488
511
 
489
512
  function generateIntegrationName(customIntegrationName) {
490
513
  var coreSdkVersion = window.mParticle.getVersion();
491
- var kitVersion = "1.13.0";
514
+ var kitVersion = "1.14.0";
492
515
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
493
516
 
494
517
  if (customIntegrationName) {
@@ -18,6 +18,7 @@ var RoktKit = (function (exports) {
18
18
 
19
19
  var name = 'Rokt';
20
20
  var moduleId = 181;
21
+ var EVENT_NAME_SELECT_PLACEMENTS = 'selectPlacements';
21
22
 
22
23
  var constructor = function () {
23
24
  var self = this;
@@ -26,7 +27,6 @@ var RoktKit = (function (exports) {
26
27
  };
27
28
 
28
29
  var EMAIL_SHA256_KEY = 'emailsha256';
29
- var EMAIL_KEY = 'email';
30
30
 
31
31
  // Dynamic identity type for Rokt's emailsha256 identity value which MP doesn't natively support - will be set during initialization
32
32
  var mappedEmailSha256Key;
@@ -62,6 +62,14 @@ var RoktKit = (function (exports) {
62
62
  return baseUrl + '?extensions=' + extensions.join(',');
63
63
  }
64
64
 
65
+ /**
66
+ * Checks if Rokt launcher is available and ready to attach
67
+ * @returns {boolean} True if launcher can be attached
68
+ */
69
+ function isLauncherReadyToAttach() {
70
+ return window.Rokt && typeof window.Rokt.createLauncher === 'function';
71
+ }
72
+
65
73
  /**
66
74
  * Passes attributes to the Rokt Web SDK for client-side hashing
67
75
  * @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
@@ -124,7 +132,9 @@ var RoktKit = (function (exports) {
124
132
  return;
125
133
  }
126
134
 
127
- if (!window.Rokt || !(window.Rokt && window.Rokt.currentLauncher)) {
135
+ if (isLauncherReadyToAttach()) {
136
+ attachLauncher(accountId, launcherOptions);
137
+ } else {
128
138
  var target = document.head || document.body;
129
139
  var script = document.createElement('script');
130
140
  script.type = 'text/javascript';
@@ -135,12 +145,7 @@ var RoktKit = (function (exports) {
135
145
  script.id = 'rokt-launcher';
136
146
 
137
147
  script.onload = function () {
138
- // Once the script loads, ensure the Rokt object is available
139
- if (
140
- window.Rokt &&
141
- typeof window.Rokt.createLauncher === 'function' &&
142
- window.Rokt.currentLauncher === undefined
143
- ) {
148
+ if (isLauncherReadyToAttach()) {
144
149
  attachLauncher(accountId, launcherOptions);
145
150
  } else {
146
151
  console.error(
@@ -155,8 +160,6 @@ var RoktKit = (function (exports) {
155
160
 
156
161
  target.appendChild(script);
157
162
  captureTiming(PerformanceMarks.RoktScriptAppended);
158
- } else {
159
- console.warn('Unable to find Rokt on the page');
160
163
  }
161
164
  }
162
165
  /**
@@ -188,24 +191,15 @@ var RoktKit = (function (exports) {
188
191
 
189
192
  function replaceOtherIdentityWithEmailsha256(userIdentities) {
190
193
  var newUserIdentities = mergeObjects({}, userIdentities || {});
191
- if (userIdentities.hasOwnProperty(mappedEmailSha256Key)) {
194
+ if (userIdentities[mappedEmailSha256Key]) {
192
195
  newUserIdentities[EMAIL_SHA256_KEY] =
193
196
  userIdentities[mappedEmailSha256Key];
194
- delete newUserIdentities[mappedEmailSha256Key];
195
197
  }
198
+ delete newUserIdentities[mappedEmailSha256Key];
196
199
 
197
200
  return newUserIdentities;
198
201
  }
199
202
 
200
- function sanitizeEmailIdentities(_data) {
201
- var data = mergeObjects({}, _data || {});
202
- if (_data.hasOwnProperty(EMAIL_SHA256_KEY)) {
203
- delete data[EMAIL_KEY];
204
- }
205
-
206
- return data;
207
- }
208
-
209
203
  /**
210
204
  * Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options
211
205
  * @see https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options/
@@ -265,12 +259,41 @@ var RoktKit = (function (exports) {
265
259
  );
266
260
 
267
261
  var selectPlacementsOptions = mergeObjects(options, {
268
- attributes: sanitizeEmailIdentities(selectPlacementsAttributes),
262
+ attributes: selectPlacementsAttributes,
269
263
  });
270
264
 
265
+ // Log custom event for selectPlacements call
266
+ logSelectPlacementsEvent(selectPlacementsAttributes);
267
+
271
268
  return self.launcher.selectPlacements(selectPlacementsOptions);
272
269
  }
273
270
 
271
+ /**
272
+ * Logs a custom event when selectPlacements is called
273
+ * This enables visibility and troubleshooting
274
+ * @param {Object} attributes - The attributes sent to Rokt
275
+ */
276
+ function logSelectPlacementsEvent(attributes) {
277
+ if (
278
+ !window.mParticle ||
279
+ typeof window.mParticle.logEvent !== 'function'
280
+ ) {
281
+ return;
282
+ }
283
+
284
+ if (!isObject(attributes)) {
285
+ return;
286
+ }
287
+
288
+ var EVENT_TYPE_OTHER = window.mParticle.EventType.Other;
289
+
290
+ window.mParticle.logEvent(
291
+ EVENT_NAME_SELECT_PLACEMENTS,
292
+ EVENT_TYPE_OTHER,
293
+ attributes
294
+ );
295
+ }
296
+
274
297
  /**
275
298
  * Enables optional Integration Launcher extensions before selecting placements
276
299
  * @param {string} extensionName - Name of the extension to enable
@@ -487,7 +510,7 @@ var RoktKit = (function (exports) {
487
510
 
488
511
  function generateIntegrationName(customIntegrationName) {
489
512
  var coreSdkVersion = window.mParticle.getVersion();
490
- var kitVersion = "1.13.0";
513
+ var kitVersion = "1.14.0";
491
514
  var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
492
515
 
493
516
  if (customIntegrationName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "files": [
@@ -19,13 +19,17 @@
19
19
  "test:debug": "npm run build && npm run build:test && DEBUG=true karma start test/karma.config.js"
20
20
  },
21
21
  "publishConfig": {
22
- "access": "public"
22
+ "access": "public",
23
+ "provenance": true,
24
+ "registry": "https://registry.npmjs.org"
23
25
  },
24
26
  "devDependencies": {
25
27
  "@rollup/plugin-json": "^6.1.0",
26
- "@semantic-release/changelog": "^5.0.1",
27
- "@semantic-release/exec": "^5.0.0",
28
- "@semantic-release/git": "^9.0.0",
28
+ "@semantic-release/changelog": "^6.0.3",
29
+ "@semantic-release/exec": "^6.0.3",
30
+ "@semantic-release/git": "^10.0.1",
31
+ "@semantic-release/npm": "^13.1.2",
32
+ "semantic-release": "^24.2.0",
29
33
  "mocha": "^5.2.0",
30
34
  "chai": "^4.2.0",
31
35
  "eslint": "^7.25.0",
@@ -46,7 +50,7 @@
46
50
  "watchify": "^3.11.0"
47
51
  },
48
52
  "dependencies": {
49
- "@mparticle/web-sdk": "^2.36.0"
53
+ "@mparticle/web-sdk": "^2.56.0"
50
54
  },
51
55
  "license": "Apache-2.0"
52
56
  }