rollbar.js
rollbar.js copied to clipboard
Allow captureIp without a window object
Description of the change
The user IP address is optionally captured at the Rollbar API. The SDK sends a token in the payload signaling whether the captured IP should be added to the payload. This token is added to the payload request
object, which is only added if a browser window object is detected. (The other keys in the request object depend on window.location
.)
Setting this token doesn't rely on the window
object and should be allowed. This is relevant for Electron apps, and for any other client side environment that doesn't support window.location
.
This PR allows the request object to be sent with the user IP token, regardless of the presence of window
or window.location
. Tests are added for this condition, as well as for generally correct behavior when config.captureIp
is set.
Type of change
- [x] Bug fix (non-breaking change that fixes an issue)
Related issues
Fixes https://github.com/rollbar/rollbar.js/issues/963
Development
- [x] Lint rules pass locally
- [x] The code changed/added as part of this pull request has been covered with tests
- [x] All tests related to the changed code pass in development
Code review
- [x] This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
- [x] "Ready for review" label attached to the PR and reviewers assigned
- [x] Issue from task tracker has a link to this pull request