Sentry: add Soapbox context

This commit is contained in:
Alex Gleason 2023-10-12 21:51:06 -05:00
parent a158b4dcf5
commit e2b8a74e91
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 6 additions and 1 deletions

View file

@ -1,3 +1,5 @@
import sourceCode from 'soapbox/utils/code';
import type { Account } from './schemas';
/** Start Sentry. */
@ -36,6 +38,8 @@ async function startSentry(dsn: string): Promise<void> {
// for finer control
tracesSampleRate: 1.0,
});
Sentry.setContext('soapbox', sourceCode);
}
/** Associate the account with Sentry events. */
@ -45,6 +49,7 @@ async function setSentryAccount(account: Account) {
Sentry.setUser({
id: account.id,
username: account.acct,
url: account.url,
});
}

View file

@ -15,7 +15,7 @@ const tryGit = (cmd: string): string | undefined => {
}
};
const version = (pkg: Record<string, any>) => {
const version = (pkg: { version: string }): string => {
// Try to discern from GitLab CI first
if (CI_COMMIT_TAG === `v${pkg.version}` || CI_COMMIT_REF_NAME === 'stable') {
return pkg.version;