Skip to content

Commit 84ed55c

Browse files
committed
feat: Support dynamic set of options to showReportDialog
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
1 parent 068352a commit 84ed55c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

packages/raven-js/src/raven.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -877,30 +877,35 @@ Raven.prototype = {
877877
)
878878
return;
879879

880-
options = options || {};
880+
options = Object.assign({
881+
eventId: this.lastEventId(),
882+
dsn: this._dsn,
883+
user: this._globalContext.user,
884+
}, options || {});
881885

882-
var lastEventId = options.eventId || this.lastEventId();
883-
if (!lastEventId) {
886+
if (!options.eventId) {
884887
throw new RavenConfigError('Missing eventId');
885888
}
886889

887-
var dsn = options.dsn || this._dsn;
888-
if (!dsn) {
890+
if (!options.dsn) {
889891
throw new RavenConfigError('Missing DSN');
890892
}
891893

892894
var encode = encodeURIComponent;
893-
var qs = '';
894-
qs += '?eventId=' + encode(lastEventId);
895-
qs += '&dsn=' + encode(dsn);
895+
var qs = '?';
896+
for (var key in options) {
897+
if (key !== 'user') {
898+
qs += encode(key) + '=' + encode(options[key]) + '&';
899+
}
900+
}
896901

897-
var user = options.user || this._globalContext.user;
902+
var user = options.user;
898903
if (user) {
899904
if (user.name) qs += '&name=' + encode(user.name);
900905
if (user.email) qs += '&email=' + encode(user.email);
901906
}
902907

903-
var globalServer = this._getGlobalServer(this._parseDSN(dsn));
908+
var globalServer = this._getGlobalServer(this._parseDSN(options.dsn));
904909

905910
var script = _document.createElement('script');
906911
script.async = true;

0 commit comments

Comments
 (0)