Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: add default sentry

Andras Bacsai40d294a24777
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 0000000000..00857eb0d5
--- /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 a1bef0b5f2..088378ecb1 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 fa4ca15eea..0cba5debbd 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://[email protected]/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`);