Skip to content

Commit 69ab6a5

Browse files
committed
chore(auth): Clean up stray log and metric format
1 parent 11f7264 commit 69ab6a5

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

packages/fxa-auth-server/lib/routes/auth-schemes/verified-session-token.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,15 @@ function strategy(getCredentialsFunc, db, config, statsd) {
7171
// 1) account email is verified
7272
if (!account?.primaryEmail?.isVerified) {
7373
if (skipEmailVerifiedCheckForRoutes?.test(req.route.path)) {
74+
// Important! Using req.route.path which has much lower cardinality than req.path
7475
statsd?.increment(
7576
'verified_session_token.primary_email_not_verified.skipped',
76-
[
77-
// Important! Using req.route.path which has much lower cardinality than req.path
78-
req.route.path,
79-
]
77+
[`path:${req.route.path}`]
8078
);
8179
} else {
8280
statsd?.increment(
8381
'verified_session_token.primary_email_not_verified.error',
84-
[req.route.path]
82+
[`path:${req.route.path}`]
8583
);
8684
throw AppError.unverifiedAccount();
8785
}
@@ -90,13 +88,12 @@ function strategy(getCredentialsFunc, db, config, statsd) {
9088
// 2) session token is verified
9189
if (token.tokenVerificationId || token.tokenVerified === false) {
9290
if (skipTokenVerifiedCheckForRoutes?.test(req.route.path)) {
93-
console.log('!!! verified_session_token.token_verified.skipped');
9491
statsd?.increment('verified_session_token.token_verified.skipped', [
95-
req.route.path,
92+
`path:${req.route.path}`,
9693
]);
9794
} else {
9895
statsd?.increment('verified_session_token.token_verified.error', [
99-
req.route.path,
96+
`path:${req.route.path}`,
10097
]);
10198
throw AppError.unverifiedSession();
10299
}
@@ -112,13 +109,12 @@ function strategy(getCredentialsFunc, db, config, statsd) {
112109

113110
if (accountAal !== sessionAal) {
114111
if (skipAalCheckForRoutes?.test(req.route.path)) {
115-
console.log('!!! verified_session_token.aal.skipped');
116112
statsd?.increment('verified_session_token.aal.skipped', [
117-
req.route.path,
113+
`path:${req.route.path}`,
118114
]);
119115
} else {
120116
statsd?.increment('verified_session_token.aal.error', [
121-
req.route.path,
117+
`path:${req.route.path}`,
122118
]);
123119
throw AppError.unauthorized('AAL mismatch');
124120
}

packages/fxa-auth-server/test/local/routes/auth-schemes/verified-session-token.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
139139
assert.isTrue(
140140
statsd.increment.calledWithExactly(
141141
'verified_session_token.primary_email_not_verified.error',
142-
['/foo/{id}']
142+
['path:/foo/{id}']
143143
)
144144
);
145145
}
@@ -162,7 +162,7 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
162162
assert.isTrue(
163163
statsd.increment.calledOnceWithExactly(
164164
'verified_session_token.primary_email_not_verified.skipped',
165-
['/foo/{id}']
165+
['path:/foo/{id}']
166166
)
167167
);
168168
});
@@ -182,7 +182,7 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
182182
assert.isTrue(
183183
statsd.increment.calledWithExactly(
184184
'verified_session_token.token_verified.error',
185-
['/foo/{id}']
185+
['path:/foo/{id}']
186186
)
187187
);
188188
}
@@ -202,7 +202,7 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
202202
assert.isTrue(
203203
statsd.increment.calledOnceWithExactly(
204204
'verified_session_token.token_verified.skipped',
205-
['/foo/{id}']
205+
['path:/foo/{id}']
206206
)
207207
);
208208
});
@@ -223,7 +223,7 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
223223
assert.equal(payload.errno, AppError.ERRNO.INVALID_TOKEN);
224224
assert.isTrue(
225225
statsd.increment.calledWithExactly('verified_session_token.aal.error', [
226-
'/foo/{id}',
226+
'path:/foo/{id}',
227227
])
228228
);
229229
}
@@ -245,7 +245,7 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
245245
assert.isTrue(
246246
statsd.increment.calledOnceWithExactly(
247247
'verified_session_token.aal.skipped',
248-
['/foo/{id}']
248+
['path:/foo/{id}']
249249
)
250250
);
251251
});

0 commit comments

Comments
 (0)