-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: Switch to new transports (#4943)
This PR switches over from the old transports to the new ones. It deletes the functionality from the client of passing in transports explicitly and instead expects the transport to be passed in through options. Instead of passing in an instance of a transport to the client, we pass in a constructor function. This allows the client to control exactly what options are passed into the transport. ```ts this._transport = options.transport({ ...options.transportOptions, url }); ```
- Loading branch information
1 parent
6a3e40d
commit c640aef
Showing
136 changed files
with
932 additions
and
1,494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ import { | |
wrap, | ||
} from '../../src'; | ||
import { getDefaultBrowserClientOptions } from './helper/browser-client-options'; | ||
import { SimpleTransport } from './mocks/simpletransport'; | ||
import { makeSimpleTransport } from './mocks/simpletransport'; | ||
|
||
const dsn = 'https://[email protected]/4291'; | ||
|
||
|
@@ -31,7 +31,7 @@ describe('SentryBrowser', () => { | |
init({ | ||
beforeSend, | ||
dsn, | ||
transport: SimpleTransport, | ||
transport: makeSimpleTransport, | ||
}); | ||
}); | ||
|
||
|
@@ -77,7 +77,7 @@ describe('SentryBrowser', () => { | |
describe('user', () => { | ||
const EX_USER = { email: '[email protected]' }; | ||
const options = getDefaultBrowserClientOptions({ dsn }); | ||
const client = new BrowserClient(options, new SimpleTransport({ dsn })); | ||
const client = new BrowserClient(options); | ||
const reportDialogSpy = jest.spyOn(client, 'showReportDialog'); | ||
|
||
beforeEach(() => { | ||
|
@@ -150,7 +150,7 @@ describe('SentryBrowser', () => { | |
}, | ||
dsn, | ||
}); | ||
getCurrentHub().bindClient(new BrowserClient(options, new SimpleTransport({ dsn }))); | ||
getCurrentHub().bindClient(new BrowserClient(options)); | ||
captureMessage('test'); | ||
}); | ||
|
||
|
@@ -164,7 +164,7 @@ describe('SentryBrowser', () => { | |
}, | ||
dsn, | ||
}); | ||
getCurrentHub().bindClient(new BrowserClient(options, new SimpleTransport({ dsn }))); | ||
getCurrentHub().bindClient(new BrowserClient(options)); | ||
captureEvent({ message: 'event' }); | ||
}); | ||
|
||
|
@@ -175,7 +175,7 @@ describe('SentryBrowser', () => { | |
dsn, | ||
integrations: [], | ||
}); | ||
getCurrentHub().bindClient(new BrowserClient(options, new SimpleTransport({ dsn }))); | ||
getCurrentHub().bindClient(new BrowserClient(options)); | ||
|
||
captureMessage('event222'); | ||
captureMessage('event222'); | ||
|
@@ -192,7 +192,7 @@ describe('SentryBrowser', () => { | |
dsn, | ||
integrations: [new Integrations.InboundFilters({ ignoreErrors: ['capture'] })], | ||
}); | ||
getCurrentHub().bindClient(new BrowserClient(options, new SimpleTransport({ dsn }))); | ||
getCurrentHub().bindClient(new BrowserClient(options)); | ||
|
||
captureMessage('capture'); | ||
|
||
|
@@ -244,7 +244,7 @@ describe('SentryBrowser initialization', () => { | |
it('should set SDK data when Sentry.init() is called', () => { | ||
init({ dsn }); | ||
|
||
const sdkData = (getCurrentHub().getClient() as any).getTransport()._api.metadata?.sdk; | ||
const sdkData = (getCurrentHub().getClient() as any).getOptions()._metadata.sdk; | ||
|
||
expect(sdkData?.name).toBe('sentry.javascript.browser'); | ||
expect(sdkData?.packages[0].name).toBe('npm:@sentry/browser'); | ||
|
@@ -254,9 +254,9 @@ describe('SentryBrowser initialization', () => { | |
|
||
it('should set SDK data when instantiating a client directly', () => { | ||
const options = getDefaultBrowserClientOptions({ dsn }); | ||
const client = new BrowserClient(options, new SimpleTransport({ dsn })); | ||
const client = new BrowserClient(options); | ||
|
||
const sdkData = (client.getTransport() as any)._api.metadata?.sdk; | ||
const sdkData = client.getOptions()._metadata?.sdk as any; | ||
|
||
expect(sdkData.name).toBe('sentry.javascript.browser'); | ||
expect(sdkData.packages[0].name).toBe('npm:@sentry/browser'); | ||
|
@@ -284,7 +284,7 @@ describe('SentryBrowser initialization', () => { | |
}, | ||
}); | ||
|
||
const sdkData = (getCurrentHub().getClient() as any).getTransport()._api.metadata?.sdk; | ||
const sdkData = (getCurrentHub().getClient() as any).getOptions()._metadata?.sdk; | ||
|
||
expect(sdkData.name).toBe('sentry.javascript.angular'); | ||
expect(sdkData.packages[0].name).toBe('npm:@sentry/angular'); | ||
|
@@ -305,7 +305,7 @@ describe('wrap()', () => { | |
}, | ||
dsn, | ||
}); | ||
getCurrentHub().bindClient(new BrowserClient(options, new SimpleTransport({ dsn }))); | ||
getCurrentHub().bindClient(new BrowserClient(options)); | ||
|
||
try { | ||
wrap(() => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,6 @@ | ||
import { eventStatusFromHttpCode, resolvedSyncPromise } from '@sentry/utils'; | ||
import { createTransport } from '@sentry/core'; | ||
import { resolvedSyncPromise } from '@sentry/utils'; | ||
|
||
import { Event, Response } from '../../../src'; | ||
import { BaseTransport } from '../../../src/transports'; | ||
|
||
// @ts-ignore It's okay that we're not implementing the `_sendRequest()` method because we don't use it in our tests | ||
export class SimpleTransport extends BaseTransport { | ||
public sendEvent(_: Event): PromiseLike<Response> { | ||
return this._buffer.add(() => | ||
resolvedSyncPromise({ | ||
status: eventStatusFromHttpCode(200), | ||
}), | ||
); | ||
} | ||
export function makeSimpleTransport() { | ||
return createTransport({}, () => resolvedSyncPromise({ statusCode: 200 })); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.