Skip to content

Commit bd70bb6

Browse files
authored
Basic Sentry Metric Functionality (#1064)
1 parent 0fc9eee commit bd70bb6

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

apps/backend/src/api/routes/auth.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { EmailService } from '@gitroom/nestjs-libraries/services/email.service';
2121
import { RealIP } from 'nestjs-real-ip';
2222
import { UserAgent } from '@gitroom/nestjs-libraries/user/user.agent';
2323
import { Provider } from '@prisma/client';
24+
import * as Sentry from '@sentry/nestjs';
2425

2526
@ApiTags('Auth')
2627
@Controller('/auth')
@@ -101,6 +102,7 @@ export class AuthController {
101102
}
102103
}
103104

105+
Sentry.metrics.count("new_user", 1);
104106
response.header('onboarding', 'true');
105107
response.status(200).json({
106108
register: true,

apps/backend/src/public-api/routes/v1/public.integrations.controller.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ import { UploadDto } from '@gitroom/nestjs-libraries/dtos/media/upload.dto';
3030
import axios from 'axios';
3131
import { Readable } from 'stream';
3232
import { lookup } from 'mime-types';
33+
import * as Sentry from '@sentry/nestjs';
3334

3435
@ApiTags('Public API')
3536
@Controller('/public/v1')
3637
export class PublicIntegrationsController {
3738
private storage = UploadFactory.createStorage();
38-
39+
3940
constructor(
4041
private _integrationService: IntegrationService,
4142
private _postsService: PostsService,
@@ -48,6 +49,7 @@ export class PublicIntegrationsController {
4849
@GetOrgFromRequest() org: Organization,
4950
@UploadedFile('file') file: Express.Multer.File
5051
) {
52+
Sentry.metrics.count("public_api-request", 1);
5153
if (!file) {
5254
throw new HttpException({ msg: 'No file provided' }, 400);
5355
}
@@ -65,6 +67,7 @@ export class PublicIntegrationsController {
6567
@GetOrgFromRequest() org: Organization,
6668
@Body() body: UploadDto
6769
) {
70+
Sentry.metrics.count("public_api-request", 1);
6871
const response = await axios.get(body.url, {
6972
responseType: 'arraybuffer',
7073
});
@@ -96,6 +99,7 @@ export class PublicIntegrationsController {
9699
@GetOrgFromRequest() org: Organization,
97100
@Param('id') id?: string
98101
) {
102+
Sentry.metrics.count("public_api-request", 1);
99103
return { date: await this._postsService.findFreeDateTime(org.id, id) };
100104
}
101105

@@ -104,6 +108,7 @@ export class PublicIntegrationsController {
104108
@GetOrgFromRequest() org: Organization,
105109
@Query() query: GetPostsDto
106110
) {
111+
Sentry.metrics.count("public_api-request", 1);
107112
const posts = await this._postsService.getPosts(org.id, query);
108113
return {
109114
posts,
@@ -117,6 +122,7 @@ export class PublicIntegrationsController {
117122
@GetOrgFromRequest() org: Organization,
118123
@Body() rawBody: any
119124
) {
125+
Sentry.metrics.count("public_api-request", 1);
120126
const body = await this._postsService.mapTypeToPost(
121127
rawBody,
122128
org.id,
@@ -133,17 +139,20 @@ export class PublicIntegrationsController {
133139
@GetOrgFromRequest() org: Organization,
134140
@Param() body: { id: string }
135141
) {
142+
Sentry.metrics.count("public_api-request", 1);
136143
const getPostById = await this._postsService.getPost(org.id, body.id);
137144
return this._postsService.deletePost(org.id, getPostById.group);
138145
}
139146

140147
@Get('/is-connected')
141148
async getActiveIntegrations(@GetOrgFromRequest() org: Organization) {
149+
Sentry.metrics.count("public_api-request", 1);
142150
return { connected: true };
143151
}
144152

145153
@Get('/integrations')
146154
async listIntegration(@GetOrgFromRequest() org: Organization) {
155+
Sentry.metrics.count("public_api-request", 1);
147156
return (await this._integrationService.getIntegrationsList(org.id)).map(
148157
(org) => ({
149158
id: org.id,
@@ -167,11 +176,13 @@ export class PublicIntegrationsController {
167176
@GetOrgFromRequest() org: Organization,
168177
@Body() body: VideoDto
169178
) {
179+
Sentry.metrics.count("public_api-request", 1);
170180
return this._mediaService.generateVideo(org, body);
171181
}
172182

173183
@Post('/video/function')
174184
videoFunction(@Body() body: VideoFunctionDto) {
185+
Sentry.metrics.count("public_api-request", 1);
175186
return this._mediaService.videoFunction(
176187
body.identifier,
177188
body.functionName,

libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { plainToInstance } from 'class-transformer';
3838
import { validate } from 'class-validator';
3939
import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation';
4040
dayjs.extend(utc);
41+
import * as Sentry from '@sentry/nestjs';
4142

4243
type PostWithConditionals = Post & {
4344
integration?: Integration;
@@ -717,6 +718,7 @@ export class PostsService {
717718
});
718719
}
719720

721+
Sentry.metrics.count("post_created", 1);
720722
postList.push({
721723
postId: posts[0].id,
722724
integration: post.integration.id,

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
"@neynar/react": "^0.9.7",
7979
"@postiz/wallets": "^0.0.1",
8080
"@prisma/client": "^6.5.0",
81-
"@sentry/nestjs": "^10.12.0",
82-
"@sentry/nextjs": "^10.12.0",
83-
"@sentry/profiling-node": "^10.12.0",
81+
"@sentry/nestjs": "^10.25.0",
82+
"@sentry/nextjs": "^10.25.0",
83+
"@sentry/profiling-node": "^10.25.0",
8484
"@solana/wallet-adapter-react": "^0.15.35",
8585
"@solana/wallet-adapter-react-ui": "^0.9.35",
8686
"@swc/helpers": "0.5.13",

0 commit comments

Comments
 (0)