Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Electron crashpad reports to Sentry from Nightly #579

Merged
merged 8 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"test": "jest"
},
"dependencies": {
"@sentry/electron": "^4.3.0",
"auto-launch": "^5.0.5",
"counterpart": "^0.18.6",
"electron-store": "^8.0.2",
Expand Down
45 changes: 32 additions & 13 deletions src/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ limitations under the License.

// Squirrel on windows starts the app with various flags as hooks to tell us when we've been installed/uninstalled etc.
import "./squirrelhooks";
import { app, BrowserWindow, Menu, autoUpdater, protocol, dialog } from "electron";
import { app, BrowserWindow, Menu, autoUpdater, protocol, dialog, Input } from "electron";
import * as Sentry from "@sentry/electron/main";
import AutoLaunch from "auto-launch";
import path from "path";
import windowStateKeeper from "electron-window-state";
Expand All @@ -38,7 +39,6 @@ import webContentsHandler from "./webcontents-handler";
import * as updater from "./updater";
import { getProfileFromDeeplink, protocolInit } from "./protocol";
import { _t, AppLocalization } from "./language-helper";
import Input = Electron.Input;

const argv = minimist(process.argv, {
alias: { help: "h" },
Expand Down Expand Up @@ -119,8 +119,9 @@ async function tryPaths(name: string, root: string, rawPaths: string[]): Promise

const homeserverProps = ["default_is_url", "default_hs_url", "default_server_name", "default_server_config"] as const;

// Find the webapp resources and set up things that require them
async function setupGlobals(): Promise<void> {
async function loadConfig(): Promise<void> {
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
if (global.vectorConfig) return;

// find the webapp asar.
asarPath = await tryPaths("webapp", __dirname, [
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
// If run from the source checkout, this will be in the directory above
Expand All @@ -134,14 +135,6 @@ async function setupGlobals(): Promise<void> {
"../../webapp",
]);

// we assume the resources path is in the same place as the asar
resPath = await tryPaths("res", path.dirname(asarPath), [
// If run from the source checkout
"res",
// if run from packaged application
"",
]);

try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
global.vectorConfig = require(asarPath + "config.json");
Expand All @@ -168,7 +161,7 @@ async function setupGlobals(): Promise<void> {
.reduce((obj, key) => {
obj[key] = global.vectorConfig[key];
return obj;
}, {} as Omit<Partial<typeof global["vectorConfig"]>, keyof typeof homeserverProps>);
}, {} as Omit<Partial<(typeof global)["vectorConfig"]>, keyof typeof homeserverProps>);
}

global.vectorConfig = Object.assign(global.vectorConfig, localConfig);
Expand All @@ -186,6 +179,19 @@ async function setupGlobals(): Promise<void> {

// Could not load local config, this is expected in most cases.
}
}

// Find the webapp resources and set up things that require them
async function setupGlobals(): Promise<void> {
await loadConfig();

// we assume the resources path is in the same place as the asar
resPath = await tryPaths("res", path.dirname(asarPath), [
// If run from the source checkout
"res",
// if run from packaged application
"",
]);

// The tray icon
// It's important to call `path.join` so we don't end up with the packaged asar in the final path.
Expand Down Expand Up @@ -321,6 +327,19 @@ if (global.store.get("disableHardwareAcceleration", false) === true) {
app.disableHardwareAcceleration();
}

loadConfig().then(() => {
const { dsn, environment } = global.vectorConfig.sentry || {};
if (dsn) {
console.log(`Enabling Sentry with dsn=${dsn} environment=${environment}`);
Sentry.init({
dsn,
environment,
// We don't actually use this IPC, but we do not want Sentry injecting preloads
ipcMode: Sentry.IPCMode.Classic,
});
}
});
t3chguy marked this conversation as resolved.
Show resolved Hide resolved

app.on("ready", async () => {
try {
await setupGlobals();
Expand Down
2 changes: 1 addition & 1 deletion test/launch-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ElectronApplication, Page } from "playwright-core";

describe("App launch", () => {
const artifactsPath = path.join(process.cwd(), "test_artifacts");
fs.mkdirSync(artifactsPath);
if (!fs.existsSync(artifactsPath)) fs.mkdirSync(artifactsPath);

const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "element-desktop-tests"));
console.log("Using temp profile directory: ", tmpDir);
Expand Down
84 changes: 81 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2629,6 +2629,74 @@
dependencies:
"@octokit/openapi-types" "^12.11.0"

"@sentry/browser@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.37.1.tgz#d452ebed7f974f20872d34744e67d856ab54a41b"
integrity sha512-MfVbKzEVHKVH6ZyMCKLtPXvMtRCvxqQzrnK735sYW6EyMpcMYhukBU0pq7ws1E/KaCZjAJi1wDx2nqf2yPIVdQ==
dependencies:
"@sentry/core" "7.37.1"
"@sentry/replay" "7.37.1"
"@sentry/types" "7.37.1"
"@sentry/utils" "7.37.1"
tslib "^1.9.3"

"@sentry/core@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.37.1.tgz#6d8d151b3d6ae0d6f81c7f4da92cd2e7cb5bf1fa"
integrity sha512-eS5hoFDjAOl7POZg6K77J0oiypiqR1782oVSB49UkjK+D8tCZzZ5PxPMv0b/O0310p7x4oZ3WGRJaWEN3vY4KQ==
dependencies:
"@sentry/types" "7.37.1"
"@sentry/utils" "7.37.1"
tslib "^1.9.3"

"@sentry/electron@^4.3.0":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@sentry/electron/-/electron-4.3.0.tgz#c38eefe5fad32122e55f7bde0147d3f9e625e3aa"
integrity sha512-LqFMvgycMd+Mcs4Km9S8YBtaHISHSiIUVUz6mgAr2khKY6SNhkW9A4GcoOKtzRJreqYLVeBSbaUVttQfQ4Ot7g==
dependencies:
"@sentry/browser" "7.37.1"
"@sentry/core" "7.37.1"
"@sentry/node" "7.37.1"
"@sentry/types" "7.37.1"
"@sentry/utils" "7.37.1"
deepmerge "4.3.0"
tslib "^2.5.0"

"@sentry/node@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.37.1.tgz#c234e8711090b7532358bb1d6ab3fcca75356e98"
integrity sha512-nGerngIo5JwinJgl7m0SaL/xI+YRBlhb53gbkuLSAAcnoitBFzbp7LjywsqYFTWuWDIyk7O2t124GNxtolBAgA==
dependencies:
"@sentry/core" "7.37.1"
"@sentry/types" "7.37.1"
"@sentry/utils" "7.37.1"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/replay@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.37.1.tgz#8ab4588b28baa07e35c417d3ffc6aaf934c58c45"
integrity sha512-3sHOE/oPirdvJbOn0IA/wpds12Sm2WaEtiAeC0+5Gg5mxQzFBLRrsA1Mz/ifzPGwr+ETn3sCyPCnd9b3PWaWMQ==
dependencies:
"@sentry/core" "7.37.1"
"@sentry/types" "7.37.1"
"@sentry/utils" "7.37.1"

"@sentry/types@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.37.1.tgz#269da7da39c1a5243bf5f9a35370291b5cc205bb"
integrity sha512-c2HWyWSgVA0V4+DSW2qVb0yjftrb1X/q2CzCom+ayjGHO72qyWC+9Tc+7ZfotU1mapRjqUWBgkXkbGmao8N8Ug==

"@sentry/utils@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.37.1.tgz#7695d6e30d6178723f3fa446a9553893bca85e96"
integrity sha512-/4mJOyDsfysx+5TXyJgSI+Ihw2/0EVJbrHjCyXPDXW5ADwbtU8VdBZ0unOmF0hk4QfftqwM9cyEu3BN4iBJsEA==
dependencies:
"@sentry/types" "7.37.1"
tslib "^1.9.3"

"@sinclair/typebox@^0.25.16":
version "0.25.23"
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.23.tgz#1c15b0d2b872d89cc0f47c7243eacb447df8b8bd"
Expand Down Expand Up @@ -4064,6 +4132,11 @@ convert-source-map@^2.0.0:
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a"
integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==

cookie@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432"
integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==

core-js-compat@^3.25.1:
version "3.28.0"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.28.0.tgz#c08456d854608a7264530a2afa281fadf20ecee6"
Expand Down Expand Up @@ -4189,7 +4262,7 @@ deep-is@^0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831"
integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==

deepmerge@^4.2.2:
deepmerge@4.3.0, deepmerge@^4.2.2:
version "4.3.0"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.0.tgz#65491893ec47756d44719ae520e0e2609233b59b"
integrity sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==
Expand Down Expand Up @@ -6494,6 +6567,11 @@ lru-queue@^0.1.0:
dependencies:
es5-ext "~0.10.2"

lru_map@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
integrity sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==

make-dir@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand Down Expand Up @@ -8227,12 +8305,12 @@ tsconfig-paths@^3.14.1:
minimist "^1.2.6"
strip-bom "^3.0.0"

tslib@^1.11.1, tslib@^1.8.1:
tslib@^1.11.1, tslib@^1.8.1, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.1.0, tslib@^2.3.1:
tslib@^2.1.0, tslib@^2.3.1, tslib@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
Expand Down