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:
@@ -181,6 +181,13 @@ enum PromoCodeScene {
|
||||
OTHER
|
||||
}
|
||||
|
||||
enum PromoMetricEventType {
|
||||
SCAN
|
||||
ATTRIBUTION
|
||||
REGISTER
|
||||
ORDER
|
||||
}
|
||||
|
||||
enum CityStatus {
|
||||
PENDING
|
||||
ACTIVE
|
||||
@@ -856,6 +863,7 @@ model CommonPromoCode {
|
||||
qrcodeResource CommonResource? @relation("PromoQrcode", fields: [qrcodeResourceId], references: [id], onDelete: SetNull)
|
||||
attributions UserPromoAttribution[]
|
||||
orders Order[]
|
||||
metricEvents LogPromoEvent[]
|
||||
|
||||
@@index([ownerUserId])
|
||||
@@index([scene, status])
|
||||
@@ -1759,6 +1767,25 @@ model LogThirdParty {
|
||||
@@map("log_third_party")
|
||||
}
|
||||
|
||||
model LogPromoEvent {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
promoCodeId BigInt @map("promo_code_id") @db.UnsignedBigInt
|
||||
eventType PromoMetricEventType @map("event_type")
|
||||
userId BigInt? @map("user_id") @db.UnsignedBigInt
|
||||
orderId BigInt? @map("order_id") @db.UnsignedBigInt
|
||||
sessionId String? @map("session_id") @db.VarChar(64)
|
||||
clientIp String? @map("client_ip") @db.VarChar(45)
|
||||
ipProvince String? @map("ip_province") @db.VarChar(32)
|
||||
ipCity String? @map("ip_city") @db.VarChar(32)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
|
||||
promoCode CommonPromoCode @relation(fields: [promoCodeId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([promoCodeId, eventType, createdAt])
|
||||
@@index([createdAt])
|
||||
@@map("log_promo_event")
|
||||
}
|
||||
|
||||
model LogUserAnalytics {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
userId BigInt? @map("user_id") @db.UnsignedBigInt
|
||||
|
||||
Reference in New Issue
Block a user