增加腾讯sdk 和活动ID收集

This commit is contained in:
COMPUTER\EDY 2026-06-23 16:09:03 +08:00
parent ca3d217488
commit 21e796331c
15 changed files with 1921 additions and 1271 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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();
}

View File

@ -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);

File diff suppressed because one or more lines are too long

View 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": {}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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) => {

View 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
View File

@ -0,0 +1,547 @@
/**
* SDK
*/
interface SdkConfig {
/**
* ID
*/
user_action_set_id: number;
/**
* key
*/
secret_key: string;
/**
* /APPIDwx开头
*/
appid: string;
/**
* openidopenid unionid , setOpenId
*/
openid?: string;
/**
* unionidopenid 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 {
/**
* 广idid
*/
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 {
/**
* IDkey
*/
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 };

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View File

@ -1,5 +1,5 @@
{
"last-module-event-record-time": 1781508024085,
"last-module-event-record-time": 1782128759179,
"group-list": [
"default",
"Map"

View File

@ -3,6 +3,6 @@
"orientation": "portrait",
"separate_engine": true,
"REMOTE_SERVER_ROOT": "https://cdn.pay.nika4games.com/",
"subContext": "SubContextView",
"subContext": "",
"startSceneAssetBundle": true
}