File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ var constructor = function () {
2020 var self = this ;
2121 var EMAIL_SHA256_IDENTITY = 'emailsha256' ;
2222 var OTHER_IDENTITY = 'other' ;
23+ var PerformanceMarks = {
24+ RoktScriptAppended : 'mp:RoktScriptAppended' ,
25+ } ;
2326
2427 self . name = name ;
2528 self . moduleId = moduleId ;
@@ -137,6 +140,7 @@ var constructor = function () {
137140 } ;
138141
139142 target . appendChild ( script ) ;
143+ captureTiming ( PerformanceMarks . RoktScriptAppended ) ;
140144 } else {
141145 console . warn ( 'Unable to find Rokt on the page' ) ;
142146 }
@@ -444,6 +448,17 @@ var constructor = function () {
444448 var LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD = 0.5 ;
445449 return Math . random ( ) > LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD ;
446450 }
451+
452+ function captureTiming ( metricName ) {
453+ if (
454+ window &&
455+ window . mParticle &&
456+ window . mParticle . captureTiming &&
457+ metricName
458+ ) {
459+ window . mParticle . captureTiming ( metricName ) ;
460+ }
461+ }
447462} ;
448463
449464function generateIntegrationName ( customIntegrationName ) {
Original file line number Diff line number Diff line change @@ -541,6 +541,9 @@ describe('Rokt Forwarder', () => {
541541 window . mParticle . Rokt = window . Rokt ;
542542 window . mParticle . Rokt . attachKitCalled = false ;
543543
544+ // Ensure currentLauncher is undefined to trigger script appending
545+ window . Rokt . currentLauncher = undefined ;
546+
544547 // Set attachKit as async to allow for await calls in the test
545548 // This is necessary to simiulate a race condition between the
546549 // core sdk and the Rokt forwarder
@@ -567,6 +570,24 @@ describe('Rokt Forwarder', () => {
567570 } ;
568571 window . mParticle . config = undefined ;
569572 Math . random = ( ) => 1 ;
573+
574+ window . mParticle . captureTiming = function ( metricName ) {
575+ window . mParticle . Rokt . capturedPerformanceMetric = metricName ;
576+ } ;
577+ } ) ;
578+
579+ it ( 'should add a performance marker when the script is appended' , async ( ) => {
580+ await window . mParticle . forwarder . init (
581+ { accountId : '123456' } ,
582+ reportService . cb ,
583+ false ,
584+ null ,
585+ { }
586+ ) ;
587+
588+ window . mParticle . Rokt . capturedPerformanceMetric . should . equal (
589+ 'mp:RoktScriptAppended'
590+ ) ;
570591 } ) ;
571592
572593 it ( 'should create a remote launcher if the partner is not in the local launcher test group' , async ( ) => {
You can’t perform that action at this time.
0 commit comments