Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions packages/browser/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,13 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
}

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(),
});
}
}
14 changes: 11 additions & 3 deletions packages/browser/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;
Expand Down