642 lines
26 KiB
Java
642 lines
26 KiB
Java
package com.gh.common.util;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.Application;
|
|
import android.content.Context;
|
|
import android.os.Build;
|
|
import android.provider.Settings;
|
|
import android.text.TextUtils;
|
|
|
|
import com.gh.common.constant.Constants;
|
|
import com.gh.common.exposure.ExposureEntity;
|
|
import com.gh.common.exposure.ExposureEvent;
|
|
import com.gh.common.exposure.ExposureSource;
|
|
import com.gh.common.exposure.meta.Meta;
|
|
import com.gh.common.exposure.meta.MetaUtil;
|
|
import com.gh.common.loghub.LoghubUtils;
|
|
import com.gh.common.loghub.SimpleLogContainerEntity;
|
|
import com.gh.gamecenter.BuildConfig;
|
|
import com.gh.gamecenter.entity.CommunityEntity;
|
|
import com.gh.gamecenter.entity.GameEntity;
|
|
import com.gh.gamecenter.entity.ShareResultEntity;
|
|
import com.gh.gamecenter.entity.SpecialColumn;
|
|
import com.gh.gamecenter.manager.UserManager;
|
|
import com.gh.gamecenter.qa.entity.Questions;
|
|
import com.gh.gamecenter.retrofit.EmptyResponse;
|
|
import com.gh.gamecenter.retrofit.RetrofitManager;
|
|
import com.halo.assistant.HaloApp;
|
|
import com.lightgame.utils.Utils;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import androidx.annotation.Nullable;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
import okhttp3.MediaType;
|
|
import okhttp3.RequestBody;
|
|
|
|
/**
|
|
* Created by khy on 2/01/18.
|
|
*/
|
|
public class LogUtils {
|
|
|
|
public static void logVideoStreamingUpload(String action, String entrance, String entranceDetail, String videoId) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payloadObject = new JSONObject();
|
|
|
|
try {
|
|
object.put("event", "UPLOAD_VIDEO_STEAMING");
|
|
object.put("action", action);
|
|
payloadObject.put("entrance", entrance);
|
|
payloadObject.put("entrance_detail", entranceDetail);
|
|
payloadObject.put("video_id", videoId);
|
|
object.put("payload", payloadObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
uploadVideoStreaming(object);
|
|
}
|
|
|
|
public static void uploadCommunityArticle(String tracers, String articleId, String articleTitle, int readTime, CommunityEntity community, SpecialColumn specialColumn) {
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("subject", "community_article");
|
|
object.put("community_id", community.getId());
|
|
object.put("community_name", community.getName());
|
|
object.put("article_id", articleId);
|
|
object.put("article_name", articleTitle);
|
|
object.put("tracers", tracers);
|
|
object.put("read", readTime);
|
|
JSONObject columnObject = new JSONObject();
|
|
if (specialColumn != null) {
|
|
columnObject.put("type", specialColumn.getType());
|
|
columnObject.put("name", specialColumn.getName());
|
|
columnObject.put("tab", specialColumn.getTab());
|
|
} else {
|
|
columnObject.put("type", "");
|
|
columnObject.put("name", "");
|
|
columnObject.put("tab", "");
|
|
}
|
|
object.put("special_column", columnObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object);
|
|
}
|
|
|
|
public static void uploadDevice(LunchType launchType) {
|
|
JSONObject object = new JSONObject();
|
|
Application application = HaloApp.getInstance().getApplication();
|
|
try {
|
|
object.put("subject", "halo_device");
|
|
object.put("launch_time", Utils.getTime(application));
|
|
object.put("launch_type", launchType.name());
|
|
object.put("manufacture", Build.MANUFACTURER);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object, true);
|
|
}
|
|
|
|
public static void uploadAnswerReadTime(String tracers, int readTime, String answerId, Questions questions, String communityId, String CommunityName, SpecialColumn specialColumn) {
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("subject", "answer");
|
|
object.put("community_id", communityId);
|
|
object.put("community_name", CommunityName);
|
|
object.put("question_id", questions.getId());
|
|
object.put("question_name", questions.getTitle());
|
|
object.put("tracers", tracers);
|
|
object.put("answer_id", answerId);
|
|
object.put("read", readTime);
|
|
JSONObject columnObject = new JSONObject();
|
|
if (specialColumn != null) {
|
|
columnObject.put("type", specialColumn.getType());
|
|
columnObject.put("name", specialColumn.getName());
|
|
columnObject.put("tab", specialColumn.getTab());
|
|
} else {
|
|
columnObject.put("type", "");
|
|
columnObject.put("name", "");
|
|
columnObject.put("tab", "");
|
|
}
|
|
object.put("special_column", columnObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object);
|
|
}
|
|
|
|
public static void uploadQuestionReadTime(String tracers, int readTime, Questions questions, String communityId, String communityName, SpecialColumn specialColumn) {
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("subject", "question");
|
|
object.put("community_id", communityId);
|
|
object.put("community_name", communityName);
|
|
object.put("question_id", questions.getId());
|
|
object.put("question_name", questions.getTitle());
|
|
object.put("tracers", tracers);
|
|
object.put("read", readTime);
|
|
JSONObject columnObject = new JSONObject();
|
|
if (specialColumn != null) {
|
|
columnObject.put("type", specialColumn.getType());
|
|
columnObject.put("name", specialColumn.getName());
|
|
columnObject.put("tab", specialColumn.getTab());
|
|
} else {
|
|
columnObject.put("type", "");
|
|
columnObject.put("name", "");
|
|
columnObject.put("tab", "");
|
|
}
|
|
object.put("special_column", columnObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object);
|
|
}
|
|
|
|
public static void uploadSearch(String searchKey) {
|
|
if (TextUtils.isEmpty(searchKey)) return;
|
|
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
|
object.put("community_name", UserManager.getInstance().getCommunity().getName());
|
|
object.put("keyword", searchKey);
|
|
object.put("subject", "search");
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object);
|
|
}
|
|
|
|
public static void communityRefresh(int dataCount, boolean manualRefresh) {
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("subject", "community_refresh");
|
|
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
|
object.put("refresh_type", "recommend");
|
|
object.put("refresh_way", manualRefresh ? "manual" : "auto");
|
|
object.put("data_count", dataCount);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object);
|
|
}
|
|
|
|
public static void login(String loginStep, String loginType, String entrance) {
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("entrance", entrance);
|
|
object.put("subject", "login");
|
|
object.put("step", loginStep);
|
|
object.put("login_type", loginType);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object, true);
|
|
}
|
|
|
|
public static void qaAccess(String access, CommunityEntity communityEntity) {
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("subject", "qa_access");
|
|
object.put("access", access);
|
|
object.put("community_id", communityEntity.getId());
|
|
object.put("community_name", communityEntity.getName());
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToCommunity(object);
|
|
}
|
|
|
|
public static void logReservation(GameEntity gameEntity, @Nullable ExposureEvent event) {
|
|
JSONObject object = new JSONObject();
|
|
List<ExposureSource> exposureSourceList;
|
|
|
|
if (event == null) {
|
|
exposureSourceList = new ArrayList<>();
|
|
exposureSourceList.add(new ExposureSource("其它", ""));
|
|
} else {
|
|
exposureSourceList = event.getSource();
|
|
}
|
|
|
|
try {
|
|
object.put("source", GsonUtils.toJson(exposureSourceList));
|
|
object.put("game_name", gameEntity.getName());
|
|
object.put("game_id", gameEntity.getId());
|
|
object.put("game_platform", gameEntity.getPlatform());
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadToReservation(object);
|
|
}
|
|
|
|
private static void uploadToCommunity(JSONObject object) {
|
|
uploadToCommunity(object, false);
|
|
}
|
|
|
|
private static void uploadToCommunity(JSONObject object, boolean forcedUpload) {
|
|
if (BuildConfig.DEBUG) {
|
|
Utils.log("LogUtils->" + object.toString());
|
|
}
|
|
|
|
Context context = HaloApp.getInstance().getApplication();
|
|
try {
|
|
object.put("version", PackageUtils.getVersionName());
|
|
object.put("channel", HaloApp.getInstance().getChannel());
|
|
object.put("android_id", Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID));
|
|
object.put("time", Utils.getTime(context));
|
|
object.put("network", DeviceUtils.getNetwork(context));
|
|
object.put("user_id", UserManager.getInstance().getUserId());
|
|
object.put("device_system", android.os.Build.VERSION.RELEASE);
|
|
object.put("device_model", android.os.Build.MODEL);
|
|
object.put("imei", MetaUtil.getIMEI());
|
|
object.put("G_ID", UserManager.getInstance().getDeviceId());
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
// 暂时除了曝光外的数据都是扔到 community 这个库的,要是不是这个这个库的话这里要改一下
|
|
LoghubUtils.log(object, "community", forcedUpload);
|
|
}
|
|
|
|
/**
|
|
* 上传数据到“预约”的 logStore
|
|
*/
|
|
private static void uploadToReservation(JSONObject object) {
|
|
Context context = HaloApp.getInstance().getApplication();
|
|
try {
|
|
object.put("version", PackageUtils.getVersionName());
|
|
object.put("channel", HaloApp.getInstance().getChannel());
|
|
object.put("android_id", Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID));
|
|
object.put("time", Utils.getTime(context));
|
|
object.put("network", DeviceUtils.getNetwork(context));
|
|
object.put("user_id", UserManager.getInstance().getUserId());
|
|
object.put("device_system", android.os.Build.VERSION.RELEASE);
|
|
object.put("device_model", android.os.Build.MODEL);
|
|
object.put("imei", MetaUtil.getIMEI());
|
|
object.put("G_ID", UserManager.getInstance().getDeviceId());
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
LoghubUtils.log(object, "appointment", false);
|
|
}
|
|
|
|
private static void uploadVideoStreaming(JSONObject object) {
|
|
Meta meta = MetaUtil.INSTANCE.getMeta();
|
|
JSONObject metaObject = new JSONObject();
|
|
try {
|
|
metaObject.put("android_id", meta.getAndroid_id());
|
|
metaObject.put("android_sdk", meta.getAndroid_sdk());
|
|
metaObject.put("android_version", meta.getAndroid_version());
|
|
metaObject.put("appVersion", meta.getAppVersion());
|
|
metaObject.put("channel", meta.getChannel());
|
|
metaObject.put("gid", meta.getGid());
|
|
metaObject.put("imei", meta.getImei());
|
|
metaObject.put("mac", meta.getMac());
|
|
metaObject.put("manufacturer", meta.getManufacturer());
|
|
metaObject.put("model", meta.getModel());
|
|
metaObject.put("network", meta.getNetwork());
|
|
metaObject.put("os", meta.getOs());
|
|
metaObject.put("userId", meta.getUserId());
|
|
|
|
object.put("meta", metaObject);
|
|
object.put("timestamp", System.currentTimeMillis() / 1000);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
if (BuildConfig.DEBUG) {
|
|
Utils.log("LogUtils->" + object.toString());
|
|
}
|
|
|
|
LoghubUtils.log(object, "video_streaming", false);
|
|
}
|
|
|
|
public static void uploadVideoStreamingEnter(String entrance, String entranceDetail, String videoId, String streamingId) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payloadObject = new JSONObject();
|
|
|
|
try {
|
|
object.put("event", "ENTERING_VIDEO_STEAMING");
|
|
payloadObject.put("entrance", entrance);
|
|
if (!TextUtils.isEmpty(entranceDetail)) {
|
|
payloadObject.put("entrance_detail", entranceDetail);
|
|
}
|
|
payloadObject.put("video_id", videoId);
|
|
payloadObject.put("streaming_id", streamingId);
|
|
object.put("payload", payloadObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
uploadVideoStreaming(object);
|
|
}
|
|
|
|
public static void uploadVideoStreamingPlaying(String action, String msg, String entrance, String entranceDetail, String videoId, String streamingId, double videoSize, int videoTotalTime, int progress, String videoPlayStatus) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payloadObject = new JSONObject();
|
|
|
|
try {
|
|
object.put("event", "VIDEO_PLAYING");
|
|
object.put("action", action);
|
|
if (!TextUtils.isEmpty(msg)) {
|
|
object.put("msg", msg);
|
|
}
|
|
|
|
payloadObject.put("entrance", entrance);
|
|
if (!TextUtils.isEmpty(entranceDetail)) {
|
|
payloadObject.put("entrance_detail", entranceDetail);
|
|
}
|
|
payloadObject.put("video_id", videoId);
|
|
payloadObject.put("streaming_id", streamingId);
|
|
if (videoSize > 0) {
|
|
payloadObject.put("video_size", videoSize);
|
|
}
|
|
if (videoTotalTime > 0) {
|
|
payloadObject.put("video_total_time", videoTotalTime);
|
|
}
|
|
payloadObject.put("progress", progress);
|
|
payloadObject.put("video_play_status", videoPlayStatus);
|
|
|
|
object.put("payload", payloadObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
uploadVideoStreaming(object);
|
|
}
|
|
|
|
public static void uploadWelcomeDialog(String action, String dialogId, String linkTitle) {
|
|
ExposureEntity payload = new ExposureEntity();
|
|
payload.setWelcomeDialogId(dialogId);
|
|
payload.setWelcomeDialogId(linkTitle);
|
|
|
|
SimpleLogContainerEntity entity = new SimpleLogContainerEntity();
|
|
entity.setEvent("dialog");
|
|
entity.setAction(action);
|
|
entity.setMeta(MetaUtil.INSTANCE.getMeta());
|
|
entity.setPayload(payload);
|
|
entity.setTimestamp(System.currentTimeMillis() / 1000);
|
|
|
|
LoghubUtils.log(GsonUtils.toJsonIgnoreNull(entity), "event", false);
|
|
}
|
|
|
|
public static void uploadLikeFromWelcomeDialog() {
|
|
String dialogId = (String) HaloApp.get(Constants.WELCOME_DIALOG_ID, false);
|
|
String linkTitle = (String) HaloApp.get(Constants.WELCOME_DIALOG_LINK_TITLE, false);
|
|
|
|
ExposureEntity payload = new ExposureEntity();
|
|
payload.setWelcomeDialogId(dialogId);
|
|
payload.setWelcomeDialogLinkTitle(linkTitle);
|
|
|
|
SimpleLogContainerEntity entity = new SimpleLogContainerEntity();
|
|
entity.setEvent("like");
|
|
entity.setMeta(MetaUtil.INSTANCE.getMeta());
|
|
entity.setPayload(payload);
|
|
entity.setTimestamp(System.currentTimeMillis() / 1000);
|
|
|
|
LoghubUtils.log(GsonUtils.toJsonIgnoreNull(entity), "event", false);
|
|
}
|
|
|
|
public static void uploadCommentFromWelcomeDialog() {
|
|
String dialogId = (String) HaloApp.get(Constants.WELCOME_DIALOG_ID, false);
|
|
String linkTitle = (String) HaloApp.get(Constants.WELCOME_DIALOG_LINK_TITLE, false);
|
|
|
|
ExposureEntity payload = new ExposureEntity();
|
|
payload.setWelcomeDialogId(dialogId);
|
|
payload.setWelcomeDialogLinkTitle(linkTitle);
|
|
|
|
SimpleLogContainerEntity entity = new SimpleLogContainerEntity();
|
|
entity.setEvent("comment");
|
|
entity.setMeta(MetaUtil.INSTANCE.getMeta());
|
|
entity.setPayload(payload);
|
|
entity.setTimestamp(System.currentTimeMillis() / 1000);
|
|
|
|
LoghubUtils.log(GsonUtils.toJsonIgnoreNull(entity), "event", false);
|
|
}
|
|
|
|
private static void uploadShare(JSONObject object) {
|
|
Meta meta = MetaUtil.INSTANCE.getMeta();
|
|
JSONObject metaObject = new JSONObject();
|
|
try {
|
|
metaObject.put("android_id", meta.getAndroid_id());
|
|
metaObject.put("android_sdk", meta.getAndroid_sdk());
|
|
metaObject.put("android_version", meta.getAndroid_version());
|
|
metaObject.put("appVersion", meta.getAppVersion());
|
|
metaObject.put("channel", meta.getChannel());
|
|
metaObject.put("gid", meta.getGid());
|
|
metaObject.put("imei", meta.getImei());
|
|
metaObject.put("mac", meta.getMac());
|
|
metaObject.put("manufacturer", meta.getManufacturer());
|
|
metaObject.put("model", meta.getModel());
|
|
metaObject.put("network", meta.getNetwork());
|
|
metaObject.put("os", meta.getOs());
|
|
metaObject.put("userId", meta.getUserId());
|
|
|
|
object.put("event", "SHARE");
|
|
object.put("meta", metaObject);
|
|
object.put("timestamp", System.currentTimeMillis() / 1000);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
if (BuildConfig.DEBUG) {
|
|
Utils.log("LogUtils->" + object.toString());
|
|
}
|
|
|
|
LoghubUtils.log(object, "event", false);
|
|
}
|
|
|
|
public static void uploadShareEnter(String entrance, String url, String title, String summary, String resourceId) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payloadObject = new JSONObject();
|
|
try {
|
|
object.put("action", "entrance_source");
|
|
payloadObject.put("entrance", entrance);
|
|
payloadObject.put("url", url);
|
|
payloadObject.put("title", title);
|
|
payloadObject.put("summary", summary);
|
|
payloadObject.put("resource_id", resourceId);
|
|
object.put("payload", payloadObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
uploadShare(object);
|
|
}
|
|
|
|
public static void uploadShareType(String shareType, String entrance, String url, String title, String summary, String resourceId) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payloadObject = new JSONObject();
|
|
try {
|
|
object.put("action", "share_type");
|
|
payloadObject.put("share_type", shareType);
|
|
payloadObject.put("entrance", entrance);
|
|
payloadObject.put("url", url);
|
|
payloadObject.put("title", title);
|
|
payloadObject.put("summary", summary);
|
|
payloadObject.put("resource_id", resourceId);
|
|
object.put("payload", payloadObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
uploadShare(object);
|
|
}
|
|
|
|
@SuppressLint("CheckResult")
|
|
public static void uploadShareResult(String shareType, String entrance, String shareResult, String url, String title, String summary, String resourceId) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payloadObject = new JSONObject();
|
|
try {
|
|
object.put("action", "share_result");
|
|
payloadObject.put("share_type", shareType);
|
|
payloadObject.put("entrance", entrance);
|
|
payloadObject.put("share_result", shareResult);
|
|
payloadObject.put("url", url);
|
|
payloadObject.put("title", title);
|
|
payloadObject.put("summary", summary);
|
|
payloadObject.put("resource_id", resourceId);
|
|
object.put("payload", payloadObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
uploadShare(object);
|
|
|
|
ShareResultEntity entity = new ShareResultEntity(new ShareResultEntity.Content(url, title, summary), shareType, shareResult);
|
|
RequestBody body = RequestBody.create(MediaType.parse("application/json"), GsonUtils.toJson(entity));
|
|
|
|
RetrofitManager.getInstance(HaloApp.getInstance().getApplication()).getApi()
|
|
.postShareResult(body)
|
|
.subscribeOn(Schedulers.io())
|
|
.subscribe(new EmptyResponse<>());
|
|
}
|
|
|
|
public static JSONObject getMetaObject() {
|
|
Meta meta = MetaUtil.INSTANCE.getMeta();
|
|
JSONObject metaObject = new JSONObject();
|
|
try {
|
|
metaObject.put("android_id", meta.getAndroid_id());
|
|
metaObject.put("android_sdk", meta.getAndroid_sdk());
|
|
metaObject.put("android_version", meta.getAndroid_version());
|
|
metaObject.put("appVersion", meta.getAppVersion());
|
|
metaObject.put("channel", meta.getChannel());
|
|
metaObject.put("gid", meta.getGid());
|
|
metaObject.put("imei", meta.getImei());
|
|
metaObject.put("mac", meta.getMac());
|
|
metaObject.put("manufacturer", meta.getManufacturer());
|
|
metaObject.put("model", meta.getModel());
|
|
metaObject.put("network", meta.getNetwork());
|
|
metaObject.put("os", meta.getOs());
|
|
metaObject.put("userId", meta.getUserId());
|
|
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return metaObject;
|
|
}
|
|
|
|
private static void uploadCommunity(JSONObject object) {
|
|
try {
|
|
object.put("meta", getMetaObject());
|
|
object.put("timestamp", System.currentTimeMillis() / 1000);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
if (BuildConfig.DEBUG) {
|
|
Utils.log("LogUtils->" + object.toString());
|
|
}
|
|
LoghubUtils.log(object, "community", false);
|
|
}
|
|
|
|
public static void uploadAccessToBbs(String bbsId, String location) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payload = new JSONObject();
|
|
try {
|
|
payload.put("location", location);//关注板块/文章外所属论坛/游戏详情/文章内所属论坛
|
|
payload.put("bbs_id", bbsId);
|
|
|
|
object.put("event", "access_to_bbs");
|
|
object.put("payload", payload);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
uploadCommunity(object);
|
|
}
|
|
|
|
public static void uploadAccessBbsTab() {
|
|
JSONObject object = new JSONObject();
|
|
try {
|
|
object.put("event", "main_tab[bbs]");
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
uploadCommunity(object);
|
|
}
|
|
|
|
|
|
public static void uploadSimulatorDownload(String event, String fileName, String simulatorId, String simulatorName, String gameId, String location, String downloadType, String startTime) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payload = new JSONObject();
|
|
try {
|
|
object.put("event", event);// 取值有[开始, 完成] [simulator_download, simulator_download_complete]
|
|
object.put("meta", getMetaObject());
|
|
object.put("timestamp", System.currentTimeMillis() / 1000);
|
|
|
|
payload.put("filename", fileName);// 下载模拟器文件名,每次新创建的下载任务文件名都不同,可以用来关联同一次的下载开始与完成
|
|
payload.put("simulator_id", simulatorId);
|
|
payload.put("simulator_name", simulatorName);
|
|
payload.put("location", location);//启动《具体的游戏名称》/模拟器游戏/模拟器游戏-模拟器管理
|
|
payload.put("game_id", gameId);//如果是 启动《游戏名称》 这种方式, 记录这个游戏具体的游戏ID
|
|
payload.put("download_type", downloadType);// update/download 下载类型(更新/下载)
|
|
if (!TextUtils.isEmpty(startTime) && event.equals("simulator_download_complete")) {
|
|
payload.put("simulator_download_timestamp", startTime);// 对应的下载开始时间
|
|
}
|
|
object.put("payload", payload);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
Utils.log("LogUtils->" + object.toString());
|
|
}
|
|
LoghubUtils.log(object, "event", false);
|
|
}
|
|
|
|
public static void uploadSearchGame(String event, String location, String key, String searchType) {
|
|
uploadSearchClick(event, location, key, searchType, "", "");
|
|
}
|
|
|
|
public static void uploadSearchClick(String event, String location, String key, String searchType, String gameId, String gameName) {
|
|
JSONObject object = new JSONObject();
|
|
JSONObject payload = new JSONObject();
|
|
try {
|
|
object.put("event", event);
|
|
object.put("location", location);
|
|
object.put("meta", getMetaObject());
|
|
object.put("timestamp", System.currentTimeMillis() / 1000);
|
|
|
|
payload.put("key", key); //搜索关键词
|
|
payload.put("search_type", searchType); //搜索类型, 有四种取值 默认搜索/历史搜索/自动搜索/主动搜索
|
|
payload.put("game_id", gameId); //event为search_click才取值
|
|
payload.put("game_name", gameName); //event为search_click才取值
|
|
object.put("payload", payload);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
Utils.log("LogUtils->" + object.toString());
|
|
}
|
|
LoghubUtils.log(object, "event", false);
|
|
}
|
|
}
|