kwai广告行为事件上报
This commit is contained in:
parent
3549e77193
commit
08be1d5f2f
|
@ -44,7 +44,7 @@ namespace WZ
|
|||
}
|
||||
|
||||
public static void TrackKwiWaterfallFill(AdsType adsType, string requestId, string unitId,
|
||||
float floorPrice, int waterfallRequestNumber, int unitRequestNumber, int floorNumber,float value)
|
||||
float floorPrice, int waterfallRequestNumber, int unitRequestNumber, int floorNumber,double value)
|
||||
{
|
||||
var eventName = "kwai_waterfall_fill";
|
||||
var dic = new Dictionary<string, object> {
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace WZ
|
|||
private FloorConfig _successfulFloor = null;
|
||||
public float _ivStartLoadTime = 0;
|
||||
private int _waterfallRequestCount = 0; // waterfall请求次数
|
||||
private Dictionary<string, int> _uniteIdRequestCounts = new Dictionary<string, int>(); // 每个unite_id的请求次数
|
||||
private Dictionary<string, int> _unitIdRequestCounts = new Dictionary<string, int>(); // 每个unite_id的请求次数
|
||||
private string _currentRequestId; // 当前waterfall请求的ID
|
||||
|
||||
|
||||
|
@ -55,6 +55,7 @@ namespace WZ
|
|||
_currentFloorIndex = 0;
|
||||
_successfulFloor = null;
|
||||
_isRequestingFloors = true;
|
||||
_currentRequestId = GenerateRequestId();
|
||||
|
||||
// 增加waterfall请求计数
|
||||
_waterfallRequestCount++;
|
||||
|
@ -100,21 +101,24 @@ namespace WZ
|
|||
{
|
||||
RequestFloorAd(floor);
|
||||
}
|
||||
AdsActionEvents.TrackKwaiWaterfallRequest(AdsType.Interstitial,
|
||||
_currentRequestId,
|
||||
_waterfallRequestCount,
|
||||
_ivParallelRequests);
|
||||
}
|
||||
|
||||
private void RequestFloorAd(FloorConfig floor)
|
||||
{
|
||||
// 更新unite_id请求计数
|
||||
if (!_uniteIdRequestCounts.ContainsKey(floor.unite_id))
|
||||
if (!_unitIdRequestCounts.ContainsKey(floor.unite_id))
|
||||
{
|
||||
_uniteIdRequestCounts[floor.unite_id] = 0;
|
||||
_unitIdRequestCounts[floor.unite_id] = 0;
|
||||
}
|
||||
_uniteIdRequestCounts[floor.unite_id]++;
|
||||
_unitIdRequestCounts[floor.unite_id]++;
|
||||
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
_currentRequestId = GenerateRequestId();
|
||||
LoggerUtils.Debug($"[kwai] floor inter Requesting floor {floor.id} (index: {floorIndex}), unite_id {floor.unite_id} has been requested {_uniteIdRequestCounts[floor.unite_id]} times, request id: {_currentRequestId}");
|
||||
LoggerUtils.Debug($"[kwai] floor inter Requesting floor {floor.id} (index: {floorIndex}), unite_id {floor.unite_id} has been requested {_unitIdRequestCounts[floor.unite_id]} times, request id: {GetUniteIdRequestCount(floor.unite_id)}");
|
||||
|
||||
IInterstitialAdController controller = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController(); ;
|
||||
_ivFloorAdControllers[floor.id] = controller;
|
||||
|
@ -125,16 +129,25 @@ namespace WZ
|
|||
controller.Load(kwaiInterstitialAdRequest,
|
||||
new FloorInterAdListener(this, floor),
|
||||
new FloorInterAdLoadListener(this, floor));
|
||||
|
||||
AdsActionEvents.TrackKwaiAdunitRequest(AdsType.Interstitial,
|
||||
_currentRequestId,
|
||||
floor.unite_id,
|
||||
floor.price,
|
||||
GetWaterfallRequestCount(),
|
||||
GetUniteIdRequestCount(floor.unite_id),
|
||||
floorIndex);
|
||||
|
||||
}
|
||||
|
||||
// 处理楼层广告加载成功
|
||||
public void OnFloorAdLoaded(FloorConfig floor, IInterstitialAdController controller)
|
||||
public void OnFloorAdLoaded(FloorConfig floor, IInterstitialAdController controller,double revenue)
|
||||
{
|
||||
if (!_isRequestingFloors || _successfulFloor != null) return;
|
||||
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
LoggerUtils.Debug($"[kwai] floor reward Floor ad loaded: {floor.id} (index: {floorIndex}) with price: {floor.price}, unite_id {floor.unite_id} has been requested {_uniteIdRequestCounts[floor.unite_id]} times");
|
||||
LoggerUtils.Debug($"[kwai] floor inter ad loaded: {floor.id} (index: {floorIndex}) with price: {floor.price}, unite_id {floor.unite_id} has been requested {GetUniteIdRequestCount(floor.unite_id)} times, revenue: {revenue}, request id: {_currentRequestId}");
|
||||
|
||||
|
||||
// 暂停其他并行请求
|
||||
|
@ -149,6 +162,14 @@ namespace WZ
|
|||
kvp.Value.Destroy();
|
||||
}
|
||||
}
|
||||
AdsActionEvents.TrackKwiWaterfallFill(AdsType.Interstitial,
|
||||
_currentRequestId,
|
||||
floor.unite_id,
|
||||
floor.price,
|
||||
GetWaterfallRequestCount(),
|
||||
GetUniteIdRequestCount(floor.unite_id),
|
||||
floorIndex,
|
||||
revenue);
|
||||
}
|
||||
|
||||
// 处理楼层广告加载失败
|
||||
|
@ -215,7 +236,7 @@ namespace WZ
|
|||
/// </summary>
|
||||
public int GetUniteIdRequestCount(string unitId)
|
||||
{
|
||||
return _uniteIdRequestCounts.TryGetValue(unitId, out var time) ? time : 0;
|
||||
return _unitIdRequestCounts.TryGetValue(unitId, out var time) ? time : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace WZ
|
|||
private FloorConfig _successfulFloor = null;
|
||||
public float _rvStartLoadTime = 0;
|
||||
private int _waterfallRequestCount = 0; // waterfall请求次数
|
||||
private Dictionary<string, int> _uniteIdRequestCounts = new Dictionary<string, int>(); // 每个unite_id的请求次数
|
||||
private Dictionary<string, int> _unitIdRequestCounts = new Dictionary<string, int>(); // 每个unite_id的请求次数
|
||||
private string _currentRequestId; // 当前waterfall请求的ID
|
||||
|
||||
public void InitializeWithFloors()
|
||||
|
@ -54,7 +54,7 @@ namespace WZ
|
|||
_currentFloorIndex = 0;
|
||||
_successfulFloor = null;
|
||||
_isRequestingFloors = true;
|
||||
|
||||
_currentRequestId = GenerateRequestId();
|
||||
|
||||
// 增加waterfall请求计数
|
||||
_waterfallRequestCount++;
|
||||
|
@ -67,6 +67,8 @@ namespace WZ
|
|||
|
||||
// 开始请求楼层广告
|
||||
RequestNextFloorBatch();
|
||||
|
||||
AdsActionEvents.TrackKwaiWaterfallRequest(AdsType.Rewarded, _currentRequestId, _waterfallRequestCount, _rvParallelRequests);
|
||||
}
|
||||
|
||||
private void RequestNextFloorBatch()
|
||||
|
@ -104,16 +106,16 @@ namespace WZ
|
|||
private void RequestFloorAd(FloorConfig floor)
|
||||
{
|
||||
// 更新unite_id请求计数
|
||||
if (!_uniteIdRequestCounts.ContainsKey(floor.unite_id))
|
||||
if (!_unitIdRequestCounts.ContainsKey(floor.unite_id))
|
||||
{
|
||||
_uniteIdRequestCounts[floor.unite_id] = 0;
|
||||
_unitIdRequestCounts[floor.unite_id] = 0;
|
||||
}
|
||||
_uniteIdRequestCounts[floor.unite_id]++;
|
||||
_unitIdRequestCounts[floor.unite_id]++;
|
||||
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
_currentRequestId = GenerateRequestId();
|
||||
LoggerUtils.Debug($"[kwai] floor reward Requesting floor {floor.id} (index: {floorIndex}), unite_id {floor.unite_id} has been requested {_uniteIdRequestCounts[floor.unite_id]} times, request id: {_currentRequestId}");
|
||||
|
||||
LoggerUtils.Debug($"[kwai] floor reward Requesting floor {floor.id} (index: {floorIndex}), unite_id {floor.unite_id} has been requested {GetUniteIdRequestCount(floor.unite_id)} times, request id: {_currentRequestId}");
|
||||
|
||||
IRewardAdController controller = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
_rvFloorAdControllers[floor.id] = controller;
|
||||
|
@ -124,16 +126,24 @@ namespace WZ
|
|||
controller.Load(kwaiRewardAdRequest,
|
||||
new FloorRewardAdListener(this, floor),
|
||||
new FloorRewardAdLoadListener(this, floor));
|
||||
|
||||
AdsActionEvents.TrackKwaiAdunitRequest(AdsType.Rewarded,
|
||||
_currentRequestId,
|
||||
floor.unite_id,
|
||||
floor.price,
|
||||
GetWaterfallRequestCount(),
|
||||
GetUniteIdRequestCount(floor.unite_id),
|
||||
floorIndex);
|
||||
}
|
||||
|
||||
// 处理楼层广告加载成功
|
||||
public void OnFloorAdLoaded(FloorConfig floor, IRewardAdController controller)
|
||||
public void OnFloorAdLoaded(FloorConfig floor, IRewardAdController controller,double revenue)
|
||||
{
|
||||
if (!_isRequestingFloors || _successfulFloor != null) return;
|
||||
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
LoggerUtils.Debug($"[kwai] floor reward Floor ad loaded: {floor.id} (index: {floorIndex}) with price: {floor.price}, unite_id {floor.unite_id} has been requested {_uniteIdRequestCounts[floor.unite_id]} times");
|
||||
LoggerUtils.Debug($"[kwai] floor reward Floor ad loaded: {floor.id} (index: {floorIndex}) with floor price: {floor.price}, unite_id {floor.unite_id} has been requested {GetUniteIdRequestCount(floor.unite_id)} times, revenue:{revenue}");
|
||||
|
||||
// 暂停其他并行请求
|
||||
_successfulFloor = floor;
|
||||
|
@ -147,6 +157,14 @@ namespace WZ
|
|||
kvp.Value.Destroy();
|
||||
}
|
||||
}
|
||||
AdsActionEvents.TrackKwiWaterfallFill(AdsType.Rewarded,
|
||||
_currentRequestId,
|
||||
floor.unite_id,
|
||||
floor.price,
|
||||
GetWaterfallRequestCount(),
|
||||
GetUniteIdRequestCount(floor.unite_id),
|
||||
floorIndex,
|
||||
revenue);
|
||||
}
|
||||
|
||||
// 处理楼层广告加载失败
|
||||
|
@ -213,7 +231,7 @@ namespace WZ
|
|||
/// </summary>
|
||||
public int GetUniteIdRequestCount(string unitId)
|
||||
{
|
||||
return _uniteIdRequestCounts.TryGetValue(unitId, out var time) ? time : 0;
|
||||
return _unitIdRequestCounts.TryGetValue(unitId, out var time) ? time : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace WZ
|
|||
trackId,
|
||||
AdsType.Interstitial,
|
||||
Time.realtimeSinceStartup - KwaiFloorIvManager.Instance._ivStartLoadTime);
|
||||
_manager.OnFloorAdLoaded(_floor, _manager._ivFloorAdControllers[_floor.id]);
|
||||
_manager.OnFloorAdLoaded(_floor, _manager._ivFloorAdControllers[_floor.id],KwaiAdsManager.Instance._interstitiaAdRevenue);
|
||||
LoggerUtils.Debug("[kwai] floor inter ad load success: "+trackId+" with price: "+price);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace WZ
|
|||
trackId,
|
||||
AdsType.Rewarded,
|
||||
Time.realtimeSinceStartup - KwaiFloorRvManager.Instance._rvStartLoadTime);
|
||||
_manager.OnFloorAdLoaded(_floor, _manager._rvFloorAdControllers[_floor.id]);
|
||||
_manager.OnFloorAdLoaded(_floor, _manager._rvFloorAdControllers[_floor.id], KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
LoggerUtils.Debug("[kwai] floor reward ad load success: "+trackId+" with price: "+price);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue