数数:埋点
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
import { COUNTER, DEFAULT_LV, ADULT_AGE, GUEST_MAX_TIME, TASK_TYPE } from '@consts';
|
||||
import { COUNTER, DEFAULT_LV, ADULT_AGE, GUEST_MAX_TIME, TASK_TYPE, TA_EVENT } from '@consts';
|
||||
import { RoleModel } from '@db/Role';
|
||||
import { UserModel, UserType } from '@db/User';
|
||||
import { STATUS, GET_SMS_TYPE, ADDICTION_PREVENTION_CODE } from '@consts';
|
||||
@@ -389,9 +389,9 @@ export default class Auth extends Service {
|
||||
* @returns
|
||||
*/
|
||||
public async channelLogin(params: {
|
||||
channelType: string, pst: string, clientId: string, deviceId: string, platform: string, platformAppid: string, childGameId: number, pkgName: string, serverType: string, getuiCID: string
|
||||
channelType: string, pst: string, clientId: string, deviceId: string, platform: string, platformAppid: string, childGameId: number, pkgName: string, serverType: string, getuiCID: string, distinctId: string
|
||||
}) {
|
||||
const { channelType, pst, clientId, deviceId, platform, platformAppid, childGameId, pkgName, serverType, getuiCID } = params;
|
||||
const { channelType, pst, clientId, deviceId, platform, platformAppid, childGameId, pkgName, serverType, getuiCID, distinctId } = params;
|
||||
|
||||
const ctx = this.ctx;
|
||||
const ip = ctx.request.ip;
|
||||
@@ -405,9 +405,13 @@ export default class Auth extends Service {
|
||||
|
||||
let channelId = getChannelId(channelType, requestResult.data.uid);
|
||||
const token = ctx.service.utils.generateStr(256);
|
||||
let user = await UserModel.createOrUpdateChannelUser(channelId, channelType, {
|
||||
let { isCreate, user} = await UserModel.createOrUpdateChannelUser(channelId, channelType, {
|
||||
...requestResult.data, childGameId, platformAppid
|
||||
}, token, platform, pkgName, serverType, deviceId, ip);
|
||||
if(isCreate) {
|
||||
ctx.service.sdk.reportTAEventWithDistinctId(distinctId, TA_EVENT.REGISTER, null, ip);
|
||||
}
|
||||
|
||||
if (getuiCID) {//更新个推cid
|
||||
await UserModel.updateGetuiCIDByChannel(channelId, getuiCID);
|
||||
}
|
||||
|
||||
@@ -258,4 +258,28 @@ export default class Sdk extends Service {
|
||||
msg: '成功'
|
||||
}
|
||||
}
|
||||
|
||||
public reportTAEventWithDistinctId(distinctId: string, eventName: string, properties: any, ip: string) {
|
||||
let ta = this.app.context.ta;
|
||||
let event = {
|
||||
// 账号 ID (可选)
|
||||
accountId: "",
|
||||
// 访客 ID (可选),账号 ID 和访客 ID 不可以都为空
|
||||
distinctId: `${distinctId}`,
|
||||
// 事件名称 (必填)
|
||||
event: eventName,
|
||||
// 事件时间 (可选) 如果不填,将以调用接口时的时间作为事件时间
|
||||
time: new Date(),
|
||||
// 事件 IP (可选) 当传入 IP 地址时,后台可以解析所在地
|
||||
ip: ip,
|
||||
// 事件属性 (可选)
|
||||
properties,
|
||||
callback(err) {
|
||||
console.log('*****测试接入事件', err)
|
||||
}
|
||||
|
||||
};
|
||||
ta.track(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user