@@ -19,6 +19,8 @@ export function createBenchmarkTest(scenarioName: string) {
1919 return {
2020 run ( runner : TestRunner ) {
2121 const metrics : Record < string , Metrics > = { }
22+ let sdkVersion : string
23+
2224 SCENARIO_CONFIGURATIONS . forEach ( ( scenarioConfiguration ) => {
2325 test ( `${ scenarioName } benchmark ${ scenarioConfiguration } ` , async ( { page } ) => {
2426 await page . setExtraHTTPHeaders ( { 'Accept-Language' : 'en-US' } )
@@ -33,13 +35,16 @@ export function createBenchmarkTest(scenarioName: string) {
3335
3436 await flushEvents ( page )
3537 metrics [ scenarioConfiguration ] = await stopProfiling ( )
38+ if ( ! sdkVersion ) {
39+ sdkVersion = await getSDKVersion ( page )
40+ }
3641 } )
3742 } )
3843
3944 test . afterAll ( async ( ) => {
40- reportToConsole ( metrics )
45+ reportToConsole ( metrics , sdkVersion )
4146 if ( isContinuousIntegration ) {
42- await reportToDatadog ( metrics , scenarioName )
47+ await reportToDatadog ( metrics , scenarioName , sdkVersion )
4348 }
4449 } )
4550 } ,
@@ -66,6 +71,7 @@ async function injectSDK(page: Page, scenarioConfiguration: ScenarioConfiguratio
6671 await page . addInitScript (
6772 ( { sdkBundleUrl, scenarioConfiguration, scenarioName, configuration } : PageInitScriptParameters ) => {
6873 function loadSDK ( ) {
74+ const browserWindow = window as BrowserWindow
6975 ; ( function ( h : any , o : Document , u : string , n : string , d : string ) {
7076 h = h [ d ] = h [ d ] || {
7177 q : [ ] ,
@@ -79,12 +85,12 @@ async function injectSDK(page: Page, scenarioConfiguration: ScenarioConfiguratio
7985 s . src = n
8086 o . head . appendChild ( s )
8187 } ) ( window , document , 'script' , sdkBundleUrl , 'DD_RUM' )
82- ; ( window as BrowserWindow ) . DD_RUM ?. onReady ( function ( ) {
83- ; ( window as BrowserWindow ) . DD_RUM ! . setGlobalContextProperty ( 'scenario' , {
88+ browserWindow . DD_RUM ?. onReady ( function ( ) {
89+ browserWindow . DD_RUM ! . setGlobalContextProperty ( 'scenario' , {
8490 configuration : scenarioConfiguration ,
8591 name : scenarioName ,
8692 } )
87- ; ( window as BrowserWindow ) . DD_RUM ! . init ( configuration as RumInitConfiguration )
93+ browserWindow . DD_RUM ! . init ( configuration as RumInitConfiguration )
8894 } )
8995 }
9096
@@ -99,6 +105,10 @@ async function injectSDK(page: Page, scenarioConfiguration: ScenarioConfiguratio
99105 )
100106}
101107
108+ async function getSDKVersion ( page : Page ) {
109+ return await page . evaluate ( ( ) => ( window as BrowserWindow ) . DD_RUM ?. version || '' )
110+ }
111+
102112function shouldInjectSDK ( scenarioConfiguration : ScenarioConfiguration ) : boolean {
103113 return ! [ 'none' , 'none_with_headers' ] . includes ( scenarioConfiguration )
104114}
0 commit comments