Skip to content

Commit

Permalink
Upgrade sentry and enhance it to better detect upload failures (#8809)
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra authored Jun 13, 2024
1 parent 53d4622 commit cd29fc1
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 101 deletions.
203 changes: 118 additions & 85 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@
"@radix-ui/react-slot": "1.0.2",
"@react-spring/web": "9.7.2",
"@reduxjs/toolkit": "1.6.1",
"@sentry/browser": "7.65.0",
"@sentry/browser": "7.117.0",
"@sentry/cli": "2.31.2",
"@sentry/integrations": "7.65.0",
"@solana/spl-token": "0.3.8",
"@solana/web3.js": "1.78.4",
"@stripe/crypto": "0.0.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/common/store/upload/sagas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('upload', () => {
])
// Reports to sentry
.call(reportToSentry, {
name: 'Upload: Error',
name: 'Upload Worker Failed: Error',
error: mockError,
additionalInfo: {
trackId: 3,
Expand All @@ -289,7 +289,7 @@ describe('upload', () => {
fn: reportToSentry,
args: [
{
name: 'Upload: Error',
name: 'Upload Worker Failed: Error',
additionalInfo: {
trackId: 1,
metadata: testTrack.metadata,
Expand Down
12 changes: 8 additions & 4 deletions packages/web/src/common/store/upload/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ export function* handleUploads({
trackIndex,
stemIndex: null,
trackId: tracks[trackIndex].metadata.track_id,
error: new Error('Stem failed to upload.'),
error: new Error(`Stem ${stemIndex} failed to upload.`, {
cause: payload.error
}),
phase
}
})
Expand All @@ -617,7 +619,7 @@ export function* handleUploads({
// Report to sentry
const e = error instanceof Error ? error : new Error(String(error))
yield* call(reportToSentry, {
name: `Upload: ${e.name}`,
name: `Upload Worker Failed: ${e.name}`,
error: e,
additionalInfo: {
trackId,
Expand Down Expand Up @@ -698,7 +700,9 @@ export function* handleUploads({
}
// Errors were reported to sentry earlier in the upload process.
// Throwing here so callers don't think they succeeded.
throw new Error('Failed to upload tracks for collection.')
throw new Error('Failed to upload tracks for collection.', {
cause: errored
})
}

const publishedTrackIds = published
Expand All @@ -710,7 +714,7 @@ export function* handleUploads({
if (publishedTrackIds.length === 0) {
// Errors were reported to sentry earlier in the upload process.
// Throwing here so callers don't think they succeeded.
throw new Error('No tracks were successfully uploaded.')
throw new Error('No tracks were successfully uploaded.', { cause: errored })
}

console.debug('Finished uploads')
Expand Down
18 changes: 10 additions & 8 deletions packages/web/src/services/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { init } from '@sentry/browser'
import { CaptureConsole } from '@sentry/integrations'
import * as Sentry from '@sentry/browser'

import { env } from './env'

Expand All @@ -15,20 +14,23 @@ const analyticsBlacklist = [
const MAX_BREADCRUMBS = 300

export const initializeSentry = () => {
init({
Sentry.init({
dsn: env.SENTRY_DSN,
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
ignoreErrors:
process.env.VITE_SENTRY_DISABLED === 'true' ? [/.*/] : undefined,

// Need to give Sentry a version so it can
// associate stacktraces with sourcemaps
release: process.env.VITE_CURRENT_GIT_SHA,

// Capture console.errors in sentry
integrations: [
new CaptureConsole({
levels: ['error']
})
// Pull extra fields off error objects
Sentry.extraErrorDataIntegration(),
// Catch failed network requests
Sentry.httpClientIntegration(),
// Capture console.errors in sentry
Sentry.captureConsoleIntegration({ levels: ['error'] })
],

normalizeDepth: 5,
Expand All @@ -43,7 +45,7 @@ export const initializeSentry = () => {
}
// filter out analytics events
if (hint && hint.xhr) {
const url = hint.xhr.__sentry_xhr__.url
const url = hint.xhr.__sentry_xhr_v3__.url
const isAnalyticsRequest = analyticsBlacklist.some(
(term) => url.search(term) !== -1
)
Expand Down

0 comments on commit cd29fc1

Please sign in to comment.