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

feat(developer): include command line in kmc sentry reports #13113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions developer/src/common/web/utils/src/utils/KeymanSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does force work as an option in SentryNodeOptions?

Or is it TestKeymanSentry the only intended usage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does force work as an option in SentryNodeOptions?

No.

Or is it TestKeymanSentry the only intended usage?

Yes

*/
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;
}

Expand Down
2 changes: 1 addition & 1 deletion developer/src/kmc/src/util/TestKeymanSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions developer/src/kmc/src/util/kmcSentryOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import Sentry from "@sentry/node";
import * as process from "node:process";
import { SentryNodeOptions } from "@keymanapp/developer-utils";

Sentry.setContext('Command Line', {
argv: process.argv.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
Expand Down