chore(sentry): add release name to configs

This commit is contained in:
Nicolas Meienberger 2024-01-09 21:09:41 +01:00 committed by Nicolas Meienberger
parent 9d8a878265
commit fc36595468
15 changed files with 69 additions and 10 deletions

View File

@ -52,6 +52,7 @@ jobs:
context: .
build-args: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
TIPI_VERSION=${{ needs.create-tag.outputs.tagname }}
file: ./packages/worker/Dockerfile
platforms: linux/amd64
push: true
@ -60,8 +61,6 @@ jobs:
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/worker:buildcache,mode=max
build-images:
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
runs-on: ubuntu-latest
needs: create-tag
steps:
@ -87,6 +86,7 @@ jobs:
context: .
build-args: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
TIPI_VERSION=${{ needs.create-tag.outputs.tagname }}
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository_owner }}/runtipi:${{ needs.create-tag.outputs.tagname }}

View File

@ -51,6 +51,7 @@ jobs:
with:
build-args: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
TIPI_VERSION=${{ needs.create-tag.outputs.tagname }}
context: .
file: ./packages/worker/Dockerfile
platforms: linux/amd64,linux/arm64
@ -84,6 +85,7 @@ jobs:
with:
build-args: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
TIPI_VERSION=${{ needs.create-tag.outputs.tagname }}
context: .
platforms: linux/amd64,linux/arm64
push: true

View File

@ -48,6 +48,7 @@ jobs:
context: .
build-args: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
TIPI_VERSION=${{ needs.create-tag.outputs.tagname }}
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository_owner }}/runtipi:${{ needs.create-tag.outputs.tagname }},ghcr.io/${{ github.repository_owner }}/runtipi:latest
@ -80,6 +81,7 @@ jobs:
context: .
build-args: |
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
TIPI_VERSION=${{ needs.create-tag.outputs.tagname }}
file: ./packages/worker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true

View File

@ -75,6 +75,7 @@ services:
- .env
environment:
NODE_ENV: development
TIPI_VERSION: 0.0.0
volumes:
# Dev mode
- ./packages/worker/src:/app/packages/worker/src
@ -127,6 +128,7 @@ services:
- .env
environment:
NODE_ENV: development
TIPI_VERSION: 0.0.0
networks:
- tipi_main_network
ports:

View File

@ -61,6 +61,7 @@ services:
dockerfile: ./packages/worker/Dockerfile
args:
- SENTRY_DISABLE_AUTO_UPLOAD=true
- TIPI_VERSION=0.0.0
container_name: tipi-worker
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:3000/healthcheck']
@ -77,6 +78,7 @@ services:
- .env
environment:
NODE_ENV: production
TIPI_VERSION: 0.0.0
volumes:
- /proc:/host/proc
- /var/run/docker.sock:/var/run/docker.sock
@ -115,6 +117,7 @@ services:
dockerfile: Dockerfile
args:
- SENTRY_DISABLE_AUTO_UPLOAD=true
- TIPI_VERSION=0.0.0
container_name: tipi-dashboard
depends_on:
tipi-db:
@ -127,6 +130,7 @@ services:
- .env
environment:
NODE_ENV: production
TIPI_VERSION: 0.0.0
networks:
- tipi_main_network
ports:

View File

@ -42,6 +42,7 @@ export default withSentryConfig(
org: 'runtipi',
project: 'runtipi-dashboard',
dryRun: process.env.SENTRY_DISABLE_AUTO_UPLOAD === 'true',
release: process.env.TIPI_VERSION,
},
{
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

View File

@ -75,6 +75,7 @@ services:
- .env
environment:
NODE_ENV: production
TIPI_VERSION: ${TIPI_VERSION}
volumes:
# Core
- /proc:/host/proc
@ -144,6 +145,7 @@ services:
- .env
environment:
NODE_ENV: production
TIPI_VERSION: ${TIPI_VERSION}
labels:
# Main
traefik.enable: true

View File

@ -59,6 +59,14 @@ export const cleanseErrorData = (event: ErrorEvent, hint: EventHint) => {
return null;
}
// IF error message starts with 'Command failed: docker-compose' then grab only the 200 last characters
if (error.message.startsWith('Command failed: docker-compose')) {
// Command failed: docker-compose --env-file /storage/app-data/<app-name>/app.env
const appName = error.message.split('/')[3];
const message = error.message.slice(-200);
result.message = `Error with ${appName}: ${message}`;
}
if (result.request && result.request.url) {
result.request.url = cleanseUrl(result.request.url);
}

View File

@ -93,6 +93,7 @@ export const envSchema = z.object({
export const settingsSchema = envSchema
.partial()
.pick({
version: true,
dnsIp: true,
internalIp: true,
postgresPort: true,

View File

@ -51,9 +51,11 @@ COPY ./packages/worker/assets ./packages/worker/assets
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_DISABLE_AUTO_UPLOAD
ARG TIPI_VERSION
ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}
ENV SENTRY_DISABLE_AUTO_UPLOAD=${SENTRY_DISABLE_AUTO_UPLOAD}
ENV TIPI_VERSION=${TIPI_VERSION}
RUN pnpm -r build --filter @runtipi/worker

View File

@ -7,6 +7,7 @@ import dotenv from 'dotenv';
import { Queue } from 'bullmq';
import * as Sentry from '@sentry/node';
import { cleanseErrorData } from '@runtipi/shared/src/helpers/error-helpers';
import { ExtraErrorData } from '@sentry/integrations';
import { copySystemFiles, ensureFilePermissions, generateSystemEnvFile, generateTlsCertificates } from '@/lib/system';
import { runPostgresMigrations } from '@/lib/migrations';
import { startWorker } from './watcher/watcher';
@ -17,11 +18,22 @@ import { SocketManager } from './lib/socket/SocketManager';
const rootFolder = '/app';
const envFile = path.join(rootFolder, '.env');
const setupSentry = () => {
const setupSentry = (release?: string) => {
Sentry.init({
release,
environment: process.env.NODE_ENV,
dsn: 'https://1cf49526d2efde9f82b6584c9c0f6912@o4504242900238336.ingest.sentry.io/4506360656035840',
beforeSend: cleanseErrorData,
includeLocalVariables: true,
initialScope: {
tags: { version: release },
},
integrations: [
new Sentry.Integrations.LocalVariables({
captureAllExceptions: true,
}),
new ExtraErrorData(),
],
});
};
@ -35,9 +47,9 @@ const main = async () => {
logger.info('Generating system env file...');
const envMap = await generateSystemEnvFile();
if (envMap.get('ALLOW_ERROR_MONITORING') === 'true' && envMap.get('NODE_ENV') === 'production') {
logger.info('Anonymous error monitoring is enabled, to disable it add "allowErrorMonitoring": false to your settings.json file');
setupSentry();
if (envMap.get('ALLOW_ERROR_MONITORING') === 'true' && process.env.NODE_ENV === 'production') {
logger.info(`Anonymous error monitoring is enabled, to disable it add "allowErrorMonitoring": false to your settings.json file. Version: ${process.env.TIPI_VERSION}`);
setupSentry(process.env.TIPI_VERSION);
}
// Reload env variables after generating the env file

View File

@ -1,4 +1,5 @@
import * as Sentry from '@sentry/nextjs';
import { ExtraErrorData } from '@sentry/integrations';
import { settingsSchema } from '@runtipi/shared/src/schemas/env-schemas';
import { cleanseErrorData } from '@runtipi/shared/src/helpers/error-helpers';
@ -18,10 +19,16 @@ const getClientConfig = () => {
return parsedSettings;
};
if (getClientConfig().allowErrorMonitoring && process.env.NODE_ENV === 'production') {
const { allowErrorMonitoring, version } = getClientConfig();
if (allowErrorMonitoring && process.env.NODE_ENV === 'production') {
Sentry.init({
release: version,
environment: process.env.NODE_ENV,
dsn: 'https://7a73d72f886948478b55621e7b92c3c7@o4504242900238336.ingest.sentry.io/4504826587971584',
beforeSend: cleanseErrorData,
integrations: [new ExtraErrorData()],
initialScope: {
tags: { version },
},
});
}

View File

@ -5,13 +5,21 @@
import * as Sentry from '@sentry/nextjs';
import { TipiConfig } from '@/server/core/TipiConfig';
import { ExtraErrorData } from '@sentry/integrations';
import { cleanseErrorData } from '@runtipi/shared/src/helpers/error-helpers';
if (TipiConfig.getConfig().allowErrorMonitoring && TipiConfig.getConfig().NODE_ENV === 'production') {
const { version, allowErrorMonitoring } = TipiConfig.getConfig();
if (allowErrorMonitoring && TipiConfig.getConfig().NODE_ENV === 'production') {
Sentry.init({
release: TipiConfig.getConfig().version,
environment: TipiConfig.getConfig().NODE_ENV,
dsn: 'https://7a73d72f886948478b55621e7b92c3c7@o4504242900238336.ingest.sentry.io/4504826587971584',
debug: TipiConfig.getConfig().NODE_ENV === 'development',
beforeSend: cleanseErrorData,
integrations: [new ExtraErrorData()],
initialScope: {
tags: { version },
},
});
}

View File

@ -3,14 +3,22 @@
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from '@sentry/nextjs';
import { ExtraErrorData } from '@sentry/integrations';
import { TipiConfig } from '@/server/core/TipiConfig';
import { cleanseErrorData } from '@runtipi/shared/src/helpers/error-helpers';
if (TipiConfig.getConfig().allowErrorMonitoring && TipiConfig.getConfig().NODE_ENV === 'production') {
const { version, allowErrorMonitoring } = TipiConfig.getConfig();
if (allowErrorMonitoring && TipiConfig.getConfig().NODE_ENV === 'production') {
Sentry.init({
release: TipiConfig.getConfig().version,
environment: TipiConfig.getConfig().NODE_ENV,
dsn: 'https://7a73d72f886948478b55621e7b92c3c7@o4504242900238336.ingest.sentry.io/4504826587971584',
debug: TipiConfig.getConfig().NODE_ENV === 'development',
beforeSend: cleanseErrorData,
integrations: [new ExtraErrorData()],
initialScope: {
tags: { version },
},
});
}

View File

@ -49,7 +49,7 @@ export class TipiConfigClass {
postgresPort: Number(conf.POSTGRES_PORT),
REDIS_HOST: conf.REDIS_HOST,
redisPassword: conf.REDIS_PASSWORD,
NODE_ENV: conf.NODE_ENV,
NODE_ENV: process.env.NODE_ENV || 'production',
architecture: conf.ARCHITECTURE || 'amd64',
rootFolder: '/runtipi',
internalIp: conf.INTERNAL_IP,