rollbar.js
rollbar.js copied to clipboard
codeVersion (and code_version) options confusing on browser targets
I am bundling rollbar in my webpack build, so I am importing rollbar from its npm package. E.g.
import Rollbar from 'rollbar';
// ... somewhere else
new Rollbar({ accessToken: ..., ... })
The Rollbar constructor accepts a bunch of options, and the type definition says that it should accept code_version as well as codeVersion (here).
Furthermore, the rollbar documentation says that code version should be shown in the UI under the client.javascript.code_version key for it to work with (f.e.) source maps.
However, both options are not recognised as 'special' on the browser target, and instead end up in notifier.configured_options.codeVersion, leading to trying to match source maps for the unknown version.
this issue suggests not using the toplevel options and instead (manually) adding them via the payload option. This works, but it is confusing to me that the type definition says the constructor accepts codeVersion and/or code_version, but doesn't assign the (to me) expected significance to these keys on the browser target.
Is it possible to have a seperate type definition for the browser target, or assign the significance on the browser target as well, or amend this documentation example with configuration for this code version feature?
@lennartbuit Thank you for the feedback. I'll take look at improving this.
I'm in a similar situation: I was trying to report the code version from Node.js but found only in client.javascript.code_version in documentation which doesn't help on server side. I tried using the root-level codeVersion key in constructor and it works. But it seem to be missing in the documentation. https://docs.rollbar.com/docs/rollbarjs-configuration-reference
The whole situation with codeVersion, branch, and environment is a mess.
- Why do they need to differ between a client-side application and a server-side application?
- Why are they mixed between top-level configuration and payload configuration?
- Why is top-level
codeVersionnot documented separately? - Why is top-level
environmentnot documented (but in the type definitions)? - Why is
code_versiononly listed underclientand notserver? - Why do you mix camelCase and snake_case?
My suggestion: Decide on top-level or payload-level configuration, and put all 3 values there (only), with the same character case.
@glen-84 It's legacy that can't change until a major version bump. The docs could be improved though.
This is still a problem as of March 2021. It's cost me at least a full day of work time on top of the time for your support team as I opened a ticket about it. The SDK types completely contradict the documentation and it doesn't say this anywhere. You openly acknowledge that "the docs could be improved" nearly a year ago but they are still wrong. Pretty disappointing from a commercial product to be honest.
Hello,
I'm new to Rollbar and this issue also cost me some hours before I could configure this product. Being such an old issue (it was reported more than 2 years ago), could you prioritize it so newcomers don't need to lose time on it and get a bad impression?
What I find confusing:
- The mixing of case. Could you decide on which case to use and be consistent everywhere?
- Allowing this property to appear in the payload or outside: decide for one place and stick to it. If you need this long confusing of an explanation in your source code, something needs to be improved:

- There is a
versionand acodeVersionproperty. What is each one used for? The d.ts file doesn't have documentation forversion.
Regards.