diff --git a/apps/api/prisma/migrations/20221128105615_custom_sentry/migration.sql b/apps/api/prisma/migrations/20221128105615_custom_sentry/migration.sql new file mode 100644 index 000000000..00857eb0d --- /dev/null +++ b/apps/api/prisma/migrations/20221128105615_custom_sentry/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Setting" ADD COLUMN "sentryDSN" TEXT; diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index a1bef0b5f..088378ecb 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -32,6 +32,7 @@ model Setting { applicationStoragePathMigrationFinished Boolean @default(false) proxyDefaultRedirect String? doNotTrack Boolean @default(false) + sentryDSN String? isAPIDebuggingEnabled Boolean @default(false) isRegistrationEnabled Boolean @default(false) isAutoUpdateEnabled Boolean @default(false) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index fa4ca15ee..0cba5debb 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -36,6 +36,8 @@ declare module 'fastify' { const port = isDev ? 3001 : 3000; const host = '0.0.0.0'; +const sentryDSN = 'https://40285978081c4739b3aed4093f0abe7d@o1082494.ingest.sentry.io/6091062'; + (async () => { const settings = await prisma.setting.findFirst() const fastify = Fastify({ @@ -177,7 +179,7 @@ const host = '0.0.0.0'; setInterval(async () => { await migrateServicesToNewTemplate() - }, isDev ? 1000 : 60000) + }, isDev ? 10000 : 60000) setInterval(async () => { await copySSLCertificates(); @@ -238,8 +240,8 @@ async function getTagsTemplates() { } } async function initServer() { + const appId = process.env['COOLIFY_APP_ID']; try { - const appId = process.env['COOLIFY_APP_ID']; let doNotTrack = false if (appId === '') { doNotTrack = true @@ -248,6 +250,21 @@ async function initServer() { } catch (error) { console.log(error) } + try { + const settings = await prisma.setting.findUnique({ where: { id: '0' } }) + if (!settings.sentryDSN) { + if (appId == '') { + console.log('Telemetry disabled') + return + } else { + await prisma.setting.update({ where: { id: '0' }, data: { sentryDSN } }) + } + } + // Initialize Sentry + + } catch (error) { + console.log(error) + } try { console.log(`[001] Initializing server...`); await asyncExecShell(`docker network create --attachable coolify`);