fix(埋点合同): 服务端同步 AGC 新增的 creation_source=platform_game
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
- 依据客户端提交 `5d01e43b6`:AGC 的 `CreationSource` 新增 `PlatformGame`,按 serde snake_case 落到线上取值 **`platform_game`**(同提交的 `creation_source_gains_platform_game_without_breaking_existing_values` 用例显式给出该字面量),上报字段仍是 `project_create_success` 的属性 `creation_source`。服务端枚举此前没有它,整条事件会被判 `invalid_properties` 直接丢弃
- `shared-contracts/src/agc_analytics.rs`:`values!(CreationSource { .. })` 追加 `PlatformGame`(注释与客户端一致);解析走 serde 派生,无需新增匹配分支
- `module-runtime/src/agc_analytics.rs`:新增 `agc_accepts_every_creation_source_and_rejects_unknown`——五个受支持取值(home_game / home_design / template / selected_directory / **platform_game**)逐个通过整批校验(事件形如 `project_create_success` 且带 `project_id`),未知取值(`remix` / `platform` / `PLATFORM_GAME` / 空串)仍然失败关闭为 `invalid_properties`
- 文档:`docs/technical/【技术方案】客户端本地埋点与主站入库契约-2026-09-21.md` §6.6 的 `creation_source` 取值列表补 `platform_game`(保持 `/` 分隔与 snake_case 风格)
- 全仓核对:该枚举只有两处定义(AGC `analytics/contract.rs` 与 `shared-contracts`),**无第二处服务端镜像**、无 TS 联合类型、无 schema/OpenAPI 取值表;生成绑定不含该类型(埋点批量跨模块边界走 `payload_json: String`),因此无需重跑 spacetime generate
This commit is contained in:
@@ -386,6 +386,45 @@ mod tests {
|
||||
raw["file_path"] = json!("secret");
|
||||
assert!(serde_json::from_value::<Event>(raw).is_err());
|
||||
}
|
||||
|
||||
/// `creation_source` 的取值集合必须与客户端埋点合同一一对应:客户端新增「从平台作品开始创作」
|
||||
/// (`platform_game`)后,服务端不认得就会把整条事件判成 `invalid_properties` 丢掉。这里把
|
||||
/// 全部受支持取值逐个跑通,并钉住未知取值仍然失败关闭(不得静默接受或静默丢弃)。
|
||||
#[test]
|
||||
fn agc_accepts_every_creation_source_and_rejects_unknown() {
|
||||
for creation_source in [
|
||||
"home_game",
|
||||
"home_design",
|
||||
"template",
|
||||
"selected_directory",
|
||||
"platform_game",
|
||||
] {
|
||||
let mut e = event(
|
||||
"project_create_success",
|
||||
json!({ "creation_source": creation_source }),
|
||||
);
|
||||
// `project_create_success` 要求 source=editor 且 project_id 非空(见 `EventRules::validate`)。
|
||||
e.project_id = Some("project-a".into());
|
||||
assert_eq!(
|
||||
validate_agc_analytics_batch(&batch(e)),
|
||||
Ok(()),
|
||||
"{creation_source}"
|
||||
);
|
||||
}
|
||||
for unknown in ["remix", "platform", "PLATFORM_GAME", ""] {
|
||||
let mut e = event(
|
||||
"project_create_success",
|
||||
json!({ "creation_source": unknown }),
|
||||
);
|
||||
e.project_id = Some("project-a".into());
|
||||
assert_eq!(
|
||||
validate_agc_analytics_batch(&batch(e)),
|
||||
Err("invalid_properties"),
|
||||
"{unknown}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn agc_requires_explicit_nullable_fields_and_no_optional_nulls() {
|
||||
let mut raw =
|
||||
|
||||
@@ -55,7 +55,9 @@ values!(CreationSource {
|
||||
HomeGame,
|
||||
HomeDesign,
|
||||
Template,
|
||||
SelectedDirectory
|
||||
SelectedDirectory,
|
||||
// 从平台作品开始创作(改编 Fork):取件自平台已授权公开作品的发行成品包。
|
||||
PlatformGame
|
||||
});
|
||||
values!(OpenSource {
|
||||
Create,
|
||||
|
||||
Reference in New Issue
Block a user