import Config from "../Config"; import Gamecfg from "../common/gameCfg"; import { gameMethod } from "../common/gameMethod"; /** * ThinkingData 数数SDK埋点数据管理 */ export default class ThinkingDataMgr { // static TDAnalytics: TDAnalytics; static isOpenTd: boolean static TDInit () { this.isOpenTD() if (!this.isOpenTd) { console.log("数数上报开关未开启") return } // TA SDK 配置对象 var config = { appId: "5899ad9ea9dd4e1f9c031b2645cfe33a", // 项目 APP ID serverUrl: "https://thinking-receiver.szfangzhouhd.com", // 上报地址 enableLog:false, autoTrack: { // appLaunch: true, // 自动采集 ta_mp_launch appShow: true, // 自动采集 ta_mp_show appHide: true, // 自动采集 ta_mp_hide // pageShow: true, // 自动采集 ta_mp_view // pageShare: true, // 自动采集 ta_mp_share } }; // var ThinkingAnalyticsAPI = window['TDAnalytics']; // this.TDAnalytics = new ThinkingAnalyticsAPI(config); // 初始化 TDAnalytics.init(config); } static isOpenTD(){ if (Config.openTD == 0) { this.isOpenTd = false; }else{ this.isOpenTd = true; } } static TDLogin (accoundId:string) { if (!this.isOpenTd) { return } //登录 TDAnalytics.login(accoundId); } static TDIdentify (openid:string){ if (!this.isOpenTd) { return } // TDAnalytics.identify(openid); TDAnalytics.setDistinctId(openid); } static TDLogout () { if (!this.isOpenTd) { return } //登出 TDAnalytics.logout(); } static TDSetSuperProperties (superProperties:object) { if (!this.isOpenTd) { return } //设置公共事件属性 // var superProperties = { // channel : "ta", //字符串 // age : 1,//数字 // isSuccess : true,//布尔 // birthday : new Date(),//对象 // object : { key : "value" },//对象 // object_arr : [ { key : "value" } ],//对象组 // arr : [ "value" ]//数组 // }; TDAnalytics.setSuperProperties(superProperties); } static TDTrack (eventName:string, properties:object) { if (!this.isOpenTd) { return } // console.log("TDTrack===",JSON.stringify(properties)) //发送事件 TDAnalytics.track({eventName: eventName, properties: properties}); // eventName: "product_buy", // 事件名称 // properties: { // product_name: "商品名" // } //事件属性 } static TDUserSet (properties:object) { if (!this.isOpenTd) { return } //设置用户属性 TDAnalytics.userSet(properties); // properties: { // username: "TE" // } } }