Skip to content

Commit f25fb26

Browse files
authored
ref: DSN to Dsn casing change (#1503)
* ref: Rename any DSN occurence to Dsn * ref: User API to filter sentry requests in breadcrumbs
1 parent 4b40c39 commit f25fb26

File tree

24 files changed

+122
-123
lines changed

24 files changed

+122
-123
lines changed

packages/browser/src/backend.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export class BrowserBackend implements Backend {
4444
* @inheritDoc
4545
*/
4646
public install(): boolean {
47-
// We are only called by the client if the SDK is enabled and a valid DSN
48-
// has been configured. If no DSN is present, this indicates a programming
47+
// We are only called by the client if the SDK is enabled and a valid Dsn
48+
// has been configured. If no Dsn is present, this indicates a programming
4949
// error.
5050
const dsn = this.options.dsn;
5151
if (!dsn) {
@@ -140,8 +140,8 @@ export class BrowserBackend implements Backend {
140140
*/
141141
public async sendEvent(event: SentryEvent): Promise<SentryResponse> {
142142
if (!this.options.dsn) {
143-
logger.warn(`Event has been skipped because no DSN is configured.`);
144-
// We do nothing in case there is no DSN
143+
logger.warn(`Event has been skipped because no Dsn is configured.`);
144+
// We do nothing in case there is no Dsn
145145
return { status: Status.Skipped };
146146
}
147147

packages/browser/src/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { API, BaseClient, SentryError } from '@sentry/core';
2-
import { DSNLike } from '@sentry/types';
2+
import { DsnLike } from '@sentry/types';
33
import { getGlobalObject } from '@sentry/utils/misc';
44
import { BrowserBackend, BrowserOptions } from './backend';
55

@@ -23,7 +23,7 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
2323
public showReportDialog(options: {
2424
[key: string]: any;
2525
eventId?: string;
26-
dsn?: DSNLike;
26+
dsn?: DsnLike;
2727
user?: {
2828
email?: string;
2929
name?: string;
@@ -47,14 +47,14 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
4747
return;
4848
}
4949

50-
const dsn = options.dsn || this.getDSN();
50+
const dsn = options.dsn || this.getDsn();
5151

5252
if (!options.eventId) {
5353
throw new SentryError('Missing `eventId` option in showReportDialog call');
5454
}
5555

5656
if (!dsn) {
57-
throw new SentryError('Missing `DSN` option in showReportDialog call');
57+
throw new SentryError('Missing `Dsn` option in showReportDialog call');
5858
}
5959

6060
const script = document.createElement('script');

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DSN } from '@sentry/core';
1+
import { API } from '@sentry/core';
22
import { getCurrentHub } from '@sentry/hub';
33
import { Integration, Severity } from '@sentry/types';
44
import { isFunction, isString } from '@sentry/utils/is';
@@ -354,8 +354,7 @@ export class Breadcrumbs implements Integration {
354354
* Can be disabled or individually configured via the `autoBreadcrumbs` config option
355355
*/
356356
public install(options: BrowserOptions = {}): void {
357-
// TODO: Use API provider instead of raw `new DSN`
358-
const filterUrl = options.dsn && new DSN(options.dsn).user;
357+
const filterUrl = options.dsn && new API(options.dsn).getStoreEndpoint();
359358

360359
if (this.config.console) {
361360
this.instrumentConsole();

packages/browser/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const defaultIntegrations = [
3232
* import { init } from '@sentry/browser';
3333
*
3434
* init({
35-
* dsn: '__DSN__',
35+
* dsn: '__Dsn__',
3636
* // ...
3737
* });
3838
*

packages/browser/test/backend.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ let backend: BrowserBackend;
2424

2525
describe('BrowserBackend', () => {
2626
describe('sendEvent()', () => {
27-
it('should throw when no DSN is provided', async () => {
27+
it('should throw when no Dsn is provided', async () => {
2828
backend = new BrowserBackend({ dsn });
2929

3030
try {
3131
await backend.sendEvent(testEvent);
3232
} catch (e) {
33-
expect(e.message).equal('Cannot sendEvent without a valid DSN');
33+
expect(e.message).equal('Cannot sendEvent without a valid Dsn');
3434
}
3535
});
3636

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect } from 'chai';
22
import { BaseTransport } from '../../src/transports/base';
33

4-
const testDSN = 'https://[email protected]/42';
4+
const testDsn = 'https://[email protected]/42';
55

66
class SimpleTransport extends BaseTransport {}
77

88
describe('BaseTransport', () => {
99
it('doesnt provide send() implementation', async () => {
10-
const transport = new SimpleTransport({ dsn: testDSN });
10+
const transport = new SimpleTransport({ dsn: testDsn });
1111

1212
try {
1313
await transport.send({});
@@ -17,7 +17,7 @@ describe('BaseTransport', () => {
1717
});
1818

1919
it('has correct endpoint url', () => {
20-
const transport = new SimpleTransport({ dsn: testDSN });
20+
const transport = new SimpleTransport({ dsn: testDsn });
2121
expect(transport.url).equal('https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7');
2222
});
2323
});

packages/browser/test/transports/beacon.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import { SinonStub, stub } from 'sinon';
33
import { Status, Transports } from '../../src';
44

5-
const testDSN = 'https://[email protected]/42';
5+
const testDsn = 'https://[email protected]/42';
66
const transportUrl = 'https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7';
77
const payload = {
88
event_id: '1337',
@@ -18,7 +18,7 @@ let transport: Transports.BaseTransport;
1818
describe('BeaconTransport', () => {
1919
beforeEach(() => {
2020
sendBeacon = stub(window.navigator, 'sendBeacon');
21-
transport = new Transports.BeaconTransport({ dsn: testDSN });
21+
transport = new Transports.BeaconTransport({ dsn: testDsn });
2222
});
2323

2424
afterEach(() => {

packages/browser/test/transports/fetch.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import { SinonStub, stub } from 'sinon';
33
import { Status, Transports } from '../../src';
44

5-
const testDSN = 'https://[email protected]/42';
5+
const testDsn = 'https://[email protected]/42';
66
const transportUrl = 'https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7';
77
const payload = {
88
event_id: '1337',
@@ -18,7 +18,7 @@ let transport: Transports.BaseTransport;
1818
describe('FetchTransport', () => {
1919
beforeEach(() => {
2020
fetch = stub(window, 'fetch');
21-
transport = new Transports.FetchTransport({ dsn: testDSN });
21+
transport = new Transports.FetchTransport({ dsn: testDsn });
2222
});
2323

2424
afterEach(() => {

packages/browser/test/transports/xhr.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import { fakeServer, SinonFakeServer } from 'sinon';
33
import { Status, Transports } from '../../src';
44

5-
const testDSN = 'https://[email protected]/42';
5+
const testDsn = 'https://[email protected]/42';
66
const transportUrl = 'https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7';
77
const payload = {
88
event_id: '1337',
@@ -19,7 +19,7 @@ describe('XHRTransport', () => {
1919
beforeEach(() => {
2020
server = fakeServer.create();
2121
server.respondImmediately = true;
22-
transport = new Transports.XHRTransport({ dsn: testDSN });
22+
transport = new Transports.XHRTransport({ dsn: testDsn });
2323
});
2424

2525
afterEach(() => {

packages/core/src/api.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { DSNLike } from '@sentry/types';
1+
import { DsnLike } from '@sentry/types';
22
import { urlEncode } from '@sentry/utils/object';
3-
import { DSN } from './dsn';
3+
import { Dsn } from './dsn';
44

55
const SENTRY_API_VERSION = '7';
66

77
/** Helper class to provide urls to different Sentry endpoints. */
88
export class API {
9-
/** The internally used DSN object. */
10-
private readonly dsnObject: DSN;
9+
/** The internally used Dsn object. */
10+
private readonly dsnObject: Dsn;
1111
/** Create a new instance of API */
12-
public constructor(public dsn: DSNLike) {
13-
this.dsnObject = new DSN(dsn);
12+
public constructor(public dsn: DsnLike) {
13+
this.dsnObject = new Dsn(dsn);
1414
}
1515

16-
/** Returns the DSN object. */
17-
public getDSN(): DSN {
16+
/** Returns the Dsn object. */
17+
public getDsn(): Dsn {
1818
return this.dsnObject;
1919
}
2020

0 commit comments

Comments
 (0)