package com.gh.gamecenter

import android.app.Activity
import android.content.Context
import android.text.TextUtils
import com.bytedance.applog.AppLog
import com.bytedance.applog.InitConfig
import com.bytedance.applog.game.GameReportHelper
import com.bytedance.applog.util.UriConstants

import com.gh.gamecenter.common.exposure.meta.MetaUtil
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils

object TeaHelper {

    @JvmStatic
    fun init(context: Context, activity: Activity, channel: String) {
        val config = InitConfig("163824", channel)
        config.setUriConfig(UriConstants.DEFAULT)
        config.appName = "guanghuan1"
        config.setEnablePlay(true)
        config.isImeiEnable = false
        config.isMacEnable = false
        config.setAutoStart(true)
        config.isLogEnable = BuildConfig.DEBUG
        config.isAutoTrackEnabled = false
        AppLog.setEncryptAndCompress(true)
        AppLog.init(context, config, activity)

        AppLog.setOaidObserver {
            if (!TextUtils.isEmpty(it.id)) {
                HaloApp.getInstance().oaid = it.id
                MetaUtil.refreshMeta()
            }
            Utils.log("oaid is ${it.id}")
        }

        // gameReportHelper ?!
        GameReportHelper.onEventRegister("wechat", true)
        GameReportHelper.onEventPurchase("gift", "flower", "008", 1, "wechat", "¥", true, 1)
        Utils.log("init TeaHelper")
    }

    @JvmStatic
    fun onEvent(type: String) {
        AppLog.onEventV3(type)
    }

}