Skip to content

Commit

Permalink
Update to Sentry v7.0.0 (Fixes mozilla#10473)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed May 31, 2022
1 parent dba56e4 commit 068a30b
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 113 deletions.
45 changes: 17 additions & 28 deletions media/js/base/sentry.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { init } from '@sentry/browser';
import {
BrowserClient,
Dedupe,
GlobalHandlers,
HttpContext,
defaultStackParser,
getCurrentHub,
makeXHRTransport
} from '@sentry/browser';

// Respect Do Not Track
if (
Expand All @@ -16,32 +24,13 @@ if (
.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 === '<anonymous>'
) {
return null;
}
} catch (e) {
// do nothing.
}
const client = new BrowserClient({
dsn: sentryDsn,
sampleRate: 0.1,
transport: makeXHRTransport,
stackParser: defaultStackParser,
integrations: [new Dedupe(), new GlobalHandlers(), new HttpContext()]
});

return event;
}
});
}
getCurrentHub().bindClient(client);
}
137 changes: 56 additions & 81 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 8 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -99,7 +100,11 @@ const jsConfig = {
}
]
}),
new Dotenv()
new Dotenv(),
new webpack.DefinePlugin({
__SENTRY_DEBUG__: false,
__SENTRY_TRACING__: false
})
]
};

Expand Down

0 comments on commit 068a30b

Please sign in to comment.