Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Capture certain network errors to Sentry #3423

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

nicholas-codecov
Copy link
Contributor

Description

This PR updates the NetworkErrorBoundary so that certain errors will be sent to Sentry so we can keep better track of them. Typically this will only be related to zod parsing errors as they're ones that we control ourselves, and it probably a good idea that we keep track of them and resolve them when able.

Example Code

const parsedData = RequestSchema.safeParse(res?.data)

if (!parsedData.success) {
  return Promise.reject({
    status: 404,
    data: {},
    dev: 'useBundleSummary - 404 Failed to parse data',
    // including the error here will trigger Sentry to capture the message and create an issue
    error: parsedData.error,
  } satisfies NetworkErrorObject)
}

const data = parsedData.data

if (data?.owner?.repository?.__typename === 'NotFoundError') {
  // No error included here, so no message will be sent to Sentry
  return Promise.reject({
    status: 404,
    data: {},
    dev: 'useBundleSummary - 404 Not found error',
  } satisfies NetworkErrorObject)
}

Notable Changes

  • Remove Sentry metrics related to network errors
  • Update NetworkErrorBoundary to send certain errors to Sentry
  • Update NetworkErrorObject to have conditional error field
  • Update tests

@codecov-staging
Copy link

codecov-staging bot commented Oct 22, 2024

Bundle Report

Changes will decrease total bundle size by 385 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 5.55MB 192 bytes (-0.0%) ⬇️
gazebo-staging-system 5.5MB 193 bytes (-0.0%) ⬇️

Copy link

codecov bot commented Oct 22, 2024

Bundle Report

Changes will decrease total bundle size by 385 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.5MB 193 bytes (-0.0%) ⬇️
gazebo-production-system-esm 5.55MB 192 bytes (-0.0%) ⬇️

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.15%. Comparing base (34c9ae8) to head (5d34d9c).
Report is 4 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3423   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files         809      808    -1     
  Lines       14239    14263   +24     
  Branches     3923     3933   +10     
=======================================
+ Hits        14118    14142   +24     
  Misses        112      112           
  Partials        9        9           
Files with missing lines Coverage Δ
...ared/NetworkErrorBoundary/NetworkErrorBoundary.jsx 100.00% <100.00%> (ø)
src/services/bundleAnalysis/useBundleSummary.tsx 100.00% <ø> (ø)
src/shared/api/helpers.ts 100.00% <ø> (ø)
src/shared/utils/metrics.ts 100.00% <ø> (ø)

... and 3 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <100.00%> (ø)
Pages 98.89% <ø> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34c9ae8...5d34d9c. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.15%. Comparing base (34c9ae8) to head (5d34d9c).
Report is 4 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3423   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files         809      808    -1     
  Lines       14239    14263   +24     
  Branches     3928     3940   +12     
=======================================
+ Hits        14118    14142   +24     
  Misses        112      112           
  Partials        9        9           
Files with missing lines Coverage Δ
...ared/NetworkErrorBoundary/NetworkErrorBoundary.jsx 100.00% <100.00%> (ø)
src/services/bundleAnalysis/useBundleSummary.tsx 100.00% <ø> (ø)
src/shared/api/helpers.ts 100.00% <ø> (ø)
src/shared/utils/metrics.ts 100.00% <ø> (ø)

... and 3 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <100.00%> (ø)
Pages 98.89% <ø> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34c9ae8...5d34d9c. Read the comment docs.

Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.15%. Comparing base (34c9ae8) to head (5d34d9c).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3423   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files         809      808    -1     
  Lines       14239    14263   +24     
  Branches     3923     3933   +10     
=======================================
+ Hits        14118    14142   +24     
  Misses        112      112           
  Partials        9        9           
Files Coverage Δ
...ared/NetworkErrorBoundary/NetworkErrorBoundary.jsx 100.00% <100.00%> (ø)
src/services/bundleAnalysis/useBundleSummary.tsx 100.00% <ø> (ø)
src/shared/api/helpers.ts 100.00% <ø> (ø)
src/shared/utils/metrics.ts 100.00% <ø> (ø)

... and 3 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <100.00%> (ø)
Pages 98.89% <ø> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34c9ae8...5d34d9c. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3423   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files         809      808    -1     
  Lines       14239    14263   +24     
  Branches     3923     3933   +10     
=======================================
+ Hits        14118    14142   +24     
  Misses        112      112           
  Partials        9        9           
Files with missing lines Coverage Δ
...ared/NetworkErrorBoundary/NetworkErrorBoundary.jsx 100.00% <100.00%> (ø)
src/services/bundleAnalysis/useBundleSummary.tsx 100.00% <ø> (ø)
src/shared/api/helpers.ts 100.00% <ø> (ø)
src/shared/utils/metrics.ts 100.00% <ø> (ø)

... and 3 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <100.00%> (ø)
Pages 98.89% <ø> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34c9ae8...5d34d9c. Read the comment docs.

@codecov-releaser
Copy link
Contributor

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
5d34d9c Tue, 22 Oct 2024 16:07:37 GMT Cloud Enterprise

Copy link
Contributor

@suejung-sentry suejung-sentry left a comment

Choose a reason for hiding this comment

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

This is really nice and useful, thank you for putting it together!

return { hasNetworkError: true, error }
}

if (Object.keys(graphQLErrorToUI).includes(error.__typename)) {
sendGraphQLErrorMetrics(error.__typename)
Copy link
Contributor

Choose a reason for hiding this comment

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

Losing out on the metrics is a bummer. Hopefully things are getting captured on the api prometheus side

sendNetworkErrorMetrics(error.status)
// only capture network errors if they are not a rate limit error
// this will typically only be schema parsing errors
if (error.status !== 429 && error.dev && error.error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on making it easier for us in the case we forget to include both error.dev and error.errror and that means our errors don't get tracked? I could definitely see myself doing that. A fallback catchall fingerprint name perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you use the NetworkErrorObject it will enforce you to add dev to the rejection object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only issue with having a catchall is that we're likely to catch errors that are out of our control, such as repo not activated, etc. which we don't want to be flooding Sentry with.

@nicholas-codecov nicholas-codecov added this pull request to the merge queue Oct 22, 2024
Merged via the queue into main with commit b094a59 Oct 22, 2024
62 checks passed
@nicholas-codecov nicholas-codecov deleted the feat-capture-certain-network-errors-to-sentry branch October 22, 2024 18:59
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