Adjust收益分离
This commit is contained in:
parent
b2cb96a38e
commit
e334189040
|
@ -0,0 +1,12 @@
|
||||||
|
[System.Serializable]
|
||||||
|
public class RevenueAdjItem
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
public int rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class RevenueAdj
|
||||||
|
{
|
||||||
|
public RevenueAdjItem[] tevenueAdjs;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 949cf822b4fa460aaafbe875d708e41b
|
||||||
|
timeCreated: 1756631216
|
|
@ -1,4 +1,6 @@
|
||||||
using AdjustSdk;
|
using AdjustSdk;
|
||||||
|
using Firebase.RemoteConfig;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using SDK.Utils;
|
using SDK.Utils;
|
||||||
|
|
||||||
public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
||||||
|
@ -14,19 +16,62 @@ public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告数据上报
|
/// 广告收益上报
|
||||||
/// 在onAdRevenuePaid的时候上报
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="TrackAdEvent"></param>
|
/// <param name="revenue">单次展示收益</param>
|
||||||
|
/// <param name="adRevenueNetwork">广告平台名称</param>
|
||||||
|
/// <param name="adRevenueUnit">广告位ID</param>
|
||||||
|
/// <param name="adRevenuePlacement">广告源ID</param>
|
||||||
public void TrackAdEvent(double revenue, string adRevenueNetwork, string adRevenueUnit, string adRevenuePlacement)
|
public void TrackAdEvent(double revenue, string adRevenueNetwork, string adRevenueUnit, string adRevenuePlacement)
|
||||||
{
|
{
|
||||||
AdjustAdRevenue adjustAdRevenue = new AdjustAdRevenue("applovin_max_sdk");
|
string source = GetSource();
|
||||||
|
AdjustAdRevenue adjustAdRevenue = new AdjustAdRevenue(source);
|
||||||
adjustAdRevenue.SetRevenue(revenue, "USD");
|
adjustAdRevenue.SetRevenue(revenue, "USD");
|
||||||
adjustAdRevenue.AdRevenueNetwork = adRevenueNetwork;
|
adjustAdRevenue.AdRevenueNetwork = adRevenueNetwork;
|
||||||
adjustAdRevenue.AdRevenueUnit = adRevenueUnit;
|
adjustAdRevenue.AdRevenueUnit = adRevenueUnit;
|
||||||
adjustAdRevenue.AdRevenuePlacement = adRevenuePlacement;
|
adjustAdRevenue.AdRevenuePlacement = adRevenuePlacement;
|
||||||
Adjust.TrackAdRevenue(adjustAdRevenue);
|
Adjust.TrackAdRevenue(adjustAdRevenue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收益分离
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private string GetSource()
|
||||||
|
{
|
||||||
|
string source = "applovin_max_sdk";
|
||||||
|
//获取在线参数
|
||||||
|
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_adj");
|
||||||
|
if (string.IsNullOrEmpty(json))
|
||||||
|
{
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
var revenueAdjs = JsonConvert.DeserializeObject<RevenueAdjItem[]>(json);
|
||||||
|
if (revenueAdjs == null && revenueAdjs.Length == 0)
|
||||||
|
{
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalRate = 0;
|
||||||
|
//获取全部概率
|
||||||
|
foreach (var item in revenueAdjs)
|
||||||
|
{
|
||||||
|
totalRate += item.rate;
|
||||||
|
}
|
||||||
|
//开始随机
|
||||||
|
int randomValue = UnityEngine.Random.Range(0, totalRate);
|
||||||
|
int accumulatedRate = 0;
|
||||||
|
|
||||||
|
//根据随机值定位
|
||||||
|
foreach (var item in revenueAdjs)
|
||||||
|
{
|
||||||
|
accumulatedRate += item.rate;
|
||||||
|
if (randomValue < accumulatedRate)
|
||||||
|
{
|
||||||
|
return item.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -78,12 +78,9 @@ public class FireBaseRemoteConfigManager : NormalSingleton<FireBaseRemoteConfigM
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// await FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero);
|
|
||||||
// await FirebaseRemoteConfig.DefaultInstance.ActivateAsync();
|
|
||||||
// 获取值
|
// 获取值
|
||||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(key);
|
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(key);
|
||||||
|
|
||||||
Debug.Log(configValue.Source);
|
|
||||||
if (configValue.Source == ValueSource.RemoteValue)
|
if (configValue.Source == ValueSource.RemoteValue)
|
||||||
{
|
{
|
||||||
return configValue.StringValue;
|
return configValue.StringValue;
|
||||||
|
@ -107,13 +104,10 @@ public class FireBaseRemoteConfigManager : NormalSingleton<FireBaseRemoteConfigM
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <param name="defaultValue"></param>
|
/// <param name="defaultValue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> GetRemoteConfigBool(string key, bool defaultValue = false)
|
public bool GetRemoteConfigBool(string key, bool defaultValue = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// await FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero);
|
|
||||||
// await FirebaseRemoteConfig.DefaultInstance.ActivateAsync();
|
|
||||||
|
|
||||||
// 获取值
|
// 获取值
|
||||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(key);
|
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(key);
|
||||||
|
|
||||||
|
@ -140,13 +134,10 @@ public class FireBaseRemoteConfigManager : NormalSingleton<FireBaseRemoteConfigM
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <param name="defaultValue"></param>
|
/// <param name="defaultValue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<float> GetRemoteConfigBool(string key, float defaultValue = 0)
|
public float GetRemoteConfigBool(string key, float defaultValue = 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// await FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero);
|
|
||||||
// await FirebaseRemoteConfig.DefaultInstance.ActivateAsync();
|
|
||||||
|
|
||||||
// 获取值
|
// 获取值
|
||||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(key);
|
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(key);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue