feat: add work-level play tracking
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-05-09 19:56:59 +08:00
parent 32a1530ab1
commit 3ad1075227
24 changed files with 1452 additions and 105 deletions

View File

@@ -10,7 +10,10 @@ use platform_auth::{
use time::OffsetDateTime;
use crate::session_client::SessionClientContext;
use crate::{http_error::AppError, state::AppState};
use crate::{
http_error::AppError, request_context::RequestContext, state::AppState,
tracking::record_daily_login_tracking_event_after_success as record_daily_login_tracking_event_via_unified_path,
};
#[derive(Debug, Clone)]
pub struct SignedAuthSession {
@@ -29,38 +32,24 @@ pub fn create_password_auth_session(
#[cfg(not(test))]
pub async fn record_daily_login_tracking_event_after_auth_success(
state: &AppState,
request_context: &crate::request_context::RequestContext,
request_context: &RequestContext,
user_id: &str,
login_method: AuthLoginMethod,
) {
// 登录埋点是运营数据,不应反向阻断已经成功的认证会话签发。
match state
.spacetime_client()
.record_daily_login_tracking_event(user_id.to_string())
.await
{
Ok(()) => tracing::info!(
request_id = request_context.request_id(),
operation = request_context.operation(),
user_id = %user_id,
login_method = %login_method.as_str(),
"登录成功每日登录埋点已记录"
),
Err(error) => tracing::warn!(
request_id = request_context.request_id(),
operation = request_context.operation(),
user_id = %user_id,
login_method = %login_method.as_str(),
error = %error,
"登录成功每日登录埋点记录失败,登录流程继续"
),
}
// 登录埋点是运营数据,不应反向阻断已经成功的认证会话签发;每日登录也走统一埋点 helper/procedure
record_daily_login_tracking_event_via_unified_path(
state,
request_context,
user_id,
login_method,
)
.await;
}
#[cfg(test)]
pub async fn record_daily_login_tracking_event_after_auth_success(
_state: &AppState,
_request_context: &crate::request_context::RequestContext,
_request_context: &RequestContext,
_user_id: &str,
_login_method: AuthLoginMethod,
) {