package com.gh.common.util; import android.content.Context; import com.gh.common.exposure.meta.MetaUtil; import com.gh.common.loghub.LoghubUtils; import com.halo.assistant.HaloApp; import com.lightgame.download.DownloadEntity; import com.lightgame.utils.Utils; import org.json.JSONObject; import java.util.HashMap; import java.util.Map; /** * Created by LGT on 2016/12/8. * 日志上传工具类 */ public class DataLogUtils { // 轮播图 public static void uploadLunbotuLog(Context context, String type, String text, String title, String index, String source) { Map map = new HashMap<>(); map.put("index", index); map.put("type", type); map.put("text", text); map.put("source", source); map.put("slide_title", title); uploadLog(context, "slide", map); } // 搜索热门标签 public static void uploadHotTagLog(Context context, String tag) { Map map = new HashMap<>(); map.put("tag", tag); uploadLog(context, "search-hot-tag", map); } // 点击下载按钮或进入游戏详情 public static void uploadGameLog(Context context, String gameId, String gameName, String entrance) { Map map = new HashMap<>(); map.put("game_id", gameId); map.put("game_name", gameName); map.put("entrance", entrance); uploadLog(context, "game", map); } // 上传日志 public static void uploadLog(Context context, String topic, Map map) { String version = PackageUtils.getVersionName(); String user = Installation.getUUID(context); String channel = HaloApp.getInstance().getChannel(); map.put("version", version); map.put("resu", user); map.put("jnfj", MetaUtil.getBase64EncodedIMEI()); map.put("channel", channel); Map params = new HashMap<>(); if ("search-hot-tag".equals(topic) || "game".equals(topic) || "slide".equals(topic)) { params.put("meta", LogUtils.getMetaObject().toString()); } params.put("topic", topic); params.put("source", "GH-ASSIST-Client"); params.put("time", String.valueOf(Utils.getTime(context))); params.put("content", new JSONObject(map).toString()); LoghubUtils.log(new JSONObject(params), "common", true); } // 网络错误 public static void uploadNeterrorLog(Context context, DownloadEntity downloadEntity) { Map map = new HashMap<>(); map.put("url", downloadEntity.getUrl()); map.put("game", downloadEntity.getName()); map.put("game_id", downloadEntity.getGameId()); map.put("platform", downloadEntity.getPlatform()); map.put("error", downloadEntity.getError()); uploadLog(context, "neterror", map); } // 助手更新 public static void uploadUpgradeLog(Context context, String step) { Map map = new HashMap<>(); map.put("step", step); uploadLog(context, "upgrade", map); } // 链接劫持 public static void uploadHijack(Context context, DownloadEntity downloadEntity) { Map map = new HashMap<>(); map.put("url", downloadEntity.getUrl()); map.put("game", downloadEntity.getName()); map.put("game_id", downloadEntity.getGameId()); map.put("platform", downloadEntity.getPlatform()); map.put("hijack_url", downloadEntity.getError()); uploadLog(context, "hijack", map); } }