Merge pull request #6 from ente-io/sentry-integration

Sentry integration
This commit is contained in:
Abhinav-grd 2021-08-09 12:35:59 +05:30 committed by GitHub
commit 1570d24132
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 976 additions and 27 deletions

View file

@ -46,4 +46,6 @@ jobs:
# macOS notarization API key
API_KEY_ID: ${{ secrets.api_key_id }}
API_KEY_ISSUER_ID: ${{ secrets.api_key_issuer_id }}
# setry crash reporting token
SENTRY_AUTH_TOKEN: ${{secrets.sentry_auth_token}}

View file

@ -44,15 +44,18 @@
},
"author": "ente <code@ente.io>",
"devDependencies": {
"@sentry/cli": "^1.68.0",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"electron": "^11.0.2",
"electron-builder": "^22.10.5",
"electron-builder-notarize": "^1.2.0",
"electron-download": "^4.1.1",
"eslint": "^7.23.0",
"typescript": "^4.2.3"
},
"dependencies": {
"@sentry/electron": "^2.5.1",
"@types/node": "^14.14.37",
"@types/promise-fs": "^2.1.1",
"electron-is-dev": "^2.0.0",

105
sentry-symbols.js Normal file
View file

@ -0,0 +1,105 @@
#!/usr/bin/env node
let SentryCli;
let download;
try {
SentryCli = require('@sentry/cli');
download = require('electron-download');
} catch (e) {
console.error('ERROR: Missing required packages, please run:');
console.error('npm install --save-dev @sentry/cli electron-download');
process.exit(1);
}
const VERSION = /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/i;
const SYMBOL_CACHE_FOLDER = '.electron-symbols';
const package = require('./package.json');
const sentryCli = new SentryCli('./sentry.properties');
async function main() {
let version = getElectronVersion();
if (!version) {
console.error('Cannot detect electron version, check package.json');
return;
}
console.log('We are starting to download all possible electron symbols');
console.log('We need it in order to symbolicate native crashes');
console.log(
'This step is only needed once whenever you update your electron version',
);
console.log('Just call this script again it should do everything for you.');
let zipPath = await downloadSymbols({
version,
platform: 'darwin',
arch: 'x64',
dsym: true,
});
await sentryCli.execute(['upload-dif', '-t', 'dsym', zipPath], true);
zipPath = await downloadSymbols({
version,
platform: 'win32',
arch: 'ia32',
symbols: true,
});
await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);
zipPath = await downloadSymbols({
version,
platform: 'win32',
arch: 'x64',
symbols: true,
});
await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);
zipPath = await downloadSymbols({
version,
platform: 'linux',
arch: 'x64',
symbols: true,
});
await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);
console.log('Finished downloading and uploading to Sentry');
console.log(`Feel free to delete the ${SYMBOL_CACHE_FOLDER}`);
}
function getElectronVersion() {
if (!package) {
return false;
}
let electronVersion =
(package.dependencies && package.dependencies.electron) ||
(package.devDependencies && package.devDependencies.electron);
if (!electronVersion) {
return false;
}
const matches = VERSION.exec(electronVersion);
return matches ? matches[0] : false;
}
async function downloadSymbols(options) {
return new Promise((resolve, reject) => {
download(
{
...options,
cache: SYMBOL_CACHE_FOLDER,
},
(err, zipPath) => {
if (err) {
reject(err);
} else {
resolve(zipPath);
}
},
);
});
}
main().catch(e => console.error(e));

4
sentry.properties Normal file
View file

@ -0,0 +1,4 @@
defaults.url=https://sentry.ente.io/
defaults.org=ente
defaults.project=bhari-frame
cli.executable=../../../../usr/local/lib/node_modules/@sentry/wizard/node_modules/@sentry/cli/bin/sentry-cli

View file

@ -12,6 +12,8 @@ import AppUpdater from './utils/appUpdater';
import { createWindow } from './utils/createWindow';
import setupIpcComs from './utils/ipcComms';
import { buildContextMenu, buildMenuBar } from './utils/menuUtil';
import initSentry from './utils/sentry';
let tray: Tray;
let mainWindow: BrowserWindow;
@ -61,12 +63,11 @@ else {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
initSentry();
setIsUpdateAvailable(false)
mainWindow = createWindow();
Menu.setApplicationMenu(buildMenuBar())
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.

12
src/utils/sentry.ts Normal file
View file

@ -0,0 +1,12 @@
import * as Sentry from "@sentry/electron/dist/main";
const SENTRY_DSN="https://e9268b784d1042a7a116f53c58ad2165@sentry.ente.io/5";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const version =require('../../package.json').version;
function initSentry():void{
Sentry.init({ dsn: SENTRY_DSN,release:version});
}
export default initSentry;

872
yarn.lock

File diff suppressed because it is too large Load diff