Commit Graph

4 Commits

Author SHA1 Message Date
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 482df12f91 fix(telemetry): 将设备信息合并到每个事件的 properties 中上报服务端
设备信息(品牌/型号/OS/版本/语言)此前只存储在本地,对服务端分析毫无价值。
现在在 logEvent() 中将 deviceProps 合并到每个事件的 properties 字段,
使服务端 analytics 表能按设备维度进行统计分析。同时修复 _deviceContext 为
null 时的空指针异常(deviceContextId 使用 ?? '' 安全降级)。
适用于 mining-app 和 mobile-app 两端。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 09:42:14 -08:00
hailin a2a318e24c feat(mining-app): 集成 telemetry 遥测功能
- TelemetryService 添加 _accessToken 字段和 setAccessToken() 方法
- _getAuthHeaders() 现在返回 Bearer token 供心跳上报使用
- splash_page.dart: 启动时初始化 TelemetryService,已登录用户自动注入 userId 和 token
- user_providers.dart: 登录成功后注入 userId/token 并恢复上报;退出时暂停上报并清除 token;token 刷新时同步更新 telemetry token

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 09:29:06 -08:00
hailin 76d566d145 feat: 集成 mining-app 升级和遥测功能,扩展 mobile-upgrade 支持多应用
## mining-app (Flutter)
- 新增 updater 模块: 版本检查、APK下载(断点续传+SHA256校验)、安装
- 新增 telemetry 模块: 事件上报、会话追踪、心跳检测(DAU统计)
- 集成原生 MethodChannel 实现 APK 安装
- 在关于页面添加"检查更新"功能入口

## mining-admin-service (NestJS)
- 新增版本管理 API (/api/v2/versions)
- 实现 DDD 架构: Entity, Value Objects, Repository
- 支持 APK/IPA 解析 (需安装 adbkit-apkreader, jszip, plist)
- 支持文件上传和静态文件服务

## mobile-upgrade (Next.js)
- 扩展支持多后端: 榴莲 App (admin-service) + 股行 App (mining-admin-service)
- 添加应用选择器 UI
- 配置独立的 API 端点

## 修复
- 移除未使用的 _apiBaseUrl 字段 (Flutter)
- 替换废弃的 WillPopScope 为 PopScope (Flutter)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:03:26 -08:00