增加腾讯sdk 和活动ID收集
This commit is contained in:
parent
ca3d217488
commit
21e796331c
File diff suppressed because it is too large
Load Diff
|
|
@ -52,10 +52,10 @@ export default class GameManager extends cc.Component {
|
|||
nowTime: number;
|
||||
|
||||
|
||||
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
/** 游戏入口初始化 */
|
||||
onLoad() {
|
||||
|
||||
window.initMgr();
|
||||
this.register_time = 0;
|
||||
this.timeNumber = 2;
|
||||
|
|
@ -65,6 +65,21 @@ export default class GameManager extends cc.Component {
|
|||
cc.fx.GameConfig.init(true);
|
||||
cc.fx.GameConfig.GM_INFO.sceneValue = "loadScene";
|
||||
cc.fx.GameConfig.GM_INFO.gameState = false;
|
||||
|
||||
//@ts-ignore
|
||||
let query = wx.getLaunchOptionsSync().query;
|
||||
if (query.ge_ad_id) cc.fx.GameConfig.GM_INFO.ge_ad_id = query.ge_ad_id;
|
||||
if (query.ge_creative_id) cc.fx.GameConfig.GM_INFO.ge_creative_id = query.ge_creative_id;
|
||||
|
||||
// 遍历 query 中除 ge_ad_id、ge_creative_id 之外的其他参数
|
||||
for (const key in query) {
|
||||
if (key !== 'ge_ad_id' && key !== 'ge_creative_id') {
|
||||
cc.fx.GameTool.trackErrorToShushu({ message: key });
|
||||
}
|
||||
}
|
||||
|
||||
//cc.fx.GameTool.trackErrorToShushu({ message: "ge_ad_id" });
|
||||
|
||||
setTimeout(() => {
|
||||
cc.fx.GameTool.initWechatErrorTracking();
|
||||
}, 500);
|
||||
|
|
@ -176,6 +191,8 @@ export default class GameManager extends cc.Component {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#region 开始游戏
|
||||
/** 开始游戏,执行逻辑 */
|
||||
startGame() {
|
||||
|
|
@ -215,6 +232,7 @@ export default class GameManager extends cc.Component {
|
|||
readUserData(retryCount = 0) {
|
||||
//@ts-ignore
|
||||
if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) {
|
||||
MiniGameSdk.API.tencent_Init();
|
||||
MiniGameSdk.API.shushu_Init();
|
||||
this.nowTime = Date.now();
|
||||
// 最大重试次数
|
||||
|
|
@ -243,9 +261,11 @@ export default class GameManager extends cc.Component {
|
|||
if (data.data.openid) {
|
||||
cc.fx.GameConfig.GM_INFO.openid = data.data.openid;
|
||||
cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid);
|
||||
MiniGameSdk.API.tencent_SetOpenId(cc.fx.GameConfig.GM_INFO.openid);
|
||||
}
|
||||
console.log("系统信息________:", data.data.version);
|
||||
|
||||
|
||||
if (data.data.version) {
|
||||
let result = cc.fx.GameTool.compareVersion(cc.fx.GameConfig.GM_INFO.version, data.data.version);
|
||||
console.log("版本号:", result);
|
||||
|
|
@ -747,7 +767,6 @@ export default class GameManager extends cc.Component {
|
|||
|
||||
//第一次进游戏用户处理信息
|
||||
setFirstInfo() {
|
||||
|
||||
const time = cc.fx.GameTool.formatDate(new Date());
|
||||
let data = {
|
||||
register_time: time, // 注册时间
|
||||
|
|
@ -755,8 +774,30 @@ export default class GameManager extends cc.Component {
|
|||
|
||||
cc.fx.GameTool.shushu_Track("register", data);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(time, false);
|
||||
|
||||
MiniGameSdk.API.tencent_OnRegister();
|
||||
}
|
||||
|
||||
//#region 获取 URL 后缀
|
||||
/** 获取当前页面 URL 中 ? 后面的查询字符串(后缀) */
|
||||
static getUrlSuffix(): string {
|
||||
const url = window.location ? window.location.href : '';
|
||||
const idx = url.indexOf('?');
|
||||
return idx >= 0 ? url.substring(idx + 1) : '';
|
||||
}
|
||||
|
||||
/** 获取 URL 后缀中指定参数名的值 */
|
||||
static getUrlParam(name: string): string {
|
||||
const suffix = GameManager.getUrlSuffix();
|
||||
if (!suffix) return '';
|
||||
const params = suffix.split('&');
|
||||
for (const item of params) {
|
||||
const [key, value] = item.split('=');
|
||||
if (key === name) return value || '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/** 主循环,判断是否各项加载完成进入游戏 */
|
||||
update(dt) {
|
||||
if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.load6 == true && this.timeNumber <= 0) {
|
||||
|
|
@ -764,6 +805,7 @@ export default class GameManager extends cc.Component {
|
|||
MiniGameSdk.API.shushu_Login();
|
||||
MiniGameSdk.API.yinli_Init();
|
||||
MiniGameSdk.API.yinli_Login();
|
||||
|
||||
if (this.register_time != 0) MiniGameSdk.API.shushu_userSet(this.register_time);
|
||||
this.startGame();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
import { SDK } from './index.js';
|
||||
import Utils from "../module/Pay/Utils";
|
||||
import { getProvinceName } from "../module/Position/GetPosition";
|
||||
// import { getProvinceName } from "../module/Position/ProvinceLocator";
|
||||
|
|
@ -972,6 +974,7 @@ export namespace MiniGameSdk {
|
|||
private static _userInfo: any = null;
|
||||
private static _ta: any = null;
|
||||
private static _ge: any = null;
|
||||
static _tencent: any;
|
||||
/**
|
||||
* 分享app给朋友,微信小游戏分享是没有onSuccess回调的。
|
||||
* @param title 标题
|
||||
|
|
@ -1525,6 +1528,42 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//#region 腾讯平台SDK
|
||||
/*
|
||||
* 腾讯平台SDK初始化以及登录
|
||||
*/
|
||||
static tencent_Init() {
|
||||
//@ts-ignore
|
||||
if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) {
|
||||
// console.log("开始接入腾讯平台");
|
||||
//getWechatGameVersion
|
||||
// 初始化SDK
|
||||
try {
|
||||
API._tencent = new SDK({
|
||||
user_action_set_id: 1221926061,
|
||||
secret_key: "932fed3776ad7c390b16b54317b856de",
|
||||
appid: "wx30f74367b3d3e7a6",
|
||||
auto_track: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static tencent_Purchase(payAmount: number) {
|
||||
if (API._tencent) API._tencent.onPurchase(payAmount);
|
||||
}
|
||||
|
||||
static tencent_SetOpenId(openId: string) {
|
||||
if (API._tencent) API._tencent.setOpenId(cc.fx.GameConfig.GM_INFO.openid);
|
||||
}
|
||||
|
||||
static tencent_OnRegister() {
|
||||
if (API._tencent) API._tencent.onRegister();
|
||||
}
|
||||
|
||||
//#region 数数平台
|
||||
/*
|
||||
* 数数平台初始化以及登录
|
||||
|
|
@ -1573,6 +1612,18 @@ export namespace MiniGameSdk {
|
|||
} else {
|
||||
// console.log('未获取到用户的 account_id');
|
||||
}
|
||||
|
||||
// 设置广告属性
|
||||
if (cc.fx.GameConfig.GM_INFO.ge_ad_id != "") {
|
||||
console.log("___________上报ge_ad_id", cc.fx.GameConfig.GM_INFO.ge_ad_id);
|
||||
API._ta.userSet({ ge_ad_id: cc.fx.GameConfig.GM_INFO.ge_ad_id });
|
||||
}
|
||||
|
||||
if (cc.fx.GameConfig.GM_INFO.ge_creative_id != "") {
|
||||
console.log("___________上报ge_creative_id", cc.fx.GameConfig.GM_INFO.ge_creative_id);
|
||||
API._ta.userSet({ ge_creative_id: cc.fx.GameConfig.GM_INFO.ge_creative_id });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1594,6 +1645,7 @@ export namespace MiniGameSdk {
|
|||
console.log("_______________设置用户注册属性", time);
|
||||
API._ta.userSet({ register_time: time });
|
||||
API._ta.userSetOnce({ uid: cc.fx.GameConfig.GM_INFO.userId.toString() });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1624,6 +1676,7 @@ export namespace MiniGameSdk {
|
|||
magic_amount: cc.fx.GameConfig.GM_INFO.magicAmount,//当前道具
|
||||
version: cc.fx.GameConfig.GM_INFO.version.toString(),//当前版本号
|
||||
user_id: cc.fx.GameConfig.GM_INFO.userId //用户id
|
||||
|
||||
};
|
||||
if (register_time != null) {
|
||||
// console.log("设置用户公共属性注册:————————————", register_time);
|
||||
|
|
@ -1786,6 +1839,7 @@ export namespace MiniGameSdk {
|
|||
if (version == "开发版" || version == "体验版") {
|
||||
}
|
||||
else {
|
||||
if (API._tencent) API._tencent.onPurchase(payAmount);
|
||||
API._ge.payEvent(payAmount, "CNY", orderId, payReason, "微信");
|
||||
}
|
||||
console.log("版本:", version);
|
||||
|
|
|
|||
6
assets/Script/Sdk/index.js
Normal file
6
assets/Script/Sdk/index.js
Normal file
File diff suppressed because one or more lines are too long
10
assets/Script/Sdk/index.js.meta
Normal file
10
assets/Script/Sdk/index.js.meta
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "0aee96c9-7352-4339-8934-b47cf019070b",
|
||||
"importer": "javascript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
|
|
@ -153,6 +153,8 @@ export class GameConfig {
|
|||
GameplayType: number; //游戏类型
|
||||
canIos: boolean, //ios展示是否可以
|
||||
iosCanPay: boolean, //ios是否支持支付
|
||||
ge_ad_id: string, //广告ID
|
||||
ge_creative_id: string, //创意ID
|
||||
};
|
||||
static bgPosition: number;
|
||||
|
||||
|
|
@ -356,6 +358,8 @@ export class GameConfig {
|
|||
GameplayType: 0, // 0 正常模式, 1无尽模式
|
||||
canIos: true, //ios展示
|
||||
iosCanPay: false, //ios是否支持支付
|
||||
ge_ad_id: "", //广告ID
|
||||
ge_creative_id: "", //创意ID
|
||||
};
|
||||
// this.setCode(this.getKey("scode"));
|
||||
// this.GM_INFO.level = 0;
|
||||
|
|
|
|||
|
|
@ -96,11 +96,11 @@ export default class ranking extends cc.Component {
|
|||
this.closeLoad();
|
||||
// 设置容器可见
|
||||
this.node.getChildByName("rank").active = true;
|
||||
this.subContextView.active = true;
|
||||
// this.subContextView.active = true;
|
||||
console.log("展示排行榜");
|
||||
// 设置随机数(把这个当做玩家每局结算时的分数)
|
||||
|
||||
this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
// this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
setTimeout(() => {
|
||||
console.log('显示排行榜');
|
||||
//@ts-ignore
|
||||
|
|
@ -111,7 +111,7 @@ export default class ranking extends cc.Component {
|
|||
wx.getOpenDataContext().postMessage({
|
||||
message: parseInt(cc.fx.GameConfig.GM_INFO.level)
|
||||
});
|
||||
this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
// this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
}, 200);
|
||||
};
|
||||
|
||||
|
|
@ -140,11 +140,11 @@ export default class ranking extends cc.Component {
|
|||
|
||||
closeRanks() {
|
||||
// console.log('关闭排行榜');
|
||||
this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
// this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
this.closeButton.active = false;
|
||||
// 设置容器不可见,即关闭排行榜,并让开放域清空排名信息
|
||||
this.node.getChildByName("rank").active = false;
|
||||
this.subContextView.active = false;
|
||||
// this.subContextView.active = false;
|
||||
//@ts-ignore
|
||||
wx.getOpenDataContext().postMessage({
|
||||
message: 'close'
|
||||
|
|
@ -153,14 +153,14 @@ export default class ranking extends cc.Component {
|
|||
|
||||
closeFriend() {
|
||||
// console.log('关闭好有排行榜');
|
||||
this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
// this.subContextView.getComponent(cc.SubContextView).updateSubContextViewport();
|
||||
//@ts-ignore
|
||||
wx.getOpenDataContext().postMessage({
|
||||
message: 'close'
|
||||
});
|
||||
// 设置容器不可见,即关闭排行榜,并让开放域清空排名信息
|
||||
this.node.getChildByName("rank").active = false;
|
||||
this.subContextView.active = false;
|
||||
// this.subContextView.active = false;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ export default class NewbieGift extends cc.Component {
|
|||
// cc.fx.GameTool.shushu_Track("payment", dataSuccess);
|
||||
let name = "购买金币道具:" + productId;
|
||||
console.log("引力付费透传", price, Utils.outTradeNo, name);
|
||||
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name)
|
||||
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name);
|
||||
console.log("7.14_______________充值成功,轮训成功,准备发货");
|
||||
Utils.setPayInfo(
|
||||
(res) => {
|
||||
|
|
|
|||
13
assets/libs/dn-sdk-minigame.meta
Normal file
13
assets/libs/dn-sdk-minigame.meta
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "2b51992c-63b4-4c7d-98bf-96b166671aae",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
547
assets/libs/index.d.ts
vendored
Normal file
547
assets/libs/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,547 @@
|
|||
/**
|
||||
* SDK 初始化参数
|
||||
*/
|
||||
interface SdkConfig {
|
||||
/**
|
||||
* 数据源ID,必填
|
||||
*/
|
||||
user_action_set_id: number;
|
||||
/**
|
||||
* 加密key,必填
|
||||
*/
|
||||
secret_key: string;
|
||||
/**
|
||||
* 微信小程序/小游戏APPID,wx开头,必填
|
||||
*/
|
||||
appid: string;
|
||||
/**
|
||||
* 微信 openid,openid 和 unionid 至少填一个, 可以调用 setOpenId 设置
|
||||
*/
|
||||
openid?: string;
|
||||
/**
|
||||
* 微信 unionid,openid 和 unionid 至少填一个, 可以调用 setUnionId 设置
|
||||
*/
|
||||
unionid?: string;
|
||||
/**
|
||||
* 自定义用户ID,选填
|
||||
*/
|
||||
user_unique_id?: string;
|
||||
/**
|
||||
* 是否自动采集事件
|
||||
*/
|
||||
auto_track?: boolean;
|
||||
/**
|
||||
* 是否自动采集属性
|
||||
*/
|
||||
auto_attr?: boolean;
|
||||
/**
|
||||
* 上报回调(包括成功、失败、重试的各种场景)
|
||||
*/
|
||||
on_report_complete?: Function | undefined;
|
||||
/**
|
||||
* 明确上报失败的回调(sdk内部会直接丢弃的行为,无法再重试上报成功的部分)
|
||||
*/
|
||||
on_report_fail?: Function | undefined;
|
||||
}
|
||||
/**
|
||||
* 小程序/小游戏信息
|
||||
*/
|
||||
interface GameInfo {
|
||||
/**
|
||||
* 广告点击id、曝光id
|
||||
*/
|
||||
ad_trace_id?: string;
|
||||
/**
|
||||
* 页面路径,小游戏没有
|
||||
*/
|
||||
page_url?: string;
|
||||
/**
|
||||
* 页面名称,小游戏没有
|
||||
*/
|
||||
page_title?: string;
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
component_name?: string;
|
||||
/**
|
||||
* 场景来源
|
||||
*/
|
||||
source_scene?: number;
|
||||
/**
|
||||
* 渠道号
|
||||
*/
|
||||
pkg_channel_id?: string;
|
||||
/**
|
||||
* 框架信息,小游戏没有
|
||||
*/
|
||||
framework?: string;
|
||||
/**
|
||||
* 渠道来源
|
||||
*/
|
||||
channel: string;
|
||||
/**
|
||||
* 启动参数
|
||||
*/
|
||||
launch_options: string;
|
||||
}
|
||||
/**
|
||||
* 设备信息
|
||||
*/
|
||||
interface DeviceInfo {
|
||||
/**
|
||||
* 设备品牌
|
||||
*/
|
||||
device_brand: string;
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
device_model: string;
|
||||
/**
|
||||
* 微信App版本
|
||||
*/
|
||||
wx_version: string;
|
||||
/**
|
||||
* 微信基础库版本
|
||||
*/
|
||||
wx_lib_version: string;
|
||||
/**
|
||||
* 微信客户端平台
|
||||
*/
|
||||
wx_platform: string;
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
os: string;
|
||||
/**
|
||||
* 操作系统版本
|
||||
*/
|
||||
os_version: string;
|
||||
/**
|
||||
* 设备性能等级
|
||||
*/
|
||||
benchmark_level: number;
|
||||
/**
|
||||
* 屏幕高度
|
||||
*/
|
||||
screen_height: number;
|
||||
/**
|
||||
* 屏幕宽度
|
||||
*/
|
||||
screen_width: number;
|
||||
}
|
||||
interface TrackBaseInfo extends SdkConfig, DeviceInfo {
|
||||
local_id: string;
|
||||
sdk_name: string;
|
||||
sdk_version: string;
|
||||
inner_param: {
|
||||
app_version: string;
|
||||
app_env_version: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 行为信息
|
||||
*/
|
||||
interface ActionInfo {
|
||||
action_type: string;
|
||||
action_param?: Record<string | number | symbol, unknown>;
|
||||
is_sdk_auto_track: boolean;
|
||||
session_id: string;
|
||||
log_id: number;
|
||||
action_id: string;
|
||||
action_time: number;
|
||||
revised_action_time: number;
|
||||
is_retry: boolean;
|
||||
retry_count: number;
|
||||
ad_trace_id?: string;
|
||||
page_url?: string;
|
||||
page_title?: string;
|
||||
component_name?: string;
|
||||
source_scene?: number;
|
||||
pkg_channel_id?: string;
|
||||
/**
|
||||
* 网络类型
|
||||
*/
|
||||
network_type?: string;
|
||||
inner_param?: Record<string | number | symbol, unknown>;
|
||||
channel?: string;
|
||||
}
|
||||
interface LogParams {
|
||||
log_type: string;
|
||||
code?: number;
|
||||
message?: string;
|
||||
err_stack?: string;
|
||||
user_action_set_id?: number;
|
||||
appid?: string;
|
||||
local_id?: string;
|
||||
session_id?: string;
|
||||
sdk_name?: string;
|
||||
sdk_version?: string;
|
||||
page_url?: string;
|
||||
framework?: string;
|
||||
device_brand?: string;
|
||||
device_model?: string;
|
||||
wx_version?: string;
|
||||
wx_lib_version?: string;
|
||||
wx_platform?: string;
|
||||
os?: string;
|
||||
os_version?: string;
|
||||
}
|
||||
interface TrackResponse {
|
||||
code: number;
|
||||
message: string;
|
||||
actionId?: string;
|
||||
}
|
||||
|
||||
interface QueueProps {
|
||||
/**
|
||||
* 数据源ID,用于本地存储队列key
|
||||
*/
|
||||
userActionSetId: number;
|
||||
/**
|
||||
* 队列长度
|
||||
*/
|
||||
maxLength: number;
|
||||
}
|
||||
interface QueueManagerProps extends QueueProps {
|
||||
/**
|
||||
* OG事件列表
|
||||
*/
|
||||
ogEvents: string[];
|
||||
}
|
||||
interface IEvent extends ActionInfo {
|
||||
inner_status?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 队列原子操作
|
||||
*/
|
||||
|
||||
declare class Queue {
|
||||
protected maxLength: any;
|
||||
protected userActionSetId: any;
|
||||
protected lostActionMaps: Record<string, number>;
|
||||
private stack;
|
||||
private localStorageKey;
|
||||
private timeStamp;
|
||||
constructor({ userActionSetId, maxLength }: QueueProps);
|
||||
getItems(): IEvent[];
|
||||
getStorage(): IEvent[];
|
||||
/**
|
||||
* 上报丢失条数到日志系统
|
||||
*/
|
||||
reportLostNum(): void;
|
||||
/**
|
||||
* 获取丢失条数map
|
||||
* @returns 丢失条数map
|
||||
*/
|
||||
getLostMaps(): Record<string, number>;
|
||||
protected init(): void;
|
||||
protected addItem(eventData: IEvent): void;
|
||||
protected removeItems(actionIds: string[]): void;
|
||||
protected updateForReportFail(actionIds: string[]): void;
|
||||
protected updateForReporting(actionIds: string[]): void;
|
||||
protected updateAllStack(stack: IEvent[]): void;
|
||||
protected updateToStorage(): void;
|
||||
/**
|
||||
* 更新丢失条数
|
||||
* @param sessionId 当前被丢弃行为的会话id
|
||||
*/
|
||||
protected updateLostAction(sessionId: string): void;
|
||||
/**
|
||||
* 设置时间戳
|
||||
*/
|
||||
protected setTimeStamp(): void;
|
||||
}
|
||||
|
||||
declare class QueueManage extends Queue {
|
||||
protected ogEvents: string[];
|
||||
constructor({ userActionSetId, maxLength, ogEvents }: QueueManagerProps);
|
||||
/**
|
||||
* 获取可上报的队列
|
||||
* @param reportMaxLength 需要上报的队列最大长度
|
||||
*/
|
||||
getReportableActions(reportMaxLength?: number): IEvent[];
|
||||
/**
|
||||
* 添加行为到队列
|
||||
* @param eventData 单条行为数据
|
||||
*/
|
||||
addAction(eventData: IEvent): TrackResponse;
|
||||
/**
|
||||
* 根据acition_id删除行为
|
||||
* @param actionIds 行为id列表
|
||||
*/
|
||||
removeActions(actionIds: string[]): void;
|
||||
/**
|
||||
* 上报失败时更新队列状态
|
||||
* @param actionIds
|
||||
*/
|
||||
updateActionsForReportFail(actionIds: string[]): void;
|
||||
/**
|
||||
* 上报时更新队列状态为reporting
|
||||
* @param actionIds 需要更新的行为id数组
|
||||
*/
|
||||
updateActionsForReporting(actionIds: string[]): void;
|
||||
/**
|
||||
* 获取可上报队列长度
|
||||
* @returns 可上报队列长度
|
||||
*/
|
||||
getReportableActionsLength(): number;
|
||||
/**
|
||||
* 按照优先级从大到小给队列排序
|
||||
* @param currEvent 当前事件
|
||||
* @param stack 当前队列
|
||||
*/
|
||||
sortQueue(currEvent: IEvent, stack: IEvent[]): IEvent[];
|
||||
/**
|
||||
* 计算优先级
|
||||
* @param currTime 当前时间
|
||||
* @param event 行为事件
|
||||
* @returns 权重值
|
||||
*/
|
||||
private caculateWeight;
|
||||
/**
|
||||
*
|
||||
* @param currTime 当前时间
|
||||
* @param actionTime 队列行为时间
|
||||
* @returns 权重值
|
||||
*/
|
||||
private formatWeight;
|
||||
}
|
||||
|
||||
interface ConfigManager {
|
||||
getRealTimeActionList: () => Array<string>;
|
||||
getRequestTimeout: () => number;
|
||||
}
|
||||
interface ActionReporterProps {
|
||||
getBaseInfo: () => TrackBaseInfo;
|
||||
reportLog: (param: LogParams) => void;
|
||||
queueManager: QueueManage;
|
||||
configManager?: ConfigManager;
|
||||
onReportComplete?: Function | undefined;
|
||||
onReportFail?: Function | undefined;
|
||||
}
|
||||
/**
|
||||
* 行为上报类
|
||||
*/
|
||||
declare class ActionReporter {
|
||||
private static currentRequestCount;
|
||||
private static requestConcurrency;
|
||||
static setRequestConcurrency(n: number): void;
|
||||
private getBaseInfo;
|
||||
private reportLog;
|
||||
private queueManager;
|
||||
private configManager;
|
||||
private onReportComplete;
|
||||
private onReportFail;
|
||||
private cgiBatchSize;
|
||||
private reportThreshold;
|
||||
private reportDelay;
|
||||
private triggerExecuteSend;
|
||||
private inspectDelay;
|
||||
private inspectTimer;
|
||||
private isNeedContinueSend;
|
||||
constructor(props: ActionReporterProps);
|
||||
/**
|
||||
* 批量上报行为,track的时候触发
|
||||
*/
|
||||
batchSend(): void;
|
||||
/**
|
||||
* 全量上报, flush的时候触发
|
||||
*/
|
||||
flushSend(): void;
|
||||
/**
|
||||
* 执行指定数量的行为上报逻辑,超过接口batch上限则并行发送请求
|
||||
*/
|
||||
private executeSend;
|
||||
/**
|
||||
* 组装上报用的行为数据
|
||||
*/
|
||||
private generateActionReportParams;
|
||||
/**
|
||||
* 上报接口请求成功逻辑处理
|
||||
* @param resData
|
||||
* @param actionIdList
|
||||
*/
|
||||
private dealSuccessData;
|
||||
/**
|
||||
* 上报接口请求失败逻辑处理
|
||||
* @param errData
|
||||
* @param actionIdList
|
||||
*/
|
||||
private dealFailData;
|
||||
/**
|
||||
* wx.request文档:https://developers.weixin.qq.com/minigame/dev/api/network/request/wx.request.html
|
||||
* @param param.data:接口请求参数、param.actionIdList:行为id列表
|
||||
* @returns
|
||||
*/
|
||||
private report;
|
||||
/**
|
||||
* 启动上报定时器
|
||||
*/
|
||||
private startInspectTimer;
|
||||
/**
|
||||
* 上报回调数据
|
||||
*/
|
||||
private doTrackCallbackFn;
|
||||
}
|
||||
|
||||
declare abstract class SdkExtCommon {
|
||||
protected special_method_symbol: symbol;
|
||||
/**
|
||||
* 付费
|
||||
*/
|
||||
onPurchase(value: number): TrackResponse;
|
||||
/**
|
||||
* 进入前台
|
||||
*/
|
||||
onEnterForeground(): TrackResponse;
|
||||
/**
|
||||
* 进入后台
|
||||
*/
|
||||
onEnterBackground(): TrackResponse;
|
||||
/**
|
||||
* 启动
|
||||
*/
|
||||
onAppStart(): TrackResponse;
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
onAppQuit(): TrackResponse;
|
||||
/**
|
||||
* 收藏
|
||||
*/
|
||||
onAddToWishlist(): TrackResponse;
|
||||
protected wrapTrack(action_type: ActionInfo["action_type"], action_param?: ActionInfo["action_param"]): TrackResponse;
|
||||
abstract track(action_type: ActionInfo["action_type"], action_param?: ActionInfo["action_param"]): TrackResponse;
|
||||
}
|
||||
|
||||
declare abstract class sdkExt extends SdkExtCommon {
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
onRegister(): TrackResponse;
|
||||
/**
|
||||
* 创角
|
||||
*/
|
||||
onCreateRole(name?: string): TrackResponse;
|
||||
/**
|
||||
* 完成新手教程
|
||||
*/
|
||||
onTutorialFinish(): TrackResponse;
|
||||
}
|
||||
|
||||
declare const initializedInstanceSymbol: unique symbol;
|
||||
declare class SDK extends sdkExt {
|
||||
private static [initializedInstanceSymbol];
|
||||
static setRequestConcurrency(n: number): void;
|
||||
static setDebug(debug: boolean): void;
|
||||
protected env: string;
|
||||
protected sdk_version: string;
|
||||
protected sdk_name: string;
|
||||
protected config?: SdkConfig;
|
||||
protected deviceInfo: Partial<DeviceInfo>;
|
||||
protected gameInfo: Partial<GameInfo>;
|
||||
protected session_id: string;
|
||||
protected log_id: number;
|
||||
protected queueManage?: QueueManage;
|
||||
protected actionReporter?: ActionReporter;
|
||||
protected openid?: string;
|
||||
protected unionid?: string;
|
||||
protected user_unique_id?: string;
|
||||
protected inited: boolean;
|
||||
protected initErrMsg: string;
|
||||
protected onReportComplete?: Function | undefined;
|
||||
protected onReportFail?: Function | undefined;
|
||||
constructor(sdkConfig: SdkConfig);
|
||||
/**
|
||||
* 返回初始化状态
|
||||
* @returns
|
||||
*/
|
||||
getInitResult(): {
|
||||
inited: boolean;
|
||||
initErrMsg: string;
|
||||
};
|
||||
/**
|
||||
* 数据上报方法
|
||||
* 0: 成功
|
||||
* 100: 未完成初始化或重复初始化导致初始化失败,请先完成初始化
|
||||
* 101: action_type 或 action_param 参数错误
|
||||
* 102: action_param 参数过大,不能超过 xxxx 字符
|
||||
* 103: 缓存队列已满,主动丢弃行为
|
||||
*
|
||||
*/
|
||||
track(action_type: ActionInfo['action_type'], action_param?: ActionInfo['action_param']): TrackResponse;
|
||||
/**
|
||||
* 立即上报数据
|
||||
*/
|
||||
flush(): void;
|
||||
/**
|
||||
* 设置 openId
|
||||
* 0: 成功
|
||||
* 101: openid 格式错误
|
||||
*/
|
||||
setOpenId(openid: string): {
|
||||
code: number;
|
||||
message: string;
|
||||
};
|
||||
/**
|
||||
* 设置 unionid
|
||||
* 0: 成功
|
||||
* 101: unionid 格式错误
|
||||
*/
|
||||
setUnionId(unionid: string): {
|
||||
code: number;
|
||||
message: string;
|
||||
};
|
||||
/**
|
||||
* 设置 user_unique_id
|
||||
* @param user_unique_id
|
||||
*/
|
||||
setUserUniqueId(user_unique_id: string): {
|
||||
code: number;
|
||||
message: string;
|
||||
};
|
||||
/**
|
||||
* strategyConfig 入参
|
||||
* callback 回调函数
|
||||
*/
|
||||
getStrategy(strategyConfig: Record<string | number | symbol, unknown>, callback: Function): void;
|
||||
protected doReportOnEnterBackground(): void;
|
||||
/**
|
||||
* 获取数据上报时所需要的 info 参数
|
||||
*/
|
||||
private getTrackBaseInfo;
|
||||
/**
|
||||
* 生成上报队列需要的行为数据
|
||||
* @param actionParams 行为参数
|
||||
* @param is_sdk_auto_track 是否自动采集
|
||||
* @returns
|
||||
*/
|
||||
private createAction;
|
||||
/**
|
||||
* 给指定行为的inner_param字段追加字段
|
||||
* @param action 待追加字段的行为
|
||||
* @param key 待添加到inner_param字段的key
|
||||
* @param value key对应的value
|
||||
*/
|
||||
private addActionInnerParam;
|
||||
/**
|
||||
* 不同行为携带的渠道来源判断逻辑
|
||||
* @param actionType
|
||||
* @returns
|
||||
*/
|
||||
private getChannelByActionType;
|
||||
/**
|
||||
* 上报日志
|
||||
* @param params 日志参数
|
||||
*/
|
||||
private reportLog;
|
||||
private useAutoTrack;
|
||||
private getAutoProxyRemoteConfig;
|
||||
/**
|
||||
* 设置openid时,如果值合法缓存到Storage
|
||||
*/
|
||||
private saveValidOpenidToStorage;
|
||||
}
|
||||
|
||||
export { SDK };
|
||||
6
assets/libs/index.d.ts.meta
Normal file
6
assets/libs/index.d.ts.meta
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"ver": "2.0.2",
|
||||
"uuid": "bb24bd9e-ffb1-43a5-b2ca-830fcd4c7508",
|
||||
"importer": "text",
|
||||
"subMetas": {}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
BIN
loadBg.jpg
Normal file
BIN
loadBg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 136 KiB |
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"last-module-event-record-time": 1781508024085,
|
||||
"last-module-event-record-time": 1782128759179,
|
||||
"group-list": [
|
||||
"default",
|
||||
"Map"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
"orientation": "portrait",
|
||||
"separate_engine": true,
|
||||
"REMOTE_SERVER_ROOT": "https://cdn.pay.nika4games.com/",
|
||||
"subContext": "SubContextView",
|
||||
"subContext": "",
|
||||
"startSceneAssetBundle": true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user