7
7
EventHint ,
8
8
Integration ,
9
9
IntegrationClass ,
10
+ NewTransport ,
10
11
Options ,
11
12
Severity ,
12
13
SeverityLevel ,
@@ -29,11 +30,10 @@ import {
29
30
uuid4 ,
30
31
} from '@sentry/utils' ;
31
32
32
- import { APIDetails , initAPIDetails } from './api' ;
33
+ import { initAPIDetails } from './api' ;
33
34
import { IS_DEBUG_BUILD } from './flags' ;
34
35
import { IntegrationIndex , setupIntegrations } from './integration' ;
35
36
import { createEventEnvelope , createSessionEnvelope } from './request' ;
36
- import { NewTransport } from './transports/base' ;
37
37
38
38
const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured." ;
39
39
@@ -82,10 +82,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
82
82
protected _numProcessing : number = 0 ;
83
83
84
84
/** Cached transport used internally. */
85
- protected _transport : Transport ;
86
-
87
- /** New v7 Transport that is initialized alongside the old one */
88
- protected _newTransport ?: NewTransport ;
85
+ protected _transport : NewTransport ;
89
86
90
87
/**
91
88
* Initializes this client instance.
@@ -94,7 +91,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
94
91
* @param transport The (old) Transport instance for the client to use (TODO(v7): remove)
95
92
* @param newTransport The NewTransport instance for the client to use
96
93
*/
97
- protected constructor ( options : O , transport : Transport , newTransport ?: NewTransport ) {
94
+ protected constructor ( options : O , transport : NewTransport ) {
98
95
this . _options = options ;
99
96
100
97
if ( options . dsn ) {
@@ -103,16 +100,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
103
100
IS_DEBUG_BUILD && logger . warn ( 'No DSN provided, client will not do anything.' ) ;
104
101
}
105
102
106
- // TODO(v7): remove old transport
107
103
this . _transport = transport ;
108
- this . _newTransport = newTransport ;
109
-
110
- // TODO(v7): refactor this to keep metadata/api outside of transport. This hack is used to
111
- // satisfy tests until we move to NewTransport where we have to revisit this.
112
- ( this . _transport as unknown as { _api : Partial < APIDetails > } ) . _api = {
113
- ...( ( this . _transport as unknown as { _api : Partial < APIDetails > } ) . _api || { } ) ,
114
- metadata : options . _metadata || { } ,
115
- } ;
116
104
}
117
105
118
106
/**
@@ -222,7 +210,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
222
210
/**
223
211
* @inheritDoc
224
212
*/
225
- public getTransport ( ) : Transport {
213
+ public getTransport ( ) : NewTransport {
226
214
return this . _transport ;
227
215
}
228
216
@@ -232,7 +220,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
232
220
public flush ( timeout ?: number ) : PromiseLike < boolean > {
233
221
return this . _isClientDoneProcessing ( timeout ) . then ( clientFinished => {
234
222
return this . getTransport ( )
235
- . close ( timeout )
223
+ . flush ( timeout )
236
224
. then ( transportFlushed => clientFinished && transportFlushed ) ;
237
225
} ) ;
238
226
}
@@ -272,20 +260,11 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
272
260
* @inheritDoc
273
261
*/
274
262
public sendEvent ( event : Event ) : void {
275
- // TODO(v7): Remove the if-else
276
- if (
277
- this . _newTransport &&
278
- this . _options . dsn &&
279
- this . _options . _experiments &&
280
- this . _options . _experiments . newTransport
281
- ) {
263
+ if ( this . _options . dsn ) {
282
264
const api = initAPIDetails ( this . _options . dsn , this . _options . _metadata , this . _options . tunnel ) ;
283
265
const env = createEventEnvelope ( event , api ) ;
284
- void this . _newTransport . send ( env ) . then ( null , reason => {
285
- IS_DEBUG_BUILD && logger . error ( 'Error while sending event:' , reason ) ;
286
- } ) ;
287
- } else {
288
- void this . _transport . sendEvent ( event ) . then ( null , reason => {
266
+ // TODO: Adjust client reports based on transport response
267
+ void this . _transport . send ( env ) . then ( null , reason => {
289
268
IS_DEBUG_BUILD && logger . error ( 'Error while sending event:' , reason ) ;
290
269
} ) ;
291
270
}
@@ -295,25 +274,11 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
295
274
* @inheritDoc
296
275
*/
297
276
public sendSession ( session : Session ) : void {
298
- if ( ! this . _transport . sendSession ) {
299
- IS_DEBUG_BUILD && logger . warn ( "Dropping session because custom transport doesn't implement sendSession" ) ;
300
- return ;
301
- }
302
-
303
- // TODO(v7): Remove the if-else
304
- if (
305
- this . _newTransport &&
306
- this . _options . dsn &&
307
- this . _options . _experiments &&
308
- this . _options . _experiments . newTransport
309
- ) {
277
+ if ( this . _options . dsn ) {
310
278
const api = initAPIDetails ( this . _options . dsn , this . _options . _metadata , this . _options . tunnel ) ;
311
279
const [ env ] = createSessionEnvelope ( session , api ) ;
312
- void this . _newTransport . send ( env ) . then ( null , reason => {
313
- IS_DEBUG_BUILD && logger . error ( 'Error while sending session:' , reason ) ;
314
- } ) ;
315
- } else {
316
- void this . _transport . sendSession ( session ) . then ( null , reason => {
280
+ // TODO: Adjust client reports based on transport response
281
+ void this . _transport . send ( env ) . then ( null , reason => {
317
282
IS_DEBUG_BUILD && logger . error ( 'Error while sending session:' , reason ) ;
318
283
} ) ;
319
284
}
@@ -595,15 +560,16 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
595
560
protected _processEvent ( event : Event , hint ?: EventHint , scope ?: Scope ) : PromiseLike < Event > {
596
561
// eslint-disable-next-line @typescript-eslint/unbound-method
597
562
const { beforeSend, sampleRate } = this . getOptions ( ) ;
598
- const transport = this . getTransport ( ) ;
563
+ // const transport = this.getTransport();
599
564
600
565
type RecordLostEvent = NonNullable < Transport [ 'recordLostEvent' ] > ;
601
566
type RecordLostEventParams = Parameters < RecordLostEvent > ;
602
567
603
- function recordLostEvent ( outcome : RecordLostEventParams [ 0 ] , category : RecordLostEventParams [ 1 ] ) : void {
604
- if ( transport . recordLostEvent ) {
605
- transport . recordLostEvent ( outcome , category ) ;
606
- }
568
+ // TODO(v7): Make client reports work with new transports
569
+ function recordLostEvent ( _outcome : RecordLostEventParams [ 0 ] , _category : RecordLostEventParams [ 1 ] ) : void {
570
+ // if (transport.recordLostEvent) {
571
+ // transport.recordLostEvent(outcome, category);
572
+ // }
607
573
}
608
574
609
575
if ( ! this . _isEnabled ( ) ) {
0 commit comments