Skip to content

feat(auth): Add client_id and service tags to StatsD, Sentry, and security events#20213

Merged
vbudhram merged 1 commit intomainfrom
FXA-13225
Mar 19, 2026
Merged

feat(auth): Add client_id and service tags to StatsD, Sentry, and security events#20213
vbudhram merged 1 commit intomainfrom
FXA-13225

Conversation

@LZoog
Copy link
Contributor

@LZoog LZoog commented Mar 18, 2026

Because:

  • We need to differentiate traffic by oauth client ID and service, as Fx currently uses the same client ID across multiple in-browser services

This commit:

  • Creates @fxa/accounts/oauth shared lib with OAuthNativeClients and OAuthNativeServices enums (moved from fxa-settings) to validate tags and prevent infinite cardinality
  • Adds clientId/service tags to the url_request timing metric and all StatsD calls in user-flow routes (account, password, session, totp, mfa, passwordless, recovery-phone, oauth)
  • Adds client_id and service to security events via the existing additionalInfo JSON column

closes FXA-13225

--

Verify the security event table changes by logging in, signing up etc. through Sync or another service (or RP to just capture the client IDs), and checking the security events table locally to see additionalInfo populated.

I threw this in temporarily:

if (tags.clientId || tags.service) {                                                                                   
  Sentry.captureMessage(`[TEST] clientTags: clientId=${tags.clientId}, service=${tags.service}`);                      
}

And I see the events coming into Sentry locally, filterable by service or client ID. You can see them if you filer in Sentry by local env.

@LZoog LZoog force-pushed the FXA-13225 branch 2 times, most recently from 3f5df3a to b48e9d3 Compare March 18, 2026 23:05
@LZoog LZoog marked this pull request as ready for review March 18, 2026 23:08
@LZoog LZoog requested a review from a team as a code owner March 18, 2026 23:08
@LZoog LZoog force-pushed the FXA-13225 branch 2 times, most recently from 83ad72d to 022df58 Compare March 19, 2026 14:24
…urity events

Because:
* We need to differentiate traffic by oauth client ID and service, as Fx currently uses the same client ID across multiple in-browser services

This commit:
* Creates @fxa/accounts/oauth shared lib with OAuthNativeClients and OAuthNativeServices enums (moved from fxa-settings) to validate tags and prevent infinite cardinality
* Adds clientId/service tags to the url_request timing metric and all StatsD calls in user-flow routes (account, password, session, totp, mfa, passwordless, recovery-phone, oauth)
* Adds client_id and service to security events via the existing additionalInfo JSON column

closes FXA-13225
Copy link
Contributor

@vbudhram vbudhram left a comment

Choose a reason for hiding this comment

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

@LZoog Thanks for adding the new lib

utmSource?: string;
utmTerm?: string;
clientId?: string;
service?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏽

additionalInfo: {
userAgent: opts?.request.headers['user-agent'],
location: opts?.request.app.geo.location,
...(clientId && { client_id: clientId }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Glad we are using additionalInfo!

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be nice to update the tests to verify entries are added but meh.

const hasLinkedAccount = (account.linkedAccounts?.length || 0) > 0;
const isExistingPasswordless = account.verifierSetAt === 0 && !hasLinkedAccount;
result.passwordlessSupported = isExistingPasswordless ||
const isExistingPasswordless =
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm wonder if we have different prettier settings.

@vbudhram
Copy link
Contributor

Just noting here that this will only register for these clients https://mozilla-hub.atlassian.net/browse/FXA-13225?focusedCommentId=1306114, not all clients since that can make the statsd have a high cardinality.

@vbudhram vbudhram merged commit f8d3edc into main Mar 19, 2026
22 checks passed
@vbudhram vbudhram deleted the FXA-13225 branch March 19, 2026 19:13
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.

2 participants