Skip to content

Commit cd4daea

Browse files
chore(build): Generate latest bundle [skip ci]
1 parent 8418e83 commit cd4daea

2 files changed

Lines changed: 82 additions & 18 deletions

File tree

dist/Rokt-Kit.common.js

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ var constructor = function () {
3434
self.filteredUser = {};
3535
self.userAttributes = {};
3636

37+
/**
38+
* Passes attributes to the Rokt Web SDK for client-side hashing
39+
* @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
40+
* @param {Object} attributes - The attributes to be hashed
41+
* @returns {Promise<Object|null>} A Promise resolving to the
42+
* hashed attributes from the launcher, or `null` if the kit is not initialized
43+
*/
44+
function hashAttributes(attributes) {
45+
if (!isInitialized()) {
46+
console.error('Rokt Kit: Not initialized');
47+
return null;
48+
}
49+
return self.launcher.hashAttributes(attributes);
50+
}
51+
3752
function initForwarder(
3853
settings,
3954
_service,
@@ -85,12 +100,15 @@ var constructor = function () {
85100
}
86101
}
87102

103+
/**
104+
* Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options
105+
* @see https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options/
106+
* @param {Object} options - The options object for selecting placements containing:
107+
* - identifier {string}: The placement identifier
108+
* - attributes {Object}: Optional attributes to merge with existing attributes
109+
* @returns {Promise<void>} A Promise resolving to the Rokt launcher's selectPlacements method with processed attributes
110+
*/
88111
function selectPlacements(options) {
89-
// https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options/
90-
// options should contain:
91-
// - identifier
92-
// - attributes
93-
94112
var attributes = (options && options.attributes) || {};
95113
var placementAttributes = mergeObjects(self.userAttributes, attributes);
96114

@@ -162,7 +180,7 @@ var constructor = function () {
162180
'wsdkv_' +
163181
window.mParticle.getVersion() +
164182
'_kitv_' +
165-
"1.2.1",
183+
"1.3.0",
166184
})
167185
.then(function (launcher) {
168186
// Assign the launcher to a global variable for later access
@@ -196,9 +214,6 @@ var constructor = function () {
196214
});
197215
}
198216

199-
// Called by the mParticle Rokt Manager
200-
this.selectPlacements = selectPlacements;
201-
202217
// mParticle Kit Callback Methods
203218
function fetchOptimizely() {
204219
var forwarders = window.mParticle
@@ -240,10 +255,27 @@ var constructor = function () {
240255
}
241256
return {};
242257
}
258+
259+
// Called by the mParticle Rokt Manager
260+
this.selectPlacements = selectPlacements;
261+
this.hashAttributes = hashAttributes;
262+
263+
// Kit Callback Methods
243264
this.init = initForwarder;
244265
this.setUserAttribute = setUserAttribute;
245266
this.onUserIdentified = onUserIdentified;
246267
this.removeUserAttribute = removeUserAttribute;
268+
269+
/**
270+
* Checks if the kit is properly initialized and ready for use.
271+
* Both conditions must be true:
272+
* 1. self.isInitialized - Set after successful initialization of the kit
273+
* 2. self.launcher - The Rokt launcher instance must be available
274+
* @returns {boolean} Whether the kit is fully initialized
275+
*/
276+
function isInitialized() {
277+
return !!(self.isInitialized && self.launcher);
278+
}
247279
};
248280

249281
function getId() {

dist/Rokt-Kit.iife.js

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ var RoktKit = (function (exports) {
3333
self.filteredUser = {};
3434
self.userAttributes = {};
3535

36+
/**
37+
* Passes attributes to the Rokt Web SDK for client-side hashing
38+
* @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
39+
* @param {Object} attributes - The attributes to be hashed
40+
* @returns {Promise<Object|null>} A Promise resolving to the
41+
* hashed attributes from the launcher, or `null` if the kit is not initialized
42+
*/
43+
function hashAttributes(attributes) {
44+
if (!isInitialized()) {
45+
console.error('Rokt Kit: Not initialized');
46+
return null;
47+
}
48+
return self.launcher.hashAttributes(attributes);
49+
}
50+
3651
function initForwarder(
3752
settings,
3853
_service,
@@ -84,12 +99,15 @@ var RoktKit = (function (exports) {
8499
}
85100
}
86101

102+
/**
103+
* Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options
104+
* @see https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options/
105+
* @param {Object} options - The options object for selecting placements containing:
106+
* - identifier {string}: The placement identifier
107+
* - attributes {Object}: Optional attributes to merge with existing attributes
108+
* @returns {Promise<void>} A Promise resolving to the Rokt launcher's selectPlacements method with processed attributes
109+
*/
87110
function selectPlacements(options) {
88-
// https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options/
89-
// options should contain:
90-
// - identifier
91-
// - attributes
92-
93111
var attributes = (options && options.attributes) || {};
94112
var placementAttributes = mergeObjects(self.userAttributes, attributes);
95113

@@ -161,7 +179,7 @@ var RoktKit = (function (exports) {
161179
'wsdkv_' +
162180
window.mParticle.getVersion() +
163181
'_kitv_' +
164-
"1.2.1",
182+
"1.3.0",
165183
})
166184
.then(function (launcher) {
167185
// Assign the launcher to a global variable for later access
@@ -195,9 +213,6 @@ var RoktKit = (function (exports) {
195213
});
196214
}
197215

198-
// Called by the mParticle Rokt Manager
199-
this.selectPlacements = selectPlacements;
200-
201216
// mParticle Kit Callback Methods
202217
function fetchOptimizely() {
203218
var forwarders = window.mParticle
@@ -239,10 +254,27 @@ var RoktKit = (function (exports) {
239254
}
240255
return {};
241256
}
257+
258+
// Called by the mParticle Rokt Manager
259+
this.selectPlacements = selectPlacements;
260+
this.hashAttributes = hashAttributes;
261+
262+
// Kit Callback Methods
242263
this.init = initForwarder;
243264
this.setUserAttribute = setUserAttribute;
244265
this.onUserIdentified = onUserIdentified;
245266
this.removeUserAttribute = removeUserAttribute;
267+
268+
/**
269+
* Checks if the kit is properly initialized and ready for use.
270+
* Both conditions must be true:
271+
* 1. self.isInitialized - Set after successful initialization of the kit
272+
* 2. self.launcher - The Rokt launcher instance must be available
273+
* @returns {boolean} Whether the kit is fully initialized
274+
*/
275+
function isInitialized() {
276+
return !!(self.isInitialized && self.launcher);
277+
}
246278
};
247279

248280
function getId() {

0 commit comments

Comments
 (0)