You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble figuring out how to restore the window.onerror event after including Raven as an AMD dependancy.
I don't want to use Raven at all during development, so I'm only calling config()/install() in production mode. But in dev mode all errors are still being thrown by TraceKit.report()... Which is pretty frustrating since the file/line number/stack trace isn't helpful anymore in the browser dev tools.
I've tried calling uninstall() in dev mode but that didn't help. Is there a reason you're binding to window.onerror no matter what instead of doing it inside config() or install()?
Reacted by Joanna Falkowska, Jason Axelson, Nathan Broadbent, Drew Dennison, Dmitry Murzin and Tommy D. Rossi
I was trying to manually set window.onerror = null in dev mode, but even that didn't work. The problem was I was require()ing Raven in a couple modules, and each time Raven was re-binding to window.onerror.
So instead I stopped using noConflict(), included it as a global dependancy in the requirejs config, and removed it as a local dependancy from the other modules. This allowed window.onerror = null to be set without Raven re-binding the event later.
@adambiggs Another solution is to create a wrapping AMD module for Raven-js which does the configure & install call, which means you only import raven-js once, but can import your own module multiple times, afaik.
This shouldn't be relevant anymore. window.onerror isn't mutated until calling install() and is restored when calling uninstall(). Let me know if there's another issue.
Is there a workaround for this? Even when I never call Raven.config() or Raven.install() or if I call Raven.config(false) the jquery or onerror handlers seem to be still be installed. The only workaround seems to be never loading the raven js in the first place (which is less than ideal).
Where process.env.RAVEN_DSN is the DSN of course, and which is only set when building for environments where I want Raven running, via webpack.EnvironmentPlugin.
In your version it's impossible to conditionally set up an Angular ErrorHandler. Either you set it up in every case, and then it swallows your errors no matter what, or don't but still list it in providers, which od dev causes entire module to crash.
As far as I know it's impossible to use or not use an Angular provider based on a condition.
To be honest that sounds to me like an Angular issue rather than a Raven one.
Having said that, I agree that a more general solution would be a good addition.
Just a thought: have you tried setting a pattern in the ignoreUrls option which matches all URLs? Would that do what you need? Something like ignoreUrls: [/./]?
It's possible to prevent Raven from sending requests and even from catching errors, but that doesn't stop the Angular ErrorHandler from swallowing errors (= at least losing track of actual lines from where errors were thrown).
I suppose you're right and it's not much of a Raven issue after all.
For those coming here trying to figure it out still, it was a config option I missed at first shouldSendCallback:
importRavenfrom'raven-js';constenv='prod';constrelease='12345';Raven.config('https://<example>@sentry.io/1234',{environment: env,release: release,shouldSendCallback: ()=>{// Do your logic here...return['prod','staging'].indexOf(env)!==-1;},}).install();
If shouldSendCallback is false sentry will not report. No need for conditional reporting logic in your code with this 👍 .
Reacted by Jaydeep Solanki, Yann Liu, Hyeoksu Han, David Furlong, david, Lewis Blackwood, Petar Bojinov, Cédric Blondeau, David Tomczyk, Daniel Saewitz and 18 more
Activity
adambiggs commentedon May 3, 2013
Found a solution, but it's not ideal...
I was trying to manually set
window.onerror = nullin dev mode, but even that didn't work. The problem was I wasrequire()ing Raven in a couple modules, and each time Raven was re-binding towindow.onerror.So instead I stopped using
noConflict(), included it as a global dependancy in the requirejs config, and removed it as a local dependancy from the other modules. This allowedwindow.onerror = nullto be set without Raven re-binding the event later.Pretty messy fix though :(
ThisIsMissEm commentedon Jun 3, 2013
@adambiggs Another solution is to create a wrapping AMD module for Raven-js which does the configure & install call, which means you only import raven-js once, but can import your own module multiple times, afaik.
I think this may be related to: #109 and #91 (comment)
mattrobenolt commentedon Jan 18, 2014
This shouldn't be relevant anymore.
window.onerrorisn't mutated until callinginstall()and is restored when callinguninstall(). Let me know if there's another issue.bobbyrenwick commentedon Mar 31, 2014
@mattrobenolt, I've upgraded to 1.1.11 and I'm not calling
install()and I still end up with raven handling errors.mattrobenolt commentedon Mar 31, 2014
@bobbyrenwick Can you link me to something public that is showing this happening?
axelson commentedon Nov 19, 2014
Is there a workaround for this? Even when I never call
Raven.config()orRaven.install()or if I callRaven.config(false)the jquery or onerror handlers seem to be still be installed. The only workaround seems to be never loading the raven js in the first place (which is less than ideal).mattrobenolt commentedon Nov 19, 2014
See: #282 :)
axelson commentedon Nov 21, 2014
Are you providing #282 as just background? I don't see any workarounds in there.
mattrobenolt commentedon Nov 21, 2014
Yes, because there is no solution yet.
elsigh commentedon Jan 21, 2016
My only fix is to use
require()in anifblock (the rest of my code now usesimport:(lawlmart commentedon Jul 25, 2016
Is there an update on this?
JoannaFalkowska commentedon Aug 2, 2017
Any update? It STILL doesn't work correctly.
EDIT: Sorry for my tone. Had a long day.
tremby commentedon Aug 2, 2017
What are you trying to do? I'm doing this, which is working just fine:
Where
process.env.RAVEN_DSNis the DSN of course, and which is only set when building for environments where I want Raven running, viawebpack.EnvironmentPlugin.JoannaFalkowska commentedon Aug 2, 2017
In your version it's impossible to conditionally set up an Angular ErrorHandler. Either you set it up in every case, and then it swallows your errors no matter what, or don't but still list it in providers, which od dev causes entire module to crash.
As far as I know it's impossible to use or not use an Angular provider based on a condition.
I've done many iterations of fix attempts today.
tremby commentedon Aug 2, 2017
To be honest that sounds to me like an Angular issue rather than a Raven one.
Having said that, I agree that a more general solution would be a good addition.
Just a thought: have you tried setting a pattern in the
ignoreUrlsoption which matches all URLs? Would that do what you need? Something likeignoreUrls: [/./]?Or maybe set
sampleRateto zero?JoannaFalkowska commentedon Aug 2, 2017
It's possible to prevent Raven from sending requests and even from catching errors, but that doesn't stop the Angular ErrorHandler from swallowing errors (= at least losing track of actual lines from where errors were thrown).
I suppose you're right and it's not much of a Raven issue after all.
paulredmond commentedon Aug 4, 2017
For those coming here trying to figure it out still, it was a config option I missed at first
shouldSendCallback:If
shouldSendCallbackisfalsesentry will not report. No need for conditional reporting logic in your code with this 👍 .davidfurlong commentedon Oct 28, 2017
Make your DSN the empty string. It will disable reporting
paragjnath commentedon Oct 30, 2017
I have used this way. It seems working for me
if (environment.production) { Raven.config('https://@sentry.io/') .install(); }and in providers
providers: [environment.production ? { provide: ErrorHandler, useClass: RavenErrorHandler } : [], ...Please let me know if I am doing anything wrong here.
Only configure sentry in production mode
Only configure sentry in production mode
Only configure sentry in production mode
chore(core): Adjust `MIGRATION.md` after CLI reintroduction (#105)