@@ -19,6 +19,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1919
2020var name = 'Rokt' ;
2121var moduleId = 181 ;
22+ var EVENT_NAME_SELECT_PLACEMENTS = 'selectPlacements' ;
2223
2324var constructor = function ( ) {
2425 var self = this ;
@@ -62,6 +63,14 @@ var constructor = function () {
6263 return baseUrl + '?extensions=' + extensions . join ( ',' ) ;
6364 }
6465
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+
6574 /**
6675 * Passes attributes to the Rokt Web SDK for client-side hashing
6776 * @see https://docs.rokt.com/developers/integration-guides/web/library/integration-launcher#hash-attributes
@@ -124,7 +133,9 @@ var constructor = function () {
124133 return ;
125134 }
126135
127- if ( ! window . Rokt || ! ( window . Rokt && window . Rokt . currentLauncher ) ) {
136+ if ( isLauncherReadyToAttach ( ) ) {
137+ attachLauncher ( accountId , launcherOptions ) ;
138+ } else {
128139 var target = document . head || document . body ;
129140 var script = document . createElement ( 'script' ) ;
130141 script . type = 'text/javascript' ;
@@ -135,12 +146,7 @@ var constructor = function () {
135146 script . id = 'rokt-launcher' ;
136147
137148 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- ) {
149+ if ( isLauncherReadyToAttach ( ) ) {
144150 attachLauncher ( accountId , launcherOptions ) ;
145151 } else {
146152 console . error (
@@ -155,8 +161,6 @@ var constructor = function () {
155161
156162 target . appendChild ( script ) ;
157163 captureTiming ( PerformanceMarks . RoktScriptAppended ) ;
158- } else {
159- console . warn ( 'Unable to find Rokt on the page' ) ;
160164 }
161165 }
162166 /**
@@ -259,9 +263,38 @@ var constructor = function () {
259263 attributes : selectPlacementsAttributes ,
260264 } ) ;
261265
266+ // Log custom event for selectPlacements call
267+ logSelectPlacementsEvent ( selectPlacementsAttributes ) ;
268+
262269 return self . launcher . selectPlacements ( selectPlacementsOptions ) ;
263270 }
264271
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+
265298 /**
266299 * Enables optional Integration Launcher extensions before selecting placements
267300 * @param {string } extensionName - Name of the extension to enable
@@ -478,7 +511,7 @@ var constructor = function () {
478511
479512function generateIntegrationName ( customIntegrationName ) {
480513 var coreSdkVersion = window . mParticle . getVersion ( ) ;
481- var kitVersion = "1.13.1 " ;
514+ var kitVersion = "1.14.0 " ;
482515 var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion ;
483516
484517 if ( customIntegrationName ) {
0 commit comments