Skip to content

Commit

Permalink
fix(sentry): set consistent Sentry release name (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
JalilArfaoui authored Oct 16, 2019
1 parent 811aa00 commit 68399ce
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
9 changes: 9 additions & 0 deletions sentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable no-var-requires, @typescript-eslint/no-var-requires, @typescript-eslint/ban-ts-ignore */
const { version } = require('./package.json');

// @ts-ignore : This file is used in plain JS in Webpack config
const getRelease = buildType => `webext@${version}-${buildType}`;

module.exports = {
getRelease
};
2 changes: 1 addition & 1 deletion src/app/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (!(window as CustomWindow).__BULLES__CONTENT_SCRIPT_INJECTED__) {
} = require('../utils/sentry');

try {
if (!process.env.FIREFOX_BUILD) {
if ((process.env as AppEnv).BUILD !== 'firefox') {
initSentry();
configureSentryScope((scope: Scope) => {
scope.setTag('context', 'content');
Expand Down
4 changes: 2 additions & 2 deletions src/app/utils/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
captureMessage as sentryCaptureMessage,
captureException as sentryCaptureException
} from '@sentry/browser';
import { version } from '../../../package.json';
import { getRelease } from '../../../sentry';
import Logger from './Logger';

let sentryInitialized = false;
Expand All @@ -18,7 +18,7 @@ export const initSentry = () => {
init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
release: `${version}-${process.env.BUILD}`,
release: getRelease(process.env.BUILD),
integrations: integrations =>
integrations.filter(i => !blacklist.includes(i.name))
});
Expand Down
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface AppEnv extends NodeJS.ProcessEnv {
SEND_CONTRIBUTION_TO: string;
SEND_IN_BLUE_TOKEN: string;
SENTRY_DSN: string;
BUILD: 'firefox' | 'chromium' | 'dev' | 'build';
}

declare module '*.png' {
Expand Down
6 changes: 3 additions & 3 deletions webpack/config.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const basePlugins = require('../webpack/config.plugins.base');
const manifests = require('../manifest');
const { version } = require('../package.json');
const { getRelease } = require('../sentry');

const BUILD_CONFIG = {
dev: {
Expand Down Expand Up @@ -90,8 +91,7 @@ module.exports = (env = {}, argv = {}, outputPath) => {
...getBuildConfig(env.build, env.api),
...processENVVarsToInject(process.env),
BUILD: JSON.stringify(env.build),
SENTRY_ENABLE: env.sentry ? 'true' : 'false',
FIREFOX_BUILD: env.build === 'firefox' ? 'true' : 'false'
SENTRY_ENABLE: env.sentry ? 'true' : 'false'
}
}),
new ModuleNotFoundPlugin(path.resolve(__dirname, '..')),
Expand All @@ -117,7 +117,7 @@ module.exports = (env = {}, argv = {}, outputPath) => {
new SentryWebpackPlugin({
include: `./build/${env.build}/js`,
ignore: ['test.*.js*'],
release: `web-extension@${version}-${env.build}`
release: getRelease(env.build)
})
);
}
Expand Down

0 comments on commit 68399ce

Please sign in to comment.