Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion packages/fxa-auth-client/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,16 @@ export default class AuthClient {

let errorCaptured = false;
try {
Sentry.addBreadcrumb({
category: 'auth-client',
message: 'outgoing request',
level: 'info',
data: {
path,
enc_path: btoa(path),
},
});

const response = await fetchOrTimeout(
this.url(path),
requestOptions,
Expand All @@ -453,6 +463,18 @@ export default class AuthClient {
throw parseError;
}
errorCaptured = true;
Sentry.addBreadcrumb({
category: 'auth-client',
message: 'response blocked by WAF',
level: 'info', // Available: fatal, error, warning, info, debug
data: {
path,
enc_path: btoa(path),
status: result.status,

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.

Shouldn't this be response? The result variable would be undefined here and we probably have to drop the code and errno parts?

code: result.code,
errno: result.errno,
},
});
throw new AuthClientError(
'WAF blocked',
'Request blocked by WAF',
Expand All @@ -463,11 +485,23 @@ export default class AuthClient {
if (result.errno) {
// We want to monitor down spikes in known responses from the auth server.
errorCaptured = true;
Sentry.addBreadcrumb({
category: 'auth-client',
message: 'response has known error',
level: 'info', // Available: fatal, error, warning, info, debug
data: {
path,
enc_path: btoa(path),
status: result.status,
code: result.code,
errno: result.errno,
},
});
Sentry.captureMessage(
`Auth client encoutered known error response during a request`,
{
tags: {
path: path,
path,
method: requestOptions.method || '',
errno: result.errno,
code: result.code,
Expand All @@ -478,6 +512,18 @@ export default class AuthClient {
}
if (!response.ok) {
errorCaptured = true;
Sentry.addBreadcrumb({
category: 'auth-client',
message: 'response not ok',
level: 'info', // Available: fatal, error, warning, info, debug
data: {
path,
enc_path: btoa(path),
status: result.status,
code: result.code,
errno: result.errno,
},
});
// We want to monitor spikes in non-ok responses.
Sentry.captureMessage(
`Auth client encoutered non-ok response during a request`,
Expand All @@ -500,6 +546,15 @@ export default class AuthClient {
return result;
} catch (e) {
if (!errorCaptured) {
Sentry.addBreadcrumb({
category: 'auth-client',
message: 'auth-client unexpected error',
level: 'error', // Available: fatal, error, warning, info, debug
data: {
path,
enc_path: btoa(path),
},
});
// One more check for unexpected errors that wouldn't have been caught by the above two check.
Sentry.captureMessage(
`Auth client encoutered unexpected error during request`,
Expand Down
Loading