π 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix tg integration
Blue Mouse153242e99739
diff --git a/src/alert/dto/alert.dto.ts b/src/alert/dto/alert.dto.tsindex cceb6d820..6461370e3 100644--- a/src/alert/dto/alert.dto.ts+++ b/src/alert/dto/alert.dto.ts@@ -32,9 +32,6 @@ export class AlertDTO {@ApiProperty()queryValue?: number | null- @ApiProperty()- lastTriggered?: Date | null-@ApiProperty()queryTime?: QueryTime | null}\ No newline at end of filediff --git a/src/task-manager/task-manager.service.ts b/src/task-manager/task-manager.service.tsindex 5c59efbc6..5ad3bb7d4 100644--- a/src/task-manager/task-manager.service.ts+++ b/src/task-manager/task-manager.service.ts@@ -413,6 +413,7 @@ export class TaskManagerService {const onlineCount = online.lengthif (onlineCount >= alert.queryValue) {+ // @ts-ignoreawait this.alertService.update(alert.id, {lastTriggered: new Date(),})@@ -469,6 +470,7 @@ export class TaskManagerService {const count = Number(queryResult[0]['count()'])if (count >= alert.queryValue) {+ // @ts-ignoreawait this.alertService.update(alert.id, {lastTriggered: new Date(),})diff --git a/src/tg-integration/tg.module.ts b/src/tg-integration/tg.module.tsindex 83f49b817..f281dea6c 100644--- a/src/tg-integration/tg.module.ts+++ b/src/tg-integration/tg.module.ts@@ -3,9 +3,10 @@ import { AnalyticsModule } from 'src/analytics/analytics.module'import { ProjectModule } from 'src/project/project.module'import { UserModule } from 'src/user/user.module'import { SwetrixUpdate } from './tg.update'+import { AlertModule } from 'src/alert/alert.module'@Module({- imports: [UserModule, ProjectModule, AnalyticsModule],+ imports: [UserModule, ProjectModule, AnalyticsModule, AlertModule],providers: [SwetrixUpdate],})export class TGModule {}diff --git a/src/tg-integration/tg.update.ts b/src/tg-integration/tg.update.tsindex c3f7c3d11..aff8bffb7 100644--- a/src/tg-integration/tg.update.ts+++ b/src/tg-integration/tg.update.ts@@ -3,11 +3,13 @@ import { ProjectService } from 'src/project/project.service'import { SWETRIX_SETTINGS_URL } from 'src/tg-integration/constants'import { UserService } from 'src/user/user.service'import { Context } from 'telegraf'+import * as _map from 'lodash/map'+import * as _isEmpty from 'lodash/isEmpty'import * as dayjs from 'dayjs'import * as utc from 'dayjs/plugin/utc'import * as timezone from 'dayjs/plugin/timezone'import { AnalyticsService } from 'src/analytics/analytics.service'-import { getPIDsArray } from 'src/analytics/analytics.controller'+import { AlertService } from 'src/alert/alert.service'dayjs.extend(utc)dayjs.extend(timezone)@@ -18,6 +20,7 @@ export class SwetrixUpdate {private readonly userService: UserService,private readonly projectService: ProjectService,private readonly analyticsService: AnalyticsService,+ private readonly alertService: AlertService,) {}@Start()@@ -102,11 +105,24 @@ export class SwetrixUpdate {return}+ const alerts = await this.alertService.findWhere({+ project: project.id,+ })+const onlineUserCount = await this.analyticsService.getOnlineUserCount(project.id,)const stats = await this.analyticsService.getSummary([project.id], 'w')+ let alertsString = ''++ if (_isEmpty(alerts)) {+ alertsString = 'β Not set'+ } else {+ alertsString = _map(alerts, (alert) => {+ return `*${alert.name}*: ${alert.type} -> ${alert.value}`+ }).join('\n')+ }const text =`π *${project.name}*` +@@ -134,13 +150,7 @@ export class SwetrixUpdate {'\n\n' +'*Alerts*' +'\n' +- `Online users: \`${- project.alertIfOnlineUsersExceeds ? 'set' : 'not set'- }\`` +- '\n' +- `Additional: \`${- project.isAdditionalAlertEnabled ? 'set' : 'not set'- }\``+ alertsStringawait ctx.editMessageText(text, {parse_mode: 'Markdown',reply_markup: {