mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-19 04:27:05 -04:00
(sentry) send deployment information to track which environment is on which release
This commit is contained in:
parent
7d478b0dd6
commit
ff716a3d41
1
Makefile
1
Makefile
@ -37,6 +37,7 @@ deploy: install
|
||||
yarn ts-node server/migrate.ts
|
||||
ln -sfn ../data/img ./static/img-local
|
||||
ln -sfn ../data/docs ./static/docs-local
|
||||
yarn ts-node server/sentry.ts
|
||||
|
||||
switch:
|
||||
rm -rf cache
|
||||
|
@ -226,6 +226,7 @@ const nuxtConfig: NuxtConfig = {
|
||||
telemetry: false,
|
||||
},
|
||||
config: {
|
||||
environment: process.env.NODE_ENV === 'production' ? config.locale : process.env.NODE_ENV!,
|
||||
attachStacktrace: true,
|
||||
initialScope(scope) {
|
||||
scope.setTag('locale', process.env.LOCALE);
|
||||
|
34
server/sentry.ts
Normal file
34
server/sentry.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import SentryCli from '@sentry/cli';
|
||||
|
||||
import './setup.ts';
|
||||
import { loadSuml } from './loader.ts';
|
||||
import allLocales from '../locale/locales.ts';
|
||||
import type { Config } from '../locale/config.ts';
|
||||
|
||||
const __dirname = new URL('.', import.meta.url).pathname;
|
||||
|
||||
async function notifyDeployment(): Promise<void> {
|
||||
if (!process.env.SENTRY_DSN) {
|
||||
process.stdout.write('SENTRY_DSN is not defined, skipping deployment information to Sentry');
|
||||
return;
|
||||
}
|
||||
|
||||
const version = fs.readFileSync(`${__dirname}/../cache/version`, 'utf-8');
|
||||
const config = loadSuml('config') as Config;
|
||||
|
||||
const sentryCli = new SentryCli();
|
||||
await sentryCli.releases.setCommits(version, {
|
||||
auto: true,
|
||||
});
|
||||
await sentryCli.releases.finalize(version);
|
||||
const environment = process.env.NODE_ENV === 'production' ? config.locale : process.env.NODE_ENV!;
|
||||
await sentryCli.releases.newDeploy(version, {
|
||||
env: environment,
|
||||
url: allLocales.find((locale) => locale.code === config.locale)?.url,
|
||||
});
|
||||
process.stdout.write(`Sent deployment information for environment ${environment} to Sentry`);
|
||||
}
|
||||
|
||||
await notifyDeployment();
|
Loading…
x
Reference in New Issue
Block a user