更新SDK代码
This commit is contained in:
parent
919f133538
commit
0b9f05f77f
|
@ -212,7 +212,6 @@ export default class GameManager extends cc.Component {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (typeof wx !== 'undefined' && wx !== null) {
|
if (typeof wx !== 'undefined' && wx !== null) {
|
||||||
MiniGameSdk.API.shushu_Init();
|
MiniGameSdk.API.shushu_Init();
|
||||||
MiniGameSdk.API.yinli_Init();
|
|
||||||
Utils.getUserInfo((data)=>{
|
Utils.getUserInfo((data)=>{
|
||||||
console.log("登陆成功",data);
|
console.log("登陆成功",data);
|
||||||
});
|
});
|
||||||
|
@ -686,6 +685,7 @@ export default class GameManager extends cc.Component {
|
||||||
if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.timeNumber <= 0) {
|
if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.timeNumber <= 0) {
|
||||||
this.load1 = this.load2 = false;
|
this.load1 = this.load2 = false;
|
||||||
MiniGameSdk.API.shushu_Login();
|
MiniGameSdk.API.shushu_Login();
|
||||||
|
MiniGameSdk.API.yinli_Init();
|
||||||
this.startGame();
|
this.startGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -704,7 +704,7 @@ export namespace MiniGameSdk {
|
||||||
private static _hasInitWechatCloudFunction: boolean = false;
|
private static _hasInitWechatCloudFunction: boolean = false;
|
||||||
private static _userInfo: any = null;
|
private static _userInfo: any = null;
|
||||||
private static _ta: any = null;
|
private static _ta: any = null;
|
||||||
|
private static _ge: any = null;
|
||||||
/**
|
/**
|
||||||
* 分享app给朋友,微信小游戏分享是没有onSuccess回调的。
|
* 分享app给朋友,微信小游戏分享是没有onSuccess回调的。
|
||||||
* @param title 标题
|
* @param title 标题
|
||||||
|
@ -1132,6 +1132,22 @@ export namespace MiniGameSdk {
|
||||||
API._ta = new ThinkingAnalyticsAPI(config);
|
API._ta = new ThinkingAnalyticsAPI(config);
|
||||||
// 初始化
|
// 初始化
|
||||||
API._ta.init();
|
API._ta.init();
|
||||||
|
|
||||||
|
const distinctId = MiniGameSdk.API.getShushuDistinctId();
|
||||||
|
if (distinctId) {
|
||||||
|
cc.fx.GameConfig.GM_INFO.shushu_DistinctId = distinctId;
|
||||||
|
console.log('用户的 distinct_id 是:', distinctId);
|
||||||
|
} else {
|
||||||
|
console.log('未获取到用户的 distinct_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
const accountId = MiniGameSdk.API.getShushuAccountId();
|
||||||
|
if (accountId) {
|
||||||
|
cc.fx.GameConfig.GM_INFO.shushu_AccountId = accountId;
|
||||||
|
console.log('用户的 account_id 是:', accountId);
|
||||||
|
} else {
|
||||||
|
console.log('未获取到用户的 account_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,6 +1155,7 @@ export namespace MiniGameSdk {
|
||||||
if (typeof wx !== 'undefined' && wx !== null) {
|
if (typeof wx !== 'undefined' && wx !== null) {
|
||||||
console.log("数数登录时,获取到的openId:",cc.fx.GameConfig.GM_INFO.openid);
|
console.log("数数登录时,获取到的openId:",cc.fx.GameConfig.GM_INFO.openid);
|
||||||
API._ta.login(cc.fx.GameConfig.GM_INFO.openid);
|
API._ta.login(cc.fx.GameConfig.GM_INFO.openid);
|
||||||
|
cc.fx.GameConfig.GM_INFO.shushu_AccountId = cc.fx.GameConfig.GM_INFO.openid;
|
||||||
const result = "success";
|
const result = "success";
|
||||||
API.shushu_Track("login", result);
|
API.shushu_Track("login", result);
|
||||||
API.shushu_SetSuperProperties(null);
|
API.shushu_SetSuperProperties(null);
|
||||||
|
@ -1158,21 +1175,19 @@ export namespace MiniGameSdk {
|
||||||
|
|
||||||
static shushu_SetSuperProperties(register_time) {
|
static shushu_SetSuperProperties(register_time) {
|
||||||
if (typeof wx !== 'undefined' && wx !== null && API._ta) {
|
if (typeof wx !== 'undefined' && wx !== null && API._ta) {
|
||||||
const versionData = "1.3";
|
|
||||||
// API._ta.userSetOnce({ register_time:time});
|
|
||||||
var superProperties = {};
|
var superProperties = {};
|
||||||
superProperties = {
|
superProperties = {
|
||||||
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
||||||
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
||||||
tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
||||||
version: versionData
|
version: cc.fx.GameConfig.GM_INFO.version.toString(),//当前版本号
|
||||||
};
|
};
|
||||||
if(register_time != null){
|
if(register_time != null){
|
||||||
superProperties = {
|
superProperties = {
|
||||||
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
||||||
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
||||||
tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
||||||
version: versionData,
|
version: cc.fx.GameConfig.GM_INFO.version.toString(),
|
||||||
register_time:register_time
|
register_time:register_time
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1204,16 +1219,69 @@ export namespace MiniGameSdk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数数平台用户的 distinct_id
|
||||||
|
* @returns distinct_id 或 null
|
||||||
|
*/
|
||||||
|
static getShushuDistinctId(): string | null {
|
||||||
|
if (typeof wx !== 'undefined' && wx !== null && API._ta) {
|
||||||
|
// 假设 SDK 提供 getDistinctId 方法
|
||||||
|
if (API._ta.getDistinctId) {
|
||||||
|
return API._ta.getDistinctId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数数平台用户的 account_id
|
||||||
|
* @returns account_id 或 null
|
||||||
|
*/
|
||||||
|
static getShushuAccountId(): string | null {
|
||||||
|
if (typeof wx !== 'undefined' && wx !== null && API._ta) {
|
||||||
|
// 假设 SDK 提供 getAccountId 方法
|
||||||
|
if (API._ta.getAccountId) {
|
||||||
|
return API._ta.getAccountId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
//#region 引力平台-
|
//#region 引力平台-
|
||||||
static yinli_Init(){
|
static yinli_Init(){
|
||||||
const config = {
|
const configYinli = {
|
||||||
accessToken: "aGws0nluotbm6Jjiv9WMuzOAbXLydxwe", // 项目通行证,在:网站后台-->设置-->应用列表中找到Access Token列 复制(首次使用可能需要先新增应用)
|
accessToken: "aGws0nluotbm6Jjiv9WMuzOAbXLydxwe", // 项目通行证,在:网站后台-->设置-->应用列表中找到Access Token列 复制(首次使用可能需要先新增应用)
|
||||||
clientId: cc.fx.GameConfig.GM_INFO.openid, // 用户唯一标识,如产品为小游戏,则必须填用户openid(注意,不是小游戏的APPID!!!)
|
clientId: cc.fx.GameConfig.GM_INFO.openid, // 用户唯一标识,如产品为小游戏,则必须填用户openid(注意,不是小游戏的APPID!!!)
|
||||||
name: "ge", // 全局变量名称
|
name: "ge", // 全局变量名称
|
||||||
debugMode: "debug", // 是否开启测试模式,开启测试模式后,可以在 网站后台--设置--元数据--事件流中查看实时数据上报结果。(测试时使用,上线之后一定要关掉,改成none或者删除)
|
debugMode: "none", // 是否开启测试模式,开启测试模式后,可以在 网站后台--设置--元数据--事件流中查看实时数据上报结果。(测试时使用,上线之后一定要关掉,改成none或者删除)
|
||||||
|
sendTimeout: 3000, // 网络请求超时时间,单位毫秒,默认值 3000 ms
|
||||||
|
maxRetries: 3, // 网络请求失败时的重试次数,1 表示不重试。默认值是 3
|
||||||
|
enablePersistence: true, // 是否使用本地缓存,主实例默认为 true,子实例默认为 false
|
||||||
|
asyncPersistence: false, // 是否使用异步存储,默认为 false
|
||||||
};
|
};
|
||||||
const ge = new GravityAnalyticsAPI(config);
|
API._ge = new GravityAnalyticsAPI(configYinli);
|
||||||
ge.setupAndStart();
|
API._ge .setupAndStart();
|
||||||
|
|
||||||
|
API._ge .initialize({
|
||||||
|
name: cc.fx.GameConfig.GM_INFO.openid,
|
||||||
|
version: cc.fx.GameConfig.GM_INFO.version,
|
||||||
|
openid: cc.fx.GameConfig.GM_INFO.openid,
|
||||||
|
enable_sync_attribution: false,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
console.log("引力引擎初始化成功", res)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log("引力引擎初始化失败 " + err);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(cc.fx.GameConfig.GM_INFO.shushu_AccountId == "") cc.fx.GameConfig.GM_INFO.shushu_AccountId =
|
||||||
|
cc.fx.GameConfig.GM_INFO.openid;
|
||||||
|
|
||||||
|
const CURRENT_USER_TA_ACCOUNT_ID = cc.fx.GameConfig.GM_INFO.shushu_AccountId; // 用户唯一标识,如产品为小游戏,则必须填用户openid(注意,不是小游戏的APPID!!!)
|
||||||
|
const CURRENT_USER_TA_DISTINCT_ID = cc.fx.GameConfig.GM_INFO.shushu_DistinctId; // 用户唯一标识,如产品为小游戏,则必须填用户openid(注意,不是小游戏的APPID!!!)
|
||||||
|
API._ge.bindTAThirdPlatform(CURRENT_USER_TA_ACCOUNT_ID, CURRENT_USER_TA_DISTINCT_ID);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,9 +90,13 @@ export class GameConfig {
|
||||||
effectOpen: boolean; //音效
|
effectOpen: boolean; //音效
|
||||||
vibrateOpen: boolean; //震动
|
vibrateOpen: boolean; //震动
|
||||||
coinnum: number; //每局的金币数
|
coinnum: number; //每局的金币数
|
||||||
paid_user: boolean;
|
paid_user: boolean; //是否是付费用户
|
||||||
|
version: number; //版本号
|
||||||
|
shushu_DistinctId: string //数数访客ID
|
||||||
|
shushu_AccountId: string //数数账号ID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//游戏内信息
|
//游戏内信息
|
||||||
|
|
||||||
static get Instance()
|
static get Instance()
|
||||||
|
@ -224,6 +228,9 @@ export class GameConfig {
|
||||||
vibrateOpen: true, //震动
|
vibrateOpen: true, //震动
|
||||||
coinnum: 0, //每局的金币数
|
coinnum: 0, //每局的金币数
|
||||||
paid_user: false, //是否是付费用户
|
paid_user: false, //是否是付费用户
|
||||||
|
version: 1.4, //版本号
|
||||||
|
shushu_DistinctId: "", //数数访客ID
|
||||||
|
shushu_AccountId: "" //数数账号ID
|
||||||
};
|
};
|
||||||
// this.setCode(this.getKey("scode"));
|
// this.setCode(this.getKey("scode"));
|
||||||
// this.GM_INFO.level = 0;
|
// this.GM_INFO.level = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user