Skip to content

Commit 0b9a266

Browse files
committed
fix: Make sure that DSN is always passed to report dialog
1 parent 7956bd8 commit 0b9a266

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

packages/browser/src/client.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,13 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
6868
}
6969

7070
if (!this._isEnabled()) {
71-
logger.error('Trying to call showReportDialog with Sentry Client is disabled');
71+
logger.error('Trying to call showReportDialog with Sentry Client disabled');
7272
return;
7373
}
7474

75-
const dsn = options.dsn || this.getDsn();
76-
77-
if (!options.eventId) {
78-
logger.error('Missing `eventId` option in showReportDialog call');
79-
return;
80-
}
81-
82-
if (!dsn) {
83-
logger.error('Missing `Dsn` option in showReportDialog call');
84-
return;
85-
}
86-
87-
injectReportDialog(options);
75+
injectReportDialog({
76+
...options,
77+
dsn: options.dsn || this.getDsn(),
78+
});
8879
}
8980
}

packages/browser/src/helpers.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { API, captureException, withScope } from '@sentry/core';
22
import { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';
3-
import { addExceptionMechanism, addExceptionTypeValue } from '@sentry/utils';
3+
import { addExceptionMechanism, addExceptionTypeValue, logger } from '@sentry/utils';
44

55
let ignoreOnError: number = 0;
66

@@ -191,10 +191,18 @@ export interface ReportDialogOptions {
191191
* @hidden
192192
*/
193193
export function injectReportDialog(options: ReportDialogOptions = {}): void {
194+
if (!options.eventId) {
195+
logger.error(`Missing eventId option in showReportDialog call`);
196+
return;
197+
}
198+
if (!options.dsn) {
199+
logger.error(`Missing dsn option in showReportDialog call`);
200+
return;
201+
}
202+
194203
const script = document.createElement('script');
195204
script.async = true;
196-
// tslint:disable-next-line: no-non-null-assertion
197-
script.src = new API(options.dsn!).getReportDialogEndpoint(options);
205+
script.src = new API(options.dsn).getReportDialogEndpoint(options);
198206

199207
if (options.onLoad) {
200208
script.onload = options.onLoad;

0 commit comments

Comments
 (0)