package com.gh.gamecenter.home.custom.tracker

import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.PageLocation
import com.gh.gamecenter.home.custom.model.CustomPageItem
import com.lightgame.download.DownloadEntity

class OtherItemTracker(private val pageLocation: PageLocation) {

    fun trackContentCardClick(item: CustomPageItem, link: LinkEntity) {
        SensorsBridge.trackContentCardClick(
            pageLocation.bottomTab,
            pageLocation.severalTabPageId,
            pageLocation.severalTabPageName,
            pageLocation.tabPosition,
            pageLocation.tabContent,
            pageLocation.pageId,
            pageLocation.pageName,
            link.link ?: "",
            link.type ?: "",
            link.text ?: ""
        )
    }

    fun trackPluginAreaClick(text: String, game: GameEntity?) {
        SensorsBridge.trackPluginAreaClick(
            text,
            pageLocation.bottomTab,
            pageLocation.severalTabPageId,
            pageLocation.severalTabPageName,
            pageLocation.tabPosition,
            pageLocation.tabContent,
            pageLocation.pageId,
            pageLocation.pageName,
            game?.id ?: "",
            game?.name ?: ""
        )
    }

    fun trackCWRecentlyPlayedClick(text: String, downloadEntity: DownloadEntity?) {
        SensorsBridge.trackCWRecentlyPlayedClick(
            text,
            pageLocation.bottomTab,
            pageLocation.severalTabPageId,
            pageLocation.severalTabPageName,
            pageLocation.tabPosition,
            pageLocation.tabContent,
            pageLocation.pageId,
            pageLocation.pageName,
            downloadEntity?.gameId ?: "",
            downloadEntity?.name ?: ""
        )
    }

    fun trackGameExploreClick(
        text: String,
        buttonType: String = "",
        game: GameEntity? = null,
        link: LinkEntity? = null
    ) {
        SensorsBridge.trackGameExploreClick(
            text,
            "首页",
            pageLocation.bottomTab,
            pageLocation.severalTabPageId,
            pageLocation.severalTabPageName,
            pageLocation.tabPosition,
            pageLocation.tabContent,
            pageLocation.pageId,
            pageLocation.pageName,
            game?.id ?: "",
            game?.name ?: "",
            link?.type ?: "",
            link?.link ?: "",
            link?.text ?: "",
            buttonType
        )
    }
}