登录信息添加

back_recharge
lvxinran 2020-07-13 16:14:06 +08:00
parent da8d764a75
commit a15ae6e4bb
3 changed files with 52 additions and 6 deletions

View File

@ -47,6 +47,7 @@ public class LoginRequestHandler extends BaseHandler<PlayerInfoProto.LoginReques
if(!Blocker.checkFlow(iSession)){ if(!Blocker.checkFlow(iSession)){
return; return;
} }
ReportUtil.saveBaseInfo(userId,loginRequest);
ParamEnvironmentBean paramEnvironmentBean = new ParamEnvironmentBean(); ParamEnvironmentBean paramEnvironmentBean = new ParamEnvironmentBean();
paramEnvironmentBean.setDevice_id_s(loginRequest.getDeviceIdS()); paramEnvironmentBean.setDevice_id_s(loginRequest.getDeviceIdS());
paramEnvironmentBean.setIp_s(loginRequest.getIpS()); paramEnvironmentBean.setIp_s(loginRequest.getIpS());
@ -147,7 +148,6 @@ public class LoginRequestHandler extends BaseHandler<PlayerInfoProto.LoginReques
MapLogic.getInstance().whenLogin(user); MapLogic.getInstance().whenLogin(user);
KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,0); KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,0);
KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,0); KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,0);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -9,6 +9,8 @@ import java.util.Map;
* @discribe * @discribe
*/ */
public class ReportUserEvent { public class ReportUserEvent {
private ReportBaseBean baseBean;
private Map<String, Object> baseInfo = new HashMap<>(); private Map<String, Object> baseInfo = new HashMap<>();
private Map<String, Object> eventInfo = new HashMap<>(); private Map<String, Object> eventInfo = new HashMap<>();
private String eventName = ""; private String eventName = "";
@ -18,6 +20,22 @@ public class ReportUserEvent {
baseInfo.put("#account_id",accountId); baseInfo.put("#account_id",accountId);
return this; return this;
} }
public ReportUserEvent setDistinct_id(String distinct_id){
baseInfo.put("#distinct_id",distinct_id);
return this;
}
public ReportUserEvent setDevice_id(String device_id){
baseInfo.put("#device_id",device_id);
return this;
}
public ReportUserEvent setIp(String ip){
baseInfo.put("#ip",ip);
return this;
}
public ReportUserEvent setCountry_code(int country_code){
baseInfo.put("#country_code",country_code);
return this;
}
public ReportUserEvent setServer_id(String server_id){ public ReportUserEvent setServer_id(String server_id){
baseInfo.put("server_id",server_id); baseInfo.put("server_id",server_id);
return this; return this;
@ -94,4 +112,12 @@ public class ReportUserEvent {
public void setUserProperties(Map<Integer, Map<String, Object>> userProperties) { public void setUserProperties(Map<Integer, Map<String, Object>> userProperties) {
this.userProperties = userProperties; this.userProperties = userProperties;
} }
public ReportBaseBean getBaseBean() {
return baseBean;
}
public void setBaseBean(ReportBaseBean baseBean) {
this.baseBean = baseBean;
}
} }

View File

@ -8,7 +8,9 @@ import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.Item; import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.root.GuildInfo; import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
@ -19,7 +21,9 @@ import java.util.Map;
public class ReportUtil { public class ReportUtil {
private static final String LOG_PATH = GameApplication.serverProperties.getLogDir(); private static final String LOG_PATH = GameApplication.serverProperties.getLogDir();
private static ThinkingDataAnalytics ta = new ThinkingDataAnalytics(new ThinkingDataAnalytics.LoggerConsumer(LOG_PATH)); private static Map<Integer,ReportBaseBean> baseBeanMap = new HashMap<>();
private static ThinkingDataAnalytics ta = new ThinkingDataAnalytics(new ThinkingDataAnalytics.LoggerConsumer(""));
public static final int COIN_ID = 14; public static final int COIN_ID = 14;
@ -30,6 +34,10 @@ public class ReportUtil {
//对外接口只有一个 //对外接口只有一个
public static void onReportEvent(User user,int type,Object... param) throws Exception { public static void onReportEvent(User user,int type,Object... param) throws Exception {
if(!GameApplication.serverProperties.isSendlog37()){
ta=null;
return;
}
ReportUserEvent reportUserEvent = userToReportBean(user); ReportUserEvent reportUserEvent = userToReportBean(user);
//根据事件类型获取对应处理 //根据事件类型获取对应处理
ReportEventEnum report = ReportEventEnum.getReport(type); ReportEventEnum report = ReportEventEnum.getReport(type);
@ -50,6 +58,7 @@ public class ReportUtil {
private static ReportUserEvent userToReportBean(User user){ private static ReportUserEvent userToReportBean(User user){
ReportUserEvent reportUserEvent = new ReportUserEvent(); ReportUserEvent reportUserEvent = new ReportUserEvent();
reportUserEvent.setBaseBean(baseBeanMap.get(user.getId()));
setBaseData(user,reportUserEvent); setBaseData(user,reportUserEvent);
return reportUserEvent; return reportUserEvent;
} }
@ -61,7 +70,12 @@ public class ReportUtil {
} }
Item coin = user.getItemManager().getItem(COIN_ID); Item coin = user.getItemManager().getItem(COIN_ID);
Item diamond = user.getItemManager().getItem(DIAMOND_ID); Item diamond = user.getItemManager().getItem(DIAMOND_ID);
reportUserEvent.setAccount_id(user.getPlayerInfoManager().getOpenId()) ReportBaseBean baseBean = reportUserEvent.getBaseBean();
reportUserEvent.setAccount_id(baseBean.getAccount_id())
.setDistinct_id(baseBean.getDistinct_id())
.setDevice_id(baseBean.getDevice_id())
.setIp(baseBean.getIp())
.setCountry_code(baseBean.getCountry_code())
.setServer_id(String.valueOf(GameApplication.serverId)) .setServer_id(String.valueOf(GameApplication.serverId))
.setAccount(user.getPlayerInfoManager().getOpenId()) .setAccount(user.getPlayerInfoManager().getOpenId())
.setRole_id(String.valueOf(user.getId())) .setRole_id(String.valueOf(user.getId()))
@ -79,17 +93,18 @@ public class ReportUtil {
try { try {
//todo 访客id //todo 访客id
ta.setSuperProperties(reportUserEvent.getBaseInfo()); ta.setSuperProperties(reportUserEvent.getBaseInfo());
ReportBaseBean baseBean = reportUserEvent.getBaseBean();
if(reportUserEvent.getUserProperties()!=null){ if(reportUserEvent.getUserProperties()!=null){
for(int type:reportUserEvent.getUserProperties().keySet()){ for(int type:reportUserEvent.getUserProperties().keySet()){
if(type==1){ if(type==1){
ta.user_set("1000001","1000001",reportUserEvent.getUserProperties().get(type)); ta.user_set(baseBean.getAccount_id(),baseBean.getDistinct_id(),reportUserEvent.getUserProperties().get(type));
}else{ }else{
ta.user_setOnce("1000001","1000001",reportUserEvent.getUserProperties().get(type)); ta.user_setOnce(baseBean.getAccount_id(),baseBean.getDistinct_id(),reportUserEvent.getUserProperties().get(type));
} }
} }
} }
if(!reportUserEvent.getEventName().isEmpty()){ if(!reportUserEvent.getEventName().isEmpty()){
ta.track("1000001","1000001",reportUserEvent.getEventName(),reportUserEvent.getEventInfo()); ta.track(baseBean.getAccount_id(),baseBean.getDistinct_id(),reportUserEvent.getEventName(),reportUserEvent.getEventInfo());
} }
ta.flush(); ta.flush();
} catch (Exception e) { } catch (Exception e) {
@ -98,4 +113,9 @@ public class ReportUtil {
System.out.println("except:"+e); System.out.println("except:"+e);
} }
} }
public static void saveBaseInfo(int uid,PlayerInfoProto.LoginRequest loginRequest){
ReportBaseBean reportBaseBean = new ReportBaseBean(loginRequest.getOpenId(),loginRequest.getDistinctId(),loginRequest.getDeviceIdS(),loginRequest.getIpS(),0);
baseBeanMap.put(uid,reportBaseBean);
}
} }