Skip to content

Events won't send from the console #1298

New issue

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

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

Already on GitHub? # to your account

Closed
seanlinsley opened this issue Apr 10, 2018 · 5 comments
Closed

Events won't send from the console #1298

seanlinsley opened this issue Apr 10, 2018 · 5 comments

Comments

@seanlinsley
Copy link

seanlinsley commented Apr 10, 2018

#1080 updated captureMessage to check whitelistUrls before sending the event. However, events typed in from a browser console have a URL of <anonymous>, so the check fails.

screen shot 2018-04-10 at 12 11 33 pm

This has affected all releases since 3.19:

screen shot 2018-04-10 at 12 44 48 pm

In my experience it's helpful to be able to trigger one-off events from the console to ensure that Raven is configured correctly (particularly when setting up Raven for the first time, or deploying a new version).

@seanlinsley
Copy link
Author

One workaround is to pass a string to captureException:

Raven.captureMessage('test')              // doesn't work
Raven.captureException(new Error('test')) // doesn't work
Raven.captureException('test')            // works

@kamilogorek
Copy link
Contributor

kamilogorek commented Apr 16, 2018

Hey @seanlinsley, thanks for reporting this issue and adding a "workaround", as it exposes the issue that shouldn't be there :) #1304

As for the original issue, you can either add this exception to whitelistUrls, or disable them when you want to verify the communication between your app and Sentry server.

var config = {
  whitelistUrls: [/yourserver.com/something/]
};

if (isDevelopment()) {
  config.whitelistUrls.push('<anonymous>');
}

// or

var config = {};

if (isProduction()) {
  config.whitelistUrls = [/yourserver.com/something/];
}

Raven.config(config).install();

Adding something like {force: true} would be too much overhead, as we'd have to pass it around everywhere, take all the other options into account and make sure to cover all the API variants.

@seanlinsley
Copy link
Author

It seems to me that commands from the console should be properly associated with the site's domain, instead of being marked as anonymous.

I'd expect to find that a lot of Sentry users rely on the old behavior. How are you supposed to be 100% sure that Sentry is working in production (w/ its usual production configuration) without being able to trigger an event from the console? Expecting users to always embed a call in their source code & then later remove it after testing is complete is too heavy-handed, IMO.

@kamilogorek
Copy link
Contributor

We don't have a control over V8, SpiderMonkey, Chakra or any other browser's JS engine and there's no reliable way to evaluate what's the source of such calls.

Chrome returns <anonymous> where IE returns Unknown script code. It's not only the console calls, it's the same for eval code for example.

I'd expect to find that a lot of Sentry users rely on the old behavior.

We didn't get a single report nor support ticket related to the issue you mention.

How are you supposed to be 100% sure that Sentry is working in production (w/ its usual production configuration) without being able to trigger an event from the console?

If you really need it, you can always do this in the console:

Raven._globalOptions.whitelistUrls = [];
Raven.captureMessage('test')

@HazAT HazAT added the raven-js label Jun 12, 2018
@kamilogorek
Copy link
Contributor

Closing due to inactivity. Feel free to reopen if still relevant.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants