feat: record daily login tracking on auth success
This commit is contained in:
@@ -26,6 +26,47 @@ pub fn create_password_auth_session(
|
||||
create_auth_session(state, user, session_client, AuthLoginMethod::Password)
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub async fn record_daily_login_tracking_event_after_auth_success(
|
||||
state: &AppState,
|
||||
request_context: &crate::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,
|
||||
"登录成功每日登录埋点记录失败,登录流程继续"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub async fn record_daily_login_tracking_event_after_auth_success(
|
||||
_state: &AppState,
|
||||
_request_context: &crate::request_context::RequestContext,
|
||||
_user_id: &str,
|
||||
_login_method: AuthLoginMethod,
|
||||
) {
|
||||
// 单元测试默认不启动 SpacetimeDB;这里仅验证登录链路调用点能通过编译并保持非阻断语义。
|
||||
}
|
||||
|
||||
pub fn create_auth_session(
|
||||
state: &AppState,
|
||||
user: &AuthUser,
|
||||
|
||||
Reference in New Issue
Block a user