Send custom data with Javascript provider
Rob M
Posted on
Nov 01 2013
I am interested in using Raygun for collecting data about Javascript errors in our app. We would, ideally, like to send some custom data along with the thrown error object but I haven't figured out how to do this.
Looking at the provider source code it hinted that Raygun.send(e, {extra: "information"}) might work, but I gave that a try and couldn't see that info in the dashboard even in the raw view.
I may have the syntax wrong, I may not understand where to look in the dashboard, or it may not work like this. I've looked at the REST api docs and there does seem to be provision for a userCustomData object, so I guess if I wrote my own provider or built upon the raygun4js provider I could achieve this, but I'd rather use the out-of-the-box offering!
Does anyone know if this is possible, and if so how?
John-Daniel Trask
Raygun
Posted on
Nov 01 2013
Thanks for bringing this issue to our attention - this is indeed the expected behaviour - both send() and init() shouldaccept custom data (as the second and third parameter, respectively). The type of the custom data is expected to be either an array or an object, and this currently does work correctly for init(), so right now you can use:
Raygun.init('yourApiKey', null, { extra: "information" });
However, this will be sent with every unhandled exception.
The issue is that send(e, customData) isn't sending either an array or object, as you've noticed. This is a bug and we're looking into a fix for it now. I will post here when the provider has been updated.
Regards,
Callum Gavin
John-Daniel Trask
Raygun
Posted on
Nov 01 2013
And the fix has been applied - send(exception, customData) now works correctly, and can accept an array or JavaScript object, so your expected example above should work now.
The updated version of the script is available here:
https://raw.github.com/MindscapeHQ/raygun4js/master/dist/raygun.min.js
Any more questions or issues let us know.
Rob M
Posted on
Nov 01 2013
Hey guys, I've taken a look at the change and given it a whirl and can confirm it's fixed the issue, I am now seeing the custom data in my dashboard. Cheers for the speedy response!
jfbloom22
Posted on
Jun 09 2015
I am not seeing the "custom data" tab in my dashboard. I do see a "RAW data" tab. But it does not have the custom data in it that I am sending. Am I doing something wrong?
var errObj = { "functionname" : data.functionname ? data.functionname : '', "msg" : data.msg ? data.msg : '', "detail" : data.detail ? data.detail : '', "title" : data.title ? data.title : '', "level" : data.level ? data.level : 'log' }; var rayMessage = data.msg ? data.msg : data.functionname; Raygun.send(new Error(rayMessage, errObj));
jfbloom22
Posted on
Jun 09 2015
aha! I answered my own question. I now see the "Custom" tab.
Raygun.send(new Error(rayMessage), errObj);
I was putting the custom data inside the Error object. Oops.
Callum
Posted on
Jun 09 2015
Yup, that's the fix! Glad you found it, and hope Raygun proves to be useful for you and your team.