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

Match configId even when userId is found #15337

Merged
merged 4 commits into from Jan 2, 2020
Merged

Match configId even when userId is found #15337

merged 4 commits into from Jan 2, 2020

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Jan 1, 2020

fix #15320
refs #15337
fyi @mattab @diosmosis

I wonder if maybe the query should be actually and user_id is null or user_id = $userIdFromRequestIfGiven?

Edit: Added the or user_id = ?

fix #15320

fyi @mattab @diosmosis 

I wonder if maybe the query should be actually and `user_id is null or user_id = $userIdFromRequestIfGiven`?
@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 Jan 1, 2020
@tsteur tsteur added this to the 3.13.1 milestone Jan 1, 2020
tsteur added a commit to matomo-org/matomo-for-wordpress that referenced this pull request Jan 1, 2020
@diosmosis
Copy link
Member

code looks good to me, and the user_id = ? addition makes sense to me after thinking about it. might be good to have a test (if current tests aren't already affected), otherwise looks good to me.


if (empty($visitRow)) {
$configIdWhere .= ' AND user_id IS NULL ';
$configIdWhere .= ' AND ( user_id IS NULL ';
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 @mattab noticing this would create a new visit when userId was previously set, and then user logs out using resetUserId. I suppose this is not what we want as we also don't create a new visit when userId is set initially. I suppose we maybe really only always want to add AND ( user_id IS NULL OR user_id = ? ) when userId is not empty?

Copy link
Member Author

@tsteur tsteur Jan 1, 2020

Choose a reason for hiding this comment

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

Also when user is found by idVisitor, then we would also not create a new visit after resetUserId so we need to make sure to have consistent behavior no matter if cookies are enabled or disabled... I will later change the query I reckon to only compare userId when a userId is set

Copy link
Member

Choose a reason for hiding this comment

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

If userId is null, we'd want to look for ( user_id IS NULL ) though, correct? Otherwise it would match the logged out user. Then again, ( user_id IS NULL OR user_id = ? ) would also match the user after they login (ie, logged out => login), so maybe both behaviors are desired?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's current desired/ implemented behaviour AFAIK and that's how it also works when it matches the visit by visitorId. See thread in matomo-org/developer-documentation#320

We just need to make sure to always have consistent behaviour on log in and log out. Either we always create a new visit on log in and log out, or never.

Copy link
Member

@diosmosis diosmosis Jan 1, 2020

Choose a reason for hiding this comment

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

I thought the point of separating user ID from visitor ID was so you could tell when a user logged in/out. Ie, it would count as the same visitor (along with same user different idvisitor being different visitors but one user), but count as different users? Maybe this isn't clear anymore w/ the userid change...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure? If that's the case, then I think this wasn't implemented.

Copy link
Member

Choose a reason for hiding this comment

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

I think you're right it was never implemented. It does seem more useful to me though. I guess it could go in another issue.

@tsteur
Copy link
Member Author

tsteur commented Jan 2, 2020

@diosmosis I'll merge for now. We'll see what comes out of matomo-org/developer-documentation#320 re forcing new visits

@tsteur tsteur merged commit bdb960e into 3.x-dev Jan 2, 2020
@tsteur tsteur deleted the 15320 branch January 2, 2020 00:27
jonasgrilleres pushed a commit to 1024pix/pix-analytics that referenced this pull request Sep 22, 2020
jbuget pushed a commit to 1024pix/pix-analytics that referenced this pull request Sep 26, 2020
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.

Multiple unique visit for each action for same User ID
2 participants