增加游戏内上报打点请求

This commit is contained in:
jtx
2025-10-16 11:19:07 +08:00
parent a7ef288b2d
commit 8d5d9eea0e
5 changed files with 38 additions and 0 deletions
+13
View File
@@ -15,6 +15,7 @@ import {
ProgressBar,
Sprite,
SpriteFrame,
sys,
Vec3,
VideoPlayer,
} from "cc";
@@ -326,8 +327,20 @@ export class PreloadUI extends Component {
const deviceId = DeviceIdService.I.id;
const os = MachineInfoService.I.getMachineOs();
// 获取fbCode,如果有则表示从落地页进来的
const qs = new URLSearchParams(window.location.search);
const fbCode = qs.get("fbCode");
// 保存fbCode到本地
if (fbCode) {
sys.localStorage.setItem("fbCode", fbCode);
// 上报事件
const reqData = {
point: 4, // 4: 进入游戏
fbCode: fbCode,
};
AuthService.I.pointEvent(reqData);
}
const reqData = {
platType: "guest",
userId: fbCode ? fbCode : deviceId,
@@ -29,4 +29,8 @@ export class AuthService implements IAuthService {
public async login(req: proto.cs.ICSLoginReq): Promise<ApiResponse<proto.cs.ICSLoginRes>> {
return this.impl.login(req);
}
/** 上报事件 */
public async pointEvent(req: proto.cs.ICSPointEventReq): Promise<ApiResponse<proto.cs.ICSPointEventRes>> {
return this.impl.pointEvent(req);
}
}
@@ -17,4 +17,15 @@ export class HttpAuthService implements IAuthService {
};
return this.api.call(ep, req);
}
/** 上报事件 */
async pointEvent(req: proto.cs.ICSPointEventReq): Promise<ApiResponse<proto.cs.ICSPointEventRes>> {
const ep: Endpoint<proto.cs.ICSPointEventReq, proto.cs.ICSPointEventRes> = {
path: "api/logic/pointEvent",
method: "POST",
codec: "json",
needsAuth: false,
};
return this.api.call(ep, req);
}
}
@@ -4,4 +4,7 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
export interface IAuthService {
// 登录
login(req: proto.cs.ICSLoginReq): Promise<ApiResponse<proto.cs.ICSLoginRes>>;
// 上报事件
pointEvent(req: proto.cs.ICSPointEventReq): Promise<ApiResponse<proto.cs.ICSPointEventRes>>;
}
@@ -40,4 +40,11 @@ export class MockAuthService implements IAuthService {
return this.ok(res);
}
/** 上报事件 */
async pointEvent(req: proto.cs.ICSPointEventReq): Promise<ApiResponse<proto.cs.ICSPointEventRes>> {
// 延时
await this.delay(150);
return this.ok({});
}
}