Merge branch 'main' of http://v4.9ms.co:7777/yufeng/SDK_UnityMoney
This commit is contained in:
commit
fb022bf083
|
@ -41,11 +41,17 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
|
||||
ShuShuEvent.Instance.Track("adjust_init");
|
||||
FireBaseAnalyticsManager.Instance.LogEvent("adjust_init");
|
||||
Adjust.GetAdid((id)=>
|
||||
Adjust.GetAdid((id) =>
|
||||
{
|
||||
ShuShuEvent.Instance.SetSuperProperties(new Dictionary<string, object>() { { "adid", id } });
|
||||
ShuShuEvent.Instance.UserSet(new Dictionary<string, object>() { { "adid", id } });
|
||||
});
|
||||
|
||||
var network = AdjustNetwork.GetNetwork();
|
||||
if (!string.IsNullOrEmpty(network))
|
||||
{
|
||||
RushSDKManager.Instance.OnUserSourceListener?.Invoke(IsOrganic(network), network);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,6 +166,8 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
{ "adgroup", adgroup ?? "" },
|
||||
{ "creative", creative ?? "" },
|
||||
});
|
||||
|
||||
RushSDKManager.Instance.OnUserSourceListener?.Invoke(IsOrganic(network), network);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,10 +29,14 @@ public class AdjustNetwork : D_MonoSingleton<AdjustNetwork>
|
|||
}
|
||||
}
|
||||
|
||||
public static string GetNetwork()
|
||||
{
|
||||
return PlayerPrefs.GetString(KEY_USER_NETWORK);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是自然量用户
|
||||
/// 默认买量用户
|
||||
/// 默认自然量用户
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool InOrganic()
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace WZ
|
|||
{
|
||||
public string id;
|
||||
public string unite_id;
|
||||
public int price;
|
||||
public float price;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using GoogleMobileAds.Common;
|
||||
using JetBrains.Annotations;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
|
@ -21,8 +22,11 @@ namespace WZ
|
|||
private bool _isRequestingFloors = false;
|
||||
private List<FloorConfig> _currentRequestBatch = new List<FloorConfig>();
|
||||
private FloorConfig _successfulFloor = null;
|
||||
|
||||
public float _ivStartLoadTime = 0;
|
||||
private int _waterfallRequestCount = 0; // waterfall请求次数
|
||||
private Dictionary<string, int> _unitIdRequestCounts = new Dictionary<string, int>(); // 每个unit_id的请求次数
|
||||
private string _currentRequestId; // 当前waterfall请求的ID
|
||||
|
||||
|
||||
public void InitializeWithFloors()
|
||||
{
|
||||
|
@ -51,6 +55,10 @@ namespace WZ
|
|||
_currentFloorIndex = 0;
|
||||
_successfulFloor = null;
|
||||
_isRequestingFloors = true;
|
||||
_currentRequestId = GenerateRequestId();
|
||||
|
||||
// 增加waterfall请求计数
|
||||
_waterfallRequestCount++;
|
||||
|
||||
// 清理之前的广告控制器
|
||||
foreach (var controller in _ivFloorAdControllers.Values)
|
||||
|
@ -93,25 +101,54 @@ namespace WZ
|
|||
{
|
||||
RequestFloorAd(floor);
|
||||
}
|
||||
AdsActionEvents.TrackKwaiWaterfallRequest(AdsType.Interstitial,
|
||||
_currentRequestId,
|
||||
_waterfallRequestCount,
|
||||
_ivParallelRequests);
|
||||
}
|
||||
|
||||
private void RequestFloorAd(FloorConfig floor)
|
||||
{
|
||||
IInterstitialAdController controller = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();;
|
||||
// 更新unite_id请求计数
|
||||
if (!_unitIdRequestCounts.ContainsKey(floor.unite_id))
|
||||
{
|
||||
_unitIdRequestCounts[floor.unite_id] = 0;
|
||||
}
|
||||
_unitIdRequestCounts[floor.unite_id]++;
|
||||
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
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;
|
||||
|
||||
KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(floor.unite_id);
|
||||
kwaiInterstitialAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = floor.price.ToString();
|
||||
|
||||
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;
|
||||
|
||||
LoggerUtils.Debug($"[kwai] floor inter Floor ad loaded: {floor.id} with price: {floor.price}");
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
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}");
|
||||
|
||||
|
||||
// 暂停其他并行请求
|
||||
_successfulFloor = floor;
|
||||
|
@ -125,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);
|
||||
}
|
||||
|
||||
// 处理楼层广告加载失败
|
||||
|
@ -177,6 +222,53 @@ namespace WZ
|
|||
_action?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前waterfall请求次数
|
||||
/// </summary>
|
||||
public int GetWaterfallRequestCount()
|
||||
{
|
||||
return _waterfallRequestCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前waterfall请求次数
|
||||
/// </summary>
|
||||
public int GetUniteIdRequestCount(string unitId)
|
||||
{
|
||||
return _unitIdRequestCounts.TryGetValue(unitId, out var time) ? time : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据floor.id获取其在排序后的楼层列表中的索引位置
|
||||
/// </summary>
|
||||
public int GetFloorIndex(string floorId)
|
||||
{
|
||||
for (int i = 0; i < _sortedFloors.Count; i++)
|
||||
{
|
||||
if (_sortedFloors[i].id == floorId)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1; // 未找到
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前Request ID
|
||||
/// </summary>
|
||||
public string GetCurrentRequestId()
|
||||
{
|
||||
return _currentRequestId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成唯一的Request ID
|
||||
/// </summary>
|
||||
private string GenerateRequestId()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
using static WZ.KwaiAdsConfigParser;
|
||||
|
@ -19,8 +20,10 @@ namespace WZ
|
|||
private bool _isRequestingFloors = false;
|
||||
private List<FloorConfig> _currentRequestBatch = new List<FloorConfig>();
|
||||
private FloorConfig _successfulFloor = null;
|
||||
|
||||
public float _rvStartLoadTime = 0;
|
||||
private int _waterfallRequestCount = 0; // waterfall请求次数
|
||||
private Dictionary<string, int> _unitIdRequestCounts = new Dictionary<string, int>(); // 每个unite_id的请求次数
|
||||
private string _currentRequestId; // 当前waterfall请求的ID
|
||||
|
||||
public void InitializeWithFloors()
|
||||
{
|
||||
|
@ -51,7 +54,10 @@ namespace WZ
|
|||
_currentFloorIndex = 0;
|
||||
_successfulFloor = null;
|
||||
_isRequestingFloors = true;
|
||||
_currentRequestId = GenerateRequestId();
|
||||
|
||||
// 增加waterfall请求计数
|
||||
_waterfallRequestCount++;
|
||||
// 清理之前的广告控制器
|
||||
foreach (var controller in _rvFloorAdControllers.Values)
|
||||
{
|
||||
|
@ -61,6 +67,8 @@ namespace WZ
|
|||
|
||||
// 开始请求楼层广告
|
||||
RequestNextFloorBatch();
|
||||
|
||||
AdsActionEvents.TrackKwaiWaterfallRequest(AdsType.Rewarded, _currentRequestId, _waterfallRequestCount, _rvParallelRequests);
|
||||
}
|
||||
|
||||
private void RequestNextFloorBatch()
|
||||
|
@ -97,21 +105,45 @@ namespace WZ
|
|||
|
||||
private void RequestFloorAd(FloorConfig floor)
|
||||
{
|
||||
// 更新unite_id请求计数
|
||||
if (!_unitIdRequestCounts.ContainsKey(floor.unite_id))
|
||||
{
|
||||
_unitIdRequestCounts[floor.unite_id] = 0;
|
||||
}
|
||||
_unitIdRequestCounts[floor.unite_id]++;
|
||||
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
|
||||
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;
|
||||
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(floor.unite_id);
|
||||
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = floor.price.ToString();
|
||||
|
||||
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;
|
||||
|
||||
LoggerUtils.Debug($"[kwai] floor reward ad loaded: {floor.id} with price: {floor.price}");
|
||||
// 获取当前楼层在排序列表中的位置
|
||||
int floorIndex = GetFloorIndex(floor.id);
|
||||
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;
|
||||
|
@ -125,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);
|
||||
}
|
||||
|
||||
// 处理楼层广告加载失败
|
||||
|
@ -177,6 +217,53 @@ namespace WZ
|
|||
_action?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前waterfall请求次数
|
||||
/// </summary>
|
||||
public int GetWaterfallRequestCount()
|
||||
{
|
||||
return _waterfallRequestCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前waterfall请求次数
|
||||
/// </summary>
|
||||
public int GetUniteIdRequestCount(string unitId)
|
||||
{
|
||||
return _unitIdRequestCounts.TryGetValue(unitId, out var time) ? time : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据floor.id获取其在排序后的楼层列表中的索引位置
|
||||
/// </summary>
|
||||
public int GetFloorIndex(string floorId)
|
||||
{
|
||||
for (int i = 0; i < _sortedFloors.Count; i++)
|
||||
{
|
||||
if (_sortedFloors[i].id == floorId)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1; // 未找到
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前Request ID
|
||||
/// </summary>
|
||||
public string GetCurrentRequestId()
|
||||
{
|
||||
return _currentRequestId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成唯一的Request ID
|
||||
/// </summary>
|
||||
private string GenerateRequestId()
|
||||
{
|
||||
return Guid.NewGuid().ToString("N");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,22 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
EFSdkManager.Instance.Init();
|
||||
}
|
||||
|
||||
#region 买量用户回调
|
||||
|
||||
public Action<bool, string> OnUserSourceListener;
|
||||
|
||||
/// Adjust归因回调
|
||||
/// <summary>
|
||||
/// <param name="is organic user">是否为买量用户</param>
|
||||
/// <param name="adNetwork">adjust 返回的network字段</param>
|
||||
/// </summary>
|
||||
public void SetUserSourceListener(Action<bool, string> _action)
|
||||
{
|
||||
OnUserSourceListener = _action;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ad
|
||||
|
||||
|
@ -49,7 +65,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
/// <returns></returns>
|
||||
public bool IsRewardedAdReady()
|
||||
{
|
||||
return AdsSDKManager.Instance.IsRewardAdReady();;
|
||||
return AdsSDKManager.Instance.IsRewardAdReady(); ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -57,7 +73,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowRewardAd(string position, Action<bool,double> callback = null)
|
||||
public void ShowRewardAd(string position, Action<bool, double> callback = null)
|
||||
{
|
||||
AdsActionEvents.TrackAdPosition(AdsType.Rewarded, position);
|
||||
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
||||
|
@ -455,7 +471,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
|
||||
public void CanGoback(Action<bool> canGobackAction)
|
||||
{
|
||||
EFSdk.get().CanGoback(canGobackAction);
|
||||
EFSdk.get().CanGoback(canGobackAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -614,7 +630,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
return;
|
||||
}
|
||||
// 如果没有通知权限就尝试申请通知权限
|
||||
if(!HasNotifyPermission())
|
||||
if (!HasNotifyPermission())
|
||||
{
|
||||
EFSdk.get().ReqNotifyPermission(isgGranted =>
|
||||
{
|
||||
|
@ -745,7 +761,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
return AdjustNetwork.Instance.InOrganic();
|
||||
}
|
||||
|
||||
public string GetGaid()
|
||||
public string GetGaid()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
|
@ -829,7 +845,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
{
|
||||
return "GetSSDistinctId";
|
||||
}
|
||||
LoggerUtils.Debug("GetSSDistinctId:"+TDAnalytics.GetDistinctId());
|
||||
LoggerUtils.Debug("GetSSDistinctId:" + TDAnalytics.GetDistinctId());
|
||||
return TDAnalytics.GetDistinctId();
|
||||
}
|
||||
|
||||
|
@ -844,4 +860,9 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
|||
LoggerUtils.Debug("GetSSDistinctId:" + JsonMapper.ToJson(superProperties));
|
||||
return superProperties == null ? "" : superProperties.ToString();
|
||||
}
|
||||
|
||||
public void OpenPrivacy()
|
||||
{
|
||||
Application.OpenURL(StaticValue.PrivacyUrl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,12 @@ public class Test : MonoBehaviour
|
|||
{
|
||||
small = gameObject.transform.Find("NativeAd-small").GetComponent<RectTransform>();
|
||||
medium = gameObject.transform.Find("NativeAd-medium").GetComponent<RectTransform>();
|
||||
RushSDKManager.Instance.SetUserSourceListener((bool success, string source) =>
|
||||
{
|
||||
LoggerUtils.Debug("adjust callback: "+success+" adnetwork:"+source);
|
||||
});
|
||||
RushSDKManager.Instance.InitializeSdk(null, true);
|
||||
|
||||
}
|
||||
|
||||
public void OnShowAd()
|
||||
|
|
Loading…
Reference in New Issue