What is the proper way to attach error reporting after a user logs in?

Joshua

Posted on
Jun 19 2014

So I want to start tracking general guest errors the moment people load up my application. Then when the user logs in a want to switch to tracking by their id. with custom data and tags. What's the best way to accomplish this? Is this something that would work?

Before:

Raygun.init(apiKey).attach();
Raygun.setUser('guest');
Raygun.setVersion(version);

After:

Raygun.detach();
Raygun.init(apiKey).attach().withCustomData().withTags();
Raygun.setUser(user);
Raygun.setVersion(version);

Does that look like it'll work the way I want or is there a better way to do it without detaching between?


Callum

Posted on
Jun 20 2014

You shouldn't need to detach and then call init/attach again after the user has logged in, just call setUser(user) to update the provider with the latest user string. If this doesn't work this may be an indication of a flaw in Raygun4JS - let us know if this is successful.


Joshua

Posted on
Jun 20 2014

Thanks, I'll just attach it and apply stuff as it becomes available. I'll let you know if it becomes a problem.


Reply