@@ -11,6 +11,7 @@ import {
1111 Severity ,
1212 SeverityLevel ,
1313 Transport ,
14+ NewTransport ,
1415} from '@sentry/types' ;
1516import {
1617 checkOrSetAlreadyCaught ,
@@ -29,7 +30,7 @@ import {
2930 uuid4 ,
3031} from '@sentry/utils' ;
3132
32- import { APIDetails , initAPIDetails } from './api' ;
33+ import { APIDetails , initAPIDetails , getEnvelopeEndpointWithUrlEncodedAuth } from './api' ;
3334import { IS_DEBUG_BUILD } from './flags' ;
3435import { IntegrationIndex , setupIntegrations } from './integration' ;
3536import { createEventEnvelope , createSessionEnvelope } from './request' ;
@@ -82,7 +83,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
8283 protected _numProcessing : number = 0 ;
8384
8485 /** Cached transport used internally. */
85- protected _transport : Transport ;
86+ protected _transport : NewTransport ;
8687
8788 /** New v7 Transport that is initialized alongside the old one */
8889 protected _newTransport ?: NewTransport ;
@@ -94,25 +95,20 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
9495 * @param transport The (old) Transport instance for the client to use (TODO(v7): remove)
9596 * @param newTransport The NewTransport instance for the client to use
9697 */
97- protected constructor ( options : O , transport : Transport , newTransport ?: NewTransport ) {
98+ protected constructor ( options : O ) {
9899 this . _options = options ;
99100
101+ let url ;
100102 if ( options . dsn ) {
101103 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 ) ;
102107 } else {
103108 IS_DEBUG_BUILD && logger . warn ( 'No DSN provided, client will not do anything.' ) ;
104109 }
105110
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 || '' } ) ;
116112 }
117113
118114 /**
0 commit comments