Developer
603c1c6c90
feat(presence-service): 添加完整的测试套件和生产部署设施
...
- 添加 165 个测试用例 (123 单元测试, 22 集成测试, 20 E2E测试)
- 添加 Docker 多阶段构建和 docker-compose 生产部署配置
- 添加完整的文档体系 (架构、API、开发、测试、部署)
- 添加环境配置 (.env.development/production/test)
- 添加部署脚本 (health-check, start-all, stop-service)
- 修复 TypeScript 类型错误
- 经 WSL2 验证所有生产部署命令测试通过
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 20:10:04 -08:00
Developer
0be3fe619e
feat(presence-service): 完整实现 DDD+Hexagonal 架构的用户活跃度与在线状态服务
...
Domain 层 (领域层):
- 值对象: InstallId, EventName, EventProperties, DeviceInfo, TimeWindow
- 实体: EventLog, OnlineSnapshot
- 聚合根: DailyActiveStats
- 领域事件: SessionStartedEvent, HeartbeatReceivedEvent, DauCalculatedEvent
- 仓储接口: IEventLogRepository, IDailyActiveStatsRepository, IOnlineSnapshotRepository
- 领域服务: DauCalculationService, OnlineDetectionService
Infrastructure 层 (基础设施层):
- Prisma: EventLog, DailyActiveStats, OnlineSnapshot 数据模型
- Redis: 在线状态存储 (ZSET) + HyperLogLog DAU 实时统计
- Kafka: 事件发布服务 (可选)
- Mappers: 领域对象 <-> Prisma 模型转换
- 仓储实现: EventLogRepositoryImpl, DailyActiveStatsRepositoryImpl, OnlineSnapshotRepositoryImpl
Application 层 (应用层):
- Commands: RecordEvents, RecordHeartbeat, CalculateDau
- Queries: GetOnlineCount, GetDauStats
- Schedulers: 每分钟记录在线快照, 每小时清理过期数据, 每天凌晨计算前一天DAU
API 层 (表现层):
- Controllers: AnalyticsController, PresenceController, HealthController
- DTOs: BatchEventsDto, HeartbeatDto, QueryDauDto, OnlineCountResponseDto, DauStatsResponseDto
- Guards: JwtAuthGuard
- Decorators: @Public, @CurrentUser
核心功能:
- ✅ 用户行为事件批量上报与存储
- ✅ 日活 DAU 统计 (按自然日去重, 支持省/市维度)
- ✅ 实时在线人数统计 (3分钟窗口)
- ✅ 心跳机制 (前台60秒间隔)
- ✅ HyperLogLog 实时 DAU 计数
- ✅ 定时任务 (快照记录, 过期清理, DAU 计算)
- ✅ Swagger API 文档
- ✅ Docker 多阶段构建
- ✅ 健康检查
技术栈:
- NestJS + TypeScript
- Prisma ORM + PostgreSQL
- Redis (ioredis)
- Kafka (kafkajs, 可选)
- CQRS 模式 (@nestjs/cqrs)
- 定时任务 (@nestjs/schedule)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 12:11:38 -08:00
Developer
566f464a9b
wip(presence-service): 初始化项目结构
...
- 创建基础配置文件 (package.json, tsconfig.json, nest-cli.json)
- 设计 Prisma schema (heartbeats, daily_active_users, online_sessions, dau_statistics)
- 待完善: Domain/Infrastructure/Application/API层实现
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 11:47:14 -08:00