import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common'; import { init } from 'mixpanel'; import { Authenticated } from 'src/decorators/authentication.decorator'; import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; import { RequestUser, User } from 'src/decorators/user.decorator'; import { MixpanelService } from './mixpanel.service'; @ApiInternalOnlyController() @Controller('trackEvent') export class MixpanelController { constructor( private mixpanelService: MixpanelService ) {} @Post(':id') async trackEvent( @Param('id') id, @Body() body, @User() user: RequestUser, @Req() request ) { delete body.info; await this.mixpanelService.track(id, user, request, body) return { id, body, user: user.username }; } }