@@ -30,12 +30,13 @@ import { UploadDto } from '@gitroom/nestjs-libraries/dtos/media/upload.dto';
3030import axios from 'axios' ;
3131import { Readable } from 'stream' ;
3232import { lookup } from 'mime-types' ;
33+ import * as Sentry from '@sentry/nestjs' ;
3334
3435@ApiTags ( 'Public API' )
3536@Controller ( '/public/v1' )
3637export 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 ,
0 commit comments