1
1
import { Session } from '@sentry/hub' ;
2
- import { Event , Integration , Options , Severity , SeverityLevel , Transport } from '@sentry/types' ;
3
- import { resolvedSyncPromise } from '@sentry/utils' ;
2
+ import { Event , Integration , Options , Severity , SeverityLevel , NewTransport , EventStatus } from '@sentry/types' ;
3
+ import { resolvedSyncPromise , resolve } from '@sentry/utils' ;
4
4
5
5
import { BaseClient } from '../../src/baseclient' ;
6
6
import { initAndBind } from '../../src/sdk' ;
7
- import { NewTransport } from '../../src/transports/base' ;
8
- import { NoopTransport } from '../../src/transports/noop' ;
7
+
9
8
export interface TestOptions extends Options {
10
9
test ?: boolean ;
11
10
mockInstallFailure ?: boolean ;
@@ -20,8 +19,8 @@ export class TestClient extends BaseClient<TestOptions> {
20
19
public event ?: Event ;
21
20
public session ?: Session ;
22
21
23
- public constructor ( options : TestOptions , transport : Transport , newTransport ?: NewTransport ) {
24
- super ( options , transport , newTransport ) ;
22
+ public constructor ( options : TestOptions , transport : NewTransport ) {
23
+ super ( options , transport ) ;
25
24
TestClient . instance = this ;
26
25
}
27
26
@@ -64,22 +63,27 @@ export class TestClient extends BaseClient<TestOptions> {
64
63
}
65
64
}
66
65
67
- export function init ( options : TestOptions , transport : Transport , newTransport ?: NewTransport ) : void {
68
- initAndBind ( TestClient , options , transport , newTransport ) ;
66
+ export function init ( options : TestOptions , transport : NewTransport ) : void {
67
+ initAndBind ( TestClient , options , transport ) ;
69
68
}
70
69
71
- export function setupTestTransport ( options : TestOptions ) : { transport : Transport ; newTransport ?: NewTransport } {
72
- const noop = { transport : new NoopTransport ( ) } ;
70
+ export function setupTestTransport ( options : TestOptions ) : NewTransport {
71
+ const noop = {
72
+ send : ( ) =>
73
+ resolvedSyncPromise ( {
74
+ reason : 'NoopTransport: Event has been skipped because no Dsn is configured.' ,
75
+ status : 'skipped' as EventStatus ,
76
+ } ) ,
77
+ flush : ( ) => resolvedSyncPromise ( true ) ,
78
+ } ;
73
79
74
80
if ( ! options . dsn ) {
75
81
// We return the noop transport here in case there is no Dsn.
76
82
return noop ;
77
83
}
78
84
79
- const transportOptions = options . transportOptions ? options . transportOptions : { dsn : options . dsn } ;
80
-
81
85
if ( options . transport ) {
82
- return { transport : new this . _options . transport ( transportOptions ) } ;
86
+ return this . _options . transport ;
83
87
}
84
88
85
89
return noop ;
0 commit comments