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!

Added request logging

Yevhenii K493f78d46cb6
diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts
index 970993616..329a11607 100644
--- a/src/user/user.controller.ts
+++ b/src/user/user.controller.ts
@@ -362,31 +362,35 @@ export class UserController {
@UseGuards(RolesGuard)
@Roles(UserType.CUSTOMER, UserType.ADMIN)
async generateApiKey(@CurrentUserId() userId: string): Promise<{
- apiKey: string;
+ apiKey: string
}> {
- const user = await this.userService.findOne(userId);
+ this.logger.log({ userId }, 'POST /user/api-key')
+
+ const user = await this.userService.findOne(userId)
if (!_isNull(user.apiKey)) {
- throw new ConflictException('You already have an API key');
+ throw new ConflictException('You already have an API key')
}
- const apiKey: string = uuidv4();
+ const apiKey: string = uuidv4()
- await this.userService.update(userId, { apiKey });
+ await this.userService.update(userId, { apiKey })
- return { apiKey };
+ return { apiKey }
}
@Delete('api-key')
@UseGuards(RolesGuard)
@Roles(UserType.CUSTOMER, UserType.ADMIN)
async deleteApiKey(@CurrentUserId() userId: string): Promise<void> {
- const user = await this.userService.findOne(userId);
+ this.logger.log({ userId }, 'DELETE /user/api-key')
+
+ const user = await this.userService.findOne(userId)
if (_isNull(user.apiKey)) {
- throw new ConflictException("You don't have an API key");
+ throw new ConflictException("You don't have an API key")
}
- await this.userService.update(userId, { apiKey: null });
+ await this.userService.update(userId, { apiKey: null })
}
}