-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use JSON instead of "PHP-style nested object syntax" to send actual data types in the metadata #217
Comments
I would be interested to see the size difference of using JSON instead, as I know the keys kinda add some redundancy to the payload right now. The main issue I see here is the fact that IE6 & 7 (and in some cases IE8) (caniuse.com) don't support I don't see an issue with conditionally stringifying the payload based on what's available in the browser - using the current method as a fallback if |
On a quite nested payload (redux state of a large app), JSON is twice shorter:
Note that Moreover, |
I was wrong to include the raw, non-URL-encoded JSON size, but the URL-encoded size is still less:
Btw, can the current Bugsnag API accept JSON payload in the query string, in a GET request? |
That's not a terrible saving. Every little helps.
It doesn't seem to be possible with the current "general" notifier endpoint, because GET requests can't have a body. Though seeing as the payload is structured differently for the JS notifier anyway, if the current JS endpoint accepted both the JSON & "PHP-style" format, it would make it even easier - as far as the changes required in the notifier. |
Are you in the Bugsnag team? There isn't any public documentation of that special "js" endpoint... |
Oops looks like my example payload, being sent as query string (either serialize or JSON), may hit the URL length limit in some browsers: http://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string (fortunately, it hasn't hit it with the Bugsnag API server yet). |
No, I'm not. And I'm not sure there is any documentation for it - but you can open up the network tab (in Chrome) and take a look at what gets sent. Or you could do a bit of code diving 😛
Yeah that's the main issue, and why every little really does help. |
Yes, I did that. I mean, to learn if there are other types of requests it can possibly accept. |
I am thinking that an option to specify a custom transport to send requests would be useful here. This way an app could implement both sendBeacon (which is URL-limited as well) and POST JSON. And I'm thinking unfortunately I'll have to abandon |
@sompylasar I think the easiest way to accomplish what you are trying to do is with a Bugsnag.beforeNotify = function(payload) {
// custom serialization and request logic
return false;
} The only other thing you would be missing is this one check that we do to filter out indecipherable cross-domain and eval script errors, but you could also paste that into your beforeNotify callback. We recommend however that you continue using the JS endpoint with the payload in the url query string (as this endpoint doesn't support posting JSON). The JS endpoint pulls out some metadata (ip address, user agent, referer) from the request itself because it is assumed to come from the user directly. If you wanted to use the main notifier endpoint you would have to collect this information manually and include it in the payload metadata in order to take advantage of it. |
@wordofchristian Looks good, thank you! I missed this part I'm sure this
is not the only error that needs to be filtered. I previously made a custom error reporter, similar to bugsnag but proprietary, for a world-wide product, and we filtered lots of false reports including this one (there was a hundred lines of code just for filtering false positives observed in different browsers and conditions).
If this endpoint could support consuming JSON payload, this could help partially, but this cannot help overcome the URL length limits that may apply. I need to post a large chunk of data and I'd like it to be structured to be able to use Bugsnag custom filters. What I dream of is to be able to apply filtering and tagging in the reporting service (backend + web UI) itself, not in the app that sends the reports. |
There's a lot of good points and interesting discussion in here. It makes sense that we give more thought to supporting a more modern delivery mechanism in addition to the existing options, though the library's API for handling this would need to be refined somewhat. I posted some related ideas on @jacobmarshall's related issue here. The next steps are to explore and define this idea more concretely, hopefully to have an expressive yet performant (and backwards compatible) library. |
@kattrali Thanks! By the way, if you're going to redefine the library's API, please consider unifying |
@sompylasar That’s a great point too. Thanks! |
Hey everybody on this thread, you can now try out the v4 beta version of this notifier which uses JSON as the serialized data format (at last 🎉)! Intro/instructions are here: https://docs.google.com/document/d/1HBBLyVv9FHsNmbkRLx58WbtisMRVHwDoR3pnxac9JQQ/ If you try the beta, please let us know how you get on. Otherwise we anticipate doing a full major release at the start of December. |
🚢 v4 is now published. Please upgrade! See UPGRADING.md and full docs for more info 😄 |
Currently, because
bugsnag-js
serializes metadata as "PHP-style nested objects" into the query string, the actual data types get lost.bugsnag-js/src/bugsnag.js
Lines 753 to 756 in 9fc759f
Preserving the data types in the reports is important to debug certain type-related issues which are not uncommon in weakly typed JavaScript.
The data types could be preserved by using JSON.
The public Bugsnag API is advertised to take JSON payload: https://docs.bugsnag.com/api/error-reporting/#json-payload
The text was updated successfully, but these errors were encountered: