package com.gh.common.util import com.gh.gamecenter.common.loghub.LoghubUtils.log import com.gh.gamecenter.common.tracker.Tracker.launchId import com.gh.gamecenter.common.tracker.Tracker.sessionId import com.gh.gamecenter.common.utils.debugOnly import com.gh.gamecenter.common.utils.tryWithDefaultCatch import com.lightgame.utils.Utils import org.json.JSONObject object IntegralLogHelper { fun log(event: String, location: String) = log(event, location, null) fun log(event: String, location: String, entrance: String? = null) { val json = JSONObject().apply { tryWithDefaultCatch { put("meta", LogUtils.getMetaObject()) put("event", event) put("location", location) put("timestamp", System.currentTimeMillis() / 1000) put("launch_id", launchId) put("session_id", sessionId) entrance?.let { put("entrance", it) } } } debugOnly { Utils.log("LogUtils->$json") } log(json, "score", false) } fun logPendent(event: String, location: String, pendentId: String, pendentType: String? = null) { val json = JSONObject().apply { tryWithDefaultCatch { put("meta", LogUtils.getMetaObject()) put("event", event) put("location", location) put("timestamp", System.currentTimeMillis() / 1000) put("launch_id", launchId) put("session_id", sessionId) put("pendant_id", pendentId) pendentType?.run { put("pendant_type", this) } } } debugOnly { Utils.log("LogUtils->$json") } log(json, "score", false) } fun logInviteResult(result: String, type: String? = null) { val json = JSONObject().apply { tryWithDefaultCatch { put("meta", LogUtils.getMetaObject()) put("event", "invite_result") put("location", "邀请途径面板") put("timestamp", System.currentTimeMillis() / 1000) put("launch_id", launchId) put("session_id", sessionId) put("invitation_result", result) put("invitation_type", type) } } debugOnly { Utils.log("LogUtils->$json") } log(json, "score", false) } }