Sourcemaps without raven.js in the browser

Hi,

We have some constraints with the way we’re currently logging errors. We use our own custom logger-service, so the browsers pushes the stacktrace and error information to our service, which then uses raven-node to post them to sentry. Is there something special that we would have to do to get sourcemaps working?

It seems like raven-node sends the right information, but we’re not getting the sourcemaps. The following is an example frame:

{  
                  "filename":"http://localhost:4300/assets/vendor-stable.js",
                  "lineno":4315,
                  "colno":28,
                  "function":"HTMLBodyElement.elemData.handle",
                  "in_app":true,
                  "module":"vendor-stable"
               },

When I use raven-js, the frame looks the same with the exception of module:

{  
                     "filename":"http://localhost:4300/assets/vendor-stable.js",
                     "lineno":4315,
                     "colno":28,
                     "function":"HTMLBodyElement.elemData.handle",
                     "in_app":true
                  },

Am I missing something else?

We don’t currently have sourcemap support in raven-node. I can only suggest trying to use Mozilla’s source-map library to fix stack traces yourself before sending them over.

But there’s an open issue on GitHub for this: https://github.com/getsentry/sentry/issues/2632

Thanks Matt.
If I want to have a stab at this, is it documented what sentry expects for this? The payload between both clients (browser and node) looks really similar.

Well, in raven-node, it’s all currently happening here: https://github.com/getsentry/raven-node/blob/master/lib/utils.js#L138-L203

So just taking a look at this dictionary that’s constructed, you should be able to easily transform it into what you need by applying the source-map library to it.

Alternatively, and I have 0 context on how you’d do this, but for example, CoffeeScript mutates the stacktraces themselves before we even get them, so when we parse the stracktrace there’s no additional work to be done.

If you want to go crazy and do this, you could probably hook into Error.prepareStackTrace and apply sourcemaps at that point, then there will be no additional work needed for raven-node to work. I’m pretty sure this is what CoffeeScript does. It’s also possible that there is existing work in another library to just do this automatically.

Possible this would work? https://github.com/evanw/node-source-map-support

Thanks. I’m still not sure what’s different. When I use sentry-js it seems like we parse the stacktrace, create frames, adds filenames, lineno, colno, etc, which I also have on my raven-node errors, but still it works for one, but not for the other. What else do I need to send to sentry for this to work? Is this API documented? I found docs for other parts of the API, but nothing for store.

@matt, I had another go at it and there is one bit that I still don’t understand. While it’s possible to use https://github.com/mozilla/source-map#consuming-a-source-map and update each frame manually, it seems like we would be duplicating the functionality that exists already in Sentry. Also, we push the sourcemaps to sentry, but our logging-service doesn’t have them. It’s possible to push them, but then again, sentry already has functionality for releases and assets for this releases that I would prefer not to have to replicate in our logging service.

We don’t currently have sourcemap support in raven-node

I’m under the impressions that original stacktraces are transformed server by Sentry, not by the client libs (raven-js or raven-node). If that’s correct, tehn raven-js doesn’t have “sourcemap support” either. This is probably the bit that I’m missing, but as you can see on my original examples, in both cases we refer to concatented/minified code (e.g. vendor-stable.js). The only difference between both is that one has a module and other one doesn’t. There’re other differents with the headers and other parts of the payload that tell sentry which client lib was used or what verison of the API is used, so I’m guessing that may be part of the difference.

Is the API documented somewhere?

Also, just to clarify, I don’t need sourcemaps for “node code” or “node errors”, but rather we use node to log client-side errors.