123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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"
- // }
- }
- }
|