@@ -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