update: 【中台】【广告】新增广告打点参数,未加入 review_creative_id
--story=1020787 --user=yufei.hu 【中台】【广告】新增广告打点参数,未加入 review_creative_id https://www.tapd.cn/33527076/s/1160827 Signed-off-by: huyufei <yufei.hu@castbox.fm>
parent
cf832d88ad
commit
96750cc3d8
|
|
@ -116,7 +116,7 @@ namespace Guru
|
||||||
|
|
||||||
private void OnLoadMaxBanner()
|
private void OnLoadMaxBanner()
|
||||||
{
|
{
|
||||||
_badsloadStartTime = DateTime.UtcNow;
|
_badsLoadStartTime = DateTime.UtcNow;
|
||||||
_chanelMax.LoadBannerAD();
|
_chanelMax.LoadBannerAD();
|
||||||
OnBannerStartLoad?.Invoke(_chanelMax.MaxBADSSlotID);
|
OnBannerStartLoad?.Invoke(_chanelMax.MaxBADSSlotID);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Guru.Ads;
|
|
||||||
|
|
||||||
|
//TODO: 将 BADS,IADS,RADS 分别放到不同的类中,方便维护
|
||||||
public abstract class ADServiceBase<T> : IADService where T : new()
|
public abstract class ADServiceBase<T> : IADService where T : new()
|
||||||
{
|
{
|
||||||
// 单利定义
|
// 单利定义
|
||||||
|
|
@ -21,9 +20,9 @@ namespace Guru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static readonly string Tag = "[SDK][ADS]";
|
private const string Tag = "[SDK][ADS]";
|
||||||
public bool IsInitialized => MaxSdk.IsInitialized() || _isServiceStarted;
|
public bool IsInitialized => MaxSdk.IsInitialized() || _isServiceStarted;
|
||||||
protected bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable;
|
private static bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable;
|
||||||
|
|
||||||
private const int MAX_ADS_RELOAD_INTERVAL = 6; // 广告加载最高时间为 2 的 6 次方 = 64秒
|
private const int MAX_ADS_RELOAD_INTERVAL = 6; // 广告加载最高时间为 2 的 6 次方 = 64秒
|
||||||
|
|
||||||
|
|
@ -31,28 +30,23 @@ namespace Guru
|
||||||
|
|
||||||
protected Action _onSdkInitReady;
|
protected Action _onSdkInitReady;
|
||||||
|
|
||||||
public static Action<string> OnBannerStartLoad;
|
public Action<string> OnBannerStartLoad;
|
||||||
public static Action OnBannerLoaded;
|
public Action OnBannerLoaded;
|
||||||
|
|
||||||
public static Action<string> OnInterstitialStartLoad;
|
public Action<string> OnInterstitialStartLoad;
|
||||||
public static Action OnInterstitialLoaded;
|
public Action OnInterstitialLoaded;
|
||||||
public static Action OnInterstitialFailed;
|
public Action OnInterstitialFailed;
|
||||||
public static Action OnInterstitialClosed;
|
public Action OnInterstitialClosed;
|
||||||
|
|
||||||
public static Action<string> OnRewardedStartLoad;
|
public Action<string> OnRewardedStartLoad;
|
||||||
public static Action OnRewardLoaded;
|
public Action OnRewardLoaded;
|
||||||
public static Action OnRewardFailed;
|
public Action OnRewardFailed;
|
||||||
public static Action OnRewardClosed;
|
public Action OnRewardClosed;
|
||||||
|
|
||||||
private Dictionary<string, string> _reviewCreativeIds = new Dictionary<string, string>(10); // Creative ID 缓存: Cid : RCid
|
private AdsModel _model;
|
||||||
private Dictionary<string, List<AdImpressionData>> _impressionCache = new Dictionary<string, List<AdImpressionData>>(10);
|
|
||||||
|
|
||||||
protected AdsModel _model;
|
|
||||||
protected AdsInitSpec _initSpec = null;
|
protected AdsInitSpec _initSpec = null;
|
||||||
|
|
||||||
private AdImpressionDriver _impressionDriver;
|
private AdsModel Model
|
||||||
|
|
||||||
public AdsModel Model
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
@ -67,8 +61,7 @@ namespace Guru
|
||||||
/// 启动广告服务
|
/// 启动广告服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="callback">广告初始化回调</param>
|
/// <param name="callback">广告初始化回调</param>
|
||||||
/// <param name="autoLoadAds">自动启动广告加载</param>
|
/// <param name="initSpec">初始化配置参数</param>
|
||||||
/// <param name="isDebugMode">debug模式</param>
|
|
||||||
public virtual void StartService(Action callback = null, AdsInitSpec initSpec = null)
|
public virtual void StartService(Action callback = null, AdsInitSpec initSpec = null)
|
||||||
{
|
{
|
||||||
if (IsInitialized) return; // 已经初始化后, 无需再次初始化
|
if (IsInitialized) return; // 已经初始化后, 无需再次初始化
|
||||||
|
|
@ -82,9 +75,6 @@ namespace Guru
|
||||||
if(_model == null) _model = AdsModel.Create();
|
if(_model == null) _model = AdsModel.Create();
|
||||||
this.Log("AD SDK Start Init");
|
this.Log("AD SDK Start Init");
|
||||||
|
|
||||||
_impressionDriver = new AdImpressionDriver();
|
|
||||||
_impressionDriver.Init(ReportAdsRevenue); // 初始化 Impression 驱动器
|
|
||||||
|
|
||||||
InitMaxCallbacks(); // 初始化 MAX 广告
|
InitMaxCallbacks(); // 初始化 MAX 广告
|
||||||
InitService(); // 内部继承接口
|
InitService(); // 内部继承接口
|
||||||
}
|
}
|
||||||
|
|
@ -99,13 +89,14 @@ namespace Guru
|
||||||
|
|
||||||
//--------------- MRec 回调 -----------------
|
//--------------- MRec 回调 -----------------
|
||||||
// MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
|
// MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
|
||||||
|
|
||||||
//--------------- Banner 回调 -----------------
|
//--------------- Banner 回调 -----------------
|
||||||
MaxSdkCallbacks.Banner.OnAdLoadedEvent += OnBannerLoadedEvent;
|
MaxSdkCallbacks.Banner.OnAdLoadedEvent += OnBannerLoadedEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdLoadFailedEvent += OnBannerFailedEvent;
|
MaxSdkCallbacks.Banner.OnAdLoadFailedEvent += OnBannerFailedEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdClickedEvent += OnBannerClickedEvent;
|
MaxSdkCallbacks.Banner.OnAdClickedEvent += OnBannerClickedEvent;
|
||||||
|
// MaxSdkCallbacks.Banner.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnBannerRevenuePaidEvent;
|
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnBannerRevenuePaidEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
|
|
||||||
//--------------- IV 回调 -----------------
|
//--------------- IV 回调 -----------------
|
||||||
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
|
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterstitialFailedEvent;
|
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterstitialFailedEvent;
|
||||||
|
|
@ -114,7 +105,7 @@ namespace Guru
|
||||||
MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayEvent;
|
MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialDismissedEvent;
|
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialDismissedEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnInterstitialPaidEvent;
|
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnInterstitialPaidEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
|
// MaxSdkCallbacks.Interstitial.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
|
||||||
//--------------- RV 回调 -----------------
|
//--------------- RV 回调 -----------------
|
||||||
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdFailedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdFailedEvent;
|
||||||
|
|
@ -122,20 +113,15 @@ namespace Guru
|
||||||
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdDismissedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdDismissedEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
|
|
||||||
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdPaidEvent;
|
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdPaidEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
|
||||||
|
// MaxSdkCallbacks.Rewarded.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
|
||||||
//--------------- Creative 回调 -----------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------- SDK 初始化 -------------------
|
//-------------- SDK 初始化 -------------------
|
||||||
MaxSdk.SetExtraParameter("enable_black_screen_fixes", "true"); // 修复黑屏
|
MaxSdk.SetExtraParameter("enable_black_screen_fixes", "true"); // 修复黑屏
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected virtual void InitService()
|
protected virtual void InitService()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +149,7 @@ namespace Guru
|
||||||
/// 可加载广告
|
/// 可加载广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool CanLoadAds()
|
private bool CanLoadAds()
|
||||||
{
|
{
|
||||||
return IsInitialized && IsNetworkEnabled;
|
return IsInitialized && IsNetworkEnabled;
|
||||||
}
|
}
|
||||||
|
|
@ -214,26 +200,21 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上报广告收益
|
/// 上报广告收益
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="adInfo"></param>
|
/// <param name="data"></param>
|
||||||
/// <param name="reviewedCreativeId"></param>
|
private void ReportAdsRevenue(AdParams data)
|
||||||
private void ReportAdsRevenue(AdImpressionData data)
|
|
||||||
{
|
{
|
||||||
// #1 ad_impression
|
// #1 ad_impression
|
||||||
Analytics.ADImpression(data);
|
Analytics.ADImpression(data.ToAdImpressionData());
|
||||||
|
|
||||||
// #2 tch_001 和 tch_02
|
// #2 tch_001
|
||||||
double revenue = data.value;
|
double revenue = data.value;
|
||||||
CalcTch001Value(revenue);
|
CalcTch001Value(revenue);
|
||||||
CalcTch02Value(revenue);
|
CalcTch02Value(revenue);
|
||||||
|
|
||||||
// #3 adjust_ad_revenue
|
// #3 adjust_ad_revenue
|
||||||
AdjustService.TrackADRevenue(data.value, data.currency, data.ad_source, data.ad_unit_name, data.ad_placement);
|
AdjustService.TrackADRevenue(data.value, data.currency, data.adSource, data.adUnitId, data.networkPlacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算太极001收益
|
/// 计算太极001收益
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -242,10 +223,10 @@ namespace Guru
|
||||||
{
|
{
|
||||||
TchAD001RevValue += revenue;
|
TchAD001RevValue += revenue;
|
||||||
double revenueValue = TchAD001RevValue;
|
double revenueValue = TchAD001RevValue;
|
||||||
Debug.Log($"[TaichConfig] get <TchAD001RevValue> totally: {revenueValue}");
|
// Debug.Log($"{Tag} --- [Tch] get <TchAD001RevValue> totally: {revenueValue}");
|
||||||
if (revenueValue >= Analytics.Tch001TargetValue)
|
if (revenueValue >= Analytics.Tch001TargetValue)
|
||||||
{
|
{
|
||||||
Debug.Log($"[TaichConfig] call <tch_ad_rev_roas_001> with value: {revenueValue}");
|
Debug.Log($"{Tag} --- [Tch] call <tch_ad_rev_roas_001> with value: {revenueValue}");
|
||||||
Analytics.Tch001ADRev(revenueValue);
|
Analytics.Tch001ADRev(revenueValue);
|
||||||
TchAD001RevValue = 0.0;
|
TchAD001RevValue = 0.0;
|
||||||
}
|
}
|
||||||
|
|
@ -274,15 +255,15 @@ namespace Guru
|
||||||
|
|
||||||
#region Banner Ads
|
#region Banner Ads
|
||||||
|
|
||||||
private string _backColorStr = "#50A436";
|
|
||||||
private Color _backColor = new Color(0, 0, 0, 0);
|
private Color _backColor = new Color(0, 0, 0, 0);
|
||||||
private string _badsCategory;
|
private string _badsCategory;
|
||||||
protected DateTime _badsloadStartTime;
|
protected DateTime _badsLoadStartTime;
|
||||||
private bool _bannerVisible = false;
|
private bool _bannerVisible = false;
|
||||||
public bool IsBannerVisible => _bannerVisible;
|
public bool IsBannerVisible => _bannerVisible;
|
||||||
private int _badsloadedNum = 0;
|
private int _badsLoadedNum = 0;
|
||||||
private int _badsLoadFailNum = 0;
|
private int _badsLoadFailNum = 0;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取动作间隔之间的毫秒数
|
/// 获取动作间隔之间的毫秒数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -309,32 +290,32 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Banner MAX 加载方式
|
/// Banner MAX 加载方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void LoadMaxBannerAd()
|
private void LoadMaxBannerAd()
|
||||||
{
|
{
|
||||||
OnLoadBads();
|
OnLoadBads();
|
||||||
// Banners are automatically sized to 320x50 on phones and 728x90 on tablets
|
// Banners are automatically sized to 320x50 on phones and 728x90 on tablets
|
||||||
// You may use the utility method `MaxSdkUtils.isTablet()` to help with view sizing adjustments
|
// You may use the utility method `MaxSdkUtils.isTablet()` to help with view sizing adjustments
|
||||||
var id = GetBannerID();
|
var adUnitId = GetBannerID();
|
||||||
MaxSdk.CreateBanner(id, MaxSdkBase.BannerPosition.BottomCenter);
|
MaxSdk.CreateBanner(adUnitId, MaxSdkBase.BannerPosition.BottomCenter);
|
||||||
MaxSdk.SetBannerExtraParameter(id, "adaptive_banner", "false");
|
MaxSdk.SetBannerExtraParameter(adUnitId, "adaptive_banner", "false");
|
||||||
// Set background or background color for banners to be fully functional
|
// Set background or background color for banners to be fully functional
|
||||||
MaxSdk.SetBannerBackgroundColor(id, _backColor);
|
MaxSdk.SetBannerBackgroundColor(adUnitId, _backColor);
|
||||||
// Analytics.ADBadsLoad(GetBannerID());
|
// Analytics.ADBadsLoad(GetBannerID());
|
||||||
Analytics.ADBadsLoad(AdParams.Build(id));
|
Analytics.TrackAdBadsLoad(AdParams.Build(adUnitId:adUnitId).ToAdLoadedData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLoadBads()
|
private void OnLoadBads()
|
||||||
{
|
{
|
||||||
_badsloadStartTime = DateTime.UtcNow;
|
_badsLoadStartTime = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnBadsLoaded()
|
private void OnBadsLoaded()
|
||||||
{
|
{
|
||||||
_badsloadStartTime = DateTime.UtcNow;
|
_badsLoadStartTime = DateTime.UtcNow;
|
||||||
OnBannerLoaded?.Invoke();
|
OnBannerLoaded?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetBannerAutoRefresh(bool value = true, string adUnitId = "")
|
public void SetBannerAutoRefresh(bool value = true, string adUnitId = "")
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(adUnitId)) adUnitId = GetBannerID();
|
if(string.IsNullOrEmpty(adUnitId)) adUnitId = GetBannerID();
|
||||||
if (value)
|
if (value)
|
||||||
|
|
@ -360,9 +341,10 @@ namespace Guru
|
||||||
SetBannerAutoRefresh(true, adUnitId);
|
SetBannerAutoRefresh(true, adUnitId);
|
||||||
if (!_bannerVisible)
|
if (!_bannerVisible)
|
||||||
{
|
{
|
||||||
|
// 从隐藏状态到显示,累计的加载次数和失败次数清零
|
||||||
_bannerVisible = true;
|
_bannerVisible = true;
|
||||||
OnBannerImpEvent(adUnitId);
|
OnBannerImpEvent(adUnitId);
|
||||||
_badsloadedNum = 0;
|
_badsLoadedNum = 0;
|
||||||
_badsLoadFailNum = 0;
|
_badsLoadFailNum = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,7 +352,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 隐藏 Banner
|
/// 隐藏 Banner
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void HideBanner()
|
public void HideBanner()
|
||||||
{
|
{
|
||||||
string adUnitId = GetBannerID();
|
string adUnitId = GetBannerID();
|
||||||
MaxSdk.HideBanner(adUnitId);
|
MaxSdk.HideBanner(adUnitId);
|
||||||
|
|
@ -386,47 +368,44 @@ namespace Guru
|
||||||
/// 设置 Banner 背景颜色
|
/// 设置 Banner 背景颜色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color"></param>
|
/// <param name="color"></param>
|
||||||
public virtual void SetBannerBackgroundColor(Color color)
|
public void SetBannerBackgroundColor(Color color)
|
||||||
{
|
{
|
||||||
_backColor = color;
|
_backColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBannerLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
private void OnBannerLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
_badsloadedNum++;
|
_badsLoadedNum++; // 记录加载次数
|
||||||
// --- fixed by Yufei 2024-5-29 为 don't report bads_loaded any more. ---
|
|
||||||
// Analytics.ADBadsLoaded(AdParams.Build(adUnitId, adInfo,
|
|
||||||
// duration: GetAdsLoadDuration(ref _badsloadStartTime), category: _badsCategory));
|
|
||||||
Debug.Log( $"[SDK][Ads][Loaded] --- adUnitId:{adUnitId} Revenue:{adInfo.Revenue} Type:{adInfo.AdFormat} CreativeId:{adInfo.CreativeIdentifier}");
|
Debug.Log( $"[SDK][Ads][Loaded] --- adUnitId:{adUnitId} Revenue:{adInfo.Revenue} Type:{adInfo.AdFormat} CreativeId:{adInfo.CreativeIdentifier}");
|
||||||
OnBadsLoaded();
|
OnBadsLoaded();
|
||||||
|
// BADSLoaded 事件已经不做上报处理了
|
||||||
|
// --- fixed by YuFei 2024-5-29 为 don't report bads_loaded any more. ---
|
||||||
|
// Analytics.ADBadsLoaded(AdParams.Build(adUnitId, adInfo,
|
||||||
|
// duration: GetAdsLoadDuration(ref _badsLoadStartTime), category: _badsCategory));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBannerFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
private void OnBannerFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||||
{
|
{
|
||||||
_badsLoadFailNum ++;
|
_badsLoadFailNum++; // 记录加载失败次数
|
||||||
// Analytics.ADBadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _badsloadStartTime), _badsCategory);
|
Analytics.TrackAdBadsFailed(BuildBadsFailedData(adUnitId, errorInfo));
|
||||||
Analytics.ADBadsFailed(AdParams.Build(adUnitId,
|
|
||||||
duration: GetActionDuration(_badsloadStartTime), category: _badsCategory,
|
|
||||||
errorCode: (int)errorInfo.Code,
|
|
||||||
waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBannerClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
private void OnBannerClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
// Analytics.ADBadsClick(adUnitId, _badsCategory);
|
// Analytics.ADBadsClick(adUnitId, _badsCategory);
|
||||||
Analytics.ADBadsClick(AdParams.Build(adUnitId, adInfo, _badsCategory));
|
Analytics.TrackAdBadsClick(BuildBadsClickData(adInfo, adUnitId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBannerImpEvent(string adUnitId)
|
private void OnBannerImpEvent(string adUnitId)
|
||||||
{
|
{
|
||||||
// Analytics.ADBadsClick(adUnitId, _badsCategory);
|
// Analytics.ADBadsClick(adUnitId, _badsCategory);
|
||||||
Analytics.ADBadsImp(AdParams.Build(adUnitId, category: _badsCategory));
|
Analytics.TrackAdBadsImp(BuildBadsImpData(adUnitId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnBannerHideEvent()
|
private void OnBannerHideEvent()
|
||||||
{
|
{
|
||||||
Analytics.ADBadsHide(_badsloadedNum, _badsLoadFailNum);
|
Analytics.TrackAdBadsHide(_badsLoadedNum, _badsLoadFailNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -438,8 +417,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (_bannerVisible)
|
if (_bannerVisible)
|
||||||
{
|
{
|
||||||
// Banner 只有显示时才上报收益值
|
ReportAdsRevenue(AdParams.Build(adInfo, adUnitId));
|
||||||
AppendImpressionData(adInfo, eventName:Analytics.EventBadsPaid, itemCategory:_badsCategory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,7 +428,7 @@ namespace Guru
|
||||||
private string _iadsCategory = "main";
|
private string _iadsCategory = "main";
|
||||||
private int _interstitialRetryAttempt;
|
private int _interstitialRetryAttempt;
|
||||||
private Action _interCloseAction;
|
private Action _interCloseAction;
|
||||||
protected bool _isIadsLoading = false;
|
private bool _isIadsLoading = false;
|
||||||
protected DateTime _iadsLoadStartTime;
|
protected DateTime _iadsLoadStartTime;
|
||||||
private DateTime _iadsDisplayStartTime;
|
private DateTime _iadsDisplayStartTime;
|
||||||
|
|
||||||
|
|
@ -468,15 +446,15 @@ namespace Guru
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void LoadMaxInterstitial()
|
private void LoadMaxInterstitial()
|
||||||
{
|
{
|
||||||
OnLoadIads();
|
OnLoadIads();
|
||||||
var id = GetInterstitialID();
|
var adUnitId = GetInterstitialID();
|
||||||
Analytics.ADIadsLoad(AdParams.Build(id));
|
Analytics.TrackAdIadsLoad(AdParams.Build(adUnitId:adUnitId).ToAdLoadedData());
|
||||||
MaxSdk.LoadInterstitial(id);
|
MaxSdk.LoadInterstitial(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLoadIads()
|
private void OnLoadIads()
|
||||||
{
|
{
|
||||||
_iadsLoadStartTime = DateTime.UtcNow;
|
_iadsLoadStartTime = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
@ -491,8 +469,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示插屏广告
|
/// 显示插屏广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rewardAction">广告奖励回调</param>
|
/// <param name="category">广告奖励回调</param>
|
||||||
/// <param name="failAction">广告失败回调</param>
|
|
||||||
/// <param name="dismissAction">广告界面关闭回调</param>
|
/// <param name="dismissAction">广告界面关闭回调</param>
|
||||||
public virtual void ShowInterstitialAD(string category, Action dismissAction = null)
|
public virtual void ShowInterstitialAD(string category, Action dismissAction = null)
|
||||||
{
|
{
|
||||||
|
|
@ -513,7 +490,6 @@ namespace Guru
|
||||||
MaxSdk.ShowInterstitial(GetInterstitialID());
|
MaxSdk.ShowInterstitial(GetInterstitialID());
|
||||||
|
|
||||||
_iadsDisplayStartTime = DateTime.UtcNow;
|
_iadsDisplayStartTime = DateTime.UtcNow;
|
||||||
// RequestInterstitialAD(); // 直接加载下一个广告
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
protected virtual void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
|
|
@ -522,12 +498,9 @@ namespace Guru
|
||||||
// Interstitial ad is ready to be shown. MaxSdk.IsInterstitialReady(interstitialAdUnitId) will now return 'true'
|
// Interstitial ad is ready to be shown. MaxSdk.IsInterstitialReady(interstitialAdUnitId) will now return 'true'
|
||||||
// Reset retry attempt
|
// Reset retry attempt
|
||||||
// Analytics.ADIadsLoaded(adUnitId, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
// Analytics.ADIadsLoaded(adUnitId, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
||||||
Analytics.ADIadsLoaded(AdParams.Build(adUnitId,
|
Analytics.TrackAdIadsLoaded(BuildIadsLoadedData(adInfo, adUnitId));
|
||||||
duration: GetActionDuration(_iadsLoadStartTime), category: _iadsCategory));
|
|
||||||
_interstitialRetryAttempt = 0;
|
_interstitialRetryAttempt = 0;
|
||||||
|
|
||||||
Debug.Log( $"[SDK][Ads][Loaded] --- adUnitId:{adUnitId} Revenue:{adInfo.Revenue} Type:{adInfo.AdFormat} CreativeId:{adInfo.CreativeIdentifier}");
|
Debug.Log( $"[SDK][Ads][Loaded] --- adUnitId:{adUnitId} Revenue:{adInfo.Revenue} Type:{adInfo.AdFormat} CreativeId:{adInfo.CreativeIdentifier}");
|
||||||
|
|
||||||
OnInterstitialLoaded?.Invoke();
|
OnInterstitialLoaded?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,11 +515,7 @@ namespace Guru
|
||||||
float retryDelay = GetRetryDelaySeconds(_interstitialRetryAttempt);
|
float retryDelay = GetRetryDelaySeconds(_interstitialRetryAttempt);
|
||||||
DelayCall(retryDelay, RequestInterstitialAD);
|
DelayCall(retryDelay, RequestInterstitialAD);
|
||||||
// Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
// Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
||||||
if(string.IsNullOrEmpty(_iadsCategory)) _iadsCategory = "not_set";
|
Analytics.TrackAdIadsFailed(BuildIadsFailedData(adUnitId, errorInfo));
|
||||||
Analytics.ADIadsFailed(AdParams.Build(adUnitId,
|
|
||||||
duration: GetActionDuration(_iadsLoadStartTime), category: _iadsCategory,
|
|
||||||
errorCode: (int)errorInfo.Code,
|
|
||||||
waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
|
|
||||||
|
|
||||||
OnInterstitialFailed?.Invoke();
|
OnInterstitialFailed?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
@ -558,10 +527,7 @@ namespace Guru
|
||||||
this.LogError(
|
this.LogError(
|
||||||
$"InterstitialFailedToDisplayEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
$"InterstitialFailedToDisplayEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
||||||
// Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
// Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
||||||
Analytics.ADIadsFailed(AdParams.Build(adUnitId,
|
Analytics.TrackAdIadsFailed(BuildIadsFailedData(adUnitId, errorInfo));
|
||||||
duration: GetActionDuration(_iadsDisplayStartTime), category: _iadsCategory,
|
|
||||||
errorCode: (int)errorInfo.Code,
|
|
||||||
waterfallName: errorInfo.WaterfallInfo?.Name ?? ""));
|
|
||||||
DelayCall(2.0f, RequestInterstitialAD);
|
DelayCall(2.0f, RequestInterstitialAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -569,16 +535,13 @@ namespace Guru
|
||||||
protected virtual void OnInterstitialDisplayEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
protected virtual void OnInterstitialDisplayEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
// Analytics.ADIadsImp(adUnitId, _iadsCategory);
|
// Analytics.ADIadsImp(adUnitId, _iadsCategory);
|
||||||
AppendImpressionData(adInfo, eventName:Analytics.EventIadsImp, itemCategory:_iadsCategory);
|
Analytics.TrackAdIadsImp(BuildIadsImpData(adInfo, adUnitId));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnInterstitialClickEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
protected virtual void OnInterstitialClickEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
// Analytics.ADIadsClick(adUnitId, _iadsCategory);
|
// Analytics.ADIadsClick(adUnitId, _iadsCategory);
|
||||||
if(string.IsNullOrEmpty(_iadsCategory)) _iadsCategory = "not_set";
|
Analytics.TrackAdIadsClick(BuildIadsClickData(adInfo, adUnitId));
|
||||||
AppendImpressionData(adInfo,
|
|
||||||
eventName:Analytics.EventIadsClick,
|
|
||||||
itemCategory:_iadsCategory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close
|
// Close
|
||||||
|
|
@ -588,13 +551,7 @@ namespace Guru
|
||||||
_interCloseAction?.Invoke();
|
_interCloseAction?.Invoke();
|
||||||
OnInterstitialClosed?.Invoke();
|
OnInterstitialClosed?.Invoke();
|
||||||
// Analytics.ADIadsClose(adUnitId, _iadsCategory);
|
// Analytics.ADIadsClose(adUnitId, _iadsCategory);
|
||||||
Analytics.ADIadsClose(new Dictionary<string, object>()
|
Analytics.TrackAdIadsClose(BuildIadsCloseData(adInfo, adUnitId));
|
||||||
{
|
|
||||||
[Analytics.ParameterItemCategory] = _iadsCategory,
|
|
||||||
[Analytics.ParameterDuration] = GetActionDuration(_iadsDisplayStartTime),
|
|
||||||
});
|
|
||||||
|
|
||||||
_impressionDriver.CleanCreativeId(adInfo.CreativeIdentifier);
|
|
||||||
|
|
||||||
//延时加载下一个广告
|
//延时加载下一个广告
|
||||||
DelayCall(2.0f, RequestInterstitialAD);
|
DelayCall(2.0f, RequestInterstitialAD);
|
||||||
|
|
@ -602,7 +559,9 @@ namespace Guru
|
||||||
|
|
||||||
private void OnInterstitialPaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
private void OnInterstitialPaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
AppendImpressionData(adInfo, eventName:Analytics.EventIadsPaid, itemCategory: _iadsCategory);
|
var p = AdParams.Build(adInfo, adUnitId, category:_iadsCategory);
|
||||||
|
Analytics.TrackAdIadsPaid(p.ToAdPaidData());
|
||||||
|
ReportAdsRevenue(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -610,14 +569,14 @@ namespace Guru
|
||||||
|
|
||||||
#region Rewarded Ads
|
#region Rewarded Ads
|
||||||
|
|
||||||
private string _rewardCategory = "main";
|
private string _radsCategory = "main";
|
||||||
private int _rewardRetryAttempt;
|
private int _rewardRetryAttempt;
|
||||||
protected DateTime _radsLoadStartTime;
|
protected DateTime _radsLoadStartTime;
|
||||||
protected DateTime _radsShowStartTime;
|
private DateTime _radsDisplayStartTime;
|
||||||
private Action _rvRewardAction;
|
private Action _rvRewardAction;
|
||||||
private Action<string> _rvFailAction;
|
private Action<string> _rvFailAction;
|
||||||
private Action _rvDismissAction;
|
private Action _rvDismissAction;
|
||||||
protected bool _isRadsLoading = false;
|
private bool _isRadsLoading = false;
|
||||||
public bool IsRadsLoading => _isRadsLoading;
|
public bool IsRadsLoading => _isRadsLoading;
|
||||||
|
|
||||||
public virtual void RequestRewardedAD()
|
public virtual void RequestRewardedAD()
|
||||||
|
|
@ -634,17 +593,17 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认加载 MAX 广告逻辑
|
/// 默认加载 MAX 广告逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void LoadMaxRewardAd(string unitId = "")
|
private void LoadMaxRewardAd()
|
||||||
{
|
{
|
||||||
if (IsRadsLoading) return;
|
if (IsRadsLoading) return;
|
||||||
|
|
||||||
OnLoadRads();
|
OnLoadRads();
|
||||||
var id = GetRewardedID();
|
var adUnitId = GetRewardedID();
|
||||||
Analytics.ADRadsLoad(AdParams.Build(id)); // 上报打点
|
Analytics.TrackAdRadsLoad(AdParams.Build(adUnitId:adUnitId).ToAdLoadData()); // 上报打点
|
||||||
MaxSdk.LoadRewardedAd(id);
|
MaxSdk.LoadRewardedAd(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLoadRads()
|
private void OnLoadRads()
|
||||||
{
|
{
|
||||||
_radsLoadStartTime = DateTime.UtcNow;
|
_radsLoadStartTime = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
@ -661,7 +620,8 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示激励视频广告
|
/// 显示激励视频广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rewardAction">广告奖励回调</param>
|
/// <param name="category">广告奖励回调</param>
|
||||||
|
/// <param name="rewardAction">广告失败回调</param>
|
||||||
/// <param name="failAction">广告失败回调</param>
|
/// <param name="failAction">广告失败回调</param>
|
||||||
/// <param name="dismissAction">广告界面关闭回调</param>
|
/// <param name="dismissAction">广告界面关闭回调</param>
|
||||||
public virtual void ShowRewardedAD(string category, Action rewardAction = null,
|
public virtual void ShowRewardedAD(string category, Action rewardAction = null,
|
||||||
|
|
@ -679,13 +639,13 @@ namespace Guru
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_rewardCategory = category;
|
_radsCategory = category;
|
||||||
_rvRewardAction = rewardAction;
|
_rvRewardAction = rewardAction;
|
||||||
_rvFailAction = failAction;
|
_rvFailAction = failAction;
|
||||||
_rvDismissAction = dismissAction;
|
_rvDismissAction = dismissAction;
|
||||||
MaxSdk.ShowRewardedAd(GetRewardedID());
|
MaxSdk.ShowRewardedAd(GetRewardedID());
|
||||||
|
|
||||||
_radsShowStartTime = DateTime.UtcNow;
|
_radsDisplayStartTime = DateTime.UtcNow;
|
||||||
|
|
||||||
// RequestRewardedAD();
|
// RequestRewardedAD();
|
||||||
}
|
}
|
||||||
|
|
@ -698,8 +658,7 @@ namespace Guru
|
||||||
// Reset retry attempt
|
// Reset retry attempt
|
||||||
// this.Log("OnRewardedAdLoadedEvent");
|
// this.Log("OnRewardedAdLoadedEvent");
|
||||||
// Analytics.ADRadsLoaded(adUnitId, GetAdsLoadDuration(ref _radsLoadStartTime), _rewardCategory);
|
// Analytics.ADRadsLoaded(adUnitId, GetAdsLoadDuration(ref _radsLoadStartTime), _rewardCategory);
|
||||||
Analytics.ADRadsLoaded(AdParams.Build(adUnitId,
|
Analytics.TrackAdRadsLoaded(BuildRadsLoadedData(adInfo, adUnitId));
|
||||||
duration: GetActionDuration(_radsLoadStartTime), category: _iadsCategory));
|
|
||||||
_rewardRetryAttempt = 0;
|
_rewardRetryAttempt = 0;
|
||||||
|
|
||||||
Debug.Log( $"[SDK][Ads][Loaded] --- adUnitId:{adUnitId} Revenue:{adInfo.Revenue} Type:{adInfo.AdFormat} CreativeId:{adInfo.CreativeIdentifier}");
|
Debug.Log( $"[SDK][Ads][Loaded] --- adUnitId:{adUnitId} Revenue:{adInfo.Revenue} Type:{adInfo.AdFormat} CreativeId:{adInfo.CreativeIdentifier}");
|
||||||
|
|
@ -716,10 +675,7 @@ namespace Guru
|
||||||
this.LogError(
|
this.LogError(
|
||||||
$"OnRewardedAdFailedEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
$"OnRewardedAdFailedEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
||||||
// Analytics.ADRadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _radsLoadStartTime), _rewardCategory);
|
// Analytics.ADRadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _radsLoadStartTime), _rewardCategory);
|
||||||
Analytics.ADRadsFailed(AdParams.Build(adUnitId,
|
Analytics.TrackAdRadsFailed(BuildRadsFailedData(adUnitId, errorInfo));
|
||||||
duration: GetActionDuration(_radsLoadStartTime), category: _rewardCategory,
|
|
||||||
errorCode: (int)errorInfo.Code,
|
|
||||||
waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
|
|
||||||
_rewardRetryAttempt++;
|
_rewardRetryAttempt++;
|
||||||
float retryDelay = GetRetryDelaySeconds(_rewardRetryAttempt);
|
float retryDelay = GetRetryDelaySeconds(_rewardRetryAttempt);
|
||||||
DelayCall(retryDelay, RequestRewardedAD);
|
DelayCall(retryDelay, RequestRewardedAD);
|
||||||
|
|
@ -734,10 +690,7 @@ namespace Guru
|
||||||
this.LogError(
|
this.LogError(
|
||||||
$"OnRewardedAdFailedToDisplayEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
$"OnRewardedAdFailedToDisplayEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}");
|
||||||
// Analytics.ADRadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _radsLoadStartTime), _rewardCategory);
|
// Analytics.ADRadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _radsLoadStartTime), _rewardCategory);
|
||||||
Analytics.ADRadsFailed(AdParams.Build(adUnitId,
|
Analytics.TrackAdRadsFailed(BuildRadsFailedData(adUnitId, errorInfo));
|
||||||
duration: GetActionDuration(_radsShowStartTime), category: _rewardCategory,
|
|
||||||
errorCode: (int)errorInfo.Code,
|
|
||||||
waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
|
|
||||||
_rvFailAction?.Invoke("OnRewardedAdFailedToDisplayEvent");
|
_rvFailAction?.Invoke("OnRewardedAdFailedToDisplayEvent");
|
||||||
DelayCall(2.0f, RequestRewardedAD);
|
DelayCall(2.0f, RequestRewardedAD);
|
||||||
|
|
||||||
|
|
@ -748,16 +701,17 @@ namespace Guru
|
||||||
{
|
{
|
||||||
this.Log("OnRewardedAdDisplayedEvent");
|
this.Log("OnRewardedAdDisplayedEvent");
|
||||||
// Analytics.ADRadsImp(adUnitId, _rewardCategory);
|
// Analytics.ADRadsImp(adUnitId, _rewardCategory);
|
||||||
AppendImpressionData(adInfo, eventName:Analytics.EventRadsImp, itemCategory: _rewardCategory);
|
Analytics.TrackAdRadsImp(BuildRadsImpData(adInfo, adUnitId));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
protected virtual void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
this.Log("OnRewardedAdClickedEvent");
|
this.Log("OnRewardedAdClickedEvent");
|
||||||
// Analytics.ADRadsClick(adUnitId, _rewardCategory);
|
// Analytics.ADRadsClick(adUnitId, _rewardCategory);
|
||||||
AppendImpressionData(adInfo, eventName:Analytics.EventRadsClick, itemCategory: _rewardCategory);
|
Analytics.TrackAdRadsClick(BuildRadsClickData(adInfo, adUnitId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// rads_close
|
// rads_close
|
||||||
protected virtual void OnRewardedAdDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
protected virtual void OnRewardedAdDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
|
|
@ -767,13 +721,7 @@ namespace Guru
|
||||||
OnRewardClosed?.Invoke();
|
OnRewardClosed?.Invoke();
|
||||||
|
|
||||||
// Analytics.ADRadsClose(adUnitId, _rewardCategory);
|
// Analytics.ADRadsClose(adUnitId, _rewardCategory);
|
||||||
Analytics.ADRadsClose(new Dictionary<string, object>()
|
Analytics.TrackAdRadsClose(BuildRadsCloseData(adInfo, adUnitId));
|
||||||
{
|
|
||||||
[Analytics.ParameterItemCategory] = _rewardCategory,
|
|
||||||
[Analytics.ParameterDuration] = GetActionDuration(_radsShowStartTime),
|
|
||||||
});
|
|
||||||
|
|
||||||
_impressionDriver.CleanCreativeId(adInfo.CreativeIdentifier);
|
|
||||||
|
|
||||||
//延时加载下一个广告
|
//延时加载下一个广告
|
||||||
DelayCall(2.0f, RequestRewardedAD);
|
DelayCall(2.0f, RequestRewardedAD);
|
||||||
|
|
@ -784,19 +732,18 @@ namespace Guru
|
||||||
MaxSdkBase.AdInfo adInfo)
|
MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
this.Log("OnRewardedAdReceivedRewardEvent");
|
this.Log("OnRewardedAdReceivedRewardEvent");
|
||||||
// Analytics.ADRadsRewarded(adUnitId, _rewardCategory);
|
Analytics.TrackAdRadsRewarded(BuildRadsRewardedData(adInfo, adUnitId));
|
||||||
AppendImpressionData(adInfo, eventName:Analytics.EventRadsRewarded, itemCategory: _rewardCategory);
|
// Rewarded ad was displayed and user should receive the reward
|
||||||
_rvRewardAction?.Invoke();
|
_rvRewardAction?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
// rads_paid
|
// rads_paid
|
||||||
private void OnRewardedAdPaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
private void OnRewardedAdPaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
this.Log("OnRewardedAdReceivedRewardEvent");
|
var p = AdParams.Build(adInfo, adUnitId, category:_iadsCategory);
|
||||||
AppendImpressionData(adInfo, eventName:Analytics.EventRadsPaid, itemCategory: _rewardCategory);
|
Analytics.TrackAdRadsPaid(p.ToAdPaidData());
|
||||||
|
ReportAdsRevenue(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Ad Settings
|
#region Ad Settings
|
||||||
|
|
@ -822,8 +769,8 @@ namespace Guru
|
||||||
|
|
||||||
public void ShowMaxDebugPanel()
|
public void ShowMaxDebugPanel()
|
||||||
{
|
{
|
||||||
if (!IsInitialized) return;
|
|
||||||
#if !UNITY_EDITOR
|
#if !UNITY_EDITOR
|
||||||
|
if (!IsInitialized) return;
|
||||||
MaxSdk.ShowMediationDebugger();
|
MaxSdk.ShowMediationDebugger();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -839,86 +786,107 @@ namespace Guru
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ImpressionData
|
#region Build AdParams
|
||||||
|
|
||||||
const int MAX_BADS_CID_NUMBER = 6;
|
|
||||||
private List<string> _badsCreativeIds = new List<string>(MAX_BADS_CID_NUMBER);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构建 Impression 数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="adInfo"></param>
|
|
||||||
/// <param name="reviewCreativeId"></param>
|
|
||||||
/// <param name="platform"></param>
|
|
||||||
/// <param name="eventName"></param>
|
|
||||||
/// <param name="itemCategory"></param>
|
|
||||||
/// <param name="duration"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private AdImpressionData CreateImpressionData(MaxSdkBase.AdInfo adInfo,
|
|
||||||
string reviewCreativeId = "", string platform = "",
|
|
||||||
string eventName = "", string itemCategory = "", int duration = 0)
|
|
||||||
{
|
|
||||||
var impression = AdImpressionDriver.Build(adInfo.Revenue, Analytics.USD, platform,
|
|
||||||
adInfo.NetworkName,
|
|
||||||
adInfo.AdFormat,
|
|
||||||
adInfo.AdUnitIdentifier,
|
|
||||||
adInfo.NetworkPlacement,
|
|
||||||
adInfo.CreativeIdentifier, reviewCreativeId,
|
|
||||||
eventName, itemCategory, duration);
|
|
||||||
|
|
||||||
return impression;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加一条ImpressionData 数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="adInfo"></param>
|
|
||||||
/// <param name="reviewCreativeId"></param>
|
|
||||||
/// <param name="platform"></param>
|
|
||||||
/// <param name="eventName"></param>
|
|
||||||
/// <param name="itemCategory"></param>
|
|
||||||
/// <param name="duration"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private void AppendImpressionData(MaxSdkBase.AdInfo adInfo, string reviewCreativeId = "", string platform = "", string eventName = "", string itemCategory = "", int duration = 0)
|
|
||||||
{
|
|
||||||
var data = CreateImpressionData(adInfo, reviewCreativeId, platform, eventName, itemCategory, duration);
|
|
||||||
_impressionDriver.Append(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取 AdReviewCreativeId 后的回调
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="adUnitId"></param>
|
|
||||||
/// <param name="reviewCreativeId"></param>
|
|
||||||
/// <param name="adInfo"></param>
|
|
||||||
private void OnAdReviewCreativeIdGeneratedEvent(string adUnitId, string reviewCreativeId, MaxSdkBase.AdInfo adInfo)
|
|
||||||
{
|
|
||||||
Debug.Log($"{Tag} --- ReviewCreativeId:{reviewCreativeId} adUnitId: {adUnitId} Type:{adInfo?.AdFormat ?? "NULL"} CreativeId: {adInfo?.CreativeIdentifier ?? "NULL"} Revenue:{adInfo.Revenue}");
|
|
||||||
if (string.IsNullOrEmpty(adInfo.CreativeIdentifier))
|
|
||||||
{
|
|
||||||
Debug.LogError($"{Tag} --- Get ReviewCreativeId:{reviewCreativeId} but CreativeIdentifier is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_impressionDriver.SetReviewCreativeId(adInfo.CreativeIdentifier, reviewCreativeId); // 缓存 ReviewCreateId
|
//---------- BADS Params --------------
|
||||||
|
private Dictionary<string, object> BuildBadsImpData(string adUnitId)
|
||||||
if (adUnitId == GetBannerID() || adInfo.AdFormat.ToUpper().Contains("BANNER"))
|
{
|
||||||
{
|
var p = AdParams.Build(adUnitId:adUnitId, category:_badsCategory);
|
||||||
// 清理 BADS CID 缓存
|
return p.ToBadsImpData();
|
||||||
_badsCreativeIds.Add(adInfo.CreativeIdentifier);
|
|
||||||
if (_badsCreativeIds.Count > MAX_BADS_CID_NUMBER)
|
|
||||||
{
|
|
||||||
var cid = _badsCreativeIds[0];
|
|
||||||
_badsCreativeIds.Remove(cid);
|
|
||||||
_impressionDriver.CleanCreativeId(cid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildBadsFailedData(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||||
|
{
|
||||||
|
int duration = GetActionDuration(_badsLoadStartTime);
|
||||||
|
int errorCode = (int)errorInfo.Code;
|
||||||
|
var p = AdParams.Build(adUnitId:adUnitId, errorCode:errorCode, duration:duration);
|
||||||
|
return p.ToAdFailedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildBadsClickData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, _badsCategory);
|
||||||
|
return p.ToAdClickData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------- IADS Params --------------
|
||||||
|
private Dictionary<string, object> BuildIadsLoadedData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
int duration = GetActionDuration(_iadsLoadStartTime);
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, duration:duration);
|
||||||
|
return p.ToAdLoadedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildIadsFailedData(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||||
|
{
|
||||||
|
int duration = GetActionDuration(_iadsLoadStartTime);
|
||||||
|
int errorCode = (int)errorInfo.Code;
|
||||||
|
var p = AdParams.Build(adUnitId:adUnitId, errorCode:errorCode, duration:duration);
|
||||||
|
return p.ToAdFailedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildIadsImpData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId:adUnitId, category:_iadsCategory);
|
||||||
|
return p.ToAdImpData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildIadsClickData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, category:_iadsCategory);
|
||||||
|
return p.ToAdClickData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildIadsCloseData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
int duration = GetActionDuration(_iadsDisplayStartTime);
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, category:_iadsCategory, duration:duration);
|
||||||
|
return p.ToAdCloseData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------- RADS Params --------------
|
||||||
|
private Dictionary<string, object> BuildRadsLoadedData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
int duration = GetActionDuration(_radsLoadStartTime);
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, duration:duration);
|
||||||
|
return p.ToAdLoadedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildRadsFailedData(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||||
|
{
|
||||||
|
int duration = GetActionDuration(_radsLoadStartTime);
|
||||||
|
int errorCode = (int)errorInfo.Code;
|
||||||
|
var p = AdParams.Build(adUnitId:adUnitId, errorCode:errorCode, duration:duration);
|
||||||
|
return p.ToAdFailedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildRadsImpData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId:adUnitId, category:_radsCategory);
|
||||||
|
return p.ToAdLoadedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildRadsClickData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, category:_radsCategory);
|
||||||
|
return p.ToAdClickData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildRadsCloseData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
int duration = GetActionDuration(_radsDisplayStartTime);
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, category:_iadsCategory, duration:duration);
|
||||||
|
return p.ToAdCloseData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> BuildRadsRewardedData(MaxSdk.AdInfo adInfo, string adUnitId)
|
||||||
|
{
|
||||||
|
var p = AdParams.Build(adInfo, adUnitId, category:_iadsCategory);
|
||||||
|
return p.ToAdRewardedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Guru
|
||||||
MaxSdk.SetBannerExtraParameter(MaxBADSSlotID, "adaptive_banner", "false");
|
MaxSdk.SetBannerExtraParameter(MaxBADSSlotID, "adaptive_banner", "false");
|
||||||
// Set background or background color for banners to be fully functional
|
// Set background or background color for banners to be fully functional
|
||||||
MaxSdk.SetBannerBackgroundColor(MaxBADSSlotID, _backColor);
|
MaxSdk.SetBannerBackgroundColor(MaxBADSSlotID, _backColor);
|
||||||
Analytics.ADBadsLoad(AdParams.Build(MaxBADSSlotID));
|
Analytics.TrackAdBadsLoad(AdParams.Build(adUnitId:MaxBADSSlotID).ToAdLoadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBannerBackColor(string hex)
|
public void SetBannerBackColor(string hex)
|
||||||
|
|
@ -69,7 +69,7 @@ namespace Guru
|
||||||
public bool IsInterstitialRequestOver => true;
|
public bool IsInterstitialRequestOver => true;
|
||||||
public void LoadInterstitialAD()
|
public void LoadInterstitialAD()
|
||||||
{
|
{
|
||||||
Analytics.ADIadsLoad(AdParams.Build(MaxIADSSlotID)); // 上报打点
|
Analytics.TrackAdIadsLoad(AdParams.Build(adUnitId:MaxIADSSlotID).ToAdLoadData()); // 上报打点
|
||||||
MaxSdk.LoadInterstitial(MaxIADSSlotID);
|
MaxSdk.LoadInterstitial(MaxIADSSlotID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ namespace Guru
|
||||||
public bool IsRewardRequestOver => true;
|
public bool IsRewardRequestOver => true;
|
||||||
public void LoadRewardAD()
|
public void LoadRewardAD()
|
||||||
{
|
{
|
||||||
Analytics.ADRadsLoad(AdParams.Build(MaxRADSSlotID)); // 上报打点
|
Analytics.TrackAdRadsLoad(AdParams.Build(adUnitId:MaxRADSSlotID).ToAdLoadData()); // 上报打点
|
||||||
MaxSdk.LoadRewardedAd(MaxRADSSlotID);
|
MaxSdk.LoadRewardedAd(MaxRADSSlotID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,185 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Guru.Ads
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// AdImpression 对象
|
|
||||||
/// </summary>
|
|
||||||
public class AdImpressionData
|
|
||||||
{
|
|
||||||
private const int MAX_VALUE_LENGTH = 96;
|
|
||||||
|
|
||||||
public double value;
|
|
||||||
public string currency = "USD";
|
|
||||||
public string ad_platform = "MAX";
|
|
||||||
public string ad_source;
|
|
||||||
public string ad_format;
|
|
||||||
public string ad_unit_name;
|
|
||||||
public string ad_placement;
|
|
||||||
public string ad_creative_id;
|
|
||||||
public string review_creative_id;
|
|
||||||
public string event_name;
|
|
||||||
public DateTime createTime;
|
|
||||||
public string item_category;
|
|
||||||
public int duration;
|
|
||||||
|
|
||||||
public AdImpressionData()
|
|
||||||
{
|
|
||||||
createTime = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return $"[AdImpressionData] ad_unit_name:{ad_unit_name} value:{value} currency:{currency} ad_platform:{ad_platform} ad_source:{ad_source} ad_format:{ad_format} ad_placement:{ad_placement} ad_creative_id:{ad_creative_id} review_creative_id:{review_creative_id} event_name:{event_name} duration:{duration} item_category:{item_category}";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool EqualsCreativeId(string cid)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(cid)) return false;
|
|
||||||
return ad_creative_id.Equals(cid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool EqualsReviewCreativeId(string rcid)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(rcid)) return false;
|
|
||||||
return review_creative_id.Equals(rcid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置 CreativeId
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="creativeId"></param>
|
|
||||||
public void SetCreativeId(string creativeId)
|
|
||||||
{
|
|
||||||
ad_creative_id = FixStringLength(creativeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置 ReviewCreativeId
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reviewCreativeId"></param>
|
|
||||||
public void SetReviewCreativeId(string reviewCreativeId)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(reviewCreativeId)) return;
|
|
||||||
review_creative_id = FixStringLength(reviewCreativeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 限制字符串长度为 96
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private string FixStringLength(string source)
|
|
||||||
{
|
|
||||||
return source.Length <= MAX_VALUE_LENGTH ? source : source.Substring(0, MAX_VALUE_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取自创建开始经过的秒数
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public double GetPassedSecond()
|
|
||||||
{
|
|
||||||
return (DateTime.UtcNow - createTime).TotalSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<string, object> BuildEventData()
|
|
||||||
{
|
|
||||||
var data = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ "value", value },
|
|
||||||
{ "currency", currency },
|
|
||||||
{ "ad_platform", ad_platform },
|
|
||||||
{ "ad_format", ad_format },
|
|
||||||
{ "ad_source", ad_source },
|
|
||||||
{ "ad_unit_name", ad_unit_name },
|
|
||||||
{ "ad_placement", ad_placement },
|
|
||||||
{ "ad_creative_id", ad_creative_id },
|
|
||||||
{ "review_creative_id", review_creative_id },
|
|
||||||
};
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<string, object> BuildEventAdImpData()
|
|
||||||
{
|
|
||||||
var data = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ "ad_platform", ad_platform },
|
|
||||||
{ "ad_source", ad_source },
|
|
||||||
{ "ad_unit_name", ad_unit_name },
|
|
||||||
{ "ad_placement", ad_placement },
|
|
||||||
{ "ad_creative_id", ad_creative_id },
|
|
||||||
{ "review_creative_id", review_creative_id },
|
|
||||||
{ "item_category", item_category}
|
|
||||||
};
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, object> BuildEventAdClickData()
|
|
||||||
{
|
|
||||||
var data = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ "value", value },
|
|
||||||
{ "currency", currency },
|
|
||||||
{ "ad_platform", ad_platform },
|
|
||||||
{ "ad_source", ad_source },
|
|
||||||
{ "ad_unit_name", ad_unit_name },
|
|
||||||
{ "ad_placement", ad_placement },
|
|
||||||
{ "ad_creative_id", ad_creative_id },
|
|
||||||
{ "review_creative_id", review_creative_id },
|
|
||||||
{ "item_category", item_category}
|
|
||||||
};
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, object> BuildEventAdPaidData()
|
|
||||||
{
|
|
||||||
var data = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ "value", value },
|
|
||||||
{ "currency", currency },
|
|
||||||
{ "ad_platform", ad_platform },
|
|
||||||
{ "ad_source", ad_source },
|
|
||||||
{ "ad_unit_name", ad_unit_name },
|
|
||||||
{ "ad_placement", ad_placement },
|
|
||||||
{ "ad_creative_id", ad_creative_id },
|
|
||||||
{ "review_creative_id", review_creative_id },
|
|
||||||
{ "item_category", item_category}
|
|
||||||
};
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, object> BuildEventAdRewardedData()
|
|
||||||
{
|
|
||||||
var data = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ "value", value },
|
|
||||||
{ "currency", currency },
|
|
||||||
{ "ad_platform", ad_platform },
|
|
||||||
{ "ad_source", ad_source },
|
|
||||||
{ "ad_unit_name", ad_unit_name },
|
|
||||||
{ "ad_placement", ad_placement },
|
|
||||||
{ "ad_creative_id", ad_creative_id },
|
|
||||||
{ "review_creative_id", review_creative_id },
|
|
||||||
{ "item_category", item_category}
|
|
||||||
};
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 1aca2a4507b94dfe9f88040125708edb
|
|
||||||
timeCreated: 1721883318
|
|
||||||
|
|
@ -1,251 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
namespace Guru.Ads
|
|
||||||
{
|
|
||||||
// using System.Collections.Concurrent;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
|
|
||||||
public class AdImpressionDriver
|
|
||||||
{
|
|
||||||
private const string Tag = "[SDK][ADS]";
|
|
||||||
private const double NEED_FLUSH_TIME = 40.0; // 单条 Impression data 存在的最大间隔时间(秒)
|
|
||||||
private List<AdImpressionData> _impressionData; // 所有缓存待上报的 impression data
|
|
||||||
private Dictionary<string, string> _savedReviewCreativeIds;
|
|
||||||
|
|
||||||
private Action<AdImpressionData> _onReportAdsRevenue;
|
|
||||||
|
|
||||||
|
|
||||||
public static AdImpressionData Build(double value, string currency,
|
|
||||||
string adPlatform, string adSource, string adFormat,
|
|
||||||
string adUnitName, string adPlacement, string adCreativeID, string reviewCreativeID,
|
|
||||||
string eventName = "", string itemCategory = "", int duration = 0)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(adPlatform)) adPlatform = Analytics.AdMAX;
|
|
||||||
if (string.IsNullOrEmpty(itemCategory)) itemCategory = "not_set";
|
|
||||||
if (string.IsNullOrEmpty(eventName)) eventName = Analytics.EventAdImpression;
|
|
||||||
|
|
||||||
var data = new AdImpressionData()
|
|
||||||
{
|
|
||||||
value = value,
|
|
||||||
currency = currency,
|
|
||||||
ad_platform = adPlatform,
|
|
||||||
ad_source = adSource,
|
|
||||||
ad_format = adFormat,
|
|
||||||
ad_unit_name = adUnitName,
|
|
||||||
ad_placement = adPlacement,
|
|
||||||
ad_creative_id = adCreativeID,
|
|
||||||
event_name = eventName,
|
|
||||||
item_category = itemCategory,
|
|
||||||
duration = duration,
|
|
||||||
};
|
|
||||||
|
|
||||||
data.SetCreativeId(adCreativeID);
|
|
||||||
data.SetReviewCreativeId(reviewCreativeID);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Init(Action<AdImpressionData> onReportRevenue)
|
|
||||||
{
|
|
||||||
_impressionData = new List<AdImpressionData>(20);
|
|
||||||
_savedReviewCreativeIds = new Dictionary<string, string>(100);
|
|
||||||
|
|
||||||
_onReportAdsRevenue = onReportRevenue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool IsCreativeIdExists(string creativeId) => _savedReviewCreativeIds.ContainsKey(creativeId);
|
|
||||||
|
|
||||||
public void SetReviewCreativeId(string creativeId, string reviewCreativeId)
|
|
||||||
{
|
|
||||||
bool isCidExists = IsCreativeIdExists(creativeId);
|
|
||||||
_savedReviewCreativeIds[creativeId] = reviewCreativeId;
|
|
||||||
|
|
||||||
if (isCidExists && !string.IsNullOrEmpty(reviewCreativeId))
|
|
||||||
{
|
|
||||||
FlushAllImpressionData(creativeId, reviewCreativeId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 强制发送相关的数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="creativeId"></param>
|
|
||||||
public void CleanCreativeId(string creativeId)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(creativeId)) return;
|
|
||||||
|
|
||||||
if (IsCreativeIdExists(creativeId))
|
|
||||||
{
|
|
||||||
FlushAllImpressionData(creativeId, "", true);
|
|
||||||
}
|
|
||||||
RemoveCreativeId(creativeId); //清理对应的 createId
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private string GetReviewCreativeId(string creativeId)
|
|
||||||
{
|
|
||||||
if(string.IsNullOrEmpty(creativeId)) return "";
|
|
||||||
return _savedReviewCreativeIds.GetValueOrDefault(creativeId, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void RemoveCreativeId(string creativeId)
|
|
||||||
{
|
|
||||||
if (IsCreativeIdExists(creativeId))
|
|
||||||
{
|
|
||||||
_savedReviewCreativeIds.Remove(creativeId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加一条Impression数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
public void Append(AdImpressionData data)
|
|
||||||
{
|
|
||||||
if (CanFlushData(data))
|
|
||||||
{
|
|
||||||
// 立即触发数据
|
|
||||||
FlushImpressionData(data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!IsCreativeIdExists(data.ad_creative_id))
|
|
||||||
{
|
|
||||||
SetReviewCreativeId(data.ad_creative_id, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 缓存数据
|
|
||||||
PushImpressionData(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void PushImpressionData(AdImpressionData data)
|
|
||||||
{
|
|
||||||
_impressionData.Add(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private bool CanFlushData(AdImpressionData data)
|
|
||||||
{
|
|
||||||
// #1 如果超时, 强制上报
|
|
||||||
if (data.GetPassedSecond() > NEED_FLUSH_TIME) return true;
|
|
||||||
// #2 如果 cid 和 rcid 都赋值了 则上报
|
|
||||||
if (!string.IsNullOrEmpty(data.review_creative_id)) return true;
|
|
||||||
// #3 如果 rcid 为空, 但是可以找到,也上报
|
|
||||||
var rcid = GetReviewCreativeId(data.ad_creative_id);
|
|
||||||
if (!string.IsNullOrEmpty(rcid))
|
|
||||||
{
|
|
||||||
data.SetReviewCreativeId(rcid);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 触发所有相关的 cid 和 reviewCreateId
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="creativeId"></param>
|
|
||||||
/// <param name="reviewCreativeId"></param>
|
|
||||||
/// <param name="force">强制触发</param>
|
|
||||||
private void FlushAllImpressionData(string creativeId, string reviewCreativeId = "", bool force = false)
|
|
||||||
{
|
|
||||||
List<AdImpressionData> tmp = new List<AdImpressionData>(_impressionData.Count);
|
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(reviewCreativeId)) reviewCreativeId = GetReviewCreativeId(creativeId); //获取 reviewCreativeId
|
|
||||||
|
|
||||||
foreach(var data in _impressionData)
|
|
||||||
{
|
|
||||||
if (data.EqualsCreativeId(creativeId))
|
|
||||||
{
|
|
||||||
data.SetReviewCreativeId(reviewCreativeId);
|
|
||||||
if (CanFlushData(data) || force)
|
|
||||||
{
|
|
||||||
FlushImpressionData(data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tmp.Add(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (CanFlushData(data))
|
|
||||||
{
|
|
||||||
FlushImpressionData(data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tmp.Add(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_impressionData = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 输出一个 Impression 事件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
private void FlushImpressionData(AdImpressionData data)
|
|
||||||
{
|
|
||||||
Debug.Log($"{Tag} --- FlushImpressionData: {data}");
|
|
||||||
switch (data.event_name)
|
|
||||||
{
|
|
||||||
case Analytics.EventBadsPaid:
|
|
||||||
// BADS 收入事件
|
|
||||||
// BADS 尚未统计 bads_paid 打点
|
|
||||||
_onReportAdsRevenue?.Invoke(data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Analytics.EventIadsImp:
|
|
||||||
Analytics.ADIadsImp(data.BuildEventAdImpData());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Analytics.EventIadsClick:
|
|
||||||
Analytics.ADIadsClick(data.BuildEventAdClickData());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Analytics.EventIadsPaid:
|
|
||||||
// IADS 收入事件
|
|
||||||
Analytics.ADIadsPaid(data.BuildEventAdPaidData());
|
|
||||||
_onReportAdsRevenue?.Invoke(data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Analytics.EventRadsImp:
|
|
||||||
Analytics.ADRadsImp(data.BuildEventAdImpData());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Analytics.EventRadsClick:
|
|
||||||
Analytics.ADRadsClick(data.BuildEventAdClickData());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Analytics.EventRadsRewarded:
|
|
||||||
Analytics.ADRadsRewarded(data.BuildEventAdRewardedData());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Analytics.EventRadsPaid:
|
|
||||||
// RADS 收入事件
|
|
||||||
Analytics.ADRadsPaid(data.BuildEventAdPaidData());
|
|
||||||
_onReportAdsRevenue?.Invoke(data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 7194cdd8ed1447508011264371e2c23d
|
|
||||||
timeCreated: 1722313472
|
|
||||||
|
|
@ -0,0 +1,254 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Guru
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 广告打点上报参数
|
||||||
|
/// </summary>
|
||||||
|
public class AdParams
|
||||||
|
{
|
||||||
|
public double value;
|
||||||
|
public string currency;
|
||||||
|
public string category;
|
||||||
|
public string networkPlacement;
|
||||||
|
public string adPlatform;
|
||||||
|
public string adSource;
|
||||||
|
public string adFormat;
|
||||||
|
public string adUnitId;
|
||||||
|
public int errorCode = 0;
|
||||||
|
public int duration = 0;
|
||||||
|
public string creativeId;
|
||||||
|
public string reviewCreativeId;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造AD参数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="adInfo"></param>
|
||||||
|
/// <param name="adUnitId"></param>
|
||||||
|
/// <param name="category"></param>
|
||||||
|
/// <param name="duration"></param>
|
||||||
|
/// <param name="errorCode"></param>
|
||||||
|
/// <param name="reviewCreativeId"></param>
|
||||||
|
/// <param name="adPlatform"></param>
|
||||||
|
/// <param name="currency"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static AdParams Build(MaxSdkBase.AdInfo adInfo = null, string adUnitId = "", string category = "",
|
||||||
|
int duration = 0, int errorCode = 0, string reviewCreativeId = "", string adPlatform = "", string currency = "")
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(adUnitId) && adInfo != null) adUnitId = adInfo.AdUnitIdentifier;
|
||||||
|
var networkPlacement = "";
|
||||||
|
var creativeId = "";
|
||||||
|
var adSource = "";
|
||||||
|
var adFormart = "";
|
||||||
|
double value = 0;
|
||||||
|
string waterfallName = "";
|
||||||
|
|
||||||
|
if (adInfo != null)
|
||||||
|
{
|
||||||
|
value = adInfo.Revenue;
|
||||||
|
networkPlacement = adInfo.NetworkPlacement;
|
||||||
|
creativeId = adInfo.CreativeIdentifier;
|
||||||
|
adSource = adInfo.NetworkName;
|
||||||
|
adFormart = adInfo.AdFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(adPlatform)) adPlatform = Analytics.AdMAX;
|
||||||
|
if (string.IsNullOrEmpty(category)) category = "not_set";
|
||||||
|
if (string.IsNullOrEmpty(currency)) currency = Analytics.USD;
|
||||||
|
|
||||||
|
var p = new AdParams()
|
||||||
|
{
|
||||||
|
value = value,
|
||||||
|
currency = currency,
|
||||||
|
adUnitId = adUnitId,
|
||||||
|
adPlatform = adPlatform,
|
||||||
|
adSource = adSource,
|
||||||
|
adFormat = adFormart,
|
||||||
|
duration = duration,
|
||||||
|
networkPlacement = networkPlacement,
|
||||||
|
category = category,
|
||||||
|
errorCode = errorCode,
|
||||||
|
creativeId = creativeId,
|
||||||
|
reviewCreativeId = reviewCreativeId,
|
||||||
|
};
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转化为 AdImpression 事件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, object> ToAdImpressionData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterValue] = value,
|
||||||
|
[Analytics.ParameterCurrency] = currency,
|
||||||
|
[Analytics.ParameterAdPlatform] = adPlatform,
|
||||||
|
[Analytics.ParameterAdSource] = adSource,
|
||||||
|
[Analytics.ParameterAdFormat] = adFormat,
|
||||||
|
[Analytics.ParameterAdUnitName] = adUnitId,
|
||||||
|
[Analytics.ParameterAdPlacement] = networkPlacement,
|
||||||
|
[Analytics.ParameterAdCreativeId] = creativeId,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(reviewCreativeId))
|
||||||
|
data[Analytics.ParameterReviewCreativeId] = reviewCreativeId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转化为 ads_imp 事件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, object> ToAdImpData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterAdPlatform] = adPlatform,
|
||||||
|
[Analytics.ParameterAdSource] = adSource,
|
||||||
|
[Analytics.ParameterAdUnitName] = adUnitId,
|
||||||
|
[Analytics.ParameterAdPlacement] = networkPlacement,
|
||||||
|
[Analytics.ParameterAdCreativeId] = creativeId,
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(reviewCreativeId))
|
||||||
|
data[Analytics.ParameterReviewCreativeId] = reviewCreativeId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转化为 ads_paid 通用事件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, object> ToAdPaidData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterValue] = value,
|
||||||
|
[Analytics.ParameterCurrency] = currency,
|
||||||
|
[Analytics.ParameterAdPlatform] = adPlatform,
|
||||||
|
[Analytics.ParameterAdSource] = adSource,
|
||||||
|
[Analytics.ParameterAdUnitName] = adUnitId,
|
||||||
|
[Analytics.ParameterAdPlacement] = networkPlacement,
|
||||||
|
[Analytics.ParameterAdCreativeId] = creativeId,
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(reviewCreativeId))
|
||||||
|
data[Analytics.ParameterReviewCreativeId] = reviewCreativeId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转化为 ads_paid 通用事件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, object> ToAdRewardedData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterValue] = value,
|
||||||
|
[Analytics.ParameterCurrency] = currency,
|
||||||
|
[Analytics.ParameterAdPlatform] = adPlatform,
|
||||||
|
[Analytics.ParameterAdSource] = adSource,
|
||||||
|
[Analytics.ParameterAdUnitName] = adUnitId,
|
||||||
|
[Analytics.ParameterAdPlacement] = networkPlacement,
|
||||||
|
[Analytics.ParameterAdCreativeId] = creativeId,
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(reviewCreativeId))
|
||||||
|
data[Analytics.ParameterReviewCreativeId] = reviewCreativeId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, object> ToAdClickData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterValue] = value,
|
||||||
|
[Analytics.ParameterCurrency] = currency,
|
||||||
|
[Analytics.ParameterAdPlatform] = adPlatform,
|
||||||
|
[Analytics.ParameterAdSource] = adSource,
|
||||||
|
[Analytics.ParameterAdUnitName] = adUnitId,
|
||||||
|
[Analytics.ParameterAdPlacement] = networkPlacement,
|
||||||
|
[Analytics.ParameterAdCreativeId] = creativeId,
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(reviewCreativeId))
|
||||||
|
data[Analytics.ParameterReviewCreativeId] = reviewCreativeId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, object> ToAdCloseData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
[Analytics.ParameterDuration] = duration,
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 广告失败事件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, object> ToAdFailedData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
[Analytics.ParameterItemName] = adUnitId,
|
||||||
|
[Analytics.ParameterErrorCode] = errorCode,
|
||||||
|
[Analytics.ParameterDuration] = duration,
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 广告加载成功事件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, object> ToAdLoadData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
[Analytics.ParameterItemName] = adUnitId,
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 广告加载成功事件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, object> ToAdLoadedData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
[Analytics.ParameterItemName] = adUnitId,
|
||||||
|
[Analytics.ParameterDuration] = duration,
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Dictionary<string, object> ToBadsImpData()
|
||||||
|
{
|
||||||
|
var data = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
[Analytics.ParameterItemCategory] = category,
|
||||||
|
[Analytics.ParameterItemName] = adUnitId,
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0341a8c153f04535a4193ce32086315a
|
||||||
|
timeCreated: 1722396384
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
public static partial class Analytics
|
public static partial class Analytics
|
||||||
{
|
{
|
||||||
#region 广告属性
|
#region 广告属性
|
||||||
|
|
||||||
//------ 广告额外的参数 --------
|
|
||||||
private static readonly string ParameterNetworkName = "network_name"; //NetworkName
|
|
||||||
private static readonly string ParameterNetworkPlacement = "network_placement"; //NetworkPlacement
|
|
||||||
private static readonly string ParameterWaterfall = "waterfall"; //Waterfall
|
|
||||||
|
|
||||||
//------ 默认值 -------
|
//------ 默认值 -------
|
||||||
public const string DefaultCategory = "not_set";
|
public const string DefaultCategory = "not_set";
|
||||||
public const string DefaultWaterfall = "unknown";
|
public const string DefaultWaterfall = "unknown";
|
||||||
|
|
@ -21,89 +17,32 @@ namespace Guru
|
||||||
|
|
||||||
#region Ads
|
#region Ads
|
||||||
|
|
||||||
private static Dictionary<string, object> BuildAdEventData(AdParams adParams, Dictionary<string, object> extra = null)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(adParams.category))
|
|
||||||
adParams.category = DefaultCategory;
|
|
||||||
if (string.IsNullOrEmpty(adParams.waterfallName))
|
|
||||||
adParams.waterfallName = DefaultWaterfall;
|
|
||||||
|
|
||||||
var data = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ ParameterItemCategory, adParams.category },
|
|
||||||
{ ParameterItemName, adParams.adUnitId },
|
|
||||||
};
|
|
||||||
|
|
||||||
if (adParams.duration > 0)
|
|
||||||
data[ParameterDuration] = adParams.duration;
|
|
||||||
|
|
||||||
if (adParams.errorCode != 0)
|
|
||||||
data[ParameterErrorCode] = adParams.errorCode;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.networkName))
|
|
||||||
data[ParameterNetworkName] = adParams.networkName;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.networkPlacement))
|
|
||||||
{
|
|
||||||
data[ParameterNetworkPlacement] = adParams.networkPlacement;
|
|
||||||
data[ParameterAdPlacement] = adParams.networkPlacement;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.waterfallName))
|
|
||||||
data[ParameterWaterfall] = adParams.waterfallName;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.creativeId))
|
|
||||||
data[ParameterAdCreativeId] = adParams.creativeId;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.reviewCreativeId))
|
|
||||||
data[ParameterReviewCreativeId] = adParams.reviewCreativeId;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.adPlatform))
|
|
||||||
data[ParameterAdPlatform] = adParams.adPlatform;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.adSource))
|
|
||||||
data[ParameterAdSource] = adParams.adSource;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(adParams.adFormat))
|
|
||||||
data[ParameterAdFormat] = adParams.adFormat;
|
|
||||||
|
|
||||||
if (extra != null && extra.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (var k in extra.Keys)
|
|
||||||
{
|
|
||||||
data[k] = extra[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------- BANNER -------------------------
|
//---------------------- BANNER -------------------------
|
||||||
public static void ADBadsLoad(AdParams adParams)
|
public static void TrackAdBadsLoad(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventBadsLoad, BuildAdEventData(adParams));
|
TrackEvent(EventBadsLoad, data);
|
||||||
}
|
}
|
||||||
public static void ADBadsLoaded(AdParams adParams)
|
public static void TrackAdBadsLoaded(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventBadsLoaded, BuildAdEventData(adParams));
|
TrackEvent(EventBadsLoaded, data);
|
||||||
}
|
}
|
||||||
public static void ADBadsFailed(AdParams adParams)
|
public static void TrackAdBadsFailed(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventBadsFailed, BuildAdEventData(adParams));
|
TrackEvent(EventBadsFailed, data);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告点击
|
/// 广告点击
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADBadsClick(AdParams adParams)
|
public static void TrackAdBadsClick(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventBadsClick, BuildAdEventData(adParams));
|
TrackEvent(EventBadsClick, data);
|
||||||
}
|
}
|
||||||
public static void ADBadsImp(AdParams adParams)
|
public static void TrackAdBadsImp(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventBadsImp, BuildAdEventData(adParams));
|
TrackEvent(EventBadsImp, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ADBadsHide( int loadedTimes, int failTimes)
|
public static void TrackAdBadsHide( int loadedTimes, int failTimes)
|
||||||
{
|
{
|
||||||
var dict = new Dictionary<string, object>()
|
var dict = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
|
|
@ -116,36 +55,31 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告拉取
|
/// 广告拉取
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADIadsLoad(AdParams adParams)
|
public static void TrackAdIadsLoad(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventIadsLoad, BuildAdEventData(adParams));
|
TrackEvent(EventIadsLoad, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告拉取成功
|
/// 广告拉取成功
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADIadsLoaded(AdParams adParams)
|
public static void TrackAdIadsLoaded(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventIadsLoaded, BuildAdEventData(adParams));
|
TrackEvent(EventIadsLoaded, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告拉取失败
|
/// 广告拉取失败
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADIadsFailed(AdParams adParams)
|
public static void TrackAdIadsFailed(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventIadsFailed, BuildAdEventData(adParams));
|
TrackEvent(EventIadsFailed, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告展示
|
/// 广告展示
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADIadsImp(AdParams adParams)
|
public static void TrackAdIadsImp(Dictionary<string, dynamic> data)
|
||||||
{
|
|
||||||
ADIadsImp(BuildAdEventData(adParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ADIadsImp(Dictionary<string, dynamic> data)
|
|
||||||
{
|
{
|
||||||
TrackEvent(EventIadsImp, data);
|
TrackEvent(EventIadsImp, data);
|
||||||
}
|
}
|
||||||
|
|
@ -153,12 +87,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告点击
|
/// 广告点击
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADIadsClick(AdParams adParams)
|
public static void TrackAdIadsClick(Dictionary<string, object> data)
|
||||||
{
|
|
||||||
ADIadsClick(BuildAdEventData(adParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ADIadsClick(Dictionary<string, object> data)
|
|
||||||
{
|
{
|
||||||
TrackEvent(EventIadsClick, data);
|
TrackEvent(EventIadsClick, data);
|
||||||
}
|
}
|
||||||
|
|
@ -166,12 +95,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户关闭广告
|
/// 用户关闭广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADIadsClose(AdParams adParams)
|
public static void TrackAdIadsClose(Dictionary<string, object> data)
|
||||||
{
|
|
||||||
ADIadsClose(BuildAdEventData(adParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ADIadsClose(Dictionary<string, object> data)
|
|
||||||
{
|
{
|
||||||
TrackEvent(EventIadsClose, data);
|
TrackEvent(EventIadsClose, data);
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +104,7 @@ namespace Guru
|
||||||
/// 插屏广告收到奖励
|
/// 插屏广告收到奖励
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
public static void ADIadsPaid(Dictionary<string, object> data)
|
public static void TrackAdIadsPaid(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventIadsPaid, data);
|
TrackEvent(EventIadsPaid, data);
|
||||||
}
|
}
|
||||||
|
|
@ -189,33 +113,28 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告开始加载
|
/// 广告开始加载
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsLoad(AdParams adParams)
|
public static void TrackAdRadsLoad(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsLoad, BuildAdEventData(adParams));
|
TrackEvent(EventRadsLoad, data);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告拉取成功
|
/// 广告拉取成功
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsLoaded(AdParams adParams)
|
public static void TrackAdRadsLoaded(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsLoaded, BuildAdEventData(adParams));
|
TrackEvent(EventRadsLoaded, data);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告拉取失败
|
/// 广告拉取失败
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsFailed(AdParams adParams)
|
public static void TrackAdRadsFailed(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsFailed, BuildAdEventData(adParams));
|
TrackEvent(EventRadsFailed, data);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告展示
|
/// 广告展示
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsImp(AdParams adParams)
|
public static void TrackAdRadsImp(Dictionary<string, dynamic> data)
|
||||||
{
|
|
||||||
ADRadsImp(BuildAdEventData(adParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ADRadsImp(Dictionary<string, dynamic> data)
|
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsImp, data);
|
TrackEvent(EventRadsImp, data);
|
||||||
}
|
}
|
||||||
|
|
@ -225,19 +144,14 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告完成观看发奖励
|
/// 广告完成观看发奖励
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsRewarded(AdParams adParams)
|
public static void TrackAdRadsRewarded(Dictionary<string, object> data)
|
||||||
{
|
|
||||||
ADRadsRewarded(BuildAdEventData(adParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ADRadsRewarded(Dictionary<string, object> data)
|
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsRewarded, data);
|
TrackEvent(EventRadsRewarded, data);
|
||||||
|
|
||||||
if (RadsRewardCount == 0)
|
if (RadsRewardCount == 0)
|
||||||
{
|
{
|
||||||
RadsRewardCount = 1;
|
RadsRewardCount = 1;
|
||||||
ADRadsFirstRewarded(data);
|
TrackAdRadsFirstRewarded(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,12 +159,11 @@ namespace Guru
|
||||||
/// 插屏广告收到奖励
|
/// 插屏广告收到奖励
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
public static void ADRadsPaid(Dictionary<string, object> data)
|
public static void TrackAdRadsPaid(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsPaid, data);
|
TrackEvent(EventRadsPaid, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static int RadsRewardCount
|
private static int RadsRewardCount
|
||||||
{
|
{
|
||||||
get => PlayerPrefs.GetInt(nameof(RadsRewardCount), 0);
|
get => PlayerPrefs.GetInt(nameof(RadsRewardCount), 0);
|
||||||
|
|
@ -260,7 +173,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户首次完成观看
|
/// 用户首次完成观看
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsFirstRewarded(Dictionary<string, object> data)
|
private static void TrackAdRadsFirstRewarded(Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
TrackEvent(EventFirstRadsRewarded, data);
|
TrackEvent(EventFirstRadsRewarded, data);
|
||||||
}
|
}
|
||||||
|
|
@ -268,12 +181,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告点击
|
/// 广告点击
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsClick(AdParams adParams)
|
public static void TrackAdRadsClick(Dictionary<string, object> data)
|
||||||
{
|
|
||||||
ADRadsClick(BuildAdEventData(adParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ADRadsClick(Dictionary<string, object> data)
|
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsClick, data);
|
TrackEvent(EventRadsClick, data);
|
||||||
}
|
}
|
||||||
|
|
@ -281,12 +189,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户关闭广告
|
/// 用户关闭广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ADRadsClose(AdParams adParams)
|
public static void TrackAdRadsClose(Dictionary<string, dynamic> data)
|
||||||
{
|
|
||||||
ADRadsClose( BuildAdEventData(adParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ADRadsClose(Dictionary<string, dynamic> data)
|
|
||||||
{
|
{
|
||||||
TrackEvent(EventRadsClose, data);
|
TrackEvent(EventRadsClose, data);
|
||||||
}
|
}
|
||||||
|
|
@ -329,78 +232,6 @@ namespace Guru
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 广告打点上报参数
|
|
||||||
/// </summary>
|
|
||||||
public class AdParams
|
|
||||||
{
|
|
||||||
public string category;
|
|
||||||
public string networkName;
|
|
||||||
public string networkPlacement;
|
|
||||||
public string adPlatform;
|
|
||||||
public string adSource;
|
|
||||||
public string adFormat;
|
|
||||||
public string waterfallName;
|
|
||||||
public string adUnitId;
|
|
||||||
public int errorCode = 0;
|
|
||||||
public int duration = 0;
|
|
||||||
public string creativeId;
|
|
||||||
public string reviewCreativeId;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构造AD参数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="adInfo"></param>
|
|
||||||
/// <param name="adUnitId"></param>
|
|
||||||
/// <param name="category"></param>
|
|
||||||
/// <param name="duration"></param>
|
|
||||||
/// <param name="errorCode"></param>
|
|
||||||
/// <param name="waterfallName"></param>
|
|
||||||
/// <param name="reviewCreativeId"></param>
|
|
||||||
/// <param name="adPlatform"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static AdParams Build(string adUnitId, MaxSdkBase.AdInfo adInfo = null, string category = "",
|
|
||||||
int duration = 0, int errorCode = 0, string waterfallName = "", string reviewCreativeId = "", string adPlatform = "")
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(adUnitId) && adInfo != null) adUnitId = adInfo.AdUnitIdentifier;
|
|
||||||
var networkName = "";
|
|
||||||
var networkPlacement = "";
|
|
||||||
var creativeId = "";
|
|
||||||
var adSource = "";
|
|
||||||
var adFormart = "";
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(adPlatform)) adPlatform = Analytics.AdMAX;
|
|
||||||
if (adInfo != null)
|
|
||||||
{
|
|
||||||
networkName = adInfo.NetworkName;
|
|
||||||
networkPlacement = adInfo.NetworkPlacement;
|
|
||||||
creativeId = adInfo.CreativeIdentifier;
|
|
||||||
adSource = adInfo.NetworkName;
|
|
||||||
adFormart = adInfo.AdFormat;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(waterfallName))
|
|
||||||
waterfallName = adInfo.WaterfallInfo?.Name ?? "";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var p = new AdParams()
|
|
||||||
{
|
|
||||||
adUnitId = adUnitId,
|
|
||||||
adPlatform = adPlatform,
|
|
||||||
adSource = adSource,
|
|
||||||
adFormat = adFormart,
|
|
||||||
duration = duration,
|
|
||||||
networkName = networkName,
|
|
||||||
networkPlacement = networkPlacement,
|
|
||||||
waterfallName = waterfallName,
|
|
||||||
category = category,
|
|
||||||
errorCode = errorCode,
|
|
||||||
creativeId = creativeId,
|
|
||||||
reviewCreativeId = reviewCreativeId,
|
|
||||||
};
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,6 @@ namespace Guru
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Facebook.Unity;
|
using Facebook.Unity;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Guru.Ads;
|
|
||||||
|
|
||||||
//游戏通用模版打点定义
|
//游戏通用模版打点定义
|
||||||
public static partial class Analytics
|
public static partial class Analytics
|
||||||
|
|
@ -412,11 +411,20 @@ namespace Guru
|
||||||
|
|
||||||
public static void FBPurchase(double revenue, string currency, string type, string platfrom)
|
public static void FBPurchase(double revenue, string currency, string type, string platfrom)
|
||||||
=> FBPurchase((float)revenue, currency, type, platfrom);
|
=> FBPurchase((float)revenue, currency, type, platfrom);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Google ARO买量点
|
/// Google ARO买量点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="impressionData">广告收入数据</param>
|
/// <param name="impressionData">广告收入数据</param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <param name="currency"></param>
|
||||||
|
/// <param name="adPlatform"></param>
|
||||||
|
/// <param name="adUnitId"></param>
|
||||||
|
/// <param name="adPlacement"></param>
|
||||||
|
/// <param name="adSource"></param>
|
||||||
|
/// <param name="adFormat"></param>
|
||||||
|
/// <param name="creativeId"></param>
|
||||||
|
/// <param name="reviewCreativeId"></param>
|
||||||
/// <a href="https://docs.google.com/spreadsheets/d/1lFWLeOGJgq34QDBTfl6OpNh7MoI37ehGrhdbxlOrJgs/edit#gid=983654222"></a>
|
/// <a href="https://docs.google.com/spreadsheets/d/1lFWLeOGJgq34QDBTfl6OpNh7MoI37ehGrhdbxlOrJgs/edit#gid=983654222"></a>
|
||||||
/// <li>
|
/// <li>
|
||||||
/// value double eg:0.002
|
/// value double eg:0.002
|
||||||
|
|
@ -427,21 +435,28 @@ namespace Guru
|
||||||
/// ad_unit_name string 广告位名称
|
/// ad_unit_name string 广告位名称
|
||||||
/// ad_creative_id string 广告素材id
|
/// ad_creative_id string 广告素材id
|
||||||
/// </li>
|
/// </li>
|
||||||
public static void ADImpression(AdImpressionData impressionData)
|
public static void ADImpression(double value, string currency = "USD", string adPlatform = "",
|
||||||
|
string adSource = "", string adFormat = "", string adUnitId = "", string adPlacement= "",
|
||||||
|
string creativeId = "", string reviewCreativeId = "")
|
||||||
{
|
{
|
||||||
TrackEvent(EventAdImpression, new Dictionary<string, dynamic>()
|
ADImpression(new Dictionary<string, dynamic>()
|
||||||
{
|
{
|
||||||
[ParameterValue] = impressionData.value,
|
[ParameterValue] = value,
|
||||||
[ParameterCurrency] = impressionData.currency,
|
[ParameterCurrency] = currency,
|
||||||
[ParameterAdPlatform] = impressionData.ad_platform,
|
[ParameterAdPlatform] = adPlatform,
|
||||||
[ParameterAdSource] = impressionData.ad_source,
|
[ParameterAdSource] = adSource,
|
||||||
[ParameterAdFormat] = impressionData.ad_format,
|
[ParameterAdFormat] = adFormat,
|
||||||
[ParameterAdUnitName] = impressionData.ad_unit_name,
|
[ParameterAdUnitName] = adUnitId,
|
||||||
[ParameterAdPlacement] = impressionData.ad_placement,
|
[ParameterAdPlacement] = adPlacement,
|
||||||
[ParameterAdCreativeId] = impressionData.ad_creative_id,
|
[ParameterAdCreativeId] = creativeId,
|
||||||
[ParameterReviewCreativeId] = impressionData.review_creative_id,
|
[ParameterReviewCreativeId] = reviewCreativeId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ADImpression(Dictionary<string, object> data)
|
||||||
|
{
|
||||||
|
TrackEvent(EventAdImpression, data);
|
||||||
|
}
|
||||||
|
|
||||||
public static void TchAdAbnormalEvent(double value)
|
public static void TchAdAbnormalEvent(double value)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,10 @@
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Consts=AdStatusConsts;
|
using Const=AdStatusConsts;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public partial class AdStatusPresenter
|
public partial class AdStatusPresenter
|
||||||
{
|
{
|
||||||
|
|
@ -104,12 +101,10 @@ namespace Guru
|
||||||
private StringBuilder _infoBuff;
|
private StringBuilder _infoBuff;
|
||||||
private string CreateMonitorInfo()
|
private string CreateMonitorInfo()
|
||||||
{
|
{
|
||||||
string msg = "";
|
string msg;
|
||||||
bool loaded = false;
|
|
||||||
|
|
||||||
if (ADService.Instance == null || !ADService.Instance.IsInitialized)
|
if (ADService.Instance == null || !ADService.Instance.IsInitialized)
|
||||||
{
|
{
|
||||||
msg = ColoredText("AdService not initialized...", Consts.ColorRed);
|
msg = ColoredText("AdService not initialized...", Const.ColorRed);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +113,7 @@ namespace Guru
|
||||||
|
|
||||||
if (_curBadsInfo == null)
|
if (_curBadsInfo == null)
|
||||||
{
|
{
|
||||||
msg = $"BADS: {ColoredText("not ready", Consts.ColorRed)}\n";
|
msg = $"BADS: {ColoredText("not ready", Const.ColorRed)}\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -126,25 +121,25 @@ namespace Guru
|
||||||
switch (_curBadsInfo.status)
|
switch (_curBadsInfo.status)
|
||||||
{
|
{
|
||||||
case AdStatusType.Loaded:
|
case AdStatusType.Loaded:
|
||||||
msg = $"BADS: {ColoredText("loaded", Consts.ColorGreen)}\n\tnetwork: {_curBadsInfo.network}\n\twaterfall: {_curBadsInfo.waterfall}\n";
|
msg = $"BADS: {ColoredText("loaded", Const.ColorGreen)}\n\tnetwork: {_curBadsInfo.network}\n\twaterfall: {_curBadsInfo.waterfall}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.LoadFailed:
|
case AdStatusType.LoadFailed:
|
||||||
msg = $"BADS: {ColoredText("loading failed", Consts.ColorRed)}\n\tmessage: {_curBadsInfo.info}\n";
|
msg = $"BADS: {ColoredText("loading failed", Const.ColorRed)}\n\tmessage: {_curBadsInfo.info}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.DisplayFailed:
|
case AdStatusType.DisplayFailed:
|
||||||
msg = $"BADS: {ColoredText("display failed", Consts.ColorRed)}\n\tmessage: {_curBadsInfo.info}\n";
|
msg = $"BADS: {ColoredText("display failed", Const.ColorRed)}\n\tmessage: {_curBadsInfo.info}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.Loading:
|
case AdStatusType.Loading:
|
||||||
msg = $"BADS: {ColoredText("loading...", Consts.ColorYellow)}\n\tformat: {_curBadsInfo.format}\n";
|
msg = $"BADS: {ColoredText("loading...", Const.ColorYellow)}\n\tformat: {_curBadsInfo.format}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.Paid:
|
case AdStatusType.Paid:
|
||||||
msg = $"BADS: {ColoredText("display", Consts.ColorGreen)}\n\tnetwork: {_curBadsInfo.network}\n\trevenue: {_curBadsInfo.revenue}\n";
|
msg = $"BADS: {ColoredText("display", Const.ColorGreen)}\n\tnetwork: {_curBadsInfo.network}\n\trevenue: {_curBadsInfo.revenue}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.NotReady:
|
case AdStatusType.NotReady:
|
||||||
msg = $"BADS: {ColoredText("not ready", Consts.ColorGray)}\n\t{ColoredText("---", Consts.ColorGray)}\n";
|
msg = $"BADS: {ColoredText("not ready", Const.ColorGray)}\n\t{ColoredText("---", Const.ColorGray)}\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg = $"BADS: {ColoredText("other", Consts.ColorGray)}\n\tstatus: {ColoredText($"{_curBadsInfo.status}", Consts.ColorYellow)}\n";
|
msg = $"BADS: {ColoredText("other", Const.ColorGray)}\n\tstatus: {ColoredText($"{_curBadsInfo.status}", Const.ColorYellow)}\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -153,32 +148,32 @@ namespace Guru
|
||||||
|
|
||||||
if (_curIadsInfo == null)
|
if (_curIadsInfo == null)
|
||||||
{
|
{
|
||||||
msg = $"IADS: {ColoredText("not ready", Consts.ColorRed)}\n";
|
msg = $"IADS: {ColoredText("not ready", Const.ColorRed)}\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (_curIadsInfo.status)
|
switch (_curIadsInfo.status)
|
||||||
{
|
{
|
||||||
case AdStatusType.Loaded:
|
case AdStatusType.Loaded:
|
||||||
msg = $"IADS: {ColoredText("loaded", Consts.ColorGreen)}\n\tnetwork: {_curIadsInfo.network}\n\twaterfall: {_curIadsInfo.waterfall}\n";
|
msg = $"IADS: {ColoredText("loaded", Const.ColorGreen)}\n\tnetwork: {_curIadsInfo.network}\n\twaterfall: {_curIadsInfo.waterfall}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.LoadFailed:
|
case AdStatusType.LoadFailed:
|
||||||
msg = $"IADS: {ColoredText("loading failed", Consts.ColorRed)}\n\tmessage: {_curIadsInfo.info}\n";
|
msg = $"IADS: {ColoredText("loading failed", Const.ColorRed)}\n\tmessage: {_curIadsInfo.info}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.DisplayFailed:
|
case AdStatusType.DisplayFailed:
|
||||||
msg = $"IADS: {ColoredText("display failed", Consts.ColorRed)}\n\tmessage: {_curIadsInfo.info}\n";
|
msg = $"IADS: {ColoredText("display failed", Const.ColorRed)}\n\tmessage: {_curIadsInfo.info}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.Loading:
|
case AdStatusType.Loading:
|
||||||
msg = $"IADS: {ColoredText("loading...", Consts.ColorYellow)}\n\tformat: {_curIadsInfo.format}\n";
|
msg = $"IADS: {ColoredText("loading...", Const.ColorYellow)}\n\tformat: {_curIadsInfo.format}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.Paid:
|
case AdStatusType.Paid:
|
||||||
msg = $"IADS: {ColoredText("get revenue", Consts.ColorGreen)}\n\trevenue: {_curIadsInfo.revenue}\n";
|
msg = $"IADS: {ColoredText("get revenue", Const.ColorGreen)}\n\trevenue: {_curIadsInfo.revenue}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.NotReady:
|
case AdStatusType.NotReady:
|
||||||
msg = $"IADS: {ColoredText("not ready", Consts.ColorGray)}\n\t{ColoredText("---", Consts.ColorGray)}\n";
|
msg = $"IADS: {ColoredText("not ready", Const.ColorGray)}\n\t{ColoredText("---", Const.ColorGray)}\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg = $"IADS: {ColoredText("other", Consts.ColorGray)}\n\tstatus: {ColoredText($"{_curIadsInfo.status}", Consts.ColorYellow)}\n";
|
msg = $"IADS: {ColoredText("other", Const.ColorGray)}\n\tstatus: {ColoredText($"{_curIadsInfo.status}", Const.ColorYellow)}\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -187,32 +182,32 @@ namespace Guru
|
||||||
|
|
||||||
if (_curRadsInfo == null)
|
if (_curRadsInfo == null)
|
||||||
{
|
{
|
||||||
msg = $"RADS: {ColoredText("not ready", Consts.ColorRed)}\n";
|
msg = $"RADS: {ColoredText("not ready", Const.ColorRed)}\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (_curRadsInfo.status)
|
switch (_curRadsInfo.status)
|
||||||
{
|
{
|
||||||
case AdStatusType.Loaded:
|
case AdStatusType.Loaded:
|
||||||
msg = $"RADS: {ColoredText("loaded", Consts.ColorGreen)}\n\tnetwork: {_curRadsInfo.network}\n\twaterfall: {_curRadsInfo.waterfall}\n";
|
msg = $"RADS: {ColoredText("loaded", Const.ColorGreen)}\n\tnetwork: {_curRadsInfo.network}\n\twaterfall: {_curRadsInfo.waterfall}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.LoadFailed:
|
case AdStatusType.LoadFailed:
|
||||||
msg = $"RADS: {ColoredText("loading failed", Consts.ColorRed)}\n\tmessage: {_curRadsInfo.info}\n";
|
msg = $"RADS: {ColoredText("loading failed", Const.ColorRed)}\n\tmessage: {_curRadsInfo.info}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.DisplayFailed:
|
case AdStatusType.DisplayFailed:
|
||||||
msg = $"RADS: {ColoredText("display failed", Consts.ColorRed)}\n\tmessage: {_curRadsInfo.info}\n";
|
msg = $"RADS: {ColoredText("display failed", Const.ColorRed)}\n\tmessage: {_curRadsInfo.info}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.Loading:
|
case AdStatusType.Loading:
|
||||||
msg = $"RADS: {ColoredText("loading...", Consts.ColorYellow)}\n\tformat: {_curRadsInfo.format}\n";
|
msg = $"RADS: {ColoredText("loading...", Const.ColorYellow)}\n\tformat: {_curRadsInfo.format}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.Paid:
|
case AdStatusType.Paid:
|
||||||
msg = $"RADS: {ColoredText("get revenue", Consts.ColorGreen)}\n\trevenue: {_curRadsInfo.revenue}\n";
|
msg = $"RADS: {ColoredText("get revenue", Const.ColorGreen)}\n\trevenue: {_curRadsInfo.revenue}\n";
|
||||||
break;
|
break;
|
||||||
case AdStatusType.NotReady:
|
case AdStatusType.NotReady:
|
||||||
msg = $"RADS: {ColoredText("not ready", Consts.ColorGray)}\n\t{ColoredText("---", Consts.ColorGray)}\n";
|
msg = $"RADS: {ColoredText("not ready", Const.ColorGray)}\n\t{ColoredText("---", Const.ColorGray)}\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg = $"RADS: {ColoredText("other", Consts.ColorGray)}\n\tstatus: {ColoredText($"{_curRadsInfo.status}", Consts.ColorYellow)}\n";
|
msg = $"RADS: {ColoredText("other", Const.ColorGray)}\n\tstatus: {ColoredText($"{_curRadsInfo.status}", Const.ColorYellow)}\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -247,13 +242,13 @@ namespace Guru
|
||||||
private void AddCallbacks()
|
private void AddCallbacks()
|
||||||
{
|
{
|
||||||
//----------------- Banner -----------------
|
//----------------- Banner -----------------
|
||||||
ADService.OnBannerStartLoad += OnBannerStartLoadEvent;
|
ADService.Instance.OnBannerStartLoad += OnBannerStartLoadEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdLoadedEvent += OnBannerAdLoadedEvent;
|
MaxSdkCallbacks.Banner.OnAdLoadedEvent += OnBannerAdLoadedEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdLoadFailedEvent += OnBannerAdLoadFailEvent;
|
MaxSdkCallbacks.Banner.OnAdLoadFailedEvent += OnBannerAdLoadFailEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnBannerAdRevenuePaidEvent;
|
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnBannerAdRevenuePaidEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdClickedEvent += OnBannerAdClickedEvent;
|
MaxSdkCallbacks.Banner.OnAdClickedEvent += OnBannerAdClickedEvent;
|
||||||
//----------------- Interstitials -----------------
|
//----------------- Interstitials -----------------
|
||||||
ADService.OnInterstitialStartLoad += OnInterStartLoadEvent;
|
ADService.Instance.OnInterstitialStartLoad += OnInterStartLoadEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterAdLoadedEvent;
|
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterAdLoadedEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterAdLoadFailEvent;
|
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterAdLoadFailEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnInterAdDisplayFailEvent;
|
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnInterAdDisplayFailEvent;
|
||||||
|
|
@ -261,7 +256,7 @@ namespace Guru
|
||||||
MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterAdClickedEvent;
|
MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterAdClickedEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterAdHiddenEvent;
|
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterAdHiddenEvent;
|
||||||
//----------------- Reward -----------------
|
//----------------- Reward -----------------
|
||||||
ADService.OnRewardedStartLoad += OnRewardedStartLoad;
|
ADService.Instance.OnRewardedStartLoad += OnRewardedStartLoad;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardAdLoadedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardAdLoadedEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardAdLoadFailEvent;
|
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardAdLoadFailEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardAdDisplayFailEvent;
|
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardAdDisplayFailEvent;
|
||||||
|
|
@ -273,13 +268,13 @@ namespace Guru
|
||||||
private void RemoveCallbacks()
|
private void RemoveCallbacks()
|
||||||
{
|
{
|
||||||
//----------------- Banner -----------------
|
//----------------- Banner -----------------
|
||||||
ADService.OnBannerStartLoad -= OnBannerStartLoadEvent;
|
ADService.Instance.OnBannerStartLoad -= OnBannerStartLoadEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdLoadedEvent -= OnBannerAdLoadedEvent;
|
MaxSdkCallbacks.Banner.OnAdLoadedEvent -= OnBannerAdLoadedEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdLoadFailedEvent -= OnBannerAdLoadFailEvent;
|
MaxSdkCallbacks.Banner.OnAdLoadFailedEvent -= OnBannerAdLoadFailEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent -= OnBannerAdRevenuePaidEvent;
|
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent -= OnBannerAdRevenuePaidEvent;
|
||||||
MaxSdkCallbacks.Banner.OnAdClickedEvent -= OnBannerAdClickedEvent;
|
MaxSdkCallbacks.Banner.OnAdClickedEvent -= OnBannerAdClickedEvent;
|
||||||
//----------------- Interstitials -----------------
|
//----------------- Interstitials -----------------
|
||||||
ADService.OnInterstitialStartLoad -= OnInterStartLoadEvent;
|
ADService.Instance.OnInterstitialStartLoad -= OnInterStartLoadEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent -= OnInterAdLoadedEvent;
|
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent -= OnInterAdLoadedEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent -= OnInterAdLoadFailEvent;
|
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent -= OnInterAdLoadFailEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent -= OnInterAdDisplayFailEvent;
|
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent -= OnInterAdDisplayFailEvent;
|
||||||
|
|
@ -287,7 +282,7 @@ namespace Guru
|
||||||
MaxSdkCallbacks.Interstitial.OnAdClickedEvent -= OnInterAdClickedEvent;
|
MaxSdkCallbacks.Interstitial.OnAdClickedEvent -= OnInterAdClickedEvent;
|
||||||
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent -= OnInterAdHiddenEvent;
|
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent -= OnInterAdHiddenEvent;
|
||||||
//----------------- Reward -----------------
|
//----------------- Reward -----------------
|
||||||
ADService.OnRewardedStartLoad -= OnRewardedStartLoad;
|
ADService.Instance.OnRewardedStartLoad -= OnRewardedStartLoad;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent -= OnRewardAdLoadedEvent;
|
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent -= OnRewardAdLoadedEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent -= OnRewardAdLoadFailEvent;
|
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent -= OnRewardAdLoadFailEvent;
|
||||||
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent -= OnRewardAdDisplayFailEvent;
|
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent -= OnRewardAdDisplayFailEvent;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue