11import { test } from '@playwright/test'
22import type { Page } from '@playwright/test'
33import type { RumInitConfiguration } from '@datadog/browser-rum-core'
4- import type { Site } from '@datadog/browser-core'
54import type { BrowserWindow , Metrics } from './profiling.type'
65import { startProfiling } from './profilers'
76import { reportToConsole } from './reporters/reportToConsole'
@@ -10,9 +9,9 @@ import { isContinuousIntegration } from './environment'
109
1110const testAppUrl = 'https://df1fyr56hap9d.cloudfront.net/'
1211const sdkBundleUrl = 'https://df1fyr56hap9d.cloudfront.net/datadog-rum.js'
13- const applicationId = 'a81f40b8-e9bd-4805-9b66-4e4edc529a14 '
14- const clientToken = 'pubfe2e138a54296da76dd66f6b0b5f3d98 '
15- const datadogSite = 'datad0g .com' as Site
12+ const applicationId = '9fa62a5b-8a7e-429d-8466-8b111a4d4693 '
13+ const clientToken = 'pubab31fd1ab9d01d2b385a8aa3dd403b1d '
14+ const datadogSite = 'datadoghq .com'
1615const scenarioConfigurations = [ 'none' , 'rum' , 'rum_replay' , 'rum_profiling' , 'none_with_headers' ] as const
1716
1817type ScenarioConfiguration = ( typeof scenarioConfigurations ) [ number ]
@@ -64,12 +63,11 @@ async function injectSDK(page: Page, scenarioConfiguration: ScenarioConfiguratio
6463 applicationId,
6564 site : datadogSite ,
6665 profilingSampleRate : scenarioConfiguration === 'rum_profiling' ? 100 : 0 ,
67- trackBfcacheViews : true ,
68- allowUntrustedEvents : true ,
66+ sessionReplaySampleRate : scenarioConfiguration === 'rum_replay' ? 100 : 0 ,
6967 }
7068
7169 await page . addInitScript (
72- ( parameters : PageInitScriptParameters ) => {
70+ ( { sdkBundleUrl , scenarioConfiguration , scenarioName , configuration } : PageInitScriptParameters ) => {
7371 function loadSDK ( ) {
7472 ; ( function ( h : any , o : Document , u : string , n : string , d : string ) {
7573 h = h [ d ] = h [ d ] || {
@@ -83,13 +81,13 @@ async function injectSDK(page: Page, scenarioConfiguration: ScenarioConfiguratio
8381 s . async = true
8482 s . src = n
8583 o . head . appendChild ( s )
86- } ) ( window , document , 'script' , parameters . sdkBundleUrl , 'DD_RUM' )
84+ } ) ( window , document , 'script' , sdkBundleUrl , 'DD_RUM' )
8785 ; ( window as BrowserWindow ) . DD_RUM ?. onReady ( function ( ) {
8886 ; ( window as BrowserWindow ) . DD_RUM ! . setGlobalContextProperty ( 'scenario' , {
8987 configuration : scenarioConfiguration ,
9088 name : scenarioName ,
9189 } )
92- ; ( window as BrowserWindow ) . DD_RUM ! . init ( parameters . configuration as RumInitConfiguration )
90+ ; ( window as BrowserWindow ) . DD_RUM ! . init ( configuration as RumInitConfiguration )
9391 } )
9492 }
9593
@@ -124,7 +122,9 @@ function buildAppUrl(scenarioConfiguration: ScenarioConfiguration): string {
124122async function flushEvents ( page : Page ) {
125123 await page . evaluate ( ( ) => {
126124 Object . defineProperty ( document , 'visibilityState' , { configurable : true , get : ( ) => 'hidden' } )
127- document . dispatchEvent ( new Event ( 'visibilitychange' ) )
125+ const hiddenEvent = new Event ( 'visibilitychange' , { bubbles : true } )
126+ ; ( hiddenEvent as unknown as { __ddIsTrusted : boolean } ) . __ddIsTrusted = true
127+ document . dispatchEvent ( hiddenEvent )
128128 } )
129129}
130130
0 commit comments