admob 数数/firebase收益事件上报
This commit is contained in:
parent
522251e648
commit
aba6cdac40
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DKManager.AdsSDKManager.Constant;
|
||||
using GoogleMobileAds.Api;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
|
@ -359,10 +360,26 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
#endregion
|
||||
|
||||
#region 收益上报
|
||||
public static void TrackAdImpression(AdapterResponseInfo loadedAdapterResponseInfo, AdValue adValue, AdsType type,string placement)
|
||||
public void TrackAdImpression(AdapterResponseInfo loadedAdapterResponseInfo, AdValue adValue, AdsType type, string placement)
|
||||
{
|
||||
AdjustTrackEvent.Instance.TrackAdEvent(adValue.Value / 1000000f,loadedAdapterResponseInfo.AdSourceName,placement,loadedAdapterResponseInfo.AdSourceInstanceName);
|
||||
AdjustTrackEvent.Instance.TrackAdEvent(adValue.Value / 1000000f,
|
||||
loadedAdapterResponseInfo.AdSourceName,
|
||||
placement,
|
||||
loadedAdapterResponseInfo.AdSourceInstanceName);
|
||||
|
||||
FireBaseAnalyticsManager.Instance.OnAdRevenueEvent(PlatformType.Admob.ToString(),
|
||||
loadedAdapterResponseInfo.AdSourceName,
|
||||
placement, type.ToString(),
|
||||
adValue.Value / 1000000f,
|
||||
type == AdsType.Rewarded ? _rvPos : "",
|
||||
AdPlayCountManager.GetAdPlayCount(type));
|
||||
|
||||
ShuShuEvent.Instance.OnAdRevenueEvent(PlatformType.Admob.ToString(),
|
||||
loadedAdapterResponseInfo.AdSourceName,
|
||||
placement, type.ToString(),
|
||||
adValue.Value / 1000000f,
|
||||
type == AdsType.Rewarded ? _rvPos : "",
|
||||
AdPlayCountManager.GetAdPlayCount(type));
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -65,10 +65,11 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
bannerAds.OnAdPaid += ((adValue) =>
|
||||
{
|
||||
LoggerUtils.Debug($"[Admob] banner -[interaction]: {adUnitId} show");
|
||||
AdmobAdsManager.TrackAdImpression(bannerAds.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
AdmobAdsManager.Instance.TrackAdImpression(bannerAds.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
adValue,
|
||||
AdsType.Banner,
|
||||
AdmobUtils.ParseResponseInfo(bannerAds.GetResponseInfo()));
|
||||
AdmobUtils.ParseResponseInfo(bannerAds.GetResponseInfo()),"");
|
||||
|
||||
OnAdPaid?.Invoke(adValue);
|
||||
});
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
ad.OnAdPaid += (AdValue adValue) =>
|
||||
{
|
||||
LoggerUtils.Debug(String.Format("[Admob] Interstitial ad paid {0} {1}.", adValue.Value, adValue.CurrencyCode));
|
||||
AdmobAdsManager.TrackAdImpression(ad.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
AdmobAdsManager.Instance.TrackAdImpression(ad.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
adValue,
|
||||
AdsType.Interstitial,
|
||||
AdmobUtils.ParseResponseInfo(ad.GetResponseInfo()));
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
ad.OnAdPaid += (AdValue adValue) =>
|
||||
{
|
||||
LoggerUtils.Debug(String.Format("[Admob] rewarded ad paid {0} {1}.", adValue.Value, adValue.CurrencyCode));
|
||||
AdmobAdsManager.TrackAdImpression(ad.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
AdmobAdsManager.Instance.TrackAdImpression(ad.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
adValue,
|
||||
AdsType.Rewarded,
|
||||
AdmobUtils.ParseResponseInfo(ad.GetResponseInfo()));
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
ad.OnAdPaid += (AdValue adValue) =>
|
||||
{
|
||||
LoggerUtils.Debug(String.Format("[Admob] appopen ad paid {0} {1}.", adValue.Value, adValue.CurrencyCode));
|
||||
AdmobAdsManager.TrackAdImpression(ad.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
AdmobAdsManager.Instance.TrackAdImpression(ad.GetResponseInfo().GetLoadedAdapterResponseInfo(),
|
||||
adValue,
|
||||
AdsType.Splash,
|
||||
AdmobUtils.ParseResponseInfo(ad.GetResponseInfo()));
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script.Utils;
|
||||
using SDKManager.AdsSDKManager.Constant;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Utils
|
||||
{
|
||||
public class AdPlayCountManager
|
||||
{
|
||||
private const string PLAY_COUNT_SUFFIX = "_PLAY_COUNT";
|
||||
|
||||
public static int GetAdPlayCount(AdsType adsType)
|
||||
{
|
||||
try
|
||||
{
|
||||
string key = GetPlayCountKey(adsType);
|
||||
return PlayerPrefsUtils.GetPlayerPrefsInt(key, 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerUtils.Error($"获取广告播放次数失败: {ex.Message}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void SetAdPlayCount(AdsType adsType, int count)
|
||||
{
|
||||
try
|
||||
{
|
||||
string key = GetPlayCountKey(adsType);
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt(key, count);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerUtils.Error($"设置广告播放次数失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void IncrementAdPlayCount(AdsType adsType)
|
||||
{
|
||||
int currentCount = GetAdPlayCount(adsType);
|
||||
SetAdPlayCount(adsType, currentCount + 1);
|
||||
}
|
||||
|
||||
private static string GetPlayCountKey(AdsType adsType)
|
||||
{
|
||||
return $"{adsType}{PLAY_COUNT_SUFFIX}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 251647f5afc7f4b58af8b52aa55f9d2c
|
|
@ -59,7 +59,7 @@ public class FireBaseAnalyticsManager : NormalSingleton<FireBaseAnalyticsManager
|
|||
/// <param name="revenue">单次展示收益</param>
|
||||
/// <param name="position">广告展示点位</param>
|
||||
/// <param name="number">第几次展示该格式的广告</param>
|
||||
private void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number)
|
||||
public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number)
|
||||
{
|
||||
var impressionParameters = new[] {
|
||||
new Firebase.Analytics.Parameter("ad_platform", ad_platform),
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ShuShuEvent : NormalSingleton<ShuShuEvent>
|
|||
/// <param name="revenue">单次展示收益</param>
|
||||
/// <param name="position">广告展示点位</param>
|
||||
/// <param name="number">第几次展示该格式的广告</param>
|
||||
private void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number)
|
||||
public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number)
|
||||
{
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
properties.Add("ad_platform", ad_platform);
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.Utils
|
||||
{
|
||||
public class PlayerPrefsUtils
|
||||
{
|
||||
private const string BXSdk_PREFIX = "Sdk_";
|
||||
public static float GetPlayerPrefsFloat(string _key, float _dValue = 0.0f)
|
||||
{
|
||||
float value = PlayerPrefs.GetFloat(string.Format("{0}{1}", BXSdk_PREFIX, _key), _dValue);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void SavePlayerPrefsFloat(string _key, float _nValue)
|
||||
{
|
||||
PlayerPrefs.SetFloat(string.Format("{0}{1}", BXSdk_PREFIX, _key), _nValue);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public static int GetPlayerPrefsInt(string _key, int _dValue = 0)
|
||||
{
|
||||
int value = PlayerPrefs.GetInt(string.Format("{0}{1}", BXSdk_PREFIX, _key), _dValue);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void SavePlayerPrefsInt(string _key, int _nValue)
|
||||
{
|
||||
PlayerPrefs.SetInt(string.Format("{0}{1}", BXSdk_PREFIX, _key), _nValue);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public static string GetPlayerPrefsString(string _key, string _dValue = "")
|
||||
{
|
||||
string value = PlayerPrefs.GetString(string.Format("{0}{1}", BXSdk_PREFIX, _key), _dValue);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void SavePlayerPrefsString(string _key, string _nValue)
|
||||
{
|
||||
PlayerPrefs.SetString(string.Format("{0}{1}", BXSdk_PREFIX, _key), _nValue);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b2572c2555e654d5aad4a845312b20e9
|
Loading…
Reference in New Issue