diff --git a/Common/Server/API/OpenSourceDeploymentAPI.ts b/Common/Server/API/OpenSourceDeploymentAPI.ts index 7d8e233b1d..7fc798fbc1 100644 --- a/Common/Server/API/OpenSourceDeploymentAPI.ts +++ b/Common/Server/API/OpenSourceDeploymentAPI.ts @@ -1,8 +1,12 @@ import OpenSourceDeployment from "../../Models/DatabaseModels/OpenSourceDeployment"; import { JSONObject } from "../../Types/JSON"; +import URL from "../../Types/API/URL"; +import API from "../../Utils/API"; import OpenSourceDeploymentService, { Service as OpenSourceDeploymentServiceType, } from "../Services/OpenSourceDeploymentService"; +import { OpenSourceDeploymentWebhookUrl } from "../EnvironmentConfig"; +import logger from "../Utils/Logger"; import Response from "../Utils/Response"; import { ExpressRequest, @@ -49,6 +53,22 @@ export default class OpenSourceDeploymentAPI extends BaseAPI< }, }); + if (OpenSourceDeploymentWebhookUrl) { + API.post({ + url: URL.fromString(OpenSourceDeploymentWebhookUrl), + data: { + email: deployment.email?.toString() || "", + name: deployment.name?.toString() || "", + companyName: deployment.companyName?.toString() || "", + companyPhoneNumber: deployment.companyPhoneNumber?.toString() || "", + oneuptimeVersion: deployment.oneuptimeVersion?.toString() || "", + instanceUrl: deployment.instanceUrl?.toString() || "", + }, + }).catch((err: Error) => { + logger.error(err); + }); + } + return Response.sendEmptySuccessResponse(req, res); } catch (err) { next(err); diff --git a/Common/Server/EnvironmentConfig.ts b/Common/Server/EnvironmentConfig.ts index 17c2218e52..91dc48b530 100644 --- a/Common/Server/EnvironmentConfig.ts +++ b/Common/Server/EnvironmentConfig.ts @@ -148,6 +148,9 @@ export const EncryptionSecret: ObjectID = new ObjectID( process.env["ENCRYPTION_SECRET"] || "secret", ); +export const OpenSourceDeploymentWebhookUrl: string = + process.env["OPEN_SOURCE_DEPLOYMENT_WEBHOOK_URL"] || ""; + export const AirtableApiKey: string = process.env["AIRTABLE_API_KEY"] || ""; export const AirtableBaseId: string = process.env["AIRTABLE_BASE_ID"] || ""; diff --git a/HelmChart/Public/oneuptime/templates/_helpers.tpl b/HelmChart/Public/oneuptime/templates/_helpers.tpl index cd38209eda..86c42e2fc4 100644 --- a/HelmChart/Public/oneuptime/templates/_helpers.tpl +++ b/HelmChart/Public/oneuptime/templates/_helpers.tpl @@ -225,6 +225,9 @@ Usage: value: {{ default "" $.Values.captcha.secretKey | quote }} +- name: OPEN_SOURCE_DEPLOYMENT_WEBHOOK_URL + value: {{ default "" $.Values.openSourceDeployment.webhookUrl | quote }} + - name: NOTIFICATION_SLACK_WEBHOOK_ON_CREATED_USER value: {{ $.Values.notifications.webhooks.slack.onCreateUser }} diff --git a/HelmChart/Public/oneuptime/values.yaml b/HelmChart/Public/oneuptime/values.yaml index 94e7f841a7..3bcea8e5ef 100644 --- a/HelmChart/Public/oneuptime/values.yaml +++ b/HelmChart/Public/oneuptime/values.yaml @@ -524,6 +524,10 @@ externalClickhouse: cert: key: +openSourceDeployment: + # This webhook is called when a new self-hosted open source deployment registers. + webhookUrl: + # Notification webhooks when certain events happen in the system. (usually they are slack webhooks) notifications: webhooks: diff --git a/config.example.env b/config.example.env index ebb51b08c1..bf44916dd5 100644 --- a/config.example.env +++ b/config.example.env @@ -276,9 +276,13 @@ LETS_ENCRYPT_ACCOUNT_KEY= # This is the number of active monitors allowed in the free plan. ALLOWED_ACTIVE_MONITOR_COUNT_IN_FREE_PLAN=10 +# Open Source Deployment Webhook +# This webhook is called when a new self-hosted open source deployment registers. +OPEN_SOURCE_DEPLOYMENT_WEBHOOK_URL= + # Notifications Webhook (Slack) -# This webhook notifies slack when the new user signs up or is created. +# This webhook notifies slack when the new user signs up or is created. NOTIFICATION_SLACK_WEBHOOK_ON_CREATED_USER= # This webhook notifies slack when the new project is created. NOTIFICATION_SLACK_WEBHOOK_ON_CREATED_PROJECT= diff --git a/docker-compose.base.yml b/docker-compose.base.yml index 7b48781298..43a5a07595 100644 --- a/docker-compose.base.yml +++ b/docker-compose.base.yml @@ -127,6 +127,9 @@ x-common-runtime-variables: &common-runtime-variables DISABLE_AUTOMATIC_ALERT_CREATION: ${DISABLE_AUTOMATIC_ALERT_CREATION} + # Open Source Deployment Webhook + OPEN_SOURCE_DEPLOYMENT_WEBHOOK_URL: ${OPEN_SOURCE_DEPLOYMENT_WEBHOOK_URL} + # Notification Webhooks NOTIFICATION_SLACK_WEBHOOK_ON_CREATED_USER: ${NOTIFICATION_SLACK_WEBHOOK_ON_CREATED_USER} NOTIFICATION_SLACK_WEBHOOK_ON_CREATED_PROJECT: ${NOTIFICATION_SLACK_WEBHOOK_ON_CREATED_PROJECT}