From f56f3cd5682c5be3a41f9a7f1ccda36ccf995895 Mon Sep 17 00:00:00 2001 From: Alex Gibson Date: Tue, 31 May 2022 09:34:10 +0100 Subject: [PATCH] Update to Sentry v7.0.0 (Fixes #10473) --- media/js/base/sentry.es6.js | 48 +++++-------- package-lock.json | 137 +++++++++++++++--------------------- package.json | 2 +- webpack.config.js | 11 ++- 4 files changed, 84 insertions(+), 114 deletions(-) diff --git a/media/js/base/sentry.es6.js b/media/js/base/sentry.es6.js index afbde37798a..b97f11fce64 100644 --- a/media/js/base/sentry.es6.js +++ b/media/js/base/sentry.es6.js @@ -4,44 +4,34 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { init } from '@sentry/browser'; +import { + BrowserClient, + Dedupe, + GlobalHandlers, + HttpContext, + defaultStackParser, + getCurrentHub, + makeFetchTransport +} from '@sentry/browser'; // Respect Do Not Track if ( typeof window.Mozilla.dntEnabled === 'function' && - !window.Mozilla.dntEnabled() + !window.Mozilla.dntEnabled() && + 'fetch' in window ) { // Get Data Source Name (DSN) const sentryDsn = document .getElementsByTagName('html')[0] .getAttribute('data-sentry-dsn'); - // Configure Sentry SDK - if (sentryDsn) { - init({ - dsn: sentryDsn, - sampleRate: 0.1, - ignoreErrors: [ - "SecurityError: Failed to execute 'open' on 'XMLHttpRequest'", // issue 10683 - 'NetworkError when attempting to fetch resource', // issue 10683 - 'Non-Error promise rejection captured with value' // issue 10380 - ], - allowUrls: ['/media/js/', 'https://cdn-3.convertexperiments.com/'], - beforeSend(event) { - try { - // https://github.com/getsentry/sentry-javascript/issues/3147 - if ( - event.exception.values[0].stacktrace.frames[0] - .filename === '' - ) { - return null; - } - } catch (e) { - // do nothing. - } + const client = new BrowserClient({ + dsn: sentryDsn, + sampleRate: 0.1, + transport: makeFetchTransport, + stackParser: defaultStackParser, + integrations: [new Dedupe(), new GlobalHandlers(), new HttpContext()] + }); - return event; - } - }); - } + getCurrentHub().bindClient(client); } diff --git a/package-lock.json b/package-lock.json index d8d8802d9b8..d0bb70fbb69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@babel/preset-env": "^7.16.11", "@mozilla-protocol/core": "16.0.0", "@mozilla/glean": "^1.0.0", - "@sentry/browser": "^6.19.0", + "@sentry/browser": "^7.0.0", "babel-loader": "^8.2.4", "clean-webpack-plugin": "^4.0.0", "copy-webpack-plugin": "^10.2.4", @@ -1667,78 +1667,64 @@ } }, "node_modules/@sentry/browser": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.19.0.tgz", - "integrity": "sha512-YwahDZxMUxWraFd11dZ+qeflzo91ZYOnW1qdbBe0kRyaWhJQuIsBzLN5onsZBHOADU4EIS3C/np8KxL6420Z/Q==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.0.0.tgz", + "integrity": "sha512-XJeQA/CIocrmShpfVcccJ2RvZbWZy+OustSbgLP5Vk+ZnzbqKQo1zQ92jO/dUoVIsl5dWpUaOKfT6gXmORf4vQ==", "dependencies": { - "@sentry/core": "6.19.0", - "@sentry/types": "6.19.0", - "@sentry/utils": "6.19.0", + "@sentry/core": "7.0.0", + "@sentry/types": "7.0.0", + "@sentry/utils": "7.0.0", "tslib": "^1.9.3" }, "engines": { - "node": ">=6" + "node": ">=8" } }, "node_modules/@sentry/core": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.19.0.tgz", - "integrity": "sha512-/Csh4Skm5EA7p5SpT5vWY2s0CRiDkCrRCduA1XzrC7yu8H51HRyddXk5IBIrh/rB0Uv8MswpxP9qgucycj4v1Q==", - "dependencies": { - "@sentry/hub": "6.19.0", - "@sentry/minimal": "6.19.0", - "@sentry/types": "6.19.0", - "@sentry/utils": "6.19.0", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@sentry/hub": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.19.0.tgz", - "integrity": "sha512-ZSu4CrWOd7xwZtx8mdbs3GG2TaRCGy3vwu2KjaXYCOIRryyw8xN/B/T8Ucpc7xtJRoYaqzNPuOL9NMcpFFb/+w==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.0.0.tgz", + "integrity": "sha512-Wl7MjmahLhuzzByYiWaYTeHKQfF6usnMp+rTTYTBbneuM4MD7TikRt6ybgnxqyqR7nI7ADH/U8OljtiqwnsOcw==", "dependencies": { - "@sentry/types": "6.19.0", - "@sentry/utils": "6.19.0", + "@sentry/hub": "7.0.0", + "@sentry/types": "7.0.0", + "@sentry/utils": "7.0.0", "tslib": "^1.9.3" }, "engines": { - "node": ">=6" + "node": ">=8" } }, - "node_modules/@sentry/minimal": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.19.0.tgz", - "integrity": "sha512-Sfw0KOX63nb+11F0ZcXcGBbctBBw6NZZfqvVtZXNhdBfu1cFjYdkMWi9DLuCulHR0BRq88RE+SuOqq1lgLSJEQ==", + "node_modules/@sentry/hub": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.0.0.tgz", + "integrity": "sha512-my4s+SPZiL6BKOK89YNk74QFRejlwVKKSetzz+Wr1cxDLbGXOIHS3uRJlagqOpfthhD1dq8m3WBQnabPf5JlHQ==", "dependencies": { - "@sentry/hub": "6.19.0", - "@sentry/types": "6.19.0", + "@sentry/types": "7.0.0", + "@sentry/utils": "7.0.0", "tslib": "^1.9.3" }, "engines": { - "node": ">=6" + "node": ">=8" } }, "node_modules/@sentry/types": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.19.0.tgz", - "integrity": "sha512-jxxinvue2PzAeEewDwYJlk7tqp1SEnkaQISBSZZsRUvdk1aRWTDR5MgGejzlnaBSihwKVvFhcukd2PKm8EY9AA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.0.0.tgz", + "integrity": "sha512-im6iugKKyeOwHWiS3u+S+Ox4F6aJQ2fe76rzTDTlzdCPol4xEqYnB2kujGVVnDYrODR+qVb24ua3OsxXxwzppA==", "engines": { - "node": ">=6" + "node": ">=8" } }, "node_modules/@sentry/utils": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.19.0.tgz", - "integrity": "sha512-Q0RT9nuMe/v9VSGs4PMIBJVLZCoUpOcVPsCtKnZNsTDzjs6+4xqDPA1dj3fXDM0A9UiJiiHeXCl66ayzbbAfNA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.0.0.tgz", + "integrity": "sha512-wmZNwzl1F/xCvaGX0TLz0+M+mZP8kn5woF770o2eUgXGURIuNsnSd0Vfi0nHuBJfngVeI/3+ofOJ9MH4Co4lIw==", "dependencies": { - "@sentry/types": "6.19.0", + "@sentry/types": "7.0.0", "tslib": "^1.9.3" }, "engines": { - "node": ">=6" + "node": ">=8" } }, "node_modules/@sinonjs/commons": { @@ -10976,59 +10962,48 @@ } }, "@sentry/browser": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.19.0.tgz", - "integrity": "sha512-YwahDZxMUxWraFd11dZ+qeflzo91ZYOnW1qdbBe0kRyaWhJQuIsBzLN5onsZBHOADU4EIS3C/np8KxL6420Z/Q==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.0.0.tgz", + "integrity": "sha512-XJeQA/CIocrmShpfVcccJ2RvZbWZy+OustSbgLP5Vk+ZnzbqKQo1zQ92jO/dUoVIsl5dWpUaOKfT6gXmORf4vQ==", "requires": { - "@sentry/core": "6.19.0", - "@sentry/types": "6.19.0", - "@sentry/utils": "6.19.0", + "@sentry/core": "7.0.0", + "@sentry/types": "7.0.0", + "@sentry/utils": "7.0.0", "tslib": "^1.9.3" } }, "@sentry/core": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.19.0.tgz", - "integrity": "sha512-/Csh4Skm5EA7p5SpT5vWY2s0CRiDkCrRCduA1XzrC7yu8H51HRyddXk5IBIrh/rB0Uv8MswpxP9qgucycj4v1Q==", - "requires": { - "@sentry/hub": "6.19.0", - "@sentry/minimal": "6.19.0", - "@sentry/types": "6.19.0", - "@sentry/utils": "6.19.0", - "tslib": "^1.9.3" - } - }, - "@sentry/hub": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.19.0.tgz", - "integrity": "sha512-ZSu4CrWOd7xwZtx8mdbs3GG2TaRCGy3vwu2KjaXYCOIRryyw8xN/B/T8Ucpc7xtJRoYaqzNPuOL9NMcpFFb/+w==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.0.0.tgz", + "integrity": "sha512-Wl7MjmahLhuzzByYiWaYTeHKQfF6usnMp+rTTYTBbneuM4MD7TikRt6ybgnxqyqR7nI7ADH/U8OljtiqwnsOcw==", "requires": { - "@sentry/types": "6.19.0", - "@sentry/utils": "6.19.0", + "@sentry/hub": "7.0.0", + "@sentry/types": "7.0.0", + "@sentry/utils": "7.0.0", "tslib": "^1.9.3" } }, - "@sentry/minimal": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.19.0.tgz", - "integrity": "sha512-Sfw0KOX63nb+11F0ZcXcGBbctBBw6NZZfqvVtZXNhdBfu1cFjYdkMWi9DLuCulHR0BRq88RE+SuOqq1lgLSJEQ==", + "@sentry/hub": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.0.0.tgz", + "integrity": "sha512-my4s+SPZiL6BKOK89YNk74QFRejlwVKKSetzz+Wr1cxDLbGXOIHS3uRJlagqOpfthhD1dq8m3WBQnabPf5JlHQ==", "requires": { - "@sentry/hub": "6.19.0", - "@sentry/types": "6.19.0", + "@sentry/types": "7.0.0", + "@sentry/utils": "7.0.0", "tslib": "^1.9.3" } }, "@sentry/types": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.19.0.tgz", - "integrity": "sha512-jxxinvue2PzAeEewDwYJlk7tqp1SEnkaQISBSZZsRUvdk1aRWTDR5MgGejzlnaBSihwKVvFhcukd2PKm8EY9AA==" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.0.0.tgz", + "integrity": "sha512-im6iugKKyeOwHWiS3u+S+Ox4F6aJQ2fe76rzTDTlzdCPol4xEqYnB2kujGVVnDYrODR+qVb24ua3OsxXxwzppA==" }, "@sentry/utils": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.19.0.tgz", - "integrity": "sha512-Q0RT9nuMe/v9VSGs4PMIBJVLZCoUpOcVPsCtKnZNsTDzjs6+4xqDPA1dj3fXDM0A9UiJiiHeXCl66ayzbbAfNA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.0.0.tgz", + "integrity": "sha512-wmZNwzl1F/xCvaGX0TLz0+M+mZP8kn5woF770o2eUgXGURIuNsnSd0Vfi0nHuBJfngVeI/3+ofOJ9MH4Co4lIw==", "requires": { - "@sentry/types": "6.19.0", + "@sentry/types": "7.0.0", "tslib": "^1.9.3" } }, diff --git a/package.json b/package.json index a308a843fa4..bfafd48e655 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@babel/preset-env": "^7.16.11", "@mozilla-protocol/core": "16.0.0", "@mozilla/glean": "^1.0.0", - "@sentry/browser": "^6.19.0", + "@sentry/browser": "^7.0.0", "babel-loader": "^8.2.4", "clean-webpack-plugin": "^4.0.0", "copy-webpack-plugin": "^10.2.4", diff --git a/webpack.config.js b/webpack.config.js index f3f11329453..d8141a516da 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -13,6 +13,7 @@ const Dotenv = require('dotenv-webpack'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const path = require('path'); const staticBundles = require('./media/static-bundles.json'); +const webpack = require('webpack'); function resolveBundles(fileList) { return fileList.map((f) => { @@ -57,8 +58,8 @@ const jsConfig = { module: { rules: [ { - test: /\.es6\.js$/, - exclude: /node_modules/, + test: /\.es6\.js|\/esm\/.+\.js$/, + exclude: /node_modules\/(?!(@sentry)\/).*/, use: { loader: 'babel-loader', options: { @@ -99,7 +100,11 @@ const jsConfig = { } ] }), - new Dotenv() + new Dotenv(), + new webpack.DefinePlugin({ + __SENTRY_DEBUG__: false, + __SENTRY_TRACING__: false + }) ] };