Skip to content

fix(authentication): reconcile logged in users metric#1468

Open
it2022031 wants to merge 7 commits into
mainfrom
fix/auth-logged-in-users-metric
Open

fix(authentication): reconcile logged in users metric#1468
it2022031 wants to merge 7 commits into
mainfrom
fix/auth-logged-in-users-metric

Conversation

@it2022031
Copy link
Copy Markdown

@it2022031 it2022031 commented May 7, 2026

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other (please describe)

Does this PR introduce a breaking change?

  • Yes
  • No

The PR fulfills these requirements:

  • It's submitted to the main branch
  • When resolving a specific issue, it's referenced in the PR's description (e.g. fix #xxx, where "xxx" is the issue number)

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature

Other information:

This PR improves the accuracy of the logged_in_users_total authentication metric.

Previously, the metric could become inconsistent because expired sessions were not always removed correctly when tokens expired naturally over time. As a result, logged_in_users_total could temporarily report incorrect values.

Additionally, the metric was effectively tracking active tokens instead of unique logged-in users, meaning the same user could be counted multiple times across different sessions.

This PR centralizes logged-in user metric updates in TokenProvider and improves cleanup/reconciliation logic so the metric reflects unique active logged-in users more reliably across authentication flows, token refreshes, session invalidation, and expired token cleanup.

No breaking changes are introduced.

Copy link
Copy Markdown
Contributor

@kkopanidis kkopanidis left a comment

Choose a reason for hiding this comment

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

Unnecessary duplication present. The "provideUserTokens" function can be utilized to call the "addLoggedInUser" and "reconcileLoggedInUserMetric", instead of adding it everywhere in the code

Comment thread modules/authentication/src/handlers/common.ts Fixed
Comment thread modules/authentication/src/handlers/metamask.ts Fixed
Comment thread modules/authentication/src/handlers/tokenProvider.ts
Comment thread modules/authentication/src/handlers/common.ts Outdated
Comment thread modules/authentication/src/handlers/magicLink.ts Outdated
@ChrisPdgn ChrisPdgn self-requested a review May 11, 2026 11:07
@it2022031 it2022031 requested a review from kkopanidis May 11, 2026 11:08
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