Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Raven.showReportDialog (experimental) #456

Merged
merged 2 commits into from
Jan 8, 2016
Merged

Add Raven.showReportDialog (experimental) #456

merged 2 commits into from
Jan 8, 2016

Conversation

benvinegar
Copy link
Contributor

No description provided.

var encode = encodeURIComponent;
var qs = '';
qs += '?eventId=' + encode(lastEventId);
qs += '&dsn=' + encode(this._dsn || '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dsn needs to be configurable via options

@benvinegar benvinegar changed the title Add Raven.showReportDialog (experimental) [WIP] Add Raven.showReportDialog (experimental) Jan 8, 2016

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't throw errors like this since they'd then get caught and in turn reported to Sentry. Thoughts?

Or we have a rule to ignore RavenConfigError's. This wasn't an issue before because RavenConfigError was only ever thrown before raven was even hooked up. Now we'll be throwing errors that will be caught and logged.

Not sure if bad or not, just pointing it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you want them reported to Sentry? It means that you misconfigured Raven (for dialog purposes) and you might never otherwise find out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if you have Raven configured to accept an error, you will have set a DSN, and will thus never hit Missing DSN.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see validity in the Missing DSN case, since that's before Raven is configured, but for missing event id... I'm not sure. I feel like we could just return a true/false instead for success/failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it should be reported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's really hard to get into an infinite loop situation here, because when calling showReportDialog:

  1. If you don't have a DSN, then Raven wasn't installed and the global error handler isn't present – the exception is thrown but nothing catches it and control flow ends.

  2. If you don't have an eventId (or there was no lastEventId), then Raven will throw an exception, and this will be caught by the global error handler. Now if showReportDialog is called a second time, now there is a lastEventId and the function will no longer error.

Also, if you have an onerror handler, and inside that handler you throw another error (e.g. RavenConfigError), onerror doesn't get called again in an infinite loop – it just stops there:

http://jsbin.com/qoqoviduru/1/edit?html,js

The user would have to use a setTimeout call to leave the onerror stack to reach this infinite loop scenario:

http://jsbin.com/moxulabigi/1/edit?html,js,output (warning, this will freeze your browser)

But I mean, if they did this, any kind of bug in their code would trigger the infinite/setTimeout scenario – not strictly this RavenConfigError. So altogether, I think this scenario is really unlikely, and would be their fault anyways.

I'm going to move ahead with merging the branch. It's flagged experimental anyways.

benvinegar added a commit that referenced this pull request Jan 8, 2016
Add Raven.showReportDialog (experimental)
@benvinegar benvinegar merged commit 2fffd81 into master Jan 8, 2016
@benvinegar benvinegar deleted the show-dialog branch January 8, 2016 05:50
@stiller-leser
Copy link

Hey,

first off: Thanks for the implementation. Looks like this is going to help us a lot. I know this is a beta-feature, but I thought I'd give it a shot anyways: Is there a way to localize the error-embed? It did not look like setting a locale via Raven.setUserContext would do the trick.

kamilogorek added a commit that referenced this pull request Jun 12, 2018
* ci: Add node 9 and 10 to travis builds

* test: Fix listeners test for Node >= 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants