Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import packageJson from '../package.json';
import { PROTOCOL_PREFIX } from './constants';
import * as ipcHandlers from './ipc-handlers';
import { hasActiveSyncOperations } from './lib/active-sync-operations';
import { getPlatformName } from './lib/app-globals';
import { bumpAggregatedUniqueStat, bumpStat } from './lib/bump-stats';
import {
listenCLICommands,
Expand All @@ -26,6 +25,7 @@ import {
} from './lib/cli';
import { getUserLocaleWithFallback } from './lib/locale-node';
import { handleAuthCallback, setUpAuthCallbackHandler } from './lib/oauth';
import { getSentryReleaseInfo } from './lib/sentry-release';
import { setupLogging } from './logging';
import { createMainWindow, getMainWindow } from './main-window';
import {
Expand All @@ -38,11 +38,14 @@ import { loadUserData, saveUserData } from './storage/user-data'; // eslint-disa
import { setupUpdates } from './updates';

if ( ! isCLI() && ! process.env.IS_DEV_BUILD ) {
const { release, environment } = getSentryReleaseInfo( app.getVersion() );

Sentry.init( {
dsn: 'https://97693275b2716fb95048c6d12f4318cf@o248881.ingest.sentry.io/4506612776501248',
debug: true,
enabled: process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'test',
release: `${ app.getVersion() ? app.getVersion() : COMMIT_HASH }-${ getPlatformName() }`,
release,
environment,
} );
}

Expand Down
14 changes: 0 additions & 14 deletions src/lib/app-globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,3 @@ export function isLinux() {
const platform = process ? process.platform : getAppGlobals().platform;
return platform === 'linux';
}

export function getPlatformName() {
const platform = process ? process.platform : getAppGlobals().platform;
switch ( platform ) {
case 'darwin':
return 'macos';
case 'win32':
return 'windows';
case 'linux':
return 'linux';
default:
return 'other';
}
}
17 changes: 17 additions & 0 deletions src/lib/sentry-release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Get the Sentry release information based on the version
* @param version The version string from package.json or app.getVersion()
*/
export function getSentryReleaseInfo( version: string ) {
const [ baseVersionWithBeta ] = version.split( '-dev.' );
const isDevEnvironment =
version.includes( '-dev.' ) ||
!! process.env.IS_DEV_BUILD ||
process.env.NODE_ENV === 'development';
const sentryRelease = `studio@${ baseVersionWithBeta }`;

return {
release: sentryRelease,
environment: isDevEnvironment ? 'development' : 'production',
};
}
11 changes: 10 additions & 1 deletion webpack.plugins.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { sentryWebpackPlugin } from '@sentry/webpack-plugin';
import { getSentryReleaseInfo } from './src/lib/sentry-release';
import type IForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import type { WebpackPluginInstance } from 'webpack';
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' );

const version = process.env.npm_package_version || '';
const { release: sentryRelease, environment } = getSentryReleaseInfo( version );
console.log( 'Sentry release version:', sentryRelease );
console.log( 'Sentry environment:', environment );

export const plugins: WebpackPluginInstance[] = [
new ForkTsCheckerWebpackPlugin( {
logger: 'webpack-infrastructure',
Expand All @@ -13,11 +19,14 @@ export const plugins: WebpackPluginInstance[] = [
},
} ),
// Sentry must be the last plugin
! process.env.IS_DEV_BUILD &&
environment !== 'development' &&
!! process.env.SENTRY_AUTH_TOKEN &&
sentryWebpackPlugin( {
authToken: process.env.SENTRY_AUTH_TOKEN,
org: 'a8c',
project: 'studio',
release: {
name: sentryRelease,
},
} ),
];