修复kwai上报广告位ID问题

This commit is contained in:
juncong lee 2025-09-22 10:53:09 +08:00
parent d5ec0e9ab1
commit 72be82d9f1
8 changed files with 58 additions and 34 deletions

View File

@ -244,16 +244,16 @@ namespace WZ
#endregion #endregion
#region #region
public void TrackAdImpression(AdsType type) public void TrackAdImpression(AdsType type,string adUnitId)
{ {
AdjustTrackEvent.Instance.TrackAdEvent(type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue, AdjustTrackEvent.Instance.TrackAdEvent(type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue,
ClientName, ClientName,
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId, adUnitId,
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId); adUnitId);
FireBaseAnalyticsManager.Instance.OnAdRevenueEvent(ClientName, FireBaseAnalyticsManager.Instance.OnAdRevenueEvent(ClientName,
ClientName, ClientName,
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId, adUnitId,
type, type,
type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue, type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue,
type == AdsType.Rewarded ? _rvPos : _ivPos, type == AdsType.Rewarded ? _rvPos : _ivPos,
@ -261,7 +261,7 @@ namespace WZ
ShuShuEvent.Instance.OnAdRevenueEvent(ClientName, ShuShuEvent.Instance.OnAdRevenueEvent(ClientName,
ClientName, ClientName,
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId, adUnitId,
type.ToString(), type.ToString(),
type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue, type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue,
type == AdsType.Rewarded ? _rvPos : _ivPos, type == AdsType.Rewarded ? _rvPos : _ivPos,

View File

@ -103,7 +103,7 @@ namespace WZ
break; break;
} }
} }
if (!hasPendingRequests) if (!hasPendingRequests)
{ {
// 所有楼层都请求完毕,并且没有正在处理的请求,确实没有填充 // 所有楼层都请求完毕,并且没有正在处理的请求,确实没有填充
@ -119,7 +119,7 @@ namespace WZ
{ {
RequestFloorAd(floor); RequestFloorAd(floor);
} }
} }
private void RequestFloorAd(FloorConfig floor) private void RequestFloorAd(FloorConfig floor)
@ -156,7 +156,7 @@ namespace WZ
} }
// 处理楼层广告加载成功 // 处理楼层广告加载成功
public void OnFloorAdLoaded(FloorConfig floor, IInterstitialAdController controller,double revenue) public void OnFloorAdLoaded(FloorConfig floor, IInterstitialAdController controller, double revenue)
{ {
if (!_isRequestingFloors || _successfulFloor != null) return; if (!_isRequestingFloors || _successfulFloor != null) return;
@ -190,15 +190,15 @@ namespace WZ
// 处理楼层广告加载失败 // 处理楼层广告加载失败
public void OnFloorAdFailed(FloorConfig floor, string error) public void OnFloorAdFailed(FloorConfig floor, string error)
{ {
LoggerUtils.Debug($"[kwai] floor inter ad failed: {floor.id} with error: {error} _isRequestingFloors:{!_isRequestingFloors} _successfulFloor: {_successfulFloor != null}" ); LoggerUtils.Debug($"[kwai] floor inter ad failed: {floor.id} with error: {error} _isRequestingFloors:{!_isRequestingFloors} _successfulFloor: {_successfulFloor != null}");
if (!_isRequestingFloors || _successfulFloor != null) return; if (!_isRequestingFloors || _successfulFloor != null) return;
// 移除失败floor // 移除失败floor
if(_currentRequestBatch.Contains(floor))_currentRequestBatch.Remove(floor); if (_currentRequestBatch.Contains(floor)) _currentRequestBatch.Remove(floor);
// 检查当前批次是否全部失败 // 检查当前批次是否全部失败
bool allFailedInBatch = true; bool allFailedInBatch = true;
if (_currentRequestBatch.Count > 0) allFailedInBatch = false; if (_currentRequestBatch.Count > 0) allFailedInBatch = false;
// 如果当前批次全部失败,请求下一批 // 如果当前批次全部失败,请求下一批
if (allFailedInBatch) if (allFailedInBatch)
@ -267,7 +267,7 @@ namespace WZ
{ {
return _currentRequestId; return _currentRequestId;
} }
/// <summary> /// <summary>
/// 生成唯一的Request ID /// 生成唯一的Request ID
/// </summary> /// </summary>
@ -275,6 +275,11 @@ namespace WZ
{ {
return Guid.NewGuid().ToString("N"); return Guid.NewGuid().ToString("N");
} }
public string GetSuccessfulFloorUnitId()
{
return _successfulFloor != null ? _successfulFloor.unite_id : "";
}
} }
} }

View File

@ -101,7 +101,7 @@ namespace WZ
break; break;
} }
} }
if (!hasPendingRequests) if (!hasPendingRequests)
{ {
// 所有楼层都请求完毕,并且没有正在处理的请求,确实没有填充 // 所有楼层都请求完毕,并且没有正在处理的请求,确实没有填充
@ -153,7 +153,7 @@ namespace WZ
} }
// 处理楼层广告加载成功 // 处理楼层广告加载成功
public void OnFloorAdLoaded(FloorConfig floor, IRewardAdController controller,double revenue) public void OnFloorAdLoaded(FloorConfig floor, IRewardAdController controller, double revenue)
{ {
if (!_isRequestingFloors || _successfulFloor != null) return; if (!_isRequestingFloors || _successfulFloor != null) return;
@ -186,15 +186,15 @@ namespace WZ
// 处理楼层广告加载失败 // 处理楼层广告加载失败
public void OnFloorAdFailed(FloorConfig floor, string error) public void OnFloorAdFailed(FloorConfig floor, string error)
{ {
LoggerUtils.Debug($"[kwai] floor reward ad failed: {floor.id} with error: {error} _isRequestingFloors:{!_isRequestingFloors} _successfulFloor: {_successfulFloor != null}" ); LoggerUtils.Debug($"[kwai] floor reward ad failed: {floor.id} with error: {error} _isRequestingFloors:{!_isRequestingFloors} _successfulFloor: {_successfulFloor != null}");
if (!_isRequestingFloors || _successfulFloor != null) return; if (!_isRequestingFloors || _successfulFloor != null) return;
// 移除失败floor // 移除失败floor
if(_currentRequestBatch.Contains(floor))_currentRequestBatch.Remove(floor); if (_currentRequestBatch.Contains(floor)) _currentRequestBatch.Remove(floor);
// 检查当前批次是否全部失败 // 检查当前批次是否全部失败
bool allFailedInBatch = true; bool allFailedInBatch = true;
if (_currentRequestBatch.Count > 0) allFailedInBatch = false; if (_currentRequestBatch.Count > 0) allFailedInBatch = false;
// 如果当前批次全部失败,请求下一批 // 如果当前批次全部失败,请求下一批
if (allFailedInBatch) if (allFailedInBatch)
@ -263,7 +263,7 @@ namespace WZ
{ {
return _currentRequestId; return _currentRequestId;
} }
/// <summary> /// <summary>
/// 生成唯一的Request ID /// 生成唯一的Request ID
/// </summary> /// </summary>
@ -271,6 +271,11 @@ namespace WZ
{ {
return Guid.NewGuid().ToString("N"); return Guid.NewGuid().ToString("N");
} }
public string GetSuccessfulFloorUnitId()
{
return _successfulFloor != null ? _successfulFloor.unite_id : "";
}
} }
} }

View File

@ -22,7 +22,7 @@ namespace WZ
{ {
AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom, AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom,
KwaiAdsManager.Instance.ClientName, KwaiAdsManager.Instance.ClientName,
KwaiAdsManager.Instance._interstitialAdUnitId, KwaiFloorIvManager.Instance.GetSuccessfulFloorUnitId(),
AdsType.Interstitial, AdsType.Interstitial,
KwaiAdsManager.Instance._ivPos, KwaiAdsManager.Instance._ivPos,
KwaiAdsManager.Instance._interstitiaAdRevenue); KwaiAdsManager.Instance._interstitiaAdRevenue);
@ -33,7 +33,7 @@ namespace WZ
{ {
AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom, AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom,
KwaiAdsManager.Instance.ClientName, KwaiAdsManager.Instance.ClientName,
KwaiAdsManager.Instance._interstitialAdUnitId, KwaiFloorIvManager.Instance.GetSuccessfulFloorUnitId(),
AdsType.Interstitial, AdsType.Interstitial,
KwaiAdsManager.Instance._ivPos, KwaiAdsManager.Instance._ivPos,
KwaiAdsManager.Instance._interstitiaAdRevenue); KwaiAdsManager.Instance._interstitiaAdRevenue);
@ -50,7 +50,7 @@ namespace WZ
public void OnAdShow() public void OnAdShow()
{ {
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Interstitial); KwaiAdsManager.Instance.TrackAdImpression(AdsType.Interstitial,KwaiFloorIvManager.Instance.GetSuccessfulFloorUnitId());
LoggerUtils.Debug("[kwai] floor inter OnAdShow"); LoggerUtils.Debug("[kwai] floor inter OnAdShow");
} }

View File

@ -40,7 +40,7 @@ namespace WZ
public void OnAdShow() public void OnAdShow()
{ {
// 插页视频曝光 | Interstitial video show // 插页视频曝光 | Interstitial video show
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Interstitial); KwaiAdsManager.Instance.TrackAdImpression(AdsType.Interstitial,KwaiAdsManager.Instance._interstitialAdUnitId);
LoggerUtils.Debug("[kwai] InterstitialAdListener#OnAdShow"); LoggerUtils.Debug("[kwai] InterstitialAdListener#OnAdShow");
} }

View File

@ -21,7 +21,7 @@ namespace WZ
{ {
AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom, AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom,
KwaiAdsManager.Instance.ClientName, KwaiAdsManager.Instance.ClientName,
KwaiAdsManager.Instance._rewardAdUnitId, KwaiFloorRvManager.Instance.GetSuccessfulFloorUnitId(),
AdsType.Rewarded, AdsType.Rewarded,
KwaiAdsManager.Instance._rvPos, KwaiAdsManager.Instance._rvPos,
KwaiAdsManager.Instance._rewardAdRevenue); KwaiAdsManager.Instance._rewardAdRevenue);
@ -34,7 +34,7 @@ namespace WZ
{ {
AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom, AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom,
KwaiAdsManager.Instance.ClientName, KwaiAdsManager.Instance.ClientName,
KwaiAdsManager.Instance._rewardAdUnitId, KwaiFloorRvManager.Instance.GetSuccessfulFloorUnitId(),
AdsType.Rewarded, AdsType.Rewarded,
KwaiAdsManager.Instance._rvPos, KwaiAdsManager.Instance._rvPos,
KwaiAdsManager.Instance._rewardAdRevenue); KwaiAdsManager.Instance._rewardAdRevenue);
@ -53,7 +53,7 @@ namespace WZ
public void OnAdShow() public void OnAdShow()
{ {
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Rewarded); KwaiAdsManager.Instance.TrackAdImpression(AdsType.Rewarded,KwaiFloorRvManager.Instance.GetSuccessfulFloorUnitId());
LoggerUtils.Debug("[kwai] floor reward RewardAdListener#OnAdShow"); LoggerUtils.Debug("[kwai] floor reward RewardAdListener#OnAdShow");
} }

View File

@ -20,11 +20,11 @@ namespace WZ
public void OnAdClose() public void OnAdClose()
{ {
AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom, AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom,
KwaiAdsManager.Instance.ClientName, KwaiAdsManager.Instance.ClientName,
KwaiAdsManager.Instance._rewardAdUnitId, KwaiAdsManager.Instance._rewardAdUnitId,
AdsType.Rewarded, AdsType.Rewarded,
KwaiAdsManager.Instance._rvPos, KwaiAdsManager.Instance._rvPos,
KwaiAdsManager.Instance._rewardAdRevenue); KwaiAdsManager.Instance._rewardAdRevenue);
KwaiAdsManager.Instance._rvCloseCallback?.Invoke(KwaiAdsManager.Instance._receivedReward, KwaiAdsManager.Instance._rewardAdRevenue); KwaiAdsManager.Instance._rvCloseCallback?.Invoke(KwaiAdsManager.Instance._receivedReward, KwaiAdsManager.Instance._rewardAdRevenue);
KwaiAdsManager.Instance._rvCloseCallback = null; KwaiAdsManager.Instance._rvCloseCallback = null;
KwaiAdsManager.Instance._receivedReward = false; KwaiAdsManager.Instance._receivedReward = false;
@ -41,7 +41,7 @@ namespace WZ
public void OnAdShow() public void OnAdShow()
{ {
// 激励视频曝光 | Reward video show // 激励视频曝光 | Reward video show
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Rewarded); KwaiAdsManager.Instance.TrackAdImpression(AdsType.Rewarded,KwaiAdsManager.Instance._rewardAdUnitId);
LoggerUtils.Debug("[kwai] RewardAdListener#OnAdShow"); LoggerUtils.Debug("[kwai] RewardAdListener#OnAdShow");
} }

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using AnyThinkAds.Api; using AnyThinkAds.Api;
using GoogleMobileAds.Api; using GoogleMobileAds.Api;
using UnityEngine; using UnityEngine;
using UnityEngine.Purchasing;
using WZ; using WZ;
public class Test : MonoBehaviour public class Test : MonoBehaviour
@ -17,6 +18,18 @@ public class Test : MonoBehaviour
{ {
small = gameObject.transform.Find("NativeAd-small").GetComponent<RectTransform>(); small = gameObject.transform.Find("NativeAd-small").GetComponent<RectTransform>();
medium = gameObject.transform.Find("NativeAd-medium").GetComponent<RectTransform>(); medium = gameObject.transform.Find("NativeAd-medium").GetComponent<RectTransform>();
RushSDKManager.Instance.RegisterPurchaseCompletionHandler((info)=>
{
LoggerUtils.Debug("[iap] result ->" + info.ToJson());
if (info.purchaseResult == true || info.orderAlreadyExists == true)
{
RushSDKManager.Instance.LogCheckingOrder(info.productName,info.productID,info.orderID,info.gameExtra,info.gameExtra);
}
});
RushSDKManager.Instance.AddProductsStatic(new Dictionary<string, UnityEngine.Purchasing.ProductType>()
{
{ "com.tilematch.1000gold", ProductType.Consumable }
});
RushSDKManager.Instance.SetUserSourceListener((bool success, string source) => RushSDKManager.Instance.SetUserSourceListener((bool success, string source) =>
{ {
LoggerUtils.Debug("adjust callback: "+success+" adnetwork:"+source); LoggerUtils.Debug("adjust callback: "+success+" adnetwork:"+source);
@ -34,7 +47,8 @@ public class Test : MonoBehaviour
// { // {
// LoggerUtils.Debug("[kwai] OnRewardedVideoAdShowed revenue:"+revenue+"+ state:"+state); // LoggerUtils.Debug("[kwai] OnRewardedVideoAdShowed revenue:"+revenue+"+ state:"+state);
// }); // });
RushSDKManager.Instance.ShowBanner(BannerType.Standard,BannerAlignType.CenterTop); // RushSDKManager.Instance.ShowBanner(BannerType.Standard,BannerAlignType.CenterTop);
RushSDKManager.Instance.PurchaseProductById("com.tilematch.1000gold","1000gold");
} }
public void OnShowInterstitial() public void OnShowInterstitial()