diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java index 3d5701ac5..a2e9eb9f7 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java @@ -47,6 +47,7 @@ public class LoginRequestHandler extends BaseHandler baseInfo = new HashMap<>(); private Map eventInfo = new HashMap<>(); private String eventName = ""; @@ -18,6 +20,22 @@ public class ReportUserEvent { baseInfo.put("#account_id",accountId); 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){ baseInfo.put("server_id",server_id); return this; @@ -94,4 +112,12 @@ public class ReportUserEvent { public void setUserProperties(Map> userProperties) { this.userProperties = userProperties; } + + public ReportBaseBean getBaseBean() { + return baseBean; + } + + public void setBaseBean(ReportBaseBean baseBean) { + this.baseBean = baseBean; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/ReportUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/ReportUtil.java index 5caf3968e..29a0ae4eb 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/ReportUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/ReportUtil.java @@ -8,7 +8,9 @@ import com.ljsd.jieling.logic.dao.GuilidManager; import com.ljsd.jieling.logic.dao.Item; import com.ljsd.jieling.logic.dao.root.GuildInfo; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import java.util.HashMap; import java.util.Map; /** @@ -19,7 +21,9 @@ import java.util.Map; public class ReportUtil { private static final String LOG_PATH = GameApplication.serverProperties.getLogDir(); - private static ThinkingDataAnalytics ta = new ThinkingDataAnalytics(new ThinkingDataAnalytics.LoggerConsumer(LOG_PATH)); + private static Map baseBeanMap = new HashMap<>(); + + private static ThinkingDataAnalytics ta = new ThinkingDataAnalytics(new ThinkingDataAnalytics.LoggerConsumer("")); 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 { + if(!GameApplication.serverProperties.isSendlog37()){ + ta=null; + return; + } ReportUserEvent reportUserEvent = userToReportBean(user); //根据事件类型获取对应处理 ReportEventEnum report = ReportEventEnum.getReport(type); @@ -50,6 +58,7 @@ public class ReportUtil { private static ReportUserEvent userToReportBean(User user){ ReportUserEvent reportUserEvent = new ReportUserEvent(); + reportUserEvent.setBaseBean(baseBeanMap.get(user.getId())); setBaseData(user,reportUserEvent); return reportUserEvent; } @@ -61,7 +70,12 @@ public class ReportUtil { } Item coin = user.getItemManager().getItem(COIN_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)) .setAccount(user.getPlayerInfoManager().getOpenId()) .setRole_id(String.valueOf(user.getId())) @@ -79,17 +93,18 @@ public class ReportUtil { try { //todo 访客id ta.setSuperProperties(reportUserEvent.getBaseInfo()); + ReportBaseBean baseBean = reportUserEvent.getBaseBean(); if(reportUserEvent.getUserProperties()!=null){ for(int type:reportUserEvent.getUserProperties().keySet()){ 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{ - 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()){ - ta.track("1000001","1000001",reportUserEvent.getEventName(),reportUserEvent.getEventInfo()); + ta.track(baseBean.getAccount_id(),baseBean.getDistinct_id(),reportUserEvent.getEventName(),reportUserEvent.getEventInfo()); } ta.flush(); } catch (Exception e) { @@ -98,4 +113,9 @@ public class ReportUtil { 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); + } }