package com.hdl.log.utils; import com.aliyu.LogProducerClient; import com.aliyun.sls.android.producer.Log; import com.hdl.log.HDLLog; import com.hdl.log.bean.LogBean; import java.util.Map; /** * Created by hxb on 2023/3/16. * */ public class PointUtil { private static LogProducerClient pointProducerClient; private static LogBean logBean; private static synchronized LogProducerClient getExceptionProducerClient() { if (pointProducerClient == null) { pointProducerClient = new LogProducerClient(HDLLog.getContext(),HDLLog.getEndPoint(),HDLLog.getProjectName(),HDLLog.getEventTracking(),HDLLog.getAccessId(),HDLLog.getAccessKey(),null,null); } return pointProducerClient; } /** * 数据埋点 * @param eventId 标题 * @param eventMap 附加数据内容 * @param otherMsg 其他附加数据,没有可为空 */ public static void point(String eventId,String eventMap,Map otherMsg) { Log log = new Log(); log.putContent("eventId", eventId); log.putContent("eventMap", eventMap); log.putContent("userId", getLogBean().getUserId()); log.putContent("homeId", getLogBean().getHomeId()); log.putContent("time", System.currentTimeMillis() + ""); log.putContent("userAgent", getLogBean().getUserAgent()); log.putContent("appVersion", getLogBean().getAppVersion()); if (otherMsg != null) { log.putContents(otherMsg); } getExceptionProducerClient().sendLog(log); } public static LogBean getLogBean() { if(logBean==null){ logBean=new LogBean(); } return logBean; } }