hailin
|
893513ad78
|
feat(presence): 添加设备档案表,实现事件流水+设备快照分离
大厂标准架构(Amplitude/Mixpanel):
- analytics_event_log: 事件流水(append-only,每条事件一行)
- analytics_device_profile: 设备快照(每台设备一行,upsert 更新)
设备分布查询从 O(events) 降为 O(devices):
- SELECT COUNT(*), device_brand FROM analytics_device_profile GROUP BY device_brand
不再需要 COUNT(DISTINCT install_id) 扫描全量事件表
ON CONFLICT (install_id) DO UPDATE:
- COALESCE 保留已有字段(不被 NULL 覆盖)
- last_seen_at 每次上报更新
- event_count 累加(可用于活跃度分析)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
2026-03-05 19:31:33 -08:00 |
hailin
|
6bca65e434
|
feat(telemetry): 设备字段提升为顶层结构化列(Amplitude 风格)
将 device_brand/device_model/device_os/app_version/locale 从 JSONB properties
提升为 analytics_event_log 表的独立列,并建立索引,支持亿级数据量下的高效
按设备维度查询和分组统计。
前端 (mining-app + mobile-app):
- toServerJson() 从 properties 中提取设备字段,以顶层字段发送给服务端
- 本地存储格式不变(properties 仍保留设备字段,便于离线队列完整性)
后端 (presence-service):
- Prisma schema: EventLog 新增 deviceBrand/deviceModel/deviceOs/appVersion/locale 列
- Migration: ALTER TABLE 添加 5 列 + 2 个索引
- DTO/Command: EventItemDto 接收顶层设备字段
- Entity: EventLog 新增 5 个字段及 getter
- Mapper: toDomain/toPersistence 映射新字段
- Handler: toEventLog 从 DTO 读取设备字段;SessionStartedEvent 优先使用顶层字段
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
2026-03-05 09:50:48 -08:00 |
hailin
|
286e6aad01
|
fix(db): 添加缺失的数据库迁移文件
问题:
- wallet-service schema 中有 version 字段,但迁移文件中缺失
- presence-service 缺少初始化迁移文件
修复:
- wallet-service: 添加 20241216000000_add_version_column 迁移
- presence-service: 添加 20241204000000_init 初始化迁移(包含 version 字段)
- presence-service: 删除无效的 20251215100000 迁移(依赖不存在的表)
验证所有服务 schema 与 migration 一致性:
- identity-service: ✅ OK
- wallet-service: ✅ 已修复
- blockchain-service: ✅ OK (无 version 字段)
- planting-service: ✅ OK
- reward-service: ✅ OK
- referral-service: ✅ OK
- leaderboard-service: ✅ OK
- presence-service: ✅ 已修复
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2025-12-15 21:53:31 -08:00 |
hailin
|
cc06638e0e
|
feat(telemetry): 将userId改为userSerialNum字符串格式并完善遥测追踪
Backend (presence-service):
- 将EventLog.userId从BigInt改为String类型,存储userSerialNum(如D25121400005)
- 更新Prisma schema,userId字段改为VarChar(20)并添加索引
- 更新心跳相关命令和事件,统一使用userSerialNum字符串
- 添加数据库迁移文件
- 更新相关单元测试和集成测试
Frontend (mobile-app):
- TelemetryEvent新增toServerJson()方法,格式化为后端API期望的格式
- AccountService登录/恢复时设置TelemetryService的userId
- MultiAccountService切换账号时同步更新TelemetryService的userId
- 退出登录时清除TelemetryService的userId
- AuthProvider初始化时设置userId
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2025-12-15 06:55:25 -08:00 |