From cd29fc16508b0435fc0175e71b3454f6464e1e24 Mon Sep 17 00:00:00 2001 From: Randy Schott <1815175+schottra@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:11:17 -0400 Subject: [PATCH] Upgrade sentry and enhance it to better detect upload failures (#8809) --- package-lock.json | 203 ++++++++++-------- packages/web/package.json | 3 +- .../web/src/common/store/upload/sagas.test.ts | 4 +- packages/web/src/common/store/upload/sagas.ts | 12 +- packages/web/src/services/sentry.ts | 18 +- 5 files changed, 139 insertions(+), 101 deletions(-) diff --git a/package-lock.json b/package-lock.json index de2b189bf9b..6d6df4229c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22764,34 +22764,6 @@ "node": ">=8" } }, - "node_modules/@sentry-internal/tracing": { - "version": "7.65.0", - "license": "MIT", - "dependencies": { - "@sentry/core": "7.65.0", - "@sentry/types": "7.65.0", - "@sentry/utils": "7.65.0", - "tslib": "^2.4.1 || ^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@sentry/browser": { - "version": "7.65.0", - "license": "MIT", - "dependencies": { - "@sentry-internal/tracing": "7.65.0", - "@sentry/core": "7.65.0", - "@sentry/replay": "7.65.0", - "@sentry/types": "7.65.0", - "@sentry/utils": "7.65.0", - "tslib": "^2.4.1 || ^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@sentry/cli": { "version": "2.31.2", "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-2.31.2.tgz", @@ -23062,18 +23034,6 @@ "webidl-conversions": "^3.0.0" } }, - "node_modules/@sentry/core": { - "version": "7.65.0", - "license": "MIT", - "dependencies": { - "@sentry/types": "7.65.0", - "@sentry/utils": "7.65.0", - "tslib": "^2.4.1 || ^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@sentry/hub": { "version": "6.2.5", "license": "BSD-3-Clause", @@ -23104,19 +23064,6 @@ "node": ">=6" } }, - "node_modules/@sentry/integrations": { - "version": "7.65.0", - "license": "MIT", - "dependencies": { - "@sentry/types": "7.65.0", - "@sentry/utils": "7.65.0", - "localforage": "^1.8.1", - "tslib": "^2.4.1 || ^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@sentry/minimal": { "version": "6.2.5", "license": "BSD-3-Clause", @@ -23186,18 +23133,6 @@ "node": ">=6" } }, - "node_modules/@sentry/replay": { - "version": "7.65.0", - "license": "MIT", - "dependencies": { - "@sentry/core": "7.65.0", - "@sentry/types": "7.65.0", - "@sentry/utils": "7.65.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@sentry/tracing": { "version": "6.2.5", "license": "MIT", @@ -23230,24 +23165,6 @@ "node": ">=6" } }, - "node_modules/@sentry/types": { - "version": "7.65.0", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/@sentry/utils": { - "version": "7.65.0", - "license": "MIT", - "dependencies": { - "@sentry/types": "7.65.0", - "tslib": "^2.4.1 || ^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@sideway/address": { "version": "4.1.4", "license": "BSD-3-Clause", @@ -146235,9 +146152,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", @@ -147586,6 +147502,123 @@ "redux": "^3.1.0 || ^4.0.0" } }, + "packages/web/node_modules/@sentry-internal/feedback": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-7.117.0.tgz", + "integrity": "sha512-4X+NnnY17W74TymgLFH7/KPTVYpEtoMMJh8HzVdCmHTOE6j32XKBeBMRaXBhmNYmEgovgyRKKf2KvtSfgw+V1Q==", + "dependencies": { + "@sentry/core": "7.117.0", + "@sentry/types": "7.117.0", + "@sentry/utils": "7.117.0" + }, + "engines": { + "node": ">=12" + } + }, + "packages/web/node_modules/@sentry-internal/replay-canvas": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-7.117.0.tgz", + "integrity": "sha512-7hjIhwEcoosr+BIa0AyEssB5xwvvlzUpvD5fXu4scd3I3qfX8gdnofO96a8r+LrQm3bSj+eN+4TfKEtWb7bU5A==", + "dependencies": { + "@sentry/core": "7.117.0", + "@sentry/replay": "7.117.0", + "@sentry/types": "7.117.0", + "@sentry/utils": "7.117.0" + }, + "engines": { + "node": ">=12" + } + }, + "packages/web/node_modules/@sentry-internal/tracing": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.117.0.tgz", + "integrity": "sha512-fAIyijNvKBZNA12IcKo+dOYDRTNrzNsdzbm3DP37vJRKVQu19ucqP4Y6InvKokffDP2HZPzFPDoGXYuXkDhUZg==", + "dependencies": { + "@sentry/core": "7.117.0", + "@sentry/types": "7.117.0", + "@sentry/utils": "7.117.0" + }, + "engines": { + "node": ">=8" + } + }, + "packages/web/node_modules/@sentry/browser": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.117.0.tgz", + "integrity": "sha512-29X9HlvDEKIaWp6XKlNPPSNND0U6P/ede5WA2nVHfs1zJLWdZ7/ijuMc0sH/CueEkqHe/7gt94hBcI7HOU/wSw==", + "dependencies": { + "@sentry-internal/feedback": "7.117.0", + "@sentry-internal/replay-canvas": "7.117.0", + "@sentry-internal/tracing": "7.117.0", + "@sentry/core": "7.117.0", + "@sentry/integrations": "7.117.0", + "@sentry/replay": "7.117.0", + "@sentry/types": "7.117.0", + "@sentry/utils": "7.117.0" + }, + "engines": { + "node": ">=8" + } + }, + "packages/web/node_modules/@sentry/core": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.117.0.tgz", + "integrity": "sha512-1XZ4/d/DEwnfM2zBMloXDwX+W7s76lGKQMgd8bwgPJZjjEztMJ7X0uopKAGwlQcjn242q+hsCBR6C+fSuI5kvg==", + "dependencies": { + "@sentry/types": "7.117.0", + "@sentry/utils": "7.117.0" + }, + "engines": { + "node": ">=8" + } + }, + "packages/web/node_modules/@sentry/integrations": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-7.117.0.tgz", + "integrity": "sha512-U3suSZysmU9EiQqg0ga5CxveAyNbi9IVdsapMDq5EQGNcVDvheXtULs+BOc11WYP3Kw2yWB38VDqLepfc/Fg2g==", + "dependencies": { + "@sentry/core": "7.117.0", + "@sentry/types": "7.117.0", + "@sentry/utils": "7.117.0", + "localforage": "^1.8.1" + }, + "engines": { + "node": ">=8" + } + }, + "packages/web/node_modules/@sentry/replay": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.117.0.tgz", + "integrity": "sha512-V4DfU+x4UsA4BsufbQ8jHYa5H0q5PYUgso2X1PR31g1fpx7yiYguSmCfz1UryM6KkH92dfTnqXapDB44kXOqzQ==", + "dependencies": { + "@sentry-internal/tracing": "7.117.0", + "@sentry/core": "7.117.0", + "@sentry/types": "7.117.0", + "@sentry/utils": "7.117.0" + }, + "engines": { + "node": ">=12" + } + }, + "packages/web/node_modules/@sentry/types": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.117.0.tgz", + "integrity": "sha512-5dtdulcUttc3F0Te7ekZmpSp/ebt/CA71ELx0uyqVGjWsSAINwskFD77sdcjqvZWek//WjiYX1+GRKlpJ1QqsA==", + "engines": { + "node": ">=8" + } + }, + "packages/web/node_modules/@sentry/utils": { + "version": "7.117.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.117.0.tgz", + "integrity": "sha512-KkcLY8643SGBiDyPvMQOubBkwVX5IPknMHInc7jYC8pDVncGp7C65Wi506bCNPpKCWspUd/0VDNWOOen51/qKA==", + "dependencies": { + "@sentry/types": "7.117.0" + }, + "engines": { + "node": ">=8" + } + }, "packages/web/node_modules/@testing-library/jest-dom": { "version": "6.4.2", "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.2.tgz", diff --git a/packages/web/package.json b/packages/web/package.json index b46f4bca9c2..bd34798e355 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -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", diff --git a/packages/web/src/common/store/upload/sagas.test.ts b/packages/web/src/common/store/upload/sagas.test.ts index ada2fbd4643..5a876a9d1e2 100644 --- a/packages/web/src/common/store/upload/sagas.test.ts +++ b/packages/web/src/common/store/upload/sagas.test.ts @@ -270,7 +270,7 @@ describe('upload', () => { ]) // Reports to sentry .call(reportToSentry, { - name: 'Upload: Error', + name: 'Upload Worker Failed: Error', error: mockError, additionalInfo: { trackId: 3, @@ -289,7 +289,7 @@ describe('upload', () => { fn: reportToSentry, args: [ { - name: 'Upload: Error', + name: 'Upload Worker Failed: Error', additionalInfo: { trackId: 1, metadata: testTrack.metadata, diff --git a/packages/web/src/common/store/upload/sagas.ts b/packages/web/src/common/store/upload/sagas.ts index cd1a884a829..faf395e89d2 100644 --- a/packages/web/src/common/store/upload/sagas.ts +++ b/packages/web/src/common/store/upload/sagas.ts @@ -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 } }) @@ -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, @@ -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 @@ -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') diff --git a/packages/web/src/services/sentry.ts b/packages/web/src/services/sentry.ts index 8fae41a790e..aa65f027f59 100644 --- a/packages/web/src/services/sentry.ts +++ b/packages/web/src/services/sentry.ts @@ -1,5 +1,4 @@ -import { init } from '@sentry/browser' -import { CaptureConsole } from '@sentry/integrations' +import * as Sentry from '@sentry/browser' import { env } from './env' @@ -15,8 +14,9 @@ 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, @@ -24,11 +24,13 @@ export const initializeSentry = () => { // 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, @@ -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 )