package com.gh.common.util

import com.gh.common.filter.RegionSettingHelper
import com.gh.gamecenter.common.json.JsonObjectBuilder
import com.gh.gamecenter.common.json.json
import com.gh.gamecenter.common.loghub.LoghubUtils
import com.gh.gamecenter.common.utils.LogUtils
import com.gh.gamecenter.common.utils.NewFlatLogUtils
import com.gh.gamecenter.entity.HomeSubSlide
import com.lightgame.utils.Utils
import org.json.JSONArray
import org.json.JSONObject

/**
 * 新平铺埋点工具类
 * 因为新的埋点都要平铺字段，所以新建此类，新埋点在此类添加即可
 */
object NewFlatLogUtils {

    private const val KEY_EVENT = "event"
    private const val KEY_ENTRANCE = "entrance"
    private const val KEY_GAME_ID = "game_id"
    private const val KEY_GAME_NAME = "game_name"
    private const val KEY_TEXT = "text"
    private const val KEY_BUTTON_TYPE = "button_type"
    private const val KEY_BBS_ID = "bbs_id"

    private const val EVENT_LOGIN_FROM_GHZS_SHOW = "halo_fun_login_from_ghzs_show"
    private const val EVENT_LOGIN_FROM_GHZS_CLICK = "halo_fun_login_from_ghzs_click"

    private fun log(jsonObject: JSONObject, logStore: String = "event", uploadImmediately: Boolean = false) {
        Utils.log("NewFlatLogUtils", jsonObject.toString(4))
        LoghubUtils.log(jsonObject, logStore, uploadImmediately, true)
    }

    private fun parseAndPutMeta(): JsonObjectBuilder.() -> Unit = {
        val meta = LogUtils.getNewMetaObject()
        val metaKeys = meta.keys()
        while (metaKeys.hasNext()) {
            val key: String = metaKeys.next().toString()
            val value = meta.getString(key)
            key to value
        }
    }

    // 畅玩助手相关事件(下载弹窗展示事件/隐私政策点击事件/下载点击事件/授权弹窗展示事件/更新弹窗展示事件)
    // 畅玩管理删除游戏弹窗展示事件/畅玩管理-畅玩广场入口点击事件/退出畅玩助手提示弹窗展示事件
    @JvmStatic
    fun logHaloFunEvent(event: String) {
        val json = json {
            KEY_EVENT to event
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 关联游戏跳转icon点击事件
    @JvmStatic
    fun logHaloFunGameDetailJumpClick(downloadStatus: String, gameId: String) {
        val json = json {
            KEY_EVENT to "halo_fun_game_detail_jump_click"
            "download_state" to downloadStatus
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 下载完成提示条点击事件
    @JvmStatic
    fun logHaloFunDownloadCompleteTipClick(buttonType: String, gameId: String) {
        val json = json {
            KEY_EVENT to "halo_fun_download_complete_tip_click"
            KEY_BUTTON_TYPE to buttonType
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩助手更新弹窗点击事件
    @JvmStatic
    fun logHaloFunUpdateDialogClick(dialogType: String, buttonType: String) {
        val json = json {
            KEY_EVENT to "halo_fun_update_dialog_click"
            "dialog_type" to dialogType
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩管理展示事件
    @JvmStatic
    fun logHaloFunManageShow(entrance: String) {
        val json = json {
            KEY_EVENT to "halo_fun_manage_show"
            KEY_ENTRANCE to entrance
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩管理-最近在玩板块展示管理事件
    @JvmStatic
    fun logHaloFunManageRecentGameSwitch(isOn: Boolean) {
        val json = json {
            KEY_EVENT to "halo_fun_manage_recent_game_switch"
            "is_on" to isOn
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩管理删除游戏弹窗点击事件
    @JvmStatic
    fun logHaloFunManageGameDeleteDialogClick(buttonType: String, gamesArray: JSONArray) {
        val json = json {
            KEY_EVENT to "halo_fun_manage_game_delete_dialog_click"
            KEY_BUTTON_TYPE to buttonType
            "games_array" to gamesArray
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 退出畅玩助手提示弹窗反馈收集事件
    @JvmStatic
    fun logHaloFunGameExitDialogSubmitClick(gameId: String, detail: String, typeTags: JSONArray) {
        val json = json {
            KEY_EVENT to "halo_fun_game_exit_dialog_submit_click"
            KEY_GAME_ID to gameId
            "detail" to detail
            "type_tags" to typeTags
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩游戏管理-长按弹出更多菜单dialog事件
    @JvmStatic
    fun logHaloFunGameMoreDialogShow(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "halo_fun_more_dialog_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }


    // 畅玩游戏管理-添加桌面图标权限提示弹框展示事件
    @JvmStatic
    fun logHaloFunShortcutPermissionDialogShow(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "halo_fun_shutcup_icon_dialog_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }


    // 畅玩游戏管理-添加桌面图标权限提示弹框按钮点击事件
    @JvmStatic
    fun logHaloFunShortcutPermissionDialogButtonClick(
        gameId: String,
        gameName: String,
        buttonType: String,
    ) {
        val json = json {
            KEY_EVENT to "halo_fun_shutcup_icon_dialog_click"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩游戏管理-清除游戏数据弹框展示事件
    @JvmStatic
    fun logHaloFunCleanDataDialogShow(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "halo_func_clean_data_dialog_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩游戏管理-添加桌面图标权限提示弹框按钮点击事件
    @JvmStatic
    fun logHaloFunCleanDataDialogButtonClick(
        gameId: String,
        gameName: String,
        buttonType: String,
    ) {
        val json = json {
            KEY_EVENT to "halo_func_clean_data_dialog_click"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 从畅玩游戏中唤起快捷图标创建弹窗（弹窗B）展示时上报
    @JvmStatic
    fun logCwFunShortcutPermissionDialogShow(gameId: String) {
        val json = json {
            KEY_EVENT to "halo_fun_shotcup_icon_dialog_b_show"
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }


    // 用户点击快捷图标创建弹窗（弹窗B）中按钮时触发
    @JvmStatic
    fun logCwFunShortcutPermissionDialogButtonClick(
        gameId: String,
        buttonType: String,
    ) {
        val json = json {
            KEY_EVENT to "halo_fun_shotcup_icon_dialog_b_click"
            KEY_GAME_ID to gameId
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 搜索-点击热门标签
    @JvmStatic
    fun logSearchHotTagClick(
        tag: String,
        linkType: String,
        linkId: String,
        linkText: String
    ) {
        val json = json {
            KEY_EVENT to "search_click_hot_tag"
            "tag" to tag
            "link_type" to linkType
            "link_id" to linkId
            "link_text" to linkText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //版块点击内容卡片
    @JvmStatic
    fun logBlockGameContentCardClick(
        blockId: String,
        blockName: String,
        linkType: String,
        linkId: String,
        linkText: String
    ) {
        val json = json {
            KEY_EVENT to "block_game_content_card_click"
            "block_id" to blockId
            "block_name" to blockName
            "link_type" to linkType
            "link_id" to linkId
            "link_text" to linkText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //首页点击内容卡片
    @JvmStatic
    fun logHomeGameContentCardClick(
        linkType: String,
        linkId: String,
        linkText: String
    ) {
        val json = json {
            KEY_EVENT to "home_game_content_card_click"
            "link_type" to linkType
            "link_id" to linkId
            "link_text" to linkText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏详情点击内容卡片
    @JvmStatic
    fun logGameDetailGameContentCardClick(
        title: String,
        gameName: String,
        gameId: String,
        linkType: String,
        linkId: String,
        linkText: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_game_content_card_click"
            "title" to title
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            "link_type" to linkType
            "link_id" to linkId
            "link_text" to linkText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //浏览自定义栏目
    @JvmStatic
    fun logGameDetailColumnOrderingView(
        title: String,
        gameName: String,
        gameId: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_column_ordering_view"
            "title" to title
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //我的游戏tab点击
    @JvmStatic
    fun logMyGameTabClick(tab: String) {
        val json = json {
            KEY_EVENT to "game_self_tab_click"
            "tab_name" to tab
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //玩过tab开启游戏时长
    @JvmStatic
    fun logMyGameTabOpenTimeLongClick() {
        val json = json {
            KEY_EVENT to "game_self_played_time_statistics_button_click"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏时长统计弹窗点击事件
    @JvmStatic
    fun logGameTimeLongDialogClick(content: String) {
        val json = json {
            KEY_EVENT to "game_self_played_time_statistics_dialog_click"
            KEY_TEXT to content
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //玩过tab游戏卡片点击事件
    @JvmStatic
    fun logMyGamePlayedTabGameCardClick(content: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_played_game_card_click"
            KEY_TEXT to content
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //玩过tab清除游戏记录
    @JvmStatic
    fun logMyGamePlayedTabClearGameClick(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_played_history_clear_click"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //玩过tab清除游戏记录弹窗点击事件
    @JvmStatic
    fun logMyGamePlayedTabClearGameDialogClick(text: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_played_history_clear_dialog_click"
            KEY_TEXT to text
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //关注tab关注游戏 我的游戏-关注 ，点击热门游戏推荐时上报
    @JvmStatic
    fun logMyGameFollowTabHotGameClick(content: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_follow_hot_recommend_click"
            KEY_TEXT to content
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //关注tab游戏卡片点击事件
    fun logMyGameFollowTabGameCardClick(content: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_follow_game_card_click"
            KEY_TEXT to content
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //取消关注弹窗点击事件
    @JvmStatic
    fun logMyGameCancelFollowDialogClick(content: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_follow_cancel_dialog_click"
            KEY_TEXT to content
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //预约tab游戏卡片点击事件
    @JvmStatic
    fun logMyGameReserveTabGameCardClick(content: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_appointment_game_card_click"
            KEY_TEXT to content
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //取消预约弹窗点击事件
    @JvmStatic
    fun logMyGameCancelReserveDialogClick(content: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "game_self_appointment_cancel_dialog_click"
            KEY_TEXT to content
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 搜索-点击搜索榜单
    @JvmStatic
    fun logSearchClickRank(
        rankName: String,
        rankSequence: String,
    ) {
        val json = json {
            KEY_EVENT to "search_click_rank"
            "rank_name" to rankName
            "rank_sequence" to rankSequence
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 搜索-点击搜索榜单内容
    @JvmStatic
    fun logSearchClickRankDetail(
        rankName: String,
        rankSequence: String,
        linkId: String,
        linkType: String,
        linkTitle: String
    ) {
        val json = json {
            KEY_EVENT to "search_click_rank_detail"
            "rank_name" to rankName
            "rank_sequence" to rankSequence
            "link_id" to linkId
            "link_type" to linkType
            "link_title" to linkTitle
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //点击社区-搜索页返回按钮
    @JvmStatic
    fun logClickSearchReturn(searchKey: String) {
        val json = json {
            KEY_EVENT to "click_search_return"
            "search_key" to searchKey
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //社区搜索结果浏览
    @JvmStatic
    fun logViewSearchList(stayTime: Long, searchKey: String) {
        val json = json {
            KEY_EVENT to "view_search_list"
            "stay_time" to stayTime
            "search_key" to searchKey
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //社区搜索tab结果切换事件
    @JvmStatic
    fun logClickSearchTab(searchKey: String, tab: String) {
        val json = json {
            KEY_EVENT to "click_search_tab"
            "search_key" to searchKey
            "tab_type" to tab
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //点击论坛-搜索页返回按钮
    @JvmStatic
    fun logClickBbsSearchReturn(searchKey: String, bbsId: String) {
        val json = json {
            KEY_EVENT to "click_bbs_search_return"
            "search_key" to searchKey
            "bbs_id" to bbsId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //论坛搜索结果浏览
    @JvmStatic
    fun logViewBbsSearchList(stayTime: Long, searchKey: String, bbsId: String) {
        val json = json {
            KEY_EVENT to "view_bbs_search_list"
            "stay_time" to stayTime
            "search_key" to searchKey
            "bbs_id" to bbsId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //新版我的光环触发登录
    @JvmStatic
    fun logHaloSelfLogin() {
        val json = json {
            KEY_EVENT to "halo_self_login_trigger"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //新版我的光环点击事件
    @JvmStatic
    fun logHaloSelfClick(profile: String, text: String) {
        val json = json {
            KEY_EVENT to "halo_self_click_v2"
            "profile" to profile
            KEY_TEXT to text
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //新版我的光环点击切换深色/日间模式
    @JvmStatic
    fun logHaloSelfNightModeClick(type: String) {
        val json = json {
            KEY_EVENT to "halo_self_night_mode_click"
            KEY_BUTTON_TYPE to type
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //触发关闭深色模式跟随系统切换弹窗
    @JvmStatic
    fun logHaloSelfNightModeOsDialog(buttonText: String) {
        val json = json {
            KEY_EVENT to "halo_self_night_mode_os_dialog"
            "button_text" to buttonText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //我的发布tab点击事件
    @JvmStatic
    fun logHaloSelfPublishTab(tabName: String) {
        val json = json {
            KEY_EVENT to "halo_self_publish_tab"
            "tab_name" to tabName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //我的发布内容点击事件
    @JvmStatic
    fun logHaloSelfPublishContent(tabName: String, location: String) {
        val json = json {
            KEY_EVENT to "halo_self_publish_content"
            "tab_name" to tabName
            "location" to location
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //论坛详情页—置顶栏
    fun logClickForumTopBar(contentType: String, contentId: String, sequence: Int, bbsId: String) {
        val json = json {
            KEY_EVENT to "click_forum_top_bar"
            "content_type" to contentType
            "content_id" to contentId
            "sequence" to sequence
            "bbs_id" to bbsId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //个人主页-内容
    fun logClickSelfPublish(contentType: String, contentId: String, refUserId: String, tabName: String) {
        val json = json {
            KEY_EVENT to "click_self_publish"
            "content_type" to contentType
            "content_id" to contentId
            "ref_user_id" to refUserId
            "tab_name" to tabName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏详情页-视频合集内容
    fun logClickGameDetailVideoCategory(contentType: String, contentId: String, refUserId: String) {
        val json = json {
            KEY_EVENT to "click_game_detail_video_category"
            "content_type" to contentType
            "content_id" to contentId
            "ref_user_id" to refUserId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //进入游戏详情
    fun logGameDetailEnter(gameName: String, gameId: String, isMirrorData: Boolean) {
        val ipInfo = RegionSettingHelper.getIpInfo()
        val json = json {
            KEY_EVENT to "game_detail_enter"
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            "is_mirror_data" to isMirrorData
            if (ipInfo != null) {
                "country" to ipInfo.country
                "province" to ipInfo.province
                "city" to ipInfo.city
            }
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //离开游戏详情
    fun logGameDetailExit(gameName: String, gameId: String) {
        val json = json {
            KEY_EVENT to "game_detail_exit"
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //手机号验证弹窗点击事件
    fun logPhoneNumberVerifyDialogClick(entrance: String, text: String) {
        val json = json {
            KEY_EVENT to "publish_phone_number_verify_dialog_click"
            KEY_ENTRANCE to entrance
            KEY_TEXT to text
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //手机号验证界面展示事件
    fun logPhoneNumberVerifyDialogShow(entrance: String) {
        val json = json {
            KEY_EVENT to "publish_phone_number_verify_dialog_show"
            KEY_ENTRANCE to entrance
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }


    //完成手机号验证
    fun logPhoneNumberVerifyDialogSuccess() {
        val json = json {
            KEY_EVENT to "publish_phone_number_verify_dialog_success"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 进入活动页面
    fun logActivityPageEnter(entrance: String, activityId: String) {
        val json = json {
            KEY_EVENT to "activity_page_enter"
            KEY_ENTRANCE to entrance
            "activity_id" to activityId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 活动页面浏览
    fun logActivityPageView(interval: Int, activityId: String) {
        val json = json {
            KEY_EVENT to "activity_page_view"
            "interval" to interval
            "activity_id" to activityId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器更新弹窗展示事件
    @JvmStatic
    fun logSimulatorUpdateAlertShow() {
        val json = json {
            KEY_EVENT to "simulator_update_pop_show"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器更新弹窗按钮点击事件
    @JvmStatic
    fun logSimulatorUpdateAlertClick(buttonText: String) {
        val json = json {
            KEY_EVENT to "simulator_update_pop_click"
            KEY_BUTTON_TYPE to buttonText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器游戏页面展示事件
    @JvmStatic
    fun logSimulatorGamePageShow() {
        val json = json {
            KEY_EVENT to "simulator_game_page_show"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器游戏类型Tab展示事件
    @JvmStatic
    fun logSimulatorGamePageTabClick(tabName: String) {
        val json = json {
            KEY_EVENT to "simulator_game_tag_show"
            "tab_name" to tabName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器游戏卡片点击事件
    @JvmStatic
    fun logSimulatorGameCardClick(buttonText: String) {
        val json = json {
            KEY_EVENT to "simulator_game_card_click"
            KEY_BUTTON_TYPE to buttonText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器游戏合集点击事件
    @JvmStatic
    fun logSimulatorGameCollectionClick() {
        val json = json {
            KEY_EVENT to "simulator_game_collection_click"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏删除提示弹窗展示事件
    @JvmStatic
    fun logSimulatorGameDeleteAlertShow() {
        val json = json {
            KEY_EVENT to "simulator_delete_game_pop_show"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏删除提示弹窗点击事件
    @JvmStatic
    fun logSimulatorGameDeleteAlertClick(buttonText: String) {
        val json = json {
            KEY_EVENT to "simulator_delete_game_pop_click"
            KEY_BUTTON_TYPE to buttonText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器管理页面展示事件
    @JvmStatic
    fun logSimulatorManagerClick() {
        val json = json {
            KEY_EVENT to "simulator_manger_page_show"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器列表相关点击事件
    fun logSimulatorListClick(buttonText: String, simulatorType: String) {
        val json = json {
            KEY_EVENT to "simulator_list_click"
            KEY_BUTTON_TYPE to buttonText
            "simulator_name" to simulatorType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器卸载提示弹窗展示事件
    fun logSimulatorUninstallAlertShow(simulatorType: String) {
        val json = json {
            KEY_EVENT to "simulator_uninstall_pop_show"
            "simulator_name" to simulatorType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //模拟器卸载提示弹窗展示事件
    fun logSimulatorUninstallAlertClick(buttonText: String) {
        val json = json {
            KEY_EVENT to "simulator_uninstall_pop_click"
            KEY_BUTTON_TYPE to buttonText
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //进入发现页面
    fun logDiscoverPageEnter() {
        val json = json {
            KEY_EVENT to "discover_page_enter"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //离开发现页面
    fun logDiscoverPageQuit(sequence: Int) {
        val json = json {
            KEY_EVENT to "discover_page_quit"
            "sequence" to sequence
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //发现页面可见事件
    fun logDiscoverPageVisible() {
        val json = json {
            KEY_EVENT to "discover_page_visible"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //发现页面不可见事件
    fun logDiscoverPageInvisible(sequence: Int) {
        val json = json {
            KEY_EVENT to "discover_page_invisible"
            "sequence" to sequence
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //页面顶部露出
    fun logDiscoverPageTopVisible(countNum: Int) {
        val json = json {
            KEY_EVENT to "discover_page_top_visible"
            "count_num" to countNum
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //页面底部停留
    fun logDiscoverPageBottomStay(countNum: Int) {
        val json = json {
            KEY_EVENT to "discover_page_bottom_stay"
            "count_num" to countNum
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //点击兴趣推荐卡片
    fun logDiscoverPageRecommendedInterestCardClick(
        sequence: Int,
        linkText: String,
        linkType: String,
        linkId: String,
        entrance: String,
        blockName: String = ""
    ) {
        val json = json {
            KEY_EVENT to "discover_page_recommended_interest_card_click"
            "sequence" to sequence
            "link_text" to linkText
            "link_type" to linkType
            "link_id" to linkId
            "entrance" to entrance
            if (blockName.isNotEmpty()) {
                "block_name" to blockName
            }
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //点击跳转游戏库
    fun logDiscoverPageJumpGamesLibraries() {
        val json = json {
            KEY_EVENT to "discover_page_jump_games_libraries"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //触发不感兴趣
    fun logDiscoverPageNotInterest(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "discover_page_not_interest"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //跳过广告
    @JvmStatic
    fun logOpenScreenAdSkip(adId: String, linkText: String, linkType: String, linkId: String) {
        val json = json {
            KEY_EVENT to "open_screen_ad_skip"
            "ad_id" to adId
            "link_text" to linkText
            "link_type" to linkType
            "link_id" to linkId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏单广场浏览时长
    fun logGameCollectSquareStayTime(interval: Long) {
        val json = json {
            KEY_EVENT to "game_collect_square_stay_time"
            "interval" to interval
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏单浏览时长
    fun logGameCollectStayTime(interval: Long, id: String, title: String) {
        val json = json {
            KEY_EVENT to "game_collect_stay_time"
            "interval" to interval
            "game_collect_id" to id
            "game_collect_title" to title
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 游戏存档页面展示事件
    fun logGameArchivePageShow(tabName: String) {
        val json = json {
            KEY_EVENT to "cloud_save_game_save_page_show"
            "tab_name" to tabName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 云存档管理页面展示事件
    fun logCloudArchiveManagePageShow(gameId: String, gameName: String, entrance: String) {
        val json = json {
            KEY_EVENT to "cloud_save_manage_page_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            KEY_ENTRANCE to entrance
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 云存档Tab页面展示事件
    fun logCloudArchiveTabShow(gameId: String, gameName: String, tabName: String) {
        val json = json {
            KEY_EVENT to "cloud_save_tab_page_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            "tab_name" to tabName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 存档分享弹窗展示事件
    fun logCloudArchiveShareDialogShow(gameId: String, gameName: String, cloudSaveId: String) {
        val json = json {
            "cloud_save_id" to cloudSaveId
            KEY_EVENT to "cloud_save_share_dialog_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 存档分享弹窗点击事件
    fun logCloudArchiveShareDialogClick(buttonType: String, gameId: String, gameName: String, cloudSaveId: String) {
        val json = json {
            "cloud_save_id" to cloudSaveId
            KEY_EVENT to "cloud_save_share_dialog_click"
            KEY_BUTTON_TYPE to buttonType
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 存档分享弹窗分享结果事件
    fun logCloudArchiveShareDialogResult(shareResult: String) {
        val json = json {
            KEY_EVENT to "cloud_save_share_dialog_result"
            "share_result" to shareResult
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 存档删除弹窗展示事件
    fun logCloudArchiveDeleteDialogShow() {
        val json = json {
            KEY_EVENT to "cloud_save_delete_dialog_show"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 存档删除弹窗点击事件
    fun logCloudArchiveDeleteDialogClick(buttonType: String) {
        val json = json {
            KEY_EVENT to "cloud_save_delete_dialog_click"
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 上传存档弹窗展示事件
    fun logCloudArchiveUploadDialogShow(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "cloud_save_upload_dialog_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 上传存档弹窗点击事件
    fun logCloudArchiveUploadDialogClick(buttonType: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "cloud_save_upload_dialog_click"
            KEY_BUTTON_TYPE to buttonType
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩助手下载提示弹窗展示事件
    fun logCloudArchiveVSpaceDownloadDialogShow() {
        val json = json {
            KEY_EVENT to "cloud_save_halo_fun_download_dialog_show"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 畅玩助手下载提示弹窗点击事件
    fun logCloudArchiveVSpaceDownloadDialogClick(buttonType: String) {
        val json = json {
            KEY_EVENT to "cloud_save_halo_fun_download_dialog_click"
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 游戏下载提示弹窗展示事件
    fun logCloudArchiveGameDownloadDialogShow() {
        val json = json {
            KEY_EVENT to "cloud_save_game_download_dialog_show"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 游戏下载提示弹窗点击事件
    fun logCloudArchiveGameDownloadDialogClick(buttonType: String) {
        val json = json {
            KEY_EVENT to "cloud_save_game_download_dialog_click"
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 推荐游戏页面下载游戏事件
    fun logCloudArchiveRecommendGameDownload(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "cloud_save_recommend_game_page_download"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 搜索功能关键词上传事件
    fun logCloudArchiveSearchKeyUpload(gameId: String, gameName: String, key: String) {
        val json = json {
            KEY_EVENT to "cloud_save_search_key_upload"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            "key" to key
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 云存档Tab展示事件/云存档Tab展示事件
    fun logCloudArchiveGameDetailTabRelated(event: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to event
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 云存档下载/使用事件
    fun logCloudArchiveDownloadOrApply(
        archiveName: String,
        entrance: String,
        gameId: String,
        gameName: String,
        cloudSaveId: String,
        isDownload: Boolean,
    ) {
        val json = json {
            KEY_EVENT to "cloud_save_download"
            "cloud_save_name" to archiveName
            "cloud_save_id" to cloudSaveId
            "is_download" to isDownload
            KEY_ENTRANCE to entrance
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 存档覆盖风险提示弹窗展示事件/存档覆盖风险提示弹窗点击事件
    fun logCloudArchiveApplyDialogRelated(event: String, buttonType: String = "") {
        val json = json {
            KEY_EVENT to event
            if (buttonType.isNotBlank()) {
                KEY_BUTTON_TYPE to buttonType
            }
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 进入发现页详情
    fun logDiscoverDetailPageEnter(entrance: String, blockName: String = "") {
        val json = json {
            KEY_EVENT to "discover_detail_page_enter"
            KEY_ENTRANCE to entrance
            if (blockName.isNotBlank()) {
                "block_name" to blockName
            }
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 点击设置偏好
    fun logInterestedGameClick(entrance: String, blockName: String = "") {
        val json = json {
            KEY_EVENT to "discover_preference_settings_click"
            KEY_ENTRANCE to entrance
            if (blockName.isNotBlank()) {
                "block_name" to blockName
            }
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 进入游戏偏好页面
    fun logInterestedGamePageEnter(frequency: String, prefer: String, tendency: String, typeTags: JSONArray) {
        val json = json {
            KEY_EVENT to "discover_preference_game_page_enter"
            "frequency" to frequency
            "prefer" to prefer
            "tendency" to tendency
            "type_tags" to typeTags
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 离开游戏偏好页面
    fun logInterestedGamePageExit(
        frequency: String,
        prefer: String,
        tendency: String,
        typeTags: JSONArray,
    ) {
        val json = json {
            KEY_EVENT to "discover_preference_game_page_quit"
            "frequency" to frequency
            "prefer" to prefer
            "tendency" to tendency
            "type_tags" to typeTags
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 浏览游戏偏好页面
    fun logInterestedGamePageBrowse(
        frequency: String,
        prefer: String,
        tendency: String,
        typeTags: JSONArray,
        interval: Long
    ) {
        val json = json {
            KEY_EVENT to "discover_preference_game_view"
            "frequency" to frequency
            "prefer" to prefer
            "tendency" to tendency
            "type_tags" to typeTags
            "interval" to interval
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 展开感兴趣的分类弹窗
    fun logInterestedGameTypeDialogShow(typeTags: JSONArray) {
        val json = json {
            KEY_EVENT to "discover_preference_type_tags_dialog_show"
            "type_tags" to typeTags
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 关闭感兴趣的分类弹窗
    fun logInterestedGameTypeDialogClose(typeTags: JSONArray) {
        val json = json {
            KEY_EVENT to "discover_preference_type_tags_dialog_close"
            "type_tags" to typeTags
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 浏览感兴趣的分类弹窗
    fun logInterestedGameTypeDialogBrowse(typeTags: JSONArray, interval: Long) {
        val json = json {
            KEY_EVENT to "discover_preference_type_tags_dialog_view"
            "type_tags" to typeTags
            "interval" to interval
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏详情-游戏单推荐，点击右上角进入游戏单广场时触发
    fun logGameDetailGameListRecommendSquareJump(gameName: String, gameId: String) {
        val json = json {
            KEY_EVENT to "game_detail_game_list_recommend_square_jump"
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //游戏详情-专题推荐，点击右上角时触发
    fun logGameDetailColumnRecommendUpperRightClick(
        gameName: String,
        gameId: String,
        buttonType: String,
        columnName: String,
        columnId: String,
        linkText: String,
        linkType: String,
        linkId: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_column_recommend_upper_right_click"
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            KEY_BUTTON_TYPE to buttonType
            "column_name" to columnName
            "column_id" to columnId
            "link_text" to linkText
            "link_type" to linkType
            "link_id" to linkId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 游戏详情点击发表评价，游戏详情-评论tab点击“我要安利/我来评价”时上报
    fun logGameDetailPublishCommentClick(
        button: String,
        gameName: String,
        gameId: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_comment_tab_game_comment_publish_click"
            "button" to button
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 浏览评价tab，页面停留游戏详情-评价tab时上报
    fun logGameDetailCommentTabView(
        interval: Long,
        gameName: String,
        gameId: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_comment_tab_view"
            "interval" to interval
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 游戏评价点击事件，游戏详情-评论tab点击游戏评价时上报
    fun logGameDetailCommentTabCommentClick(
        location: String,
        tag: String,
        filter: String,
        button: String,
        gameName: String,
        gameId: String,
        commentId: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_comment_tab_game_comment_click"
            "location" to location
            "tag" to tag
            "filter_tag_name" to filter
            "button" to button
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            "comment_id" to commentId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 浏览评价详情，页面停留游戏评价详情页面时上报
    fun logGameDetailCommentDetailPageView(
        interval: Long,
        gameName: String,
        gameId: String,
        commentId: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_comment_tab_detail_view"
            "interval" to interval
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            "comment_id" to commentId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 评价详情点击事件，评价详情页面点击时上报
    fun logGameDetailCommentDetailCommentClick(
        location: String,
        tag: String,
        filter: String,
        button: String,
        gameName: String,
        gameId: String,
        commentId: String
    ) {
        val json = json {
            KEY_EVENT to "game_detail_comment_tab_game_comment_detail_click"
            "location" to location
            "tag" to tag
            "filter_tag_name" to filter
            "button" to button
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            "comment_id" to commentId
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 安利墙点击上墙，安利墙点击“上墙”时上报
    fun logAmwayPasteClick() {
        val json = json {
            KEY_EVENT to "recommend_wall_paste_click"
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 安利墙发表评价，通过安利墙进入发表评价页面时上报
    fun logAmwayGameCommentPublish(entrance: String) {
        val json = json {
            KEY_EVENT to "recommend_wall_game_comment_publish"
            KEY_ENTRANCE to entrance
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 成功发表评价，成功发布游戏评价时上报
    fun logGameCommentPublishSuccess(
        entrance: String,
        commentId: String,
        type: String
    ) {
        val json = json {
            KEY_EVENT to "game_comment_publish_success"
            KEY_ENTRANCE to entrance
            "comment_id" to commentId
            "type" to type
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    //用户通过活动页的“立即投稿/添加”成功创建游戏单时上报
    fun logActivityGameListCreateSuccessV2(
        entrance: String,
        gameId: String,
        gameName: String,
        gameCollectId: String,
        gameCollectTitle: String,
        activityId: String,
        activityName: String,
    ) {
        val json = json {
            "event" to "activity_game_list_create_success_v2"
            "entrance" to entrance
            if (gameId.isNotEmpty()) {
                "game_id" to gameId
            }
            if (gameName.isNotEmpty()) {
                "game_name" to gameName
            }
            "game_collect_id" to gameCollectId
            "game_collect_title" to gameCollectTitle
            "activity_id" to activityId
            "activity_name" to activityName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    //新游开测详情页点击tab
    fun logGameTestDetailTabClick(tabName: String) {
        val json = json {
            "event" to "game_test_detail_tab_click"
            "tab_name" to tabName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    //新游开测详情页点击时间轴
    fun logGameTestDetailTimelineClick(tabName: String, action: String, gameTestStartType: String) {
        val json = json {
            "event" to "game_test_detail_timeline_click"
            "tab_name" to tabName
            "action" to action
            "game_test_start_type" to gameTestStartType
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    //新游开测详情页点击游戏类型
    fun logGameTestDetailGameCategoryClick(tabName: String, gameCategory: String, gameTestStartType: String) {
        val json = json {
            "event" to "game_test_detail_game_category_click"
            "tab_name" to tabName
            "game_category" to gameCategory
            "game_test_start_type" to gameTestStartType
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    //浏览新游开测详情页
    fun logGameTestDetailView(tabName: String, interval: Long, gameTestStart: Long, gameTestStartType: String) {
        val json = json {
            "event" to "game_test_detail_view"
            "tab_name" to tabName
            "interval" to interval
            "game_test_start" to gameTestStart
            "game_test_start_type" to gameTestStartType
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    /**
     * 新游开测首页/板块，点击右上角（全部/更多）
     */
    fun logGameTestV2MoreClick(
        text: String,
        location: String,
        blockId: String = "",
        blockName: String = "",
        linkType: String = "",
        linkId: String = "",
        linkText: String = ""
    ) {
        val json = json {
            "event" to "game_test_home_more_click"
            "text" to text //右上角文案，包括：全部、更多
            "location" to location //新游开测所处位置，包括：首页、版块
            "block_id" to blockId //新游开测所处位置为“版块”，上报版块ID
            "block_name" to blockName //新游开测所处位置为“版块”，上报版块名称
            "link_type" to linkType //右上角文案为“更多”时的链接类型
            "link_id" to linkId //右上角文案为“更多”时的链接ID
            "link_text" to linkText //右上角文案为“更多”时的跳转链接
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    /**
     * 新游开测首页/板块，点击推荐标签
     */
    fun logGameTestV2RecommendLabelClick(
        location: String,
        blockId: String = "",
        blockName: String = "",
        tagId: String = "",
        text: String = "",
        sequence: Int = 0,
        linkType: String = "",
        linkId: String = "",
        linkText: String = ""
    ) {
        val json = json {
            "event" to "game_test_home_recommend_tag_click"
            "location" to location //新游开测所处位置，包括：首页、版块
            "block_id" to blockId //新游开测所处位置为“版块”，上报版块ID
            "block_name" to blockName //新游开测所处位置为“版块”，上报版块名称
            "tag_id" to tagId //点击推荐标签的ID
            "text" to text //点击推荐标签的文案
            "sequence" to sequence //点击推荐标签在所有标签中所处位置，从左往右依次计算
            "link_type" to linkType //点击推荐标签的链接类型
            "link_id" to linkId //点击推荐标签的链接ID
            "link_text" to linkText //点击推荐标签的跳转链接
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    /**
     * 新游开测首页点击时间轴
     */
    fun logGameTestV2TimeLineClick(
        action: String,
        type: String,
        time: Long,
        sequence: Int,
    ) {
        val json = json {
            "event" to "game_test_home_timeline_click"
            "action" to action //类型包括： 1.自动定位：滑动游戏时间轴自动更换定位 2.手动点击：手动点击时间轴的定位
            "type" to type //类型包括“推荐/全部”，时间轴定位在“推荐”时记“推荐”，其余位置则记“全部”
            "game_test_start" to time //节点时间字符串 2023-03-10 转时间戳
            "sequence" to sequence //时间类型为“全部”时，时间轴排除“推荐”，从左往右依次计算，记录在时间轴实际上所处的位置顺序，例如：12.30排在“推荐”后面，则记录“1”
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    /**
     * 新游开测条目完整展示时长上报
     */
    fun logGameTestV2ItemViewTime(
        location: String,
        blockId: String = "",
        blockName: String = "",
        interval: Long = 0,
        type: String = "",
        startTime: Long = 0,
        sequence: Int = 0,
    ) {
        val json = json {
            "event" to "game_test_home_view"
            "location" to location //新游开测所处位置，包括：首页、版块
            "block_id" to blockId //新游开测所处位置为“版块”，上报版块ID
            "block_name" to blockName //新游开测所处位置为“版块”，上报版块名称
            "interval" to interval //内容在屏幕可见范围完整展示的时长
            "type" to type //触发事件时所停留的时间定位；类型包括“推荐/全部”，时间轴定位在“推荐”时记“推荐”，其余位置则记“全部”
            "game_test_start" to startTime //触发事件时所停留的时间定位；时间类型为“全部”时，记录具体的月份日期 ；例如：12.30、12.31
            "sequence" to sequence //点击推荐标签在所有标签中所处位置，从左往右依次计算
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // gid 变更事件
    @JvmStatic
    fun logGidChanged(oldGid: String, newGid: String) {
        val json = json {
            KEY_EVENT to "gid_changed"
            "old_gid" to oldGid
            "new_gid" to newGid
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }


    //发现页下拉刷新
    fun logDiscoverPageDropDownRefresh(refreshCount: Int) {
        val json = json {
            "event" to "discover_page_drop_down_refresh"
            "count_num" to refreshCount
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    //更换头像弹窗点击
    fun logChangeAvatarDialogClick(button: String) {
        val json = json {
            "event" to "profile_picture_change_dialog_click"
            "button" to button
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    //默认头像弹窗点击
    fun logDefaultAvatarDialogClick(button: String) {
        val json = json {
            "event" to "profile_picture_default_dialog_click"
            "button" to button
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 出现 XAPK 安装权限引导弹窗
    fun logXApkInstallPermissionDialogShowed(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "xapk_install_permission_dialog_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 点击引导设置“安装权限”弹窗 时上报
    fun logXApkInstallPermissionDialogClick(button: String, isOn: Boolean, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "xapk_install_permission_dialog_click"
            "button" to button
            "is_on" to isOn
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 出现xapk解压失败弹窗时上报
    fun logXApkUnzipFailedDialogShowed(trigger: String, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "xapk_decompression_failed_dialog_show"
            "trigger" to trigger
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 点击解压失败弹窗 时上报
    fun logXApkUnzipFailedDialogClick(button: String, isOn: Boolean, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "xapk_decompression_failed_dialog_click"
            "button" to button
            "is_on" to isOn
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // vpn 弹窗显示
    fun logVpnHintDialogShow(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "vpn_pre_access_dialog_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // vpn 弹窗点击
    fun logVpnHintDialogClick(gameId: String, gameName: String, button: String) {
        val json = json {
            KEY_EVENT to "vpn_pre_access_dialog_click"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            "button" to button
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 谷歌框架弹窗显示
    fun logGAppsDialogShowed(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "google_services_hint_pop_show"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 谷歌框架弹窗点击
    fun logGAppsDialogClicked(gameId: String, gameName: String, buttonType: String) {
        val json = json {
            KEY_EVENT to "google_services_hint_pop_click"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 谷歌框架安装成功
    fun logGAppsInstallSuccess(gameId: String, gameName: String, interval: Int) {
        val json = json {
            KEY_EVENT to "google_services_install_success"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            "interval" to interval
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 谷歌框架安装失败
    fun logGAppsInstallFailed(gameId: String, gameName: String, interval: Int) {
        val json = json {
            KEY_EVENT to "google_services_install_fail"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            "interval" to interval
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 谷歌框架安装成功并点击启动游戏
    fun logGAppsInstalledAndLaunchGame(gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "google_services_install_game_launch"
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 点击子版块
    fun logClickSection(sectionId: String, bbsId: String, sequence: Int) {
        val json = json {
            KEY_EVENT to "click_section"
            "section_id" to sectionId
            KEY_BBS_ID to bbsId
            "sequence" to sequence
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 点击更多板块按钮
    fun logClickMoreSection() {
        val json = json {
            KEY_EVENT to "click_more_section"
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 左右滑动子版块
    fun logSlideSection() {
        val json = json {
            KEY_EVENT to "slide_section"
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 点击论坛详情页—专区tab
    fun logClickBBSDetailGameZoneTab(bbsId: String, entrance: String, url: String) {
        val json = json {
            KEY_EVENT to "click_bbs_detail_game_zone_tab"
            KEY_BBS_ID to bbsId
            KEY_ENTRANCE to entrance
            "url" to url
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 点击论坛详情页—游戏详情
    fun logClickBBSDetailGameDetail() {
        val json = json {
            KEY_EVENT to "click_bbs_detail_game_detail"
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 首页下拉刷新
    fun logHomePagePullRefresh(countNum: Int) {
        val json = json {
            KEY_EVENT to "home_page_pull_refresh"
            "count_num" to countNum
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 右侧卡片点击事件
    fun logRightSideCardClick(homeSubSlide: HomeSubSlide, countNum: Int, location: String) {
        val json = json {
            KEY_EVENT to "right_side_card_click"
            "title" to homeSubSlide.title
            "card_id" to homeSubSlide.cardId
            "type" to homeSubSlide.cardType
            "text" to homeSubSlide.cardText
            "count_num" to countNum
            "location" to location
            "link_type" to homeSubSlide.linkType
            "link_id" to homeSubSlide.linkId
            "link_text" to homeSubSlide.linkText
            parseAndPutMeta().invoke(this)
        }
        log(json, "event", false)
    }

    // 游戏详情浏览大事件
    @JvmStatic
    fun logGameDetailMajorEventDetailClick(
        gameId: String,
        gameName: String,
        linkId: String = "",
        linkType: String = "",
        linkTitle: String = ""
    ) {
        val json = json {
            KEY_EVENT to "game_detail_major_event_detail_click"
            KEY_GAME_NAME to gameName
            KEY_GAME_ID to gameId
            "link_id" to linkId
            "link_type" to linkType
            "link_title" to linkTitle
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 我的光环点击 banner
    @JvmStatic
    fun logHaloPersonalActivityBannerClick(
        linkId: String = "",
        linkType: String = "",
        linkTitle: String = ""
    ) {
        val json = json {
            KEY_EVENT to "halo_self_activity_banner_click"
            "link_id" to linkId
            "link_type" to linkType
            "link_title" to linkTitle
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 视频流点击广告
    @JvmStatic
    fun logVideoAdsClick(
        linkId: String = "",
        linkType: String = "",
        linkTitle: String = ""
    ) {
        val json = json {
            KEY_EVENT to "video_ads_click"
            "link_id" to linkId
            "link_type" to linkType
            "link_title" to linkTitle
            parseAndPutMeta().invoke(this)
        }
        log(json, "video_streaming")
    }

    // 社区-搜索榜单-内容点击
    @JvmStatic
    fun logCommunitySearchClickRankDetail(
        rankName: String,
        linkId: String = "",
        linkType: String = "",
        linkTitle: String = ""
    ) {
        val json = json {
            KEY_EVENT to "click_search_rank_detail"
            "rank_name" to rankName
            "link_id" to linkId
            "link_type" to linkType
            "link_title" to linkTitle
            parseAndPutMeta().invoke(this)
        }
        log(json, "bbs_community")
    }

    // 首页下拉推送触发
    @JvmStatic
    fun logHomePushTrigger(pushId: String, count: Int, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "home_push_trigger"
            "home_push_id" to pushId
            "count_num" to count
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 首页下拉推送显示
    @JvmStatic
    fun logHomePushShow(pushId: String, action: String, count: Int, gameId: String, gameName: String) {
        val json = json {
            KEY_EVENT to "home_push_show"
            "home_push_id" to pushId
            "action" to action
            "count_num" to count
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    // 首页下拉推送消失
    @JvmStatic
    fun logHomePushClose(pushId: String, action: String, count: Int, gameId: String, gameName: String, interval: Int) {
        val json = json {
            KEY_EVENT to "home_push_close"
            "home_push_id" to pushId
            "action" to action
            "count_num" to count
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            "interval" to interval
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    /**
     * 埋点序号：24
     * 事件ID：halo_fun_login_from_ghzs_show
     * 事件名称：光环助手登录授权界面
     * 触发时机：畅玩助手点击授权登录跳转光环助手展示对应界面时
     * @param gameId 畅玩助手当前运行的游戏ID
     * @param gameName 畅玩助手当前运行的游戏名称
     */
    fun logLoginFromGHZSShow(
        gameId: String,
        gameName: String
    ) {
        val json = json {
            KEY_EVENT to EVENT_LOGIN_FROM_GHZS_SHOW
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }

    /**
     * 埋点序号：25
     * 事件ID：halo_fun_login_from_ghzs_click
     * 事件名称：光环助手登录授权界面点击事件
     * 触发时机：点击相关按钮时
     * @param gameId 畅玩助手当前运行的游戏ID
     * @param gameName 畅玩助手当前运行的游戏名称
     * @param buttonType 按钮：确定\返回
     */
    fun logLoginFromGHZSClick(
        gameId: String,
        gameName: String,
        buttonType: String
    ) {
        val json = json {
            KEY_EVENT to EVENT_LOGIN_FROM_GHZS_CLICK
            KEY_GAME_ID to gameId
            KEY_GAME_NAME to gameName
            KEY_BUTTON_TYPE to buttonType
            parseAndPutMeta().invoke(this)
        }
        log(json)
    }
}