package com.gamedog.statisticreporter

import com.gamedog.statisticreporter.firbase.FireBaseManager
import com.gamedog.statisticreporter.shushu.ShushuManager
import com.remax.base.report.DataReportManager
import com.remax.base.report.DataReporter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

object StatisticUtil {

    private val mBgScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)

    const val KEY_Loading_Start: String = "Loading_Start"
    const val KEY_Loading_End: String = "Loading_End"
    const val KEY_Home_Show: String = "Home_Show"
    const val KEY_Guide: String = "Guide"
    const val KEY_RV_Button_Show: String = "RV_Button_Show"
    const val KEY_RV_Button_Click_Game: String = "RV_Button_Click_Game"
    const val KEY_Video_Play_Start: String = "Video_Play_Start"
    const val KEY_Video_Play_End: String = "Video_Play_End"
    const val KEY_Welfare_Show: String = "Welfare_Show"
    const val KEY_Chest_Claim_Click: String = "Chest_Claim_Click"
    const val KEY_Welfare_Task_Click: String = "Welfare_Task_Click"
    const val KEY_H5_Button_Click: String = "H5_Button_Click"
    const val KEY_H5_Show: String = "H5_Show"
    const val KEY_lottery_Button_Click: String = "lottery_Button_Click"
    const val KEY_lottery_Show: String = "lottery_Show"
    const val KEY_Daily_Task_Complete: String = "Daily_Task_Complete"
    const val KEY_Daily_Sign: String = "Daily_Sign"
    const val KEY_Withdraw_Click: String = "Withdraw_Click"
    const val KEY_Withdrawal_Show: String = "Withdrawal_Show"
    const val KEY_Withdrawal_finsh: String = "Withdrawal_finsh"
    const val KEY_Withdrawal_Info: String = "Withdrawal_Info"
    const val KEY_Withdrawal_Apply: String = "Withdrawal_Apply"
    const val KEY_Withdrawal_Reason: String = "Withdrawal_Reason"
    const val KEY_Push_Request_Show: String = "Push_Request_Show"
    const val KEY_Push_Request_Result: String = "Push_Request_Result"
    const val KEY_Push_Show: String = "Push_Show"
    const val KEY_Push_Click: String = "Push_Click"
    const val KEY_Push_EnterGame: String = "Push_EnterGame"
    const val KEY_adjust_init: String = "adjust_init"
    const val KEY_adjust_get_success: String = "adjust_get_success"
    const val ad_click: String = "ad_click"
    const val KEY_ad_close: String = "ad_close"
    const val KEY_ad_start_load: String = "ad_start_load"
    const val KEY_ad_loaded: String = "ad_loaded"
    const val KEY_ad_load_fail: String = "ad_load_fail"
    const val KEY_ad_show_fail: String = "ad_show_fail"
    const val KEY_ad_position: String = "ad_position"
    const val KEY_ad_impression: String = "ad_impression"
    

    fun reportEvents(eventKey: String, eventData: Map<String, Any>? = null) {
        mBgScope.launch {
            FireBaseManager.instance().reportEvent(eventKey, eventData)
            ShushuManager.instance().reportEvent(eventKey, eventData)
        }
    }


    init {
        initAdReporter()
    }


    private fun initAdReporter() {
        DataReportManager.addReporters(object : DataReporter {
            override fun getName(): String {
                return "Firebase&Shushu"
            }

            override fun reportData(
                eventName: String,
                data: Map<String, Any>
            ) {
                StatisticUtil.reportEvents(eventName, data)
            }

            override fun setCommonParams(params: Map<String, Any>) {
                val aaa = 1
            }

            override fun setUserParams(params: Map<String, Any>) {
                val aaa = 1
            }
        })
    }

}


