Problem/Motivation
Exception: API key is not set in the configuration. in Drupal\posthog\CookieReader->getCookieName() (line 60 of /var/www/drupal/web/modules/contrib/posthog/src/CookieReader.php).
on first login after module installation!
Problem 2:
In Cookie Reader we assume a certain name for the cookie we read.
The PH docs say:
By default, we store all this information in both a cookie and localStorage, which means PostHog can identify your users across subdomains. By default, the name of the cookie PostHog sets is ph_
_posthog and it expires after 365 days.
Mind ph_
_posthog
https://git.drupalcode.org/issue/posthog-3586186/-/blob/3586186-identify...
So this should be relatively reliable.
Still we should add a test which does something to create this cookie and then in PHP should check to read it for 3 reasons:
Ensure the functionality works as expected in general
The cookie name is not changed
The cookie value we read is not changed
Both last tests should contain a message that if this fails, probably PostHog changed the name and that should be checked first!
Please link the docs there: https://git.drupalcode.org/issue/posthog-3586186/-/blob/3586186-identify...
I also though if we should move the cookies prefix, suffix and value distinct_id into config variables, but I think that might be prone to errors. Please instead move them to constants in the cookie reader!
Steps to reproduce
Log in in a fresh installation
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork posthog-3586061
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyComment #4
grevil commentedComment #6
anybody@grevil nice catch, makes perfect sense this way!
Comment #7
grevil commentedAlright, let's wait for the tests!
Comment #8
grevil commentedAll green!! Ready to merge. Final review by @anybody.
Comment #9
anybodyComment #11
anybodyComment #13
grevil commented