Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

feat: Preserve some non-enumerable properties from request #379

Merged
merged 2 commits into from
Sep 27, 2017

Conversation

kamilogorek
Copy link
Contributor

Fixes #360

lib/utils.js Outdated
@@ -56,6 +56,22 @@ module.exports.getAuthHeader = function getAuthHeader(timestamp, apiKey, apiSecr
return header.join(', ');
};

module.exports.prepareInitialRequest = function prepareInitialRequest() {
var request = {};
var nonEnumberables = ['ip'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be passed as an argument, but I wasn't sure if that's worth it, as it's one-off util.

Copy link
Contributor

@MaxBittker MaxBittker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a good fix, but it's still slightly confusing and I think the comments + test would help.

lib/client.js Outdated
@@ -228,14 +228,29 @@ extend(Raven.prototype, {
so we only parse a `req` property if the `request` property is absent/empty (and hence we won't clobber)
parseUser returns a partial kwargs object with a `request` property and possibly a `user` property
*/
var initialRequest = utils.prepareInitialRequest(
this._globalContext.request,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind adding some comments here? I'm having trouble understanding why it is needed to use both prepareInitialRequest and extend on these groups of request & req objects, instead of replacing in extend with prepareInitialRequest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just me missing it. Fixed :)

@@ -98,6 +98,66 @@ describe('raven.utils', function() {
});
});

describe('#prepareInitialRequest', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests on the prepareInitialRequest utility seem good to me, but would you mind writing a slightly broader test that recreates the original problem outlined in #360?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@kamilogorek
Copy link
Contributor Author

@MaxBittker everything has been addressed

@kamilogorek kamilogorek requested review from a team and removed request for benvinegar September 26, 2017 15:38
@kamilogorek kamilogorek merged commit 343da4a into master Sep 27, 2017
@kamilogorek kamilogorek deleted the preserve-nonenums branch September 27, 2017 11:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants