Basic Sentry Metric Functionality (#1064)

This commit is contained in:
Enno Gelhaus 2025-11-19 15:05:03 +01:00 committed by GitHub
parent 0fc9eeecaa
commit bd70bb6555
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import { EmailService } from '@gitroom/nestjs-libraries/services/email.service';
import { RealIP } from 'nestjs-real-ip';
import { UserAgent } from '@gitroom/nestjs-libraries/user/user.agent';
import { Provider } from '@prisma/client';
import * as Sentry from '@sentry/nestjs';
@ApiTags('Auth')
@Controller('/auth')
@ -101,6 +102,7 @@ export class AuthController {
}
}
Sentry.metrics.count("new_user", 1);
response.header('onboarding', 'true');
response.status(200).json({
register: true,

View File

@ -30,12 +30,13 @@ import { UploadDto } from '@gitroom/nestjs-libraries/dtos/media/upload.dto';
import axios from 'axios';
import { Readable } from 'stream';
import { lookup } from 'mime-types';
import * as Sentry from '@sentry/nestjs';
@ApiTags('Public API')
@Controller('/public/v1')
export class PublicIntegrationsController {
private storage = UploadFactory.createStorage();
constructor(
private _integrationService: IntegrationService,
private _postsService: PostsService,
@ -48,6 +49,7 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@UploadedFile('file') file: Express.Multer.File
) {
Sentry.metrics.count("public_api-request", 1);
if (!file) {
throw new HttpException({ msg: 'No file provided' }, 400);
}
@ -65,6 +67,7 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@Body() body: UploadDto
) {
Sentry.metrics.count("public_api-request", 1);
const response = await axios.get(body.url, {
responseType: 'arraybuffer',
});
@ -96,6 +99,7 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@Param('id') id?: string
) {
Sentry.metrics.count("public_api-request", 1);
return { date: await this._postsService.findFreeDateTime(org.id, id) };
}
@ -104,6 +108,7 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@Query() query: GetPostsDto
) {
Sentry.metrics.count("public_api-request", 1);
const posts = await this._postsService.getPosts(org.id, query);
return {
posts,
@ -117,6 +122,7 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@Body() rawBody: any
) {
Sentry.metrics.count("public_api-request", 1);
const body = await this._postsService.mapTypeToPost(
rawBody,
org.id,
@ -133,17 +139,20 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@Param() body: { id: string }
) {
Sentry.metrics.count("public_api-request", 1);
const getPostById = await this._postsService.getPost(org.id, body.id);
return this._postsService.deletePost(org.id, getPostById.group);
}
@Get('/is-connected')
async getActiveIntegrations(@GetOrgFromRequest() org: Organization) {
Sentry.metrics.count("public_api-request", 1);
return { connected: true };
}
@Get('/integrations')
async listIntegration(@GetOrgFromRequest() org: Organization) {
Sentry.metrics.count("public_api-request", 1);
return (await this._integrationService.getIntegrationsList(org.id)).map(
(org) => ({
id: org.id,
@ -167,11 +176,13 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@Body() body: VideoDto
) {
Sentry.metrics.count("public_api-request", 1);
return this._mediaService.generateVideo(org, body);
}
@Post('/video/function')
videoFunction(@Body() body: VideoFunctionDto) {
Sentry.metrics.count("public_api-request", 1);
return this._mediaService.videoFunction(
body.identifier,
body.functionName,

View File

@ -38,6 +38,7 @@ import { plainToInstance } from 'class-transformer';
import { validate } from 'class-validator';
import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation';
dayjs.extend(utc);
import * as Sentry from '@sentry/nestjs';
type PostWithConditionals = Post & {
integration?: Integration;
@ -717,6 +718,7 @@ export class PostsService {
});
}
Sentry.metrics.count("post_created", 1);
postList.push({
postId: posts[0].id,
integration: post.integration.id,

View File

@ -78,9 +78,9 @@
"@neynar/react": "^0.9.7",
"@postiz/wallets": "^0.0.1",
"@prisma/client": "^6.5.0",
"@sentry/nestjs": "^10.12.0",
"@sentry/nextjs": "^10.12.0",
"@sentry/profiling-node": "^10.12.0",
"@sentry/nestjs": "^10.25.0",
"@sentry/nextjs": "^10.25.0",
"@sentry/profiling-node": "^10.25.0",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-react-ui": "^0.9.35",
"@swc/helpers": "0.5.13",