mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-18 22:37:43 +00:00
Merge pull request #13113 from keymanapp/feat/developer/kmc-include-command-line-in-sentry-reports
feat(developer): include command line in kmc sentry reports
This commit is contained in:
commit
9db0d086dc
3 changed files with 23 additions and 3 deletions
|
|
@ -64,11 +64,17 @@ export class KeymanSentry {
|
|||
}
|
||||
}
|
||||
|
||||
static async captureException(e: any): Promise<never> {
|
||||
/**
|
||||
* capture an exception for Sentry; note that in local environments, this will normally
|
||||
* throw the exception rather than sending to Sentry
|
||||
* @param e
|
||||
* @param force if true, reports to Sentry even in local environments
|
||||
*/
|
||||
static async captureException(e: any, force?: boolean): Promise<never> {
|
||||
if(isInit) {
|
||||
// For local development, we don't want to bury the trace; we need the cast to avoid
|
||||
// TS2367 (comparison appears to be unintentional)
|
||||
if((KEYMAN_VERSION.VERSION_ENVIRONMENT as string) == 'local') {
|
||||
if(!force && (KEYMAN_VERSION.VERSION_ENVIRONMENT as string) == 'local') {
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export class TestKeymanSentry {
|
|||
try {
|
||||
throw new Error('Test error from -sentry-client-test-exception event');
|
||||
} catch(e: any) {
|
||||
await KeymanSentry.captureException(e);
|
||||
await KeymanSentry.captureException(e, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,19 @@
|
|||
import Sentry from "@sentry/node";
|
||||
import * as process from "node:process";
|
||||
import { SentryNodeOptions } from "@keymanapp/developer-utils";
|
||||
|
||||
Sentry.setContext('Command Line', {
|
||||
// obfusate parameters with longer paths e.g. from 'c:/users/name/a/b' to
|
||||
// '…/a/b' to minimize PII risk without losing all command line data.
|
||||
// Also normalizes backslashes to slashes for simplicity.
|
||||
argv: process.argv.map(param => {
|
||||
const p = param.replaceAll('\\', '/').split('/');
|
||||
return (p.length < 3)
|
||||
? param
|
||||
: ("…/" + p.slice(-2).join('/'));
|
||||
}).join(' ')
|
||||
});
|
||||
|
||||
/**
|
||||
* Rewrites sourcemap paths for the esbuild distribution of kmc (as used in
|
||||
* Keyman Developer itself) /<arbitrary-path>/kmc.mjs to /dist/kmc.mjs, so that
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue