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

@@ -29,9 +29,14 @@ use spacetime_client::{
use time::OffsetDateTime;
use crate::{
api_response::json_success_body, auth::AuthenticatedAccessToken, http_error::AppError,
prompt::visual_novel as vn_prompt, request_context::RequestContext, state::AppState,
api_response::json_success_body,
auth::AuthenticatedAccessToken,
http_error::AppError,
prompt::visual_novel as vn_prompt,
request_context::RequestContext,
state::AppState,
work_author::resolve_work_author_by_user_id,
work_play_tracking::{WorkPlayTrackingDraft, record_work_play_start_after_success},
};
const VISUAL_NOVEL_PROVIDER: &str = "visual-novel";
@@ -445,7 +450,7 @@ pub async fn start_visual_novel_run(
.start_visual_novel_run(VisualNovelRunStartRecordInput {
run_id: build_prefixed_uuid_id(domain::VISUAL_NOVEL_RUN_ID_PREFIX),
owner_user_id: authenticated.claims().user_id().to_string(),
profile_id,
profile_id: profile_id.clone(),
mode: run_mode_to_wire(&payload.mode).to_string(),
snapshot_json: None,
started_at_micros: current_utc_micros(),
@@ -455,6 +460,23 @@ pub async fn start_visual_novel_run(
visual_novel_error_response(&request_context, map_spacetime_error(error))
})?;
record_work_play_start_after_success(
&state,
&request_context,
WorkPlayTrackingDraft::new(
"visual-novel",
profile_id.clone(),
&authenticated,
"/api/runtime/visual-novel/...",
)
.profile_id(profile_id.clone())
.extra(json!({
"mode": run_mode_to_wire(&payload.mode),
"runId": run.run_id,
})),
)
.await;
Ok(json_success_body(
Some(&request_context),
contract::VisualNovelRunResponse {