f207f9a8-6ba3-4b60-aedd-2d49c3882381.js
3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"use strict";
cc._RF.push(module, 'f207fmoa6NLYK7dLUnDiCOB', 'CooperationDotMgr');
// script/cooperation/script/CooperationDotMgr.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const CooperationDataCenter_1 = require("./CooperationDataCenter");
const CryptoJS_1 = require("../script/CryptoJS");
const SALT = "d0dd883ae80667d27b924d1e52b78b59";
/**打点服务 */
const DOT_SERVER = "/client/v1/event/log/put";
/**测试服打点地址 */
const DOT_URL_DEBUG = "https://eventstat-test.icesimba.com";
/**正式服打点地址 */
const DOT_URL_RELEASE = "https://eventstat.icesimba.com";
/**是否打点到测试服,否则打点到正式服 */
const DOT_DEBUG = false;
/**游戏id */
const GAME_ID = "cooperation";
let CooperationDotMgr = /** @class */ (() => {
class CooperationDotMgr {
static getInstance() {
return CooperationDotMgr._instance;
}
/**获取打点请求服务 */
getXHR() {
let url = DOT_DEBUG ? DOT_URL_DEBUG : DOT_URL_RELEASE;
url += DOT_SERVER;
let xmlHttp = new XMLHttpRequest();
xmlHttp.open('POST', url);
xmlHttp.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4) {
if (xmlHttp.status === 200) {
console.log("dot succeed");
}
}
};
return xmlHttp;
}
async dot(eventKey, gameData, category) {
let channel = CooperationDataCenter_1.default.getInstance().getCurGameChannel();
if ("dummy" === channel || "" === channel)
return;
let data = this.getBaseElements();
data["category"] = category ? category : "cooperation_event";
data["id"] = eventKey ? eventKey : "event";
data["game_data"] = gameData ? gameData : {};
data["game_id"] = GAME_ID;
let xhr = this.getXHR();
let stringfyData = JSON.stringify(data);
let upLoadData = {
event_type: category,
data: stringfyData,
sign: CryptoJS_1.CryptoJS.MD5(stringfyData + SALT).toString()
};
let upLoadStringfy = JSON.stringify(upLoadData);
await xhr.send(upLoadStringfy);
}
getBaseElements() {
let base = {
mainGameId: CooperationDataCenter_1.default.getInstance().getCurGameID(),
mainAppId: CooperationDataCenter_1.default.getInstance().getCurGameAppID(),
dotTime: (new Date()).toTimeString(),
channel: CooperationDataCenter_1.default.getInstance().getCurGameChannel()
};
return base;
}
/**点击子游戏打点 */
dotClickSubGame(appId, appName, index, location) {
let eventKey = "clickSubGame";
this.dot(eventKey, { appId: appId, appName: appName, index: index, location: location }, eventKey);
}
/**点击游戏中心打点 */
dotClickGameCenter() {
let eventKey = "clickGameCenter";
this.dot(eventKey, {}, eventKey);
}
}
CooperationDotMgr._instance = new CooperationDotMgr();
return CooperationDotMgr;
})();
exports.default = CooperationDotMgr;
cc._RF.pop();