package com.cheng.blzb.manager

import com.alibaba.fastjson.JSONObject
import com.cheng.blzb.net.ApiFactory
import com.example.base.utils.L
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody

object EventReportManager {

    fun eventReport(key: String?, value: String? = "", extra: String = "") {
        GlobalScope.launch {
            try {
                val jsonObject = JSONObject()
                jsonObject["source"] = "android"
                jsonObject["type"] = "click"
                jsonObject["key"] = key//点击的地方
                jsonObject["value"] = value
                jsonObject["extra"] = extra//附加参数
                L.d("TAG-->>${jsonObject}")
                ApiFactory.apiService.eventReport(jsonObject.toString().toRequestBody("application/json".toMediaType()))
            } catch (e: Exception) {
                e.printStackTrace()
            }
        }

    }

}