【埋点】广告点击事件和广告收益上报事件中 position 属性上报不一致
This commit is contained in:
parent
090e819e84
commit
3745010e38
|
|
@ -37,6 +37,7 @@ object VidiConst {
|
||||||
const val WATCH_AD_FOR_DAILY_SIGN_SINGLE = 8
|
const val WATCH_AD_FOR_DAILY_SIGN_SINGLE = 8
|
||||||
const val WATCH_AD_FOR_DAILY_SIGN_DOUBLE = 9
|
const val WATCH_AD_FOR_DAILY_SIGN_DOUBLE = 9
|
||||||
const val WATCH_AD_FOR_DAILY_SIGN_COMPLEMENT = 10
|
const val WATCH_AD_FOR_DAILY_SIGN_COMPLEMENT = 10
|
||||||
|
const val WATCH_AD_FOR_DAILY_EARN_GOLD_POPMENU = 11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ object VidiStatisticHelper {
|
||||||
return "RV_VideoStream"
|
return "RV_VideoStream"
|
||||||
}
|
}
|
||||||
|
|
||||||
VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD -> {
|
VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD_POPMENU -> {
|
||||||
return "RV_Home_Menu"
|
return "RV_Home_Menu"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity
|
||||||
import com.ama.core.architecture.util.AndroidUtil
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
import com.gamedog.vididin.VidiConst
|
import com.gamedog.vididin.VidiConst
|
||||||
|
import com.gamedog.vididin.VidiStatisticHelper
|
||||||
import com.gamedog.vididin.VididinEvents
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
|
@ -117,7 +118,7 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
||||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_DAILY_WATCH_AD
|
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_DAILY_WATCH_AD
|
||||||
}
|
}
|
||||||
|
|
||||||
VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD -> {
|
VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD_POPMENU, VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD -> {
|
||||||
shouldNotifyOneAdWatched = true
|
shouldNotifyOneAdWatched = true
|
||||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_EARN_GOLD
|
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_EARN_GOLD
|
||||||
}
|
}
|
||||||
|
|
@ -192,11 +193,12 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
|
||||||
if (!mIsLoadSuccess) {
|
if (!mIsLoadSuccess) {
|
||||||
handleLoadFailed()
|
handleLoadFailed()
|
||||||
}
|
}
|
||||||
}, 3000)
|
}, 30000)
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
when(AdShowExt.showRewardedVideoAd(this@WatchAdActivity, { rewardedData ->
|
when(AdShowExt.showRewardedVideoAd(this@WatchAdActivity,
|
||||||
|
VidiStatisticHelper.getShowFromStr(mWatchType), { rewardedData ->
|
||||||
mRewardedDollarNum = rewardedData.rewardNum
|
mRewardedDollarNum = rewardedData.rewardNum
|
||||||
}, {
|
}, {
|
||||||
notifyAdWatchFinish()
|
notifyAdWatchFinish()
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class HomeFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnSwit
|
||||||
StatisticUtil.reportEvents(StatisticUtil.KEY_Chest_Claim_Click)
|
StatisticUtil.reportEvents(StatisticUtil.KEY_Chest_Claim_Click)
|
||||||
},
|
},
|
||||||
PopMenuView.MenuItem(R.mipmap.home_menu_2,R.mipmap.icon_gold_ss_new, 0) {
|
PopMenuView.MenuItem(R.mipmap.home_menu_2,R.mipmap.icon_gold_ss_new, 0) {
|
||||||
WatchAdDialog(requireActivity(), VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD, WatchAdDialog.FROM_HOME_MENU,null).show()
|
WatchAdDialog(requireActivity(), VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD_POPMENU, WatchAdDialog.FROM_HOME_MENU,null).show()
|
||||||
},
|
},
|
||||||
PopMenuView.MenuItem(R.mipmap.home_menu_3,0, 0) {
|
PopMenuView.MenuItem(R.mipmap.home_menu_3,0, 0) {
|
||||||
Router.Game.startActivity(requireActivity())
|
Router.Game.startActivity(requireActivity())
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ class RewardedAdController private constructor() {
|
||||||
/**
|
/**
|
||||||
* 预加载广告
|
* 预加载广告
|
||||||
*/
|
*/
|
||||||
suspend fun preloadAd(context: Context, adUnitId: String? = null): AdResult<Unit> {
|
suspend fun preloadAd(context: Context, adUnitId: String? = null, positionStr: String): AdResult<Unit> {
|
||||||
if(!GlobalAdSwitchInterceptor.isGlobalAdEnabled()){
|
if(!GlobalAdSwitchInterceptor.isGlobalAdEnabled()){
|
||||||
return AdResult.Failure(
|
return AdResult.Failure(
|
||||||
AdException(
|
AdException(
|
||||||
|
|
@ -126,7 +126,7 @@ class RewardedAdController private constructor() {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
val finalAdUnitId = adUnitId ?: BuildConfig.ADMOB_REWARDED_ID
|
val finalAdUnitId = adUnitId ?: BuildConfig.ADMOB_REWARDED_ID
|
||||||
return loadAdToCache(context, finalAdUnitId)
|
return loadAdToCache(context, finalAdUnitId, positionStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,6 +134,7 @@ class RewardedAdController private constructor() {
|
||||||
*/
|
*/
|
||||||
suspend fun showAd(
|
suspend fun showAd(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
positionStr: String,
|
||||||
adUnitId: String? = null,
|
adUnitId: String? = null,
|
||||||
onRewardEarned: ((RewardItem, CommonRewardedData) -> Unit)? = null,
|
onRewardEarned: ((RewardItem, CommonRewardedData) -> Unit)? = null,
|
||||||
closeCallback: () -> Unit,
|
closeCallback: () -> Unit,
|
||||||
|
|
@ -149,7 +150,7 @@ class RewardedAdController private constructor() {
|
||||||
eventName = "ad_position",
|
eventName = "ad_position",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to finalAdUnitId,
|
"ad_unit_name" to finalAdUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowTriggerCount
|
"number" to totalShowTriggerCount
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -165,7 +166,7 @@ class RewardedAdController private constructor() {
|
||||||
// eventName = "ad_show_fail",
|
// eventName = "ad_show_fail",
|
||||||
// params = mapOf(
|
// params = mapOf(
|
||||||
// "ad_unit_name" to finalAdUnitId,
|
// "ad_unit_name" to finalAdUnitId,
|
||||||
// "position" to PositionGet.get(),
|
// "position" to positionStr,
|
||||||
// "number" to totalShowFailCount,
|
// "number" to totalShowFailCount,
|
||||||
// "reason" to interceptResult.error.message
|
// "reason" to interceptResult.error.message
|
||||||
// )
|
// )
|
||||||
|
|
@ -185,7 +186,7 @@ class RewardedAdController private constructor() {
|
||||||
// 激励广告阻塞loading
|
// 激励广告阻塞loading
|
||||||
ADLoadingDialog.show(activity)
|
ADLoadingDialog.show(activity)
|
||||||
AdLogger.d("Admob缓存为空,立即加载激励广告,广告位ID: %s", finalAdUnitId)
|
AdLogger.d("Admob缓存为空,立即加载激励广告,广告位ID: %s", finalAdUnitId)
|
||||||
loadAdToCache(activity, finalAdUnitId)
|
loadAdToCache(activity, finalAdUnitId, positionStr)
|
||||||
cachedAd = getCachedAd(finalAdUnitId)
|
cachedAd = getCachedAd(finalAdUnitId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,7 +196,7 @@ class RewardedAdController private constructor() {
|
||||||
AdLogger.d("Admob使用缓存中的激励广告,广告位ID: %s", finalAdUnitId)
|
AdLogger.d("Admob使用缓存中的激励广告,广告位ID: %s", finalAdUnitId)
|
||||||
|
|
||||||
// 3. 显示广告
|
// 3. 显示广告
|
||||||
val result = showAdInternal(activity, cachedAd.ad, finalAdUnitId, onRewardEarned, closeCallback)
|
val result = showAdInternal(activity, positionStr,cachedAd.ad, finalAdUnitId, onRewardEarned, closeCallback)
|
||||||
|
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -212,7 +213,7 @@ class RewardedAdController private constructor() {
|
||||||
/**
|
/**
|
||||||
* 基础广告加载方法(可复用)
|
* 基础广告加载方法(可复用)
|
||||||
*/
|
*/
|
||||||
private suspend fun loadAd(context: Context, adUnitId: String): RewardedAd? {
|
private suspend fun loadAd(context: Context, adUnitId: String, positionStr: String): RewardedAd? {
|
||||||
// 累积加载次数统计
|
// 累积加载次数统计
|
||||||
totalLoadCount++
|
totalLoadCount++
|
||||||
AdLogger.d("Admob激励广告累积加载次数: $totalLoadCount")
|
AdLogger.d("Admob激励广告累积加载次数: $totalLoadCount")
|
||||||
|
|
@ -258,7 +259,7 @@ class RewardedAdController private constructor() {
|
||||||
eventName = "ad_impression",
|
eventName = "ad_impression",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowCount,
|
"number" to totalShowCount,
|
||||||
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
||||||
"value" to (currentAdValue?.let { it.valueMicros / 1_000_000.0 }
|
"value" to (currentAdValue?.let { it.valueMicros / 1_000_000.0 }
|
||||||
|
|
@ -305,7 +306,7 @@ class RewardedAdController private constructor() {
|
||||||
/**
|
/**
|
||||||
* 加载广告到缓存
|
* 加载广告到缓存
|
||||||
*/
|
*/
|
||||||
suspend fun loadAdToCache(context: Context, adUnitId: String): AdResult<Unit> {
|
suspend fun loadAdToCache(context: Context, adUnitId: String, positionStr: String): AdResult<Unit> {
|
||||||
return try {
|
return try {
|
||||||
|
|
||||||
// 检查缓存是否已满
|
// 检查缓存是否已满
|
||||||
|
|
@ -316,7 +317,7 @@ class RewardedAdController private constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载广告
|
// 加载广告
|
||||||
val rewardedAd = loadAd(context, adUnitId)
|
val rewardedAd = loadAd(context, adUnitId, positionStr)
|
||||||
if (rewardedAd != null) {
|
if (rewardedAd != null) {
|
||||||
synchronized(adCachePool) {
|
synchronized(adCachePool) {
|
||||||
adCachePool.add(CachedRewardedAd(rewardedAd, adUnitId))
|
adCachePool.add(CachedRewardedAd(rewardedAd, adUnitId))
|
||||||
|
|
@ -379,6 +380,7 @@ class RewardedAdController private constructor() {
|
||||||
*/
|
*/
|
||||||
private suspend fun showAdInternal(
|
private suspend fun showAdInternal(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
positionStr: String,
|
||||||
rewardedAd: RewardedAd,
|
rewardedAd: RewardedAd,
|
||||||
adUnitId: String,
|
adUnitId: String,
|
||||||
onRewardEarned: ((RewardItem, CommonRewardedData) -> Unit)?,
|
onRewardEarned: ((RewardItem, CommonRewardedData) -> Unit)?,
|
||||||
|
|
@ -399,7 +401,7 @@ class RewardedAdController private constructor() {
|
||||||
eventName = "ad_close",
|
eventName = "ad_close",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalCloseCount,
|
"number" to totalCloseCount,
|
||||||
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
||||||
"value" to (currentAdValue?.let { it.valueMicros / 1_000_000.0 }
|
"value" to (currentAdValue?.let { it.valueMicros / 1_000_000.0 }
|
||||||
|
|
@ -428,7 +430,7 @@ class RewardedAdController private constructor() {
|
||||||
eventName = "ad_show_fail",
|
eventName = "ad_show_fail",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowFailCount,
|
"number" to totalShowFailCount,
|
||||||
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
||||||
"reason" to adError.message
|
"reason" to adError.message
|
||||||
|
|
@ -460,7 +462,7 @@ class RewardedAdController private constructor() {
|
||||||
eventName = "ad_click",
|
eventName = "ad_click",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalClickCount,
|
"number" to totalClickCount,
|
||||||
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
"ad_source" to (rewardedAd.responseInfo?.loadedAdapterResponseInfo?.adSourceName.orEmpty()),
|
||||||
"value" to (currentAdValue?.let { it.valueMicros / 1_000_000.0 }
|
"value" to (currentAdValue?.let { it.valueMicros / 1_000_000.0 }
|
||||||
|
|
@ -500,7 +502,7 @@ class RewardedAdController private constructor() {
|
||||||
eventName = "ad_reward_earned",
|
eventName = "ad_reward_earned",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalRewardEarnedCount,
|
"number" to totalRewardEarnedCount,
|
||||||
"reward_type" to rewardItem.type,
|
"reward_type" to rewardItem.type,
|
||||||
"reward_amount" to rewardItem.amount,
|
"reward_amount" to rewardItem.amount,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ object RewardedBiddingManager {
|
||||||
|
|
||||||
suspend fun bidding(
|
suspend fun bidding(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
positionStr: String,
|
||||||
admobAdUnitId: String = BuildConfig.ADMOB_REWARDED_ID,
|
admobAdUnitId: String = BuildConfig.ADMOB_REWARDED_ID,
|
||||||
pangleAdUnitId: String = BuildConfig.PANGLE_REWARDED_ID,
|
pangleAdUnitId: String = BuildConfig.PANGLE_REWARDED_ID,
|
||||||
toponPlacementId: String = BuildConfig.TOPON_REWARDED_ID,
|
toponPlacementId: String = BuildConfig.TOPON_REWARDED_ID,
|
||||||
|
|
@ -34,17 +35,18 @@ object RewardedBiddingManager {
|
||||||
AdSourceController.AdSource.TOPON -> BiddingWinner.TOPON
|
AdSourceController.AdSource.TOPON -> BiddingWinner.TOPON
|
||||||
AdSourceController.AdSource.BIDDING -> {
|
AdSourceController.AdSource.BIDDING -> {
|
||||||
// 不会执行到这里,但为了完整性保留
|
// 不会执行到这里,但为了完整性保留
|
||||||
performBidding(context, admobAdUnitId, pangleAdUnitId, toponPlacementId)
|
performBidding(context, positionStr, admobAdUnitId, pangleAdUnitId, toponPlacementId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用竞价逻辑
|
// 使用竞价逻辑
|
||||||
return performBidding(context, admobAdUnitId, pangleAdUnitId, toponPlacementId)
|
return performBidding(context, positionStr, admobAdUnitId, pangleAdUnitId, toponPlacementId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun performBidding(
|
private suspend fun performBidding(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
positionStr: String,
|
||||||
admobAdUnitId: String,
|
admobAdUnitId: String,
|
||||||
pangleAdUnitId: String,
|
pangleAdUnitId: String,
|
||||||
toponPlacementId: String,
|
toponPlacementId: String,
|
||||||
|
|
@ -58,7 +60,7 @@ object RewardedBiddingManager {
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
val admobDeferred = async {
|
val admobDeferred = async {
|
||||||
runCatching {
|
runCatching {
|
||||||
admobController.loadAdToCache(context, admobAdUnitId)
|
admobController.loadAdToCache(context, admobAdUnitId, positionStr)
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
val pangleDeferred = async {
|
val pangleDeferred = async {
|
||||||
|
|
@ -68,7 +70,7 @@ object RewardedBiddingManager {
|
||||||
}
|
}
|
||||||
val toponDeferred = async {
|
val toponDeferred = async {
|
||||||
runCatching {
|
runCatching {
|
||||||
toponController.preloadAd(context, toponPlacementId)
|
toponController.preloadAd(context, positionStr, toponPlacementId)
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
// 等待所有加载完成
|
// 等待所有加载完成
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import com.iab.omid.library.bigosg.adsession.media.Position
|
||||||
import com.remax.bill.BuildConfig
|
import com.remax.bill.BuildConfig
|
||||||
import com.remax.bill.ads.AdResult
|
import com.remax.bill.ads.AdResult
|
||||||
import com.remax.bill.ads.AppOpenAdController
|
import com.remax.bill.ads.AppOpenAdController
|
||||||
|
|
@ -294,12 +295,13 @@ object AdShowExt {
|
||||||
*/
|
*/
|
||||||
suspend fun showRewardedVideoAd(
|
suspend fun showRewardedVideoAd(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
positionStr: String,
|
||||||
rewardCallback: ((CommonRewardedData) -> Unit)? = null,
|
rewardCallback: ((CommonRewardedData) -> Unit)? = null,
|
||||||
closeCallback: ()->Unit,
|
closeCallback: ()->Unit,
|
||||||
readyCallback:() -> Unit,
|
readyCallback:() -> Unit,
|
||||||
): AdResult<Unit> {
|
): AdResult<Unit> {
|
||||||
AdLogger.d("激励视频广告竞价开始")
|
AdLogger.d("激励视频广告竞价开始")
|
||||||
val winner = RewardedBiddingManager.bidding(activity)
|
val winner = RewardedBiddingManager.bidding(activity, positionStr)
|
||||||
AdLogger.d("激励视频广告竞价结果: $winner")
|
AdLogger.d("激励视频广告竞价结果: $winner")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -308,7 +310,7 @@ object AdShowExt {
|
||||||
BiddingWinner.ADMOB -> {
|
BiddingWinner.ADMOB -> {
|
||||||
AdLogger.d("使用 AdMob 展示激励视频广告")
|
AdLogger.d("使用 AdMob 展示激励视频广告")
|
||||||
RewardedAdController.getInstance().showAd(
|
RewardedAdController.getInstance().showAd(
|
||||||
activity,
|
activity, positionStr,
|
||||||
BuildConfig.ADMOB_REWARDED_ID,
|
BuildConfig.ADMOB_REWARDED_ID,
|
||||||
{ rewardItem, commonRewardedData ->
|
{ rewardItem, commonRewardedData ->
|
||||||
rewardCallback?.invoke(commonRewardedData)
|
rewardCallback?.invoke(commonRewardedData)
|
||||||
|
|
@ -319,7 +321,7 @@ object AdShowExt {
|
||||||
BiddingWinner.PANGLE -> {
|
BiddingWinner.PANGLE -> {
|
||||||
AdLogger.d("使用 Pangle 展示激励视频广告")
|
AdLogger.d("使用 Pangle 展示激励视频广告")
|
||||||
PangleRewardedAdController.getInstance().showAd(
|
PangleRewardedAdController.getInstance().showAd(
|
||||||
activity,
|
activity, positionStr,
|
||||||
BuildConfig.PANGLE_REWARDED_ID,
|
BuildConfig.PANGLE_REWARDED_ID,
|
||||||
{ pagRewardItem, commonRewardedData ->
|
{ pagRewardItem, commonRewardedData ->
|
||||||
rewardCallback?.invoke(commonRewardedData)
|
rewardCallback?.invoke(commonRewardedData)
|
||||||
|
|
@ -330,7 +332,7 @@ object AdShowExt {
|
||||||
BiddingWinner.TOPON -> {
|
BiddingWinner.TOPON -> {
|
||||||
AdLogger.d("使用 TopOn 展示激励视频广告")
|
AdLogger.d("使用 TopOn 展示激励视频广告")
|
||||||
TopOnRewardedAdController.getInstance().showAd(
|
TopOnRewardedAdController.getInstance().showAd(
|
||||||
activity,
|
activity, positionStr,
|
||||||
BuildConfig.TOPON_REWARDED_ID,
|
BuildConfig.TOPON_REWARDED_ID,
|
||||||
{ _, _, revenueValue ->
|
{ _, _, revenueValue ->
|
||||||
val rewardedData = CommonRewardedData(revenueValue.toDouble())
|
val rewardedData = CommonRewardedData(revenueValue.toDouble())
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
|
|
||||||
suspend fun showAd(
|
suspend fun showAd(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
positionStr: String,
|
||||||
adUnitId: String? = null,
|
adUnitId: String? = null,
|
||||||
onRewardEarned: ((PAGRewardItem, CommonRewardedData) -> Unit)? = null,
|
onRewardEarned: ((PAGRewardItem, CommonRewardedData) -> Unit)? = null,
|
||||||
closeCallback: () -> Unit, readyCallback:() -> Unit,
|
closeCallback: () -> Unit, readyCallback:() -> Unit,
|
||||||
|
|
@ -112,7 +113,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_position",
|
eventName = "ad_position",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to finalAdUnitId,
|
"ad_unit_name" to finalAdUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowTriggerCount
|
"number" to totalShowTriggerCount
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -124,7 +125,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
// eventName = "ad_show_fail",
|
// eventName = "ad_show_fail",
|
||||||
// params = mapOf(
|
// params = mapOf(
|
||||||
// "ad_unit_name" to finalAdUnitId,
|
// "ad_unit_name" to finalAdUnitId,
|
||||||
// "position" to PositionGet.get(),
|
// "position" to positionStr,
|
||||||
// "number" to totalShowFailCount,
|
// "number" to totalShowFailCount,
|
||||||
// "reason" to interceptResult.error.message
|
// "reason" to interceptResult.error.message
|
||||||
// )
|
// )
|
||||||
|
|
@ -150,7 +151,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
currentRewardedAd = null
|
currentRewardedAd = null
|
||||||
currentAdUnitId = null
|
currentAdUnitId = null
|
||||||
readyCallback.invoke()
|
readyCallback.invoke()
|
||||||
showAdInternal(activity, ad, finalAdUnitId, onRewardEarned, closeCallback)
|
showAdInternal(activity, positionStr,ad, finalAdUnitId, onRewardEarned, closeCallback)
|
||||||
} else {
|
} else {
|
||||||
ADLoadingDialog.hide()
|
ADLoadingDialog.hide()
|
||||||
totalShowFailCount++
|
totalShowFailCount++
|
||||||
|
|
@ -158,7 +159,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_show_fail",
|
eventName = "ad_show_fail",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to finalAdUnitId,
|
"ad_unit_name" to finalAdUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowFailCount,
|
"number" to totalShowFailCount,
|
||||||
"reason" to "load_failed"
|
"reason" to "load_failed"
|
||||||
)
|
)
|
||||||
|
|
@ -172,7 +173,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_show_fail",
|
eventName = "ad_show_fail",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to finalAdUnitId,
|
"ad_unit_name" to finalAdUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowFailCount,
|
"number" to totalShowFailCount,
|
||||||
"reason" to e.message.orEmpty()
|
"reason" to e.message.orEmpty()
|
||||||
)
|
)
|
||||||
|
|
@ -248,6 +249,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
|
|
||||||
private suspend fun showAdInternal(
|
private suspend fun showAdInternal(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
positionStr: String,
|
||||||
rewardedAd: PAGRewardedAd,
|
rewardedAd: PAGRewardedAd,
|
||||||
adUnitId: String,
|
adUnitId: String,
|
||||||
onRewardEarned: ((PAGRewardItem, CommonRewardedData) -> Unit)?,
|
onRewardEarned: ((PAGRewardItem, CommonRewardedData) -> Unit)?,
|
||||||
|
|
@ -282,7 +284,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_impression",
|
eventName = "ad_impression",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowCount,
|
"number" to totalShowCount,
|
||||||
"ad_source" to (currentAdSource ?: "Pangle"),
|
"ad_source" to (currentAdSource ?: "Pangle"),
|
||||||
"value" to impressionValue,
|
"value" to impressionValue,
|
||||||
|
|
@ -320,7 +322,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_click",
|
eventName = "ad_click",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalClickCount,
|
"number" to totalClickCount,
|
||||||
"ad_source" to (currentAdSource ?: "Pangle"),
|
"ad_source" to (currentAdSource ?: "Pangle"),
|
||||||
"value" to (rewardedAd.pagRevenueInfo?.showEcpm?.revenue?.toDoubleOrNull() ?: 0.0),
|
"value" to (rewardedAd.pagRevenueInfo?.showEcpm?.revenue?.toDoubleOrNull() ?: 0.0),
|
||||||
|
|
@ -334,6 +336,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
isShowing = false
|
isShowing = false
|
||||||
closeEvent(
|
closeEvent(
|
||||||
adUnitId = adUnitId,
|
adUnitId = adUnitId,
|
||||||
|
positionStr,
|
||||||
adSource = currentAdSource,
|
adSource = currentAdSource,
|
||||||
valueUsd = currentRevenueUsd,
|
valueUsd = currentRevenueUsd,
|
||||||
currencyCode = currentCurrency,
|
currencyCode = currentCurrency,
|
||||||
|
|
@ -365,7 +368,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_reward_earned",
|
eventName = "ad_reward_earned",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalRewardEarnedCount,
|
"number" to totalRewardEarnedCount,
|
||||||
"reward_name" to rewardItem.rewardName,
|
"reward_name" to rewardItem.rewardName,
|
||||||
"reward_amount" to rewardItem.rewardAmount,
|
"reward_amount" to rewardItem.rewardAmount,
|
||||||
|
|
@ -401,7 +404,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_show_fail",
|
eventName = "ad_show_fail",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowFailCount,
|
"number" to totalShowFailCount,
|
||||||
"reason" to model.errorMessage.orEmpty(),
|
"reason" to model.errorMessage.orEmpty(),
|
||||||
"ad_source" to (currentAdSource ?: "Pangle")
|
"ad_source" to (currentAdSource ?: "Pangle")
|
||||||
|
|
@ -419,7 +422,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_show_fail",
|
eventName = "ad_show_fail",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowFailCount,
|
"number" to totalShowFailCount,
|
||||||
"reason" to "rewarded_not_ready",
|
"reason" to "rewarded_not_ready",
|
||||||
"ad_source" to (currentAdSource ?: "Pangle")
|
"ad_source" to (currentAdSource ?: "Pangle")
|
||||||
|
|
@ -439,7 +442,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_show_fail",
|
eventName = "ad_show_fail",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowFailCount,
|
"number" to totalShowFailCount,
|
||||||
"reason" to e.message.orEmpty(),
|
"reason" to e.message.orEmpty(),
|
||||||
"ad_source" to (currentAdSource ?: "Pangle")
|
"ad_source" to (currentAdSource ?: "Pangle")
|
||||||
|
|
@ -464,6 +467,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
|
|
||||||
private fun closeEvent(
|
private fun closeEvent(
|
||||||
adUnitId: String,
|
adUnitId: String,
|
||||||
|
positionStr: String,
|
||||||
adSource: String? = "Pangle",
|
adSource: String? = "Pangle",
|
||||||
valueUsd: Double? = null,
|
valueUsd: Double? = null,
|
||||||
currencyCode: String? = null,
|
currencyCode: String? = null,
|
||||||
|
|
@ -474,7 +478,7 @@ class PangleRewardedAdController private constructor() {
|
||||||
eventName = "ad_close",
|
eventName = "ad_close",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to adUnitId,
|
"ad_unit_name" to adUnitId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalCloseCount,
|
"number" to totalCloseCount,
|
||||||
"ad_source" to (adSource ?: "Pangle"),
|
"ad_source" to (adSource ?: "Pangle"),
|
||||||
"value" to (valueUsd ?: 0.0),
|
"value" to (valueUsd ?: 0.0),
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
/**
|
/**
|
||||||
* 预加载广告
|
* 预加载广告
|
||||||
*/
|
*/
|
||||||
suspend fun preloadAd(context: Context, placementId: String? = null): AdResult<Unit> {
|
suspend fun preloadAd(context: Context, positionStr: String, placementId: String? = null): AdResult<Unit> {
|
||||||
if (!GlobalAdSwitchInterceptor.isGlobalAdEnabled()) {
|
if (!GlobalAdSwitchInterceptor.isGlobalAdEnabled()) {
|
||||||
return AdResult.Failure(
|
return AdResult.Failure(
|
||||||
AdException(
|
AdException(
|
||||||
|
|
@ -117,7 +117,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
return AdResult.Success(Unit)
|
return AdResult.Success(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (loadAd(context, finalPlacementId) != null) {
|
return if (loadAd(context, positionStr, finalPlacementId) != null) {
|
||||||
AdResult.Success(Unit)
|
AdResult.Success(Unit)
|
||||||
} else {
|
} else {
|
||||||
AdResult.Failure(createAdException("广告加载失败"))
|
AdResult.Failure(createAdException("广告加载失败"))
|
||||||
|
|
@ -129,6 +129,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
*/
|
*/
|
||||||
suspend fun showAd(
|
suspend fun showAd(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
positionStr: String,
|
||||||
placementId: String? = null,
|
placementId: String? = null,
|
||||||
onRewardEarned: ((String, Int, Double) -> Unit)? = null,
|
onRewardEarned: ((String, Int, Double) -> Unit)? = null,
|
||||||
closeCallback: ()->Unit, readyCallback:() -> Unit,
|
closeCallback: ()->Unit, readyCallback:() -> Unit,
|
||||||
|
|
@ -145,7 +146,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
eventName = "ad_position",
|
eventName = "ad_position",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to finalPlacementId,
|
"ad_unit_name" to finalPlacementId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowTriggerCount
|
"number" to totalShowTriggerCount
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -159,7 +160,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
// eventName = "ad_show_fail",
|
// eventName = "ad_show_fail",
|
||||||
// params = mapOf(
|
// params = mapOf(
|
||||||
// "ad_unit_name" to finalPlacementId,
|
// "ad_unit_name" to finalPlacementId,
|
||||||
// "position" to PositionGet.get(),
|
// "position" to positionStr,
|
||||||
// "number" to totalShowFailCount,
|
// "number" to totalShowFailCount,
|
||||||
// "reason" to interceptResult.error.message
|
// "reason" to interceptResult.error.message
|
||||||
// )
|
// )
|
||||||
|
|
@ -176,7 +177,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
|
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
ADLoadingDialog.show(activity)
|
ADLoadingDialog.show(activity)
|
||||||
loadAd(activity, finalPlacementId)
|
loadAd(activity, positionStr, finalPlacementId)
|
||||||
entry = synchronized(adCache) {
|
entry = synchronized(adCache) {
|
||||||
adCache[finalPlacementId]?.takeUnless { it.isExpired() }
|
adCache[finalPlacementId]?.takeUnless { it.isExpired() }
|
||||||
}
|
}
|
||||||
|
|
@ -202,7 +203,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
/**
|
/**
|
||||||
* 加载广告
|
* 加载广告
|
||||||
*/
|
*/
|
||||||
private suspend fun loadAd(context: Context, placementId: String): TopOnRewardedAdEntry? {
|
private suspend fun loadAd(context: Context, positionStr: String, placementId: String): TopOnRewardedAdEntry? {
|
||||||
totalLoadCount++
|
totalLoadCount++
|
||||||
AdLogger.d("TopOn激励广告开始加载,广告位ID: %s,当前累计加载次数: %d", placementId, totalLoadCount)
|
AdLogger.d("TopOn激励广告开始加载,广告位ID: %s,当前累计加载次数: %d", placementId, totalLoadCount)
|
||||||
|
|
||||||
|
|
@ -219,6 +220,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
val applicationContext = context.applicationContext
|
val applicationContext = context.applicationContext
|
||||||
val rewardedVideoAd = TURewardVideoAd(applicationContext, placementId)
|
val rewardedVideoAd = TURewardVideoAd(applicationContext, placementId)
|
||||||
val listener = TopOnRewardedVideoListener(
|
val listener = TopOnRewardedVideoListener(
|
||||||
|
positionStr = positionStr,
|
||||||
placementId = placementId,
|
placementId = placementId,
|
||||||
startLoadTime = System.currentTimeMillis(),
|
startLoadTime = System.currentTimeMillis(),
|
||||||
rewardedVideoAd = rewardedVideoAd,
|
rewardedVideoAd = rewardedVideoAd,
|
||||||
|
|
@ -286,6 +288,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
* TopOn 激励视频广告监听器
|
* TopOn 激励视频广告监听器
|
||||||
*/
|
*/
|
||||||
private inner class TopOnRewardedVideoListener(
|
private inner class TopOnRewardedVideoListener(
|
||||||
|
private val positionStr: String,
|
||||||
private val placementId: String,
|
private val placementId: String,
|
||||||
private val startLoadTime: Long,
|
private val startLoadTime: Long,
|
||||||
private val rewardedVideoAd: TURewardVideoAd,
|
private val rewardedVideoAd: TURewardVideoAd,
|
||||||
|
|
@ -443,7 +446,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
eventName = "ad_show_fail",
|
eventName = "ad_show_fail",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to placementId,
|
"ad_unit_name" to placementId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowFailCount,
|
"number" to totalShowFailCount,
|
||||||
"ad_source" to (adInfo?.networkName ?: ""),
|
"ad_source" to (adInfo?.networkName ?: ""),
|
||||||
"reason" to (adError.desc ?: adError.getFullErrorInfo())
|
"reason" to (adError.desc ?: adError.getFullErrorInfo())
|
||||||
|
|
@ -467,7 +470,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
eventName = "ad_close",
|
eventName = "ad_close",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to placementId,
|
"ad_unit_name" to placementId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalCloseCount,
|
"number" to totalCloseCount,
|
||||||
"ad_source" to (adInfo.networkName ?: ""),
|
"ad_source" to (adInfo.networkName ?: ""),
|
||||||
"value" to (adInfo.publisherRevenue ?: 0.0),
|
"value" to (adInfo.publisherRevenue ?: 0.0),
|
||||||
|
|
@ -484,7 +487,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
CoroutineScope(SupervisorJob() + Dispatchers.IO).launch {
|
CoroutineScope(SupervisorJob() + Dispatchers.IO).launch {
|
||||||
try {
|
try {
|
||||||
AdLogger.d("TopOn激励广告关闭,开始重新预缓存,广告位ID: %s", placementId)
|
AdLogger.d("TopOn激励广告关闭,开始重新预缓存,广告位ID: %s", placementId)
|
||||||
preloadAd(applicationContext, placementId)
|
preloadAd(applicationContext, positionStr, placementId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
AdLogger.e("TopOn激励广告重新预缓存失败", e)
|
AdLogger.e("TopOn激励广告重新预缓存失败", e)
|
||||||
}
|
}
|
||||||
|
|
@ -507,7 +510,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
eventName = "ad_click",
|
eventName = "ad_click",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to placementId,
|
"ad_unit_name" to placementId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalClickCount,
|
"number" to totalClickCount,
|
||||||
"ad_source" to (adInfo.networkName ?: ""),
|
"ad_source" to (adInfo.networkName ?: ""),
|
||||||
"value" to (adInfo.publisherRevenue ?: 0.0),
|
"value" to (adInfo.publisherRevenue ?: 0.0),
|
||||||
|
|
@ -530,7 +533,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
eventName = "ad_reward_earned",
|
eventName = "ad_reward_earned",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to placementId,
|
"ad_unit_name" to placementId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalRewardEarnedCount,
|
"number" to totalRewardEarnedCount,
|
||||||
"reward_type" to rewardType,
|
"reward_type" to rewardType,
|
||||||
"reward_amount" to rewardAmount,
|
"reward_amount" to rewardAmount,
|
||||||
|
|
@ -555,7 +558,7 @@ class TopOnRewardedAdController private constructor() {
|
||||||
eventName = "ad_impression",
|
eventName = "ad_impression",
|
||||||
params = mapOf(
|
params = mapOf(
|
||||||
"ad_unit_name" to placementId,
|
"ad_unit_name" to placementId,
|
||||||
"position" to PositionGet.get(),
|
"position" to positionStr,
|
||||||
"number" to totalShowCount,
|
"number" to totalShowCount,
|
||||||
"ad_source" to (adInfo.networkName ?: ""),
|
"ad_source" to (adInfo.networkName ?: ""),
|
||||||
"value" to (adInfo.publisherRevenue ?: 0.0),
|
"value" to (adInfo.publisherRevenue ?: 0.0),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue