% Preamble %
I am setting up ember-cli-sentry and am looking to identify the user so that when we get exceptions reported, we know what user those exceptions were associated with, in case they were user-specific. (Say, we deploy to staging, we got some data from the backend that was bad, causing certain errors with the only the users who got that bad data into their account).
& Actual question &
I want to execute some code immediately after the user model loads. I do not know what route is going to be triggering the user model to load.
In theory, actually, the earliest possible place I could get the user model data is immediately after the request for that data is completed. I wonder, would it be crazy to hijack the XHR method, and when the user id is requested, run my code to tell raven/sentry who this user is?
It would be better if there was simply a “loaded” hook for model files, but I’ve never heard of such a thing. Maybe this is the one use case where this would be desirable?
An h1 for google/seo:
3
Answers
Thank you @duizendnegen and @Isaac Askew, observers were a great starting point and led me to the final solution. This observer code, placed in my application route, helped me figure out exactly what I could add as user context:
However, I did try just
get
ing the props I care about in mylogger
service at exception time instead, and this worked well. It's better because you won't have code needlessly executing every time a property you want to log changes:For some reason the observer wouldn't work in my logr service..
Extra notes:
config/DEPLOY.js
, notconfig/environment.js
To trigger an error somewhere in some application route hook:
development: false
to let raven actually send this test error to sentry (unless you aren't testing end to end) (I typically have this set:development: environment === 'development'
In application route actions, add this to your error action handler:
Perhaps in your main application route you can do something like this:
I’d suggest to either