feat(promo): promo metric event logs and HQ timeline charts (v3.4.13)
Add log_promo_event for scan/attribution/register/order with IP; admin metrics APIs and ECharts on promo detail page. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { BadRequestException, Body, Controller, Post, UseGuards } from '@nestjs/common';
|
||||
import { BadRequestException, Body, Controller, Post, Req, UseGuards } from '@nestjs/common';
|
||||
import type { Request } from 'express';
|
||||
import { AnalyticsService } from './analytics.service';
|
||||
import { PromoCodeService } from '../promo/promo-code.service';
|
||||
import { extractClientIp } from '../../common/geo/client-ip.util';
|
||||
import { JwtAuthGuard, AuthUser } from '../../common/guards/jwt-auth.guard';
|
||||
import { OptionalJwtAuthGuard } from '../../common/guards/optional-jwt-auth.guard';
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
||||
@@ -66,8 +68,13 @@ export class PromoController {
|
||||
|
||||
@Post('touch')
|
||||
@UseGuards(OptionalJwtAuthGuard)
|
||||
async touch(@CurrentUser() user: AuthUser | undefined, @Body() dto: PromoTouchDto) {
|
||||
async touch(
|
||||
@CurrentUser() user: AuthUser | undefined,
|
||||
@Body() dto: PromoTouchDto,
|
||||
@Req() req: Request,
|
||||
) {
|
||||
const userId = user?.actorType === ActorType.USER ? user.actorId : undefined;
|
||||
const clientIp = extractClientIp(req) ?? undefined;
|
||||
const result = await this.promoCodeService.touch(
|
||||
{
|
||||
promoCode: dto.promoCode,
|
||||
@@ -76,6 +83,7 @@ export class PromoController {
|
||||
countScan: dto.countScan,
|
||||
},
|
||||
userId,
|
||||
{ clientIp, sessionId: dto.sessionId },
|
||||
);
|
||||
|
||||
void this.analyticsService.trackBatchOptional(
|
||||
|
||||
Reference in New Issue
Block a user