diff --git a/packages/browser/src/client.ts b/packages/browser/src/client.ts index 46b755970fae..af85e468015e 100644 --- a/packages/browser/src/client.ts +++ b/packages/browser/src/client.ts @@ -68,22 +68,13 @@ export class BrowserClient extends BaseClient { } if (!this._isEnabled()) { - logger.error('Trying to call showReportDialog with Sentry Client is disabled'); + logger.error('Trying to call showReportDialog with Sentry Client disabled'); return; } - const dsn = options.dsn || this.getDsn(); - - if (!options.eventId) { - logger.error('Missing `eventId` option in showReportDialog call'); - return; - } - - if (!dsn) { - logger.error('Missing `Dsn` option in showReportDialog call'); - return; - } - - injectReportDialog(options); + injectReportDialog({ + ...options, + dsn: options.dsn || this.getDsn(), + }); } } diff --git a/packages/browser/src/helpers.ts b/packages/browser/src/helpers.ts index 18872d09282f..c2133638f6d6 100644 --- a/packages/browser/src/helpers.ts +++ b/packages/browser/src/helpers.ts @@ -1,6 +1,6 @@ import { API, captureException, withScope } from '@sentry/core'; import { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types'; -import { addExceptionMechanism, addExceptionTypeValue } from '@sentry/utils'; +import { addExceptionMechanism, addExceptionTypeValue, logger } from '@sentry/utils'; let ignoreOnError: number = 0; @@ -191,10 +191,18 @@ export interface ReportDialogOptions { * @hidden */ export function injectReportDialog(options: ReportDialogOptions = {}): void { + if (!options.eventId) { + logger.error(`Missing eventId option in showReportDialog call`); + return; + } + if (!options.dsn) { + logger.error(`Missing dsn option in showReportDialog call`); + return; + } + const script = document.createElement('script'); script.async = true; - // tslint:disable-next-line: no-non-null-assertion - script.src = new API(options.dsn!).getReportDialogEndpoint(options); + script.src = new API(options.dsn).getReportDialogEndpoint(options); if (options.onLoad) { script.onload = options.onLoad;