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

@@ -74,6 +74,7 @@ use crate::{
request_context::RequestContext,
state::AppState,
work_author::resolve_work_author_by_user_id,
work_play_tracking::{WorkPlayTrackingDraft, record_work_play_start_after_success},
};
const DRAFT_ASSET_GENERATION_MAX_ATTEMPTS: u32 = 3;
@@ -827,7 +828,7 @@ pub async fn record_custom_world_gallery_play(
State(state): State<AppState>,
Path((owner_user_id, profile_id)): Path<(String, String)>,
Extension(request_context): Extension<RequestContext>,
Extension(_authenticated): Extension<AuthenticatedAccessToken>,
Extension(authenticated): Extension<AuthenticatedAccessToken>,
) -> Result<Json<Value>, Response> {
if owner_user_id.trim().is_empty() || profile_id.trim().is_empty() {
return Err(custom_world_error_response(
@@ -842,8 +843,8 @@ pub async fn record_custom_world_gallery_play(
let mutation = state
.spacetime_client()
.record_custom_world_profile_play(CustomWorldProfilePlayReportRecordInput {
owner_user_id,
profile_id,
owner_user_id: owner_user_id.clone(),
profile_id: profile_id.clone(),
played_at_micros: current_utc_micros(),
})
.await
@@ -851,6 +852,20 @@ pub async fn record_custom_world_gallery_play(
custom_world_error_response(&request_context, map_custom_world_client_error(error))
})?;
record_work_play_start_after_success(
&state,
&request_context,
WorkPlayTrackingDraft::new(
"custom-world",
profile_id.clone(),
&authenticated,
"/api/runtime/custom-world-gallery/{owner_user_id}/{profile_id}/play",
)
.owner_user_id(owner_user_id.clone())
.profile_id(profile_id.clone()),
)
.await;
Ok(json_success_body(
Some(&request_context),
CustomWorldGalleryDetailResponse {