diff --git a/src/modules/mixpanel/mixpanel.controller.ts b/src/modules/mixpanel/mixpanel.controller.ts index 76f7809..04e8950 100644 --- a/src/modules/mixpanel/mixpanel.controller.ts +++ b/src/modules/mixpanel/mixpanel.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Inject, Param, Post } from '@nestjs/common'; +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'; @@ -13,7 +13,12 @@ export class MixpanelController { private readonly mixpanelToken: string, ) {} @Post(':id') - async trackEvent(@Param('id') id, @Body() body, @User() user: RequestUser) { + async trackEvent( + @Param('id') id, + @Body() body, + @User() user: RequestUser, + @Req() request + ) { delete body.info; const mixpanel = init(this.mixpanelToken); @@ -66,13 +71,16 @@ export class MixpanelController { $email: user.username.includes('@') ? user.username : user.username + '@dadosfera.ai', - customer_name: user.customer_name, + customer_name: user.customer_name }); await mixpanel.track(id, { distinct_id: user.username, customer: user.customer_name, env: process.env.ENV, + $ip: request.ip, + $os: request.headers['sec-ch-ua-platform'] || '', + $browser: request.headers['user-agent'], ...body, });