Skip to content
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

accept numbers for setUserId, setEcommerceView, addEcommerceItem, removeEcommerceItem #15131

Merged
merged 1 commit into from Nov 8, 2019

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Nov 7, 2019

fix #14714

We ran into this issue ourselves actually eg in Matomo for WordPress etc https://github.com/matomo-org/wp-matomo/pull/67/files therefore moved it into 3.13.0 so userId and ecommerce tracking is easier.

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Nov 7, 2019
@tsteur tsteur added this to the 3.13.0 milestone Nov 7, 2019
category = "";
} else if (category instanceof Array) {
category = JSON_PIWIK.stringify(category);
}

customVariablesPage[5] = ['_pkc', category];

if (isDefined(price) && String(price).length) {
if (isDefined(price) && price !== null && price !== false && String(price).length) {
Copy link
Member Author

Choose a reason for hiding this comment

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

BTW I'm not sure it's on purpose we allow tracking price when there is only category set? Could create another issue for it... maybe it's on purpose ... @mattab

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW String(false).length would return 5 which is why I added specific check for false and null etc.

Copy link
Member

Choose a reason for hiding this comment

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

Can't remember if it's on purpose or not, but seems one should be able to track price even without a category set @tsteur

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, if I see this right you can track just a category, or a category with a price. Not sure why you would track a category with a price but not an SKU or name... sounds to me like price makes only sense when also name or SKU is set?

deepEqual( tracker3.getCustomVariable(3, "page"), false, "All numbers Ecommerce view SKU");
deepEqual( tracker3.getCustomVariable(4, "page"), false, "All numbers Ecommerce view Name");
deepEqual( tracker3.getCustomVariable(5, "page"), ["_pkc", ''], "All numbers Ecommerce view Category");
tracker3.deleteCustomVariables('page');
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a similar test w/ nulls?

Copy link
Member Author

Choose a reason for hiding this comment

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

@diosmosis I don't think it's needed. Then we would need to start doing this kind of for all methods...

@diosmosis diosmosis merged commit 99a6050 into 3.x-dev Nov 8, 2019
@diosmosis diosmosis deleted the 14714 branch November 8, 2019 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS Tracker: setUserId and addEcommerceItem sku should work when User ID is a number
3 participants