File tree Expand file tree Collapse file tree 5 files changed +47
-7
lines changed
dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-sdk-disabled Expand file tree Collapse file tree 5 files changed +47
-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
+ window . fetchCallCount = 0 ;
6
+ window . spanEnded = false ;
7
+
8
+ const originalWindowFetch = window . fetch ;
9
+ window . fetch = ( ...args ) => {
10
+ window . fetchCallCount ++ ;
11
+ return originalWindowFetch ( ...args ) ;
12
+ } ;
13
+
14
+ Sentry . init ( {
15
+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
16
+ tracesSampleRate : 1.0 ,
17
+ enabled : false ,
18
+ } ) ;
Original file line number Diff line number Diff line change
1
+ Sentry . startSpan ( { name : 'standalone_segment_span' , experimental : { standalone : true } } , ( ) => { } ) ;
2
+
3
+ window . spanEnded = true ;
Original file line number Diff line number Diff line change
1
+ import { expect } from '@playwright/test' ;
2
+
3
+ import { sentryTest } from '../../../../utils/fixtures' ;
4
+ import { shouldSkipTracingTest } from '../../../../utils/helpers' ;
5
+
6
+ sentryTest ( "doesn't send a standalone span envelope if SDK is disabled" , async ( { getLocalTestPath, page } ) => {
7
+ if ( shouldSkipTracingTest ( ) ) {
8
+ sentryTest . skip ( ) ;
9
+ }
10
+
11
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
12
+ await page . goto ( url ) ;
13
+
14
+ // @ts -expect-error this exists in the test init/subject
15
+ await page . waitForFunction ( ( ) => ! ! window . spanEnded ) ;
16
+ await page . waitForTimeout ( 2000 ) ;
17
+
18
+ // @ts -expect-error this exists in the test init
19
+ const fetchCallCount = await page . evaluate ( ( ) => window . fetchCallCount ) ;
20
+ // We expect no fetch calls because the SDK is disabled
21
+ expect ( fetchCallCount ) . toBe ( 0 ) ;
22
+ } ) ;
Original file line number Diff line number Diff line change @@ -565,7 +565,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
565
565
566
566
if ( this . _isEnabled ( ) && this . _transport ) {
567
567
return this . _transport . send ( envelope ) . then ( null , reason => {
568
- DEBUG_BUILD && logger . error ( 'Error while sending event :' , reason ) ;
568
+ DEBUG_BUILD && logger . error ( 'Error while sending envelope :' , reason ) ;
569
569
return reason ;
570
570
} ) ;
571
571
}
Original file line number Diff line number Diff line change @@ -429,10 +429,7 @@ function sendSpanEnvelope(envelope: SpanEnvelope): void {
429
429
return ;
430
430
}
431
431
432
- const transport = client . getTransport ( ) ;
433
- if ( transport ) {
434
- transport . send ( envelope ) . then ( null , reason => {
435
- DEBUG_BUILD && logger . error ( 'Error while sending span:' , reason ) ;
436
- } ) ;
437
- }
432
+ // sendEnvelope should not throw
433
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
434
+ client . sendEnvelope ( envelope ) ;
438
435
}
You can’t perform that action at this time.
0 commit comments