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!

fix alert update issue

Blue Mouse74ab37266a4f
diff --git a/src/alert/alert.controller.ts b/src/alert/alert.controller.ts
index ec2009a5f..21961e516 100644
--- a/src/alert/alert.controller.ts
+++ b/src/alert/alert.controller.ts
@@ -9,6 +9,7 @@ import { RolesGuard } from '../common/guards/roles.guard'
import * as _isEmpty from 'lodash/isEmpty'
import * as _map from 'lodash/map'
import * as _omit from 'lodash/omit'
+import * as _pick from 'lodash/pick'
import { UserService } from 'src/user/user.service'
import { ProjectService } from 'src/project/project.service'
@@ -150,7 +151,7 @@ export class AlertController {
alert = {
...alert,
- ...alertDTO,
+ ..._pick(alertDTO, ['queryMetric', 'queryCondition', 'queryValue', 'queryTime', 'active', 'name']),
}
await this.alertService.update(id, _omit(alert, ['project', 'lastTriggered']))
diff --git a/src/alert/dto/alert.dto.ts b/src/alert/dto/alert.dto.ts
index d51f88ad0..98a9ae0ee 100644
--- a/src/alert/dto/alert.dto.ts
+++ b/src/alert/dto/alert.dto.ts
@@ -24,6 +24,11 @@ export enum QueryTime {
}
export class AlertDTO {
+ @ApiProperty()
+ @IsNotEmpty()
+ @Length(1, 50)
+ name?: string
+
@ApiProperty()
@IsOptional()
queryMetric?: QueryMetric