refactor(data): replace schema classes with readonly models

This commit is contained in:
2026-07-17 13:21:40 +08:00
parent 3437312167
commit ae97366a4a
103 changed files with 1220 additions and 2117 deletions
+9 -9
View File
@@ -2,12 +2,12 @@
* Metrics API
*
* 数据看板/上报相关接口
*
*
*/
import { httpClient } from "./http_client";
import { ApiPath } from "./api_path";
import { ApiEnvelope, unwrapOptional } from "./response_helper";
import { AppEvent, PwaEvent } from "@/data/schemas/metrics";
import { ApiPath } from "./api_path";
import { httpClient } from "./http_client";
import { ApiEnvelope, unwrapOptional } from "./response_helper";
export class MetricsApi {
/**
@@ -16,7 +16,7 @@ export class MetricsApi {
async reportPwaEvent(body: PwaEvent): Promise<void> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.metricsPwaEvent,
{ method: "POST", body: body.toJson() }
{ method: "POST", body },
);
unwrapOptional(env);
}
@@ -25,10 +25,10 @@ export class MetricsApi {
* 上报用户信息
*/
async reportUserInfo(body: AppEvent): Promise<void> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.reportUserInfo,
{ method: "POST", body: body.toJson() }
);
const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.reportUserInfo, {
method: "POST",
body,
});
unwrapOptional(env);
}
}