@@ -11,6 +11,7 @@ import {
11
11
Severity ,
12
12
SeverityLevel ,
13
13
Transport ,
14
+ NewTransport ,
14
15
} from '@sentry/types' ;
15
16
import {
16
17
checkOrSetAlreadyCaught ,
@@ -29,7 +30,7 @@ import {
29
30
uuid4 ,
30
31
} from '@sentry/utils' ;
31
32
32
- import { APIDetails , initAPIDetails } from './api' ;
33
+ import { APIDetails , initAPIDetails , getEnvelopeEndpointWithUrlEncodedAuth } from './api' ;
33
34
import { IS_DEBUG_BUILD } from './flags' ;
34
35
import { IntegrationIndex , setupIntegrations } from './integration' ;
35
36
import { createEventEnvelope , createSessionEnvelope } from './request' ;
@@ -82,7 +83,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
82
83
protected _numProcessing : number = 0 ;
83
84
84
85
/** Cached transport used internally. */
85
- protected _transport : Transport ;
86
+ protected _transport : NewTransport ;
86
87
87
88
/** New v7 Transport that is initialized alongside the old one */
88
89
protected _newTransport ?: NewTransport ;
@@ -94,25 +95,20 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
94
95
* @param transport The (old) Transport instance for the client to use (TODO(v7): remove)
95
96
* @param newTransport The NewTransport instance for the client to use
96
97
*/
97
- protected constructor ( options : O , transport : Transport , newTransport ?: NewTransport ) {
98
+ protected constructor ( options : O ) {
98
99
this . _options = options ;
99
100
101
+ let url ;
100
102
if ( options . dsn ) {
101
103
this . _dsn = makeDsn ( options . dsn ) ;
104
+ // TODO(v7): Figure out what to do with transport when dsn is not defined
105
+ const api = initAPIDetails ( this . _dsn , options . _metadata , options . tunnel ) ;
106
+ url = getEnvelopeEndpointWithUrlEncodedAuth ( api . dsn , api . tunnel ) ;
102
107
} else {
103
108
IS_DEBUG_BUILD && logger . warn ( 'No DSN provided, client will not do anything.' ) ;
104
109
}
105
110
106
- // TODO(v7): remove old transport
107
- 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
- } ;
111
+ this . _transport = options . transport ( { ...options . transportOptions , url : url || '' } ) ;
116
112
}
117
113
118
114
/**
0 commit comments