jeudi 18 janvier 2018

Ember:Hook to execute code after model loads from any route?

% 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 user model data is after the XHR for that data comes in over the network. 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?




Aucun commentaire:

Enregistrer un commentaire