Skip to content

fix(event-tags): do not exclude falsy revenue and event values in the event payload #213

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

Merged
merged 2 commits into from
Jan 28, 2019

Conversation

mikeproeng37
Copy link
Contributor

Summary

  • The revenue and event values were excluded from the event object if they evaluated as falsy.
  • The fix is to check against null instead of performing a truthy check because the utility method will return null if the revenue or event values cannot be parsed from the tags.

Test plan

  • Unit tests and integration tests

@mikeproeng37
Copy link
Contributor Author

@mikeproeng37
Copy link
Contributor Author

Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -133,12 +133,12 @@ function getVisitorSnapshot(configObj, eventKey, eventTags, logger) {

if (eventTags) {
var revenue = eventTagUtils.getRevenueValue(eventTags, logger);
if (revenue) {
if (revenue !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check for undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah because the getRevenueValue function will always return either null or the parsed value

Copy link
Contributor

Choose a reason for hiding this comment

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

The most robust (redundant) solution would be to check whether the returned value is a number, but I'm not sure it matters

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 97.468% when pulling 827d633 on mng/fix-falsy-event-revenue into d6e6809 on master.

@coveralls
Copy link

coveralls commented Jan 25, 2019

Coverage Status

Coverage increased (+0.005%) to 97.468% when pulling e7ed58a on mng/fix-falsy-event-revenue into d6e6809 on master.

Copy link
Contributor

@nchilada nchilada left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@@ -133,12 +133,12 @@ function getVisitorSnapshot(configObj, eventKey, eventTags, logger) {

if (eventTags) {
var revenue = eventTagUtils.getRevenueValue(eventTags, logger);
if (revenue) {
if (revenue !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The most robust (redundant) solution would be to check whether the returned value is a number, but I'm not sure it matters

@@ -1097,6 +1097,54 @@ describe('lib/core/event_builder', function() {
assert.deepEqual(actualParams, expectedParams);
});

it('should include falsy revenue values in the event object', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just mention 0 directly? The current test name incorrectly implies that NaN and non-numeric falsy values like '' would also be sent.

@mikeproeng37 mikeproeng37 merged commit cac996b into master Jan 28, 2019
@nchilada nchilada deleted the mng/fix-falsy-event-revenue branch January 28, 2019 23:23
oakbani pushed a commit that referenced this pull request Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants