Skip to content

Commit

Permalink
feat: Support dynamic set of options to showReportDialog
Browse files Browse the repository at this point in the history
This enables support for what our docs suggest is the way to customize the feedback dialog.

https://docs.sentry.io/learn/user-feedback/#customizing-the-widget
  • Loading branch information
dcramer committed Jul 18, 2018
1 parent 068352a commit 84ed55c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/raven-js/src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,30 +877,35 @@ Raven.prototype = {
)
return;

options = options || {};
options = Object.assign({
eventId: this.lastEventId(),
dsn: this._dsn,
user: this._globalContext.user,
}, options || {});

var lastEventId = options.eventId || this.lastEventId();
if (!lastEventId) {
if (!options.eventId) {
throw new RavenConfigError('Missing eventId');
}

var dsn = options.dsn || this._dsn;
if (!dsn) {
if (!options.dsn) {
throw new RavenConfigError('Missing DSN');
}

var encode = encodeURIComponent;
var qs = '';
qs += '?eventId=' + encode(lastEventId);
qs += '&dsn=' + encode(dsn);
var qs = '?';
for (var key in options) {
if (key !== 'user') {
qs += encode(key) + '=' + encode(options[key]) + '&';
}
}

var user = options.user || this._globalContext.user;
var user = options.user;
if (user) {
if (user.name) qs += '&name=' + encode(user.name);
if (user.email) qs += '&email=' + encode(user.email);
}

var globalServer = this._getGlobalServer(this._parseDSN(dsn));
var globalServer = this._getGlobalServer(this._parseDSN(options.dsn));

var script = _document.createElement('script');
script.async = true;
Expand Down

0 comments on commit 84ed55c

Please sign in to comment.