Go to file
hailin 5a66b3071f feat: 新增用户遥测(Telemetry)与移动端OTA版本管理功能
## 遥测系统 (Telemetry)
- 心跳检测: 客户端60s上报心跳,Redis Sorted Set实时计算在线用户数(180s窗口)
- 事件采集: 批量上报客户端事件(会话/页面/操作),写入PostgreSQL telemetry_events表
- DAU统计: 基于app_session_start事件按userId/installId去重
  - 实时近似: Redis HyperLogLog (PFADD/PFCOUNT)
  - 精确计算: 每天凌晨1:00从事件表聚合,支持平台/地区维度
- 在线快照: 每分钟记录在线用户数快照,支持1m/5m/1h区间聚合查询
- 定时任务: @nestjs/schedule驱动 (每分钟快照/每小时清理/凌晨DAU/滚动DAU)

## 版本管理 (App Version / OTA Update)
- 版本CRUD: 管理员创建/编辑/删除/启禁用版本记录
- 文件上传: APK/IPA上传至MinIO(app-releases bucket),自动计算SHA256
- 强制更新: isForceUpdate标志,客户端据此决定是否阻断使用
- 检查更新API: GET /app/version/check?platform=android&current_version_code=200
- 预签名下载: MinIO presigned URL (24h有效)

## 新增文件清单 (18个新文件 + 3个修改)

数据库迁移 (4):
- 032_create_telemetry_events.sql — 事件日志表(append-only, BIGSERIAL)
- 033_create_daily_active_stats.sql — DAU日统计表(day PK, JSONB平台/地区)
- 034_create_online_snapshots.sql — 在线快照表(每分钟记录)
- 035_create_app_versions.sql — 应用版本表(platform CHECK, 唯一索引)

TypeORM实体 (4):
- telemetry-event.entity.ts — 遥测事件(userId, installId, eventName, properties)
- online-snapshot.entity.ts — 在线快照(ts, onlineCount, windowSeconds)
- daily-active-stats.entity.ts — DAU统计(day PK, dauByPlatform/Region JSONB)
- app-version.entity.ts — 应用版本(Platform enum, @VersionColumn乐观锁)

Redis基础设施 (1):
- presence-redis.service.ts — ZADD心跳 + ZCOUNT在线 + PFADD/PFCOUNT DAU

业务服务 (4):
- telemetry.service.ts — 批量事件入库 + 心跳记录 + 在线/DAU查询
- telemetry-scheduler.service.ts — 4个Cron定时任务
- app-version.service.ts — checkUpdate + CRUD + toggle + 重复检测
- file-storage.service.ts — MinIO上传(SHA256) + presigned下载URL

HTTP控制器 (4):
- telemetry.controller.ts — POST events(无需认证) + POST heartbeat + GET online
- admin-telemetry.controller.ts — GET /admin/telemetry/dau|events|realtime
- app-version.controller.ts — GET /app/version/check (移动端)
- admin-version.controller.ts — 完整CRUD + multipart上传 + toggle启禁用

修改文件 (3):
- user.module.ts — 注册4实体+4控制器+5服务+ScheduleModule
- package.json — 新增@nestjs/schedule, minio, @types/multer
- kong.yml — 新增4条Kong路由(telemetry, admin/telemetry, app/version, admin/versions)

文档 (1):
- docs/guides/07-遥测与版本管理开发指南.md — 完整开发指导(参考rwadurian适配)

注: admin遥测路径为/admin/telemetry,避免与issuer-service的/admin/analytics冲突

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 17:53:50 -08:00
backend feat: 新增用户遥测(Telemetry)与移动端OTA版本管理功能 2026-02-12 17:53:50 -08:00
docs feat: 新增用户遥测(Telemetry)与移动端OTA版本管理功能 2026-02-12 17:53:50 -08:00
frontend feat: 小程序功能移植,新增12页面+160 i18n keys,覆盖率提升至~70% 2026-02-12 04:16:33 -08:00
.gitignore chore: Ignore Claude Code config and Flutter auto-generated files 2026-02-11 07:28:02 -08:00
README.md Update company names and structure (Inc. for West, Ltd. for Asia) 2026-01-28 00:15:01 -08:00

README.md

Global Coupon Exchange

Website: gogenex.com

Brand Naming Strategy

This project adopts a regional branding strategy, using different brand names for different markets while maintaining brand family consistency.

Brand Structure

Market Brand Abbr Description
Western (US/Europe) Genex GNX Derived from Generation + Exchange, familiar Western naming style
Asian (including China) Gensen / 券信 GS "Gensen" from Cantonese pronunciation of Chinese characters "券信"

Unified Domain

  • gogenex.com - Single global domain for all markets
  • Subdomains or paths for regional content (e.g., gogenex.com/cn, gogenex.com/asia)

Naming Logic

Genex (Western Markets)

  • Gen = Generation / Generic / Genesis
  • ex = Exchange
  • Natural pronunciation, similar to well-known Western brands like FedEx, Amex
  • Professional, modern, and trustworthy fintech image

Gensen / 券信 (Asian Markets)

  • 券 (Quan) = Coupon / Voucher
  • 信 (Xin) = Trust / Credit
  • Gensen = Romanization of Cantonese pronunciation "gyun seon"
  • Use Chinese characters "券信" in Mainland China
  • Use romanized "Gensen" in other Asian regions
  • Two characters conveying core values: coupon trading + trust guarantee

Brand Consistency

Genex    ←── "Gen-" prefix ──→  Gensen
   ↑                              ↑
   └─────── Same brand family ────┘
                   ↓
                 券信 (Chinese localization)
  • Genex and Gensen share the "Gen-" prefix, establishing brand family recognition
  • Gensen directly transliterates to 券信, providing seamless connection
  • Global users can recognize these as regional versions of the same platform

Usage Scenarios

Scenario Western Markets Asian Markets (non-China) China Market
Company Name GoGenex Inc. Gensen Asia Ltd. 券信科技有限公司
App Name Genex Gensen 券信
Domain gogenex.com gogenex.com/asia gogenex.com/cn
Social Media @gogenex @gensen_official @券信official

Note on Company Structure:

  • Inc. (Corporation) for Western markets: Better for VC funding, stock issuance, and potential IPO
  • Ltd. (Limited) for Asian markets: Common structure in Asia-Pacific region
  • Social media handles use variations to avoid conflicts with existing accounts

Due to varying financial regulations across countries, each regional brand will:

  • Operate as an independent legal entity
  • Comply with local regulatory requirements
  • Share core technology platform and philosophy
  • Establish brand association through parent company

Project Overview

Global Coupon Exchange (GCX) is a coupon asset trading platform designed to provide users with secure and convenient trading services for digital assets such as coupons, gift cards, and vouchers.

Core Features

  • Coupon asset listing and trading
  • Secure transaction matching mechanism
  • Multi-currency settlement support
  • User credit system

Tech Stack

TBD

Documentation

For detailed development documentation, please refer to the docs directory.

License

TBD