-
Notifications
You must be signed in to change notification settings - Fork 124
Continuation - Since our CMS Drupal does occasionally assign the value zero to userID #82
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
Conversation
|
The 2nd part of my hesitation still stands #77 (comment).
Why can't this be fixed upstream of the library? When is sending |
|
It can be fixed upstream. My thought for this pull request is that analytics.js allows user 0. I think the PHP library should be expected to behave the same as the JS library. |
|
SGTM - it sucks that cc @calvinfo and @dominicbarnes if I could get your eyes on this as well! |
|
SGTM, thanks for the contribution @btruong. Do you mind adding a test case for the zero user and showing that it passes validation? |
…, we need to allow segment calls to still validate when the userId is zero, so instead using not empty, using isset would allow the call to validate if the userId value happens to be zero
|
Thanks for you input @f2prateek and @calvinfo, I just updated the PR with some improved logic and we were able to test and verify on our Drupal instance that when the userId is zero, we no longer get an error using the following logic
this allows all empty checks to correctly detect when the $message array has an array key of 'userID' and whatever that value happens to be, it will be type-casted as a string so that we can use strlen to detect for the presence of 0 values. The question remains, we have anonymous users throughout our Drupal site triggering segment events and so why haven't we seen the error as often? We also are considering the hunch that the the error that spawned this initiative might represent and edge case where the browser might have some kind of ad blocking enabled where cookies are not stored (ajs_anonymous_id, etc.) and that might have caused the Segment.php script to rely on the userId check instead. Here was the initial error that spawned our investigation:
Stack trace |
|
Sorry for the delay here! The CI issues are a separate problem we'll get fixed, but I'd like to see some other changes here before merging:
Tracking internally in JIRA as well — https://segment.atlassian.net/browse/LIB-142. |
nd4p90x
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are causing tests to fail, I believe this is due to the variable name change for userID. Please review and make necessary changes. Thank you.
|
Issue #157 is replacing this request |
This is a continuation of the closed PR #77 and applies suggestions from @dustincurrie in the comments of that closed PR.