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

Issue with setUserId - setting to null creates error in Url building when tracking #7043

Closed
000panther opened this issue Jan 16, 2015 · 2 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@000panther
Copy link

We track our users with the users userId and are using the

_queueApiCall('setUserId', userId);

API call to track them. This works great, although we found a small problem. When a User logs out, we unset this property, by calling:

_queueApiCall('setUserId', null);

This leads to problems when calling

_queueApiCall('trackEvent', type, action, title);

Because in this line in piwik.js:2919

(configUserId.length ? '&uid=' + encodeWrapper(configUserId) : '') +

the configUserId.length call will fail because configUserId is null. We resolved this issue locally by just setting the user id to an empty string, but it was hard work finding what failed in the minified source code.

  1. How should one unset the configUserId correctly if the user logs out?
  2. In my opinion, the application should be robust enough to handle wrong values or fail when they are passed. I am not sure which way piwik is going here, but it would be nice if the current behavior would be replaced.
@000panther
Copy link
Author

It seems like this problem is handled by typecasting values to String in other cases in the pwik.js source code.

@tsteur tsteur closed this as completed in 18b2dcf Jan 19, 2015
@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Jan 19, 2015
@tsteur tsteur added this to the Piwik 2.11.0 milestone Jan 19, 2015
@tsteur tsteur self-assigned this Jan 19, 2015
@tsteur
Copy link
Member

tsteur commented Jan 19, 2015

Thx for the report! Checking whether a value exists before accessing .length

tsteur added a commit that referenced this issue Jan 19, 2015
…esult in a string null, check whether it exists instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants