Skip to content

Commit 7a3f92e

Browse files
committed
Normalize error paths
1 parent 5e9a6a6 commit 7a3f92e

File tree

3 files changed

+133
-66
lines changed

3 files changed

+133
-66
lines changed

package-lock.json

Lines changed: 110 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
"publish": null
110110
},
111111
"dependencies": {
112-
"@sentry/electron": "^2.4.1",
112+
"@sentry/electron": "^2.5.0",
113+
"@sentry/integrations": "^6.7.1",
113114
"electron-context-menu": "^0.15.1",
114115
"electron-first-run": "^3.0.0",
115116
"electron-window-state": "^5.0.3",

src/index.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1-
import * as Sentry from '@sentry/electron';
1+
const DEV_MODE = process.env.HTK_DEV === 'true';
22

3-
Sentry.init({ dsn: 'https://1194b128453942ed9470d49a74c35992@o202389.ingest.sentry.io/1367048' });
3+
import * as Sentry from '@sentry/electron';
4+
import { RewriteFrames } from '@sentry/integrations';
5+
6+
if (!DEV_MODE) {
7+
Sentry.init({
8+
dsn: 'https://1194b128453942ed9470d49a74c35992@o202389.ingest.sentry.io/1367048',
9+
integrations: [
10+
new RewriteFrames({
11+
// Make all paths relative to this root, because otherwise it can make
12+
// errors unnecessarily distinct, especially on Windows.
13+
root: process.platform === 'win32'
14+
// Root must always be POSIX format, so we transform it on Windows:
15+
? __dirname
16+
.replace(/^[A-Z]:/, '') // remove Windows-style prefix
17+
.replace(/\\/g, '/') // replace all `\\` instances with `/`
18+
: __dirname
19+
})
20+
]
21+
});
22+
}
423

524
function reportError(error: Error | string) {
625
console.log(error);
@@ -43,7 +62,6 @@ const packageJson = require('../package.json');
4362

4463
const isWindows = os.platform() === 'win32';
4564

46-
const DEV_MODE = process.env.HTK_DEV === 'true';
4765
const APP_URL = process.env.APP_URL || 'https://app.httptoolkit.tech';
4866
const AUTH_TOKEN = uuid();
4967
const DESKTOP_VERSION = packageJson.version;

0 commit comments

Comments
 (0)