Skip to content

πŸ“ˆ Open source, privacy-first web analytics β€” a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Update checkOnlineUsersAlerts with an integration

Yehor Dremliuha2f9d39f8c9ad
diff --git a/apps/production/src/task-manager/task-manager.service.ts b/apps/production/src/task-manager/task-manager.service.ts
index 847180d3a..22853e52b 100644
--- a/apps/production/src/task-manager/task-manager.service.ts
+++ b/apps/production/src/task-manager/task-manager.service.ts
@@ -1034,6 +1034,7 @@ export class TaskManagerService {
}
const online = await this.analyticsService.getOnlineUserCount(project.id)
+ const text = `πŸ”” Alert *${alert.name}* got triggered!\nYour project *${project.name}* has *${online}* online users right now!`
if (online >= alert.queryValue) {
// @ts-ignore
@@ -1041,12 +1042,21 @@ export class TaskManagerService {
lastTriggered: new Date(),
})
if (project.admin && project.admin.isTelegramChatIdConfirmed) {
- this.telegramService.addMessage(
- project.admin.telegramChatId,
- `πŸ”” Alert *${alert.name}* got triggered!\nYour project *${project.name}* has *${online}* online users right now!`,
- {
- parse_mode: 'Markdown',
- },
+ this.telegramService.addMessage(project.admin.telegramChatId, text, {
+ parse_mode: 'Markdown',
+ })
+ }
+ if (project.admin.discordWebhookUrl) {
+ await this.discordService.sendWebhook(
+ project.admin.discordWebhookUrl,
+ text,
+ )
+ }
+
+ if (project.admin.slackWebhookUrl) {
+ await this.slackService.sendWebhook(
+ project.admin.slackWebhookUrl,
+ text,
)
}
}