数数:初步数数接入
This commit is contained in:
@@ -27,6 +27,7 @@ import _pinus = require('pinus');
|
||||
import { updateTeamStatus } from './app/services/comBattleService';
|
||||
import { resResult, genCode } from './app/pubUtils/util';
|
||||
import { errlogger, infologger } from './app/util/logger';
|
||||
import { connectThinkingData } from './app/services/sdkService';
|
||||
|
||||
const filePath = (_pinus as any).FILEPATH;
|
||||
filePath.MASTER = '/config/master';
|
||||
@@ -69,6 +70,7 @@ app.configure(function () {
|
||||
initRedis(app);
|
||||
setupRoutes(app);
|
||||
setupFilters(app);
|
||||
connectThinkingData(app);
|
||||
|
||||
app.set(RESERVED.ERROR_HANDLER, errorHandler);
|
||||
app.set(RESERVED.GLOBAL_ERROR_HANDLER, globalErrorHandler);
|
||||
|
||||
@@ -25,6 +25,8 @@ import { Figure } from '../../../domain/dbGeneral';
|
||||
import { getActivities } from '../../../services/activity/activityService';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
import Counter from '../../../db/Counter';
|
||||
import { UserModel } from '../../../db/User';
|
||||
import { reportTAEvent } from '../../../services/sdkService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -596,4 +598,20 @@ export class RoleHandler {
|
||||
return resResult(STATUS.SUCCESS, { role });
|
||||
|
||||
}
|
||||
|
||||
public async test(msg: { magicWord: string }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
|
||||
let { magicWord } = msg;
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let user = await UserModel.findUserByUid(role.userInfo.uid);
|
||||
|
||||
reportTAEvent(roleId, 'test', user.ip);
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ import { Chat37Params, CheckGuild37Params, CheckName37Params } from "../domain/s
|
||||
import { sendMailByContent, sendMailToGuildByContent } from './mailService';
|
||||
import { getGoldObject } from '../pubUtils/itemUtils';
|
||||
import { NAMEPLATE } from '../pubUtils/dicParam';
|
||||
import { CHANNEL_PREFIX, getSdkChannelId, MAIL_TYPE, REDIS_KEY, SDK_37_ADDR, SDK_37_CONST } from "../consts";
|
||||
import { CHANNEL_PREFIX, getSdkChannelId, MAIL_TYPE, REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, SDK_TA_CONST, THINKING_DATA_MODE, THINKING_DATA_MODE_LIST } from "../consts";
|
||||
import { UserModel } from "../db/User";
|
||||
import { request37CheckChat, request37Post } from "../pubUtils/httpUtil";
|
||||
import { GuildModel } from "../db/Guild";
|
||||
import { getRoleOnlineInfo, updateUserInfo } from "./redisService";
|
||||
import { pinus } from "pinus";
|
||||
import { Application, pinus } from "pinus";
|
||||
import { getGuildChannelSid } from "./chatService";
|
||||
const ThinkingAnalytics = require("thinkingdata-node");
|
||||
|
||||
// 检查私聊是否合法
|
||||
|
||||
@@ -131,3 +132,52 @@ export async function treatGuildName(content: string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function connectThinkingData(app: Application) {
|
||||
let ta;
|
||||
if(THINKING_DATA_MODE == THINKING_DATA_MODE_LIST.DEBUG) {
|
||||
ta = ThinkingAnalytics.initWithDebugMode(SDK_TA_CONST.APPID, SDK_TA_CONST.SERVER_URL);
|
||||
} else if (THINKING_DATA_MODE == THINKING_DATA_MODE_LIST.BATCH) {
|
||||
ta = ThinkingAnalytics.initWithBatchMode(SDK_TA_CONST.APPID, SDK_TA_CONST.SERVER_URL);
|
||||
} else if (THINKING_DATA_MODE == THINKING_DATA_MODE_LIST.LOGGING) {
|
||||
ta = ThinkingAnalytics.initWithLoggingMode(SDK_TA_CONST.LOG_PATH, {
|
||||
rotateHourly: true,
|
||||
pm2: true
|
||||
});
|
||||
}
|
||||
ta.setDynamicSuperProperties(() => {
|
||||
return {
|
||||
env: app.get('env'),
|
||||
server: app.getServerId()
|
||||
};
|
||||
});
|
||||
app.set('ta', ta);
|
||||
}
|
||||
|
||||
export function reportTAEvent(roleId: string, eventName: string, ip: string) {
|
||||
let ta = pinus.app.get('ta');
|
||||
let event = {
|
||||
// 账号 ID (可选)
|
||||
accountId: roleId,
|
||||
// 访客 ID (可选),账号 ID 和访客 ID 不可以都为空
|
||||
distinctId: "",
|
||||
// 事件名称 (必填)
|
||||
event: eventName,
|
||||
// 事件时间 (可选) 如果不填,将以调用接口时的时间作为事件时间
|
||||
time: new Date(),
|
||||
// 事件 IP (可选) 当传入 IP 地址时,后台可以解析所在地
|
||||
ip: ip,
|
||||
// 事件属性 (可选)
|
||||
properties: {
|
||||
prop_date: new Date(),
|
||||
prop_double: 134.1,
|
||||
prop_string: "hello world",
|
||||
prop_int: 67
|
||||
},
|
||||
callback() {
|
||||
console.log('*****测试接入事件')
|
||||
}
|
||||
|
||||
};
|
||||
ta.track(event);
|
||||
}
|
||||
27
game-server/package-lock.json
generated
27
game-server/package-lock.json
generated
@@ -3318,6 +3318,33 @@
|
||||
"thenify": ">= 3.1.0 < 4"
|
||||
}
|
||||
},
|
||||
"thinkingdata-node": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/thinkingdata-node/-/thinkingdata-node-1.2.2.tgz",
|
||||
"integrity": "sha512-U5Nz2/OsFj3oFGboo/OmQcc1bcbibNJm2KVMPy7JpIVdYAH8U/VKzXCHfuVvbGSalLAdvMiBklL49r5uQnVqvw==",
|
||||
"requires": {
|
||||
"log4js": "^5.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"date-format": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz",
|
||||
"integrity": "sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA=="
|
||||
},
|
||||
"log4js": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/log4js/-/log4js-5.3.0.tgz",
|
||||
"integrity": "sha512-PZHXaXJKMKEscvQxSnTjM4UosQalSDlNpMw63eCKW+/DiAFKIZPW1jGyIPXZDjiEYFusMfiI7zzvnxeGozUcAw==",
|
||||
"requires": {
|
||||
"date-format": "^2.1.0",
|
||||
"debug": "^4.1.1",
|
||||
"flatted": "^2.0.1",
|
||||
"rfdc": "^1.1.4",
|
||||
"streamroller": "^2.2.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"through": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
"request-promise": "^4.2.6",
|
||||
"source-map-support": "^0.5.0",
|
||||
"tenpay": "^2.1.18",
|
||||
"thinkingdata-node": "^1.2.2",
|
||||
"ts-node": "^8.2.0",
|
||||
"typegoose": "^5.9.1",
|
||||
"xprofiler": "^1.2.5"
|
||||
|
||||
@@ -26,4 +26,10 @@ export enum SDK_37_CONST {
|
||||
LOGIN_KEY = '3PerD)H!JdTC_pEUnZl8vXKgasj5;7Q~', // 登录KEY
|
||||
PAY_KEY = '0;_Zy.qodXCF8NGQmrOYltk%HgfAz*39', // 重置KEY
|
||||
CHAT_KEY = '3PerD)H!JdTC_pEUnZl8vXKgasj5;7Q~', // 聊天KEY
|
||||
}
|
||||
|
||||
export enum SDK_TA_CONST {
|
||||
APPID = '74120ffc6f2945448cc60bf1540c5ad4',
|
||||
SERVER_URL = 'https://shushu.xyplay.cn',
|
||||
LOG_PATH = '/home/app/logs/',
|
||||
}
|
||||
@@ -738,4 +738,11 @@ export enum RANK_FIRST_REWARD_STATUS {
|
||||
WAITING = 0, // 不可领取
|
||||
CAN_RECEIVE = 1, // 可领取
|
||||
RECEIVED = 2, // 已领取
|
||||
}
|
||||
}
|
||||
|
||||
export enum THINKING_DATA_MODE_LIST {
|
||||
DEBUG = 'debug',
|
||||
BATCH = 'batch',
|
||||
LOGGING = 'logging',
|
||||
}
|
||||
export const THINKING_DATA_MODE = THINKING_DATA_MODE_LIST.DEBUG;
|
||||
Reference in New Issue
Block a user