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 f56f3cd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 114 deletions.
48 changes: 19 additions & 29 deletions media/js/base/sentry.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '<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()]
});

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 f56f3cd

Please sign in to comment.