feat: record daily login tracking on session refresh

This commit is contained in:
2026-05-08 14:08:22 +08:00
parent f343555a19
commit 91d993dc6b
2 changed files with 12 additions and 3 deletions

View File

@@ -20,11 +20,12 @@
- 重置密码后自动登录:`POST /api/auth/password/reset`
- 微信 OAuth callback 登录:`GET /api/auth/wechat/callback`
- 微信绑定手机号后激活/登录态刷新:`POST /api/auth/wechat/bind-phone`
- refresh cookie 续期:`POST /api/auth/session/refresh`
## 设计约束
1. 埋点写入不能阻断登录成功响应。
2. 只有认证成功并已创建会话后才记录。
2. 只有认证成功并已创建会话后,或 refresh session rotate 成功并签发新 access token 后才记录。
3. 失败只记 warning继续返回 token / cookie。
4. 写入统一收口,避免多个登录 handler 各自拼 procedure 调用。
5. 不修改 SpacetimeDB 表结构,不需要更新 `migration.rs`
@@ -48,7 +49,7 @@ record_daily_login_tracking_event_after_auth_success(
- 成功时记录 info
- 失败时记录 warn并明确“登录流程继续”
在各登录入口 `create_auth_session` 成功后调用该 helper。
在各登录入口 `create_auth_session` 成功后调用该 helper。refresh cookie 续期在 `rotate_session``sign_access_token_for_user` 成功后调用同一个 helper`login_method` 使用 refresh session 上保存的 `issued_by_provider`,避免把续期统一误标成 password。
## 验收