@@ -287,6 +287,112 @@ sentryTest(
287
287
} ,
288
288
) ;
289
289
290
+ sentryTest (
291
+ '[buffer-mode] manually starting replay ignores earlier performance entries' ,
292
+ async ( { getLocalTestUrl, page, browserName } ) => {
293
+ // This was sometimes flaky on webkit, so skipping for now
294
+ if ( shouldSkipReplayTest ( ) || browserName === 'webkit' ) {
295
+ sentryTest . skip ( ) ;
296
+ }
297
+
298
+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
299
+
300
+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
301
+ return route . fulfill ( {
302
+ status : 200 ,
303
+ contentType : 'application/json' ,
304
+ body : JSON . stringify ( { id : 'test-id' } ) ,
305
+ } ) ;
306
+ } ) ;
307
+
308
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
309
+
310
+ await page . goto ( url ) ;
311
+
312
+ // Wait for everything to be initialized - Replay is not running yet
313
+ await page . waitForFunction ( '!!window.Replay' ) ;
314
+
315
+ // Wait for a second, then start replay
316
+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
317
+ await page . evaluate ( 'window.Replay.start()' ) ;
318
+
319
+ const req0 = await reqPromise0 ;
320
+
321
+ const event0 = getReplayEvent ( req0 ) ;
322
+ const content0 = getReplayRecordingContent ( req0 ) ;
323
+
324
+ expect ( event0 ) . toEqual (
325
+ getExpectedReplayEvent ( {
326
+ replay_type : 'session' ,
327
+ } ) ,
328
+ ) ;
329
+
330
+ const { performanceSpans } = content0 ;
331
+
332
+ // Here, we test that this does not contain any web-vital etc. performance spans
333
+ // as these have been emitted _before_ the replay was manually started
334
+ expect ( performanceSpans ) . toEqual ( [
335
+ {
336
+ op : 'memory' ,
337
+ description : 'memory' ,
338
+ startTimestamp : expect . any ( Number ) ,
339
+ endTimestamp : expect . any ( Number ) ,
340
+ data : {
341
+ memory : {
342
+ jsHeapSizeLimit : expect . any ( Number ) ,
343
+ totalJSHeapSize : expect . any ( Number ) ,
344
+ usedJSHeapSize : expect . any ( Number ) ,
345
+ } ,
346
+ } ,
347
+ } ,
348
+ ] ) ;
349
+ } ,
350
+ ) ;
351
+
352
+ sentryTest (
353
+ '[buffer-mode] manually starting replay includes performance entries with 1s wiggle room' ,
354
+ async ( { getLocalTestUrl, page, browserName } ) => {
355
+ // This was sometimes flaky on webkit, so skipping for now
356
+ if ( shouldSkipReplayTest ( ) || browserName === 'webkit' ) {
357
+ sentryTest . skip ( ) ;
358
+ }
359
+
360
+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
361
+
362
+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
363
+ return route . fulfill ( {
364
+ status : 200 ,
365
+ contentType : 'application/json' ,
366
+ body : JSON . stringify ( { id : 'test-id' } ) ,
367
+ } ) ;
368
+ } ) ;
369
+
370
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
371
+
372
+ page . goto ( url ) ;
373
+
374
+ // Wait for everything to be initialized, then start replay as soon as possible
375
+ await page . waitForFunction ( '!!window.Replay' ) ;
376
+ await page . evaluate ( 'window.Replay.start()' ) ;
377
+
378
+ const req0 = await reqPromise0 ;
379
+
380
+ const event0 = getReplayEvent ( req0 ) ;
381
+ const content0 = getReplayRecordingContent ( req0 ) ;
382
+
383
+ expect ( event0 ) . toEqual (
384
+ getExpectedReplayEvent ( {
385
+ replay_type : 'session' ,
386
+ } ) ,
387
+ ) ;
388
+
389
+ const { performanceSpans } = content0 ;
390
+
391
+ // web vitals etc. are included with 1s wiggle room, to accomodate "immediate" start
392
+ expect ( performanceSpans . length ) . toBeGreaterThan ( 1 ) ;
393
+ } ,
394
+ ) ;
395
+
290
396
// Doing this in buffer mode to test changing error sample rate after first
291
397
// error happens.
292
398
sentryTest (
0 commit comments