File tree Expand file tree Collapse file tree 5 files changed +79
-7
lines changed
dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/long-tasks-before-navigation Expand file tree Collapse file tree 5 files changed +79
-7
lines changed Original file line number Diff line number Diff line change
1
+ import * as Sentry from '@sentry/browser' ;
2
+
3
+ window . Sentry = Sentry ;
4
+
5
+ Sentry . init ( {
6
+ dsn :
'https://[email protected] /1337' ,
7
+ integrations : [
8
+ Sentry . browserTracingIntegration ( {
9
+ idleTimeout : 9000 ,
10
+ enableLongAnimationFrame : false ,
11
+ instrumentPageLoad : false ,
12
+ instrumentNavigation : true ,
13
+ enableInp : false ,
14
+ enableLongTask : true ,
15
+ } ) ,
16
+ ] ,
17
+ tracesSampleRate : 1 ,
18
+ debug : true ,
19
+ } ) ;
Original file line number Diff line number Diff line change
1
+ const longTaskButton = document . getElementById ( 'myButton' ) ;
2
+
3
+ longTaskButton ?. addEventListener ( 'click' , ( ) => {
4
+ const startTime = Date . now ( ) ;
5
+
6
+ function getElapsed ( ) {
7
+ const time = Date . now ( ) ;
8
+ return time - startTime ;
9
+ }
10
+
11
+ while ( getElapsed ( ) < 500 ) {
12
+ //
13
+ }
14
+
15
+ // trigger a navigation in the same event loop tick
16
+ window . history . pushState ( { } , '' , '/#myHeading' ) ;
17
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+ </ head >
6
+ < body >
7
+ < div > Rendered Before Long Task</ div >
8
+ < script src ="https://example.com/path/to/script.js "> </ script >
9
+
10
+ < button id ="myButton "> Start long task</ button >
11
+ < h1 id ="myHeading "> Heading</ h1 >
12
+ </ body >
13
+ </ html >
Original file line number Diff line number Diff line change
1
+ import type { Event } from '@sentry/types' ;
2
+ import { expect } from '@playwright/test' ;
3
+
4
+ import { sentryTest } from '../../../../utils/fixtures' ;
5
+ import { getFirstSentryEnvelopeRequest , shouldSkipTracingTest } from '../../../../utils/helpers' ;
6
+
7
+ sentryTest (
8
+ "doesn't capture long task spans starting before a navigation in the navigation transaction" ,
9
+ async ( { browserName, getLocalTestPath, page } ) => {
10
+ // Long tasks only work on chrome
11
+ if ( shouldSkipTracingTest ( ) || browserName !== 'chromium' ) {
12
+ sentryTest . skip ( ) ;
13
+ }
14
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
15
+
16
+ await page . goto ( url ) ;
17
+
18
+ await page . locator ( '#myButton' ) . click ( ) ;
19
+
20
+ const navigationTransactionEvent = await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
21
+
22
+ expect ( navigationTransactionEvent . contexts ?. trace ?. op ) . toBe ( 'navigation' ) ;
23
+
24
+ const longTaskSpans = navigationTransactionEvent ?. spans ?. filter ( span => span . op === 'ui.long-task' ) ;
25
+ expect ( longTaskSpans ) . toHaveLength ( 0 ) ;
26
+ } ,
27
+ ) ;
Original file line number Diff line number Diff line change 9
9
"engines" : {
10
10
"node" : " >=14.18"
11
11
},
12
- "files" : [
13
- " /build/npm"
14
- ],
12
+ "files" : [" /build/npm" ],
15
13
"main" : " build/npm/cjs/index.js" ,
16
14
"module" : " build/npm/esm/index.js" ,
17
15
"types" : " build/npm/types/index.d.ts" ,
30
28
},
31
29
"typesVersions" : {
32
30
"<4.9" : {
33
- "build/npm/types/index.d.ts" : [
34
- " build/npm/types-ts3.8/index.d.ts"
35
- ]
31
+ "build/npm/types/index.d.ts" : [" build/npm/types-ts3.8/index.d.ts" ]
36
32
}
37
33
},
38
34
"publishConfig" : {
53
49
},
54
50
"scripts" : {
55
51
"build" : " run-p build:transpile build:bundle build:types" ,
56
- "build:dev" : " yarn build" ,
52
+ "build:dev" : " run-p build:transpile build:types " ,
57
53
"build:bundle" : " rollup -c rollup.bundle.config.mjs" ,
58
54
"build:transpile" : " rollup -c rollup.npm.config.mjs" ,
59
55
"build:types" : " run-s build:types:core build:types:downlevel" ,
You can’t perform that action at this time.
0 commit comments