firebase 关键事件上报
This commit is contained in:
parent
51d6bbfb04
commit
3e2a9d42f9
|
@ -86,7 +86,7 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
|||
var storeName = "FPU_" + item.Name;
|
||||
|
||||
// 包含当前广告类型
|
||||
LoggerUtils.Debug("[keyevents] adcount 当前广告类型:" + adType + " 在线参数数组:" + JsonConvert.SerializeObject(item.AdType, Formatting.Indented) + " FPU:" + item.FPU + " 当前广告ecpm" + " name:" + item.Name);
|
||||
LoggerUtils.Debug("[keyevents] fpu 当前广告类型:" + adType + " 在线参数数组:" + JsonConvert.SerializeObject(item.AdType, Formatting.Indented) + " FPU:" + item.FPU + " 当前广告ecpm" + " name:" + item.Name);
|
||||
if (item.AdType.Contains((int)adType))
|
||||
{
|
||||
LogEventByFPU(storeName, item.FPU, storeName, item.adjust_token);
|
||||
|
@ -96,10 +96,10 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
|||
|
||||
private void LogEventByFPU(string m_key, int m_fpu, string m_eventName, string m_token)
|
||||
{
|
||||
AdPlayCountManager.IncrementKeyEventPlayCount(m_key);
|
||||
var showCounts = AdPlayCountManager.GetKeyEventPlayCount(m_key);
|
||||
LoggerUtils.Debug("[keyevents] adcount count:" + showCounts + " fpu:" + m_fpu + " eventName:" + m_key);
|
||||
if (showCounts >= m_fpu)
|
||||
AdPlayCountManager.IncrementKeyEventFPUCount(m_key);
|
||||
var loadCounts = AdPlayCountManager.GetKeyEventFPUCount(m_key);
|
||||
LoggerUtils.Debug("[keyevents] fpu load count:" + loadCounts + " fpu:" + m_fpu + " eventName:" + m_key);
|
||||
if (loadCounts >= m_fpu)
|
||||
{
|
||||
// 未上报过
|
||||
if (PlayerPrefsUtils.IfFirstCheckPlayerPrefs(m_key))
|
||||
|
@ -107,12 +107,55 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
|||
AdjustTrackEvent.Instance.TrackEvent(m_token);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(m_key);
|
||||
ShuShuEvent.Instance.Track(m_key);
|
||||
LoggerUtils.Debug("[keyevents] adcount key:" + m_key + " fpu" + m_fpu + " eventName:" + m_eventName + " token:" + m_token);
|
||||
LoggerUtils.Debug("[keyevents] fpu key:" + m_key + " fpu" + m_fpu + " eventName:" + m_eventName + " token:" + m_token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
public void LogAdTotalRevenueEvents(AdsType adType, double revenue)
|
||||
{
|
||||
if (_adTotalRevenueData == null || _adTotalRevenueData.Count == 0) return;
|
||||
foreach (var item in _adTotalRevenueData)
|
||||
{
|
||||
// 本地存储 key
|
||||
var storeName = "Total_Revenue_" + item.Name;
|
||||
|
||||
// 包含当前广告类型
|
||||
LoggerUtils.Debug("[keyevents] totalrevenue 当前广告类型:" + adType + " 在线参数数组:" + JsonConvert.SerializeObject(item.AdType, Formatting.Indented) + " totalrevenue:" + item.Revenue + " name:" + item.Name);
|
||||
if (item.AdType.Contains((int)adType))
|
||||
{
|
||||
LogEventByTotalRevenue(storeName, item.Revenue, storeName, item.adjust_token,item.reset_after_trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LogEventByTotalRevenue(string m_key, float m_revenue, string m_eventName, string m_token,bool m_reset_after_trigger)
|
||||
{
|
||||
AdPlayCountManager.IncrementKeyEventTotalRevenue(m_key,m_revenue);
|
||||
var totalRevenue = AdPlayCountManager.GetKeyEventTotalRevenue(m_key);
|
||||
LoggerUtils.Debug("[keyevents] totalrevenue :" + totalRevenue + " revenue:" + m_revenue + " eventName:" + m_key);
|
||||
if (totalRevenue >= m_revenue)
|
||||
{
|
||||
// 未上报过
|
||||
if (PlayerPrefsUtils.IfFirstCheckPlayerPrefs(m_key))
|
||||
{
|
||||
AdjustTrackEvent.Instance.TrackEvent(m_token);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(m_key);
|
||||
ShuShuEvent.Instance.Track(m_key);
|
||||
LoggerUtils.Debug("[keyevents] totalrevenue key:" + m_key + " revenu" + m_revenue + " eventName:" + m_eventName + " token:" + m_token);
|
||||
if (!m_reset_after_trigger) return;
|
||||
AdPlayCountManager.ResetKeyEventTotalRevenue(m_key);
|
||||
PlayerPrefsUtils.DeletePlayerPrefs(m_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region AdTotalRevenue
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
[System.Serializable]
|
||||
|
@ -138,8 +181,8 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
|||
public class AdTotalRevenurData
|
||||
{
|
||||
public string Name;
|
||||
public string Revenue;
|
||||
public int reset_after_trigger;
|
||||
public float Revenue;
|
||||
public bool reset_after_trigger;
|
||||
public List<int> AdType;
|
||||
public string adjust_token;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
|||
{
|
||||
private const string PLAY_COUNT_SUFFIX = "_PLAY_COUNT";
|
||||
|
||||
// 关键事件数据
|
||||
#region 关键事件数据
|
||||
public static int GetKeyEventPlayCount(string key)
|
||||
{
|
||||
try
|
||||
|
@ -32,7 +32,7 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerUtils.Error($"设置广告播放次数失败: {ex.Message}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,76 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
|||
int currentCount = GetKeyEventPlayCount(key);
|
||||
SetKeyEventPlayCount(key, currentCount + 1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 关键事件加载次数
|
||||
public static int GetKeyEventFPUCount(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return PlayerPrefsUtils.GetPlayerPrefsInt(key, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetKeyEventFPUCount(string key, int count)
|
||||
{
|
||||
try
|
||||
{
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt(key, count);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void IncrementKeyEventFPUCount(string key)
|
||||
{
|
||||
int currentCount = GetKeyEventFPUCount(key);
|
||||
SetKeyEventFPUCount(key, currentCount + 1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 关键事件总revenue
|
||||
public static float GetKeyEventTotalRevenue(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return PlayerPrefsUtils.GetPlayerPrefsFloat(key, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetKeyEventTotalRevenue(string key, float count)
|
||||
{
|
||||
try
|
||||
{
|
||||
PlayerPrefsUtils.SavePlayerPrefsFloat(key, count);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void IncrementKeyEventTotalRevenue(string key, float revenue)
|
||||
{
|
||||
float currentCount = GetKeyEventTotalRevenue(key);
|
||||
SetKeyEventTotalRevenue(key, currentCount + revenue);
|
||||
}
|
||||
|
||||
public static void ResetKeyEventTotalRevenue(string key)
|
||||
{
|
||||
SetKeyEventTotalRevenue(key, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public static int GetAdPlayCount(AdsType adsType)
|
||||
|
|
|
@ -50,5 +50,11 @@ namespace Script.Utils
|
|||
PlayerPrefs.Save();
|
||||
return isFirstClick;
|
||||
}
|
||||
|
||||
public static void DeletePlayerPrefs(string _key)
|
||||
{
|
||||
PlayerPrefs.DeleteKey(_key);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue