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 Jun 6, 2022
1 parent 01823c9 commit bd396da
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 111 deletions.
1 change: 1 addition & 0 deletions bedrock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,7 @@ def before_send(event, hint):
"1003343.metrics.convertexperiments.com",
"sentry.prod.mozaws.net", # DEPRECATED. TODO: remove this once all sites are talking to sentry.io instead
"o1069899.sentry.io",
"o1069899.ingest.sentry.io",
"cdn.cookielaw.org",
"privacyportal.onetrust.com",
FXA_ENDPOINT,
Expand Down
51 changes: 23 additions & 28 deletions media/js/base/sentry.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

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

// Respect Do Not Track
if (
Expand All @@ -16,32 +25,18 @@ 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: makeFetchTransport,
stackParser: defaultStackParser,
integrations: [
new Dedupe(),
new GlobalHandlers(),
new HttpContext(),
new TryCatch()
]
});

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
7 changes: 6 additions & 1 deletion 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 @@ -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 bd396da

Please sign in to comment.