Skip to content

fix(analytics): clear GA user id on logout - #2381

Merged
thostetler merged 3 commits into
adsabs:masterfrom
thostetler:fix/ga-user-id-clear-on-logout
Sep 21, 2026
Merged

thostetler merged 3 commits into
adsabs:masterfrom
thostetler:fix/ga-user-id-clear-on-logout

Conversation

@thostetler

@thostetler thostetler commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Logging out never cleared the GA user_id, so hits for the rest of the browsing session kept attributing to the logged-out user.

user_signed_out never cleared the GA user_id set on sign-in, so
hits for the rest of the session stayed attributed to the logged-out
user. Also catches the digestMessage rejection crypto.subtle throws
on insecure origins, previously unhandled.

No test coverage for this file.
@thostetler
thostetler force-pushed the fix/ga-user-id-clear-on-logout branch from 61a4d8a to aed9cb8 Compare September 16, 2026 16:46
@thostetler
thostetler marked this pull request as ready for review September 16, 2026 16:49
Copilot AI lite review requested due to automatic review settings September 16, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

馃煛 Changes recommended

Two moderate issues remain involving stale asynchronous digests and synchronously thrown hashing errors.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates analytics identity handling to clear the GA user ID on logout and handle user-ID hashing failures.

Changes:

  • Sends user_id: null on user_signed_out.
  • Adds handling around user-ID hashing.
File summaries
File Description
src/js/components/navigator.js Handles GA identity updates on sign-in and sign-out.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

analytics('send', 'user_update', {
user_id: userIdHash,
});
digestMessage(data)
Comment on lines +99 to +102
.then((userIdHash) => {
analytics('send', 'user_update', {
user_id: userIdHash,
});
digestMessage assumed crypto.subtle exists; on insecure origins it's
undefined, so digest() threw synchronously past the caller's catch.
digest is also async, so a sign-out could land before a pending
sign-in hash resolved and re-attribute hits to the logged-out user.

- Reject instead of throwing when crypto.subtle is unavailable
- Run TextEncoder and digest() inside the promise chain
- Bump a token per announcement, discard hashes from a prior session
Fails with "el.onerror is not a function": a RequireJS module load
during the async window hits the global appendChild stub with an
element lacking onerror.
@thostetler
thostetler force-pushed the fix/ga-user-id-clear-on-logout branch from ea6f2b1 to 8d9eb59 Compare September 21, 2026 21:05
@thostetler
thostetler merged commit 4d81469 into adsabs:master Sep 21, 2026
1 check failed
@thostetler
thostetler deleted the fix/ga-user-id-clear-on-logout branch September 21, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants