Compare commits

...

2 Commits

Author SHA1 Message Date
胡宇飞 67abd081c8 update: 更新 Connectivity iOS 原生库为正式版本, 补全 meta 文件
Signed-off-by: huyufei <yufei.hu@castbox.fm>
2024-07-26 15:07:48 +08:00
胡宇飞 400498af17 update:新增打点需求 review_creative_id 和 ad_placement
--story=1020787 --user=yufei.hu 【中台】【广告】新增打点需求 review_creative_id 和 ad_placement https://www.tapd.cn/33527076/s/1159788

Signed-off-by: huyufei <yufei.hu@castbox.fm>
2024-07-26 14:39:32 +08:00
27 changed files with 430 additions and 73 deletions

View File

@ -1,4 +1,5 @@
using System;
using UnityEngine; using UnityEngine;
namespace Guru namespace Guru
@ -115,7 +116,7 @@ namespace Guru
private void OnLoadMaxBanner() private void OnLoadMaxBanner()
{ {
_badsloadStartTime = Time.realtimeSinceStartup; _badsloadStartTime = DateTime.UtcNow;
_chanelMax.LoadBannerAD(); _chanelMax.LoadBannerAD();
OnBannerStartLoad?.Invoke(_chanelMax.MaxBADSSlotID); OnBannerStartLoad?.Invoke(_chanelMax.MaxBADSSlotID);
} }
@ -147,7 +148,7 @@ namespace Guru
} }
private void OnLoadMaxIV() { private void OnLoadMaxIV() {
_iadsLoadStartTime = Time.realtimeSinceStartup; // 更新计时器 _iadsLoadStartTime = DateTime.UtcNow; // 更新计时器
_chanelMax.LoadInterstitialAD(); _chanelMax.LoadInterstitialAD();
OnInterstitialStartLoad?.Invoke(_chanelMax.MaxIADSSlotID); OnInterstitialStartLoad?.Invoke(_chanelMax.MaxIADSSlotID);
} }
@ -180,7 +181,7 @@ namespace Guru
private void OnLoadMaxRV() private void OnLoadMaxRV()
{ {
_radsLoadStartTime = Time.realtimeSinceStartup; // 更新计时器 _radsLoadStartTime = DateTime.UtcNow; // 更新计时器
_chanelMax.LoadRewardAD(); _chanelMax.LoadRewardAD();
OnRewardedStartLoad?.Invoke(_chanelMax.MaxRADSSlotID); OnRewardedStartLoad?.Invoke(_chanelMax.MaxRADSSlotID);
} }

View File

@ -213,11 +213,24 @@ namespace Guru
// #2 tch_001 // #2 tch_001
double revenue = impressionData.value; double revenue = impressionData.value;
CalcTaichi001Value(revenue); CalcTch001Value(revenue);
CalcTaichi02Value(revenue); CalcTch02Value(revenue);
// #3 adjust_ad_revenue // #3 adjust_ad_revenue
AdjustService.TrackADRevenue(impressionData); AdjustService.TrackADRevenue(impressionData);
var adType = impressionData.ad_format.ToUpper();
// #4 Paid Event
Debug.Log($"{Tag} --- ReportAdsRevenue :: Send Paid Event: {adType}");
if (adType.Contains("INTER"))
{
OnInterstitialPaidEvent(impressionData);
}
else if (adType.Contains("REWARD"))
{
OnRewardedAdPaidEvent(impressionData);
}
} }
@ -238,7 +251,7 @@ namespace Guru
else else
{ {
// 找不到的话会缓存 adInfo, 等待获取 RCid // 找不到的话会缓存 adInfo, 等待获取 RCid
_impressionCache[adInfo.CreativeIdentifier] = CreateImpressionData(adInfo, "", Analytics.AdMAX); SetImpressionData(adInfo);
} }
} }
@ -281,7 +294,7 @@ namespace Guru
/// 计算太极001收益 /// 计算太极001收益
/// </summary> /// </summary>
/// <param name="revenue"></param> /// <param name="revenue"></param>
private void CalcTaichi001Value(double revenue) private void CalcTch001Value(double revenue)
{ {
TchAD001RevValue += revenue; TchAD001RevValue += revenue;
double revenueValue = TchAD001RevValue; double revenueValue = TchAD001RevValue;
@ -298,7 +311,7 @@ namespace Guru
/// 计算太极02收益 /// 计算太极02收益
/// </summary> /// </summary>
/// <param name="revenue"></param> /// <param name="revenue"></param>
private void CalcTaichi02Value(double revenue) private void CalcTch02Value(double revenue)
{ {
if (!Analytics.EnableTch02Event) return; if (!Analytics.EnableTch02Event) return;
@ -320,21 +333,25 @@ namespace Guru
private string _backColorStr = "#50A436"; 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 float _badsloadStartTime = 0; 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>
private int GetAdsLoadDuration(ref float startTime) /// 获取动作间隔之间的毫秒数
/// </summary>
/// <param name="startTime"></param>
/// <returns></returns>
private int GetActionDuration(DateTime startTime)
{ {
int duration = (int)((Time.realtimeSinceStartup - startTime) * 1000); var sp = DateTime.UtcNow.Subtract(startTime.ToUniversalTime()).Duration();
startTime = Time.realtimeSinceStartup; return (int) sp.TotalMilliseconds;
return duration;
} }
public virtual void RequestBannerAD() public virtual void RequestBannerAD()
{ {
_backColor = Color.clear; _backColor = Color.clear;
@ -365,12 +382,12 @@ namespace Guru
public void OnLoadBads() public void OnLoadBads()
{ {
_badsloadStartTime = Time.realtimeSinceStartup; _badsloadStartTime = DateTime.UtcNow;
} }
protected virtual void OnBadsLoaded() protected virtual void OnBadsLoaded()
{ {
_badsloadStartTime = Time.realtimeSinceStartup; _badsloadStartTime = DateTime.UtcNow;
OnBannerLoaded?.Invoke(); OnBannerLoaded?.Invoke();
} }
@ -446,7 +463,7 @@ namespace Guru
_badsLoadFailNum ++; _badsLoadFailNum ++;
// Analytics.ADBadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _badsloadStartTime), _badsCategory); // Analytics.ADBadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _badsloadStartTime), _badsCategory);
Analytics.ADBadsFailed(AdParams.Build(adUnitId, Analytics.ADBadsFailed(AdParams.Build(adUnitId,
duration: GetAdsLoadDuration(ref _badsloadStartTime), category: _badsCategory, duration: GetActionDuration(_badsloadStartTime), category: _badsCategory,
errorCode: (int)errorInfo.Code, errorCode: (int)errorInfo.Code,
waterfallName: errorInfo?.WaterfallInfo?.Name ?? "")); waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
} }
@ -488,9 +505,12 @@ namespace Guru
private string _iadsCategory = "main"; private string _iadsCategory = "main";
private int _interstitialRetryAttempt; private int _interstitialRetryAttempt;
protected float _iadsLoadStartTime;
private Action _interCloseAction; private Action _interCloseAction;
protected bool _isIadsLoading = false; protected bool _isIadsLoading = false;
protected DateTime _iadsLoadStartTime;
private DateTime _iadsDisplayStartTime;
public bool IsIadsLoading => _isIadsLoading; public bool IsIadsLoading => _isIadsLoading;
public virtual void RequestInterstitialAD() public virtual void RequestInterstitialAD()
@ -514,7 +534,7 @@ namespace Guru
public void OnLoadIads() public void OnLoadIads()
{ {
_iadsLoadStartTime = Time.realtimeSinceStartup; _iadsLoadStartTime = DateTime.UtcNow;
} }
@ -548,6 +568,7 @@ namespace Guru
_interCloseAction = dismissAction; _interCloseAction = dismissAction;
MaxSdk.ShowInterstitial(GetInterstitialID()); MaxSdk.ShowInterstitial(GetInterstitialID());
_iadsDisplayStartTime = DateTime.UtcNow;
// RequestInterstitialAD(); // 直接加载下一个广告 // RequestInterstitialAD(); // 直接加载下一个广告
} }
@ -558,7 +579,7 @@ namespace Guru
// 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.ADIadsLoaded(AdParams.Build(adUnitId,
duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory)); 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}");
@ -577,8 +598,9 @@ 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.ADIadsFailed(AdParams.Build(adUnitId, Analytics.ADIadsFailed(AdParams.Build(adUnitId,
duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory, duration: GetActionDuration(_iadsLoadStartTime), category: _iadsCategory,
errorCode: (int)errorInfo.Code, errorCode: (int)errorInfo.Code,
waterfallName: errorInfo?.WaterfallInfo?.Name ?? "")); waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
@ -593,42 +615,65 @@ namespace Guru
$"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.ADIadsFailed(AdParams.Build(adUnitId,
duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory, duration: GetActionDuration(_iadsDisplayStartTime), category: _iadsCategory,
errorCode: (int)errorInfo.Code, errorCode: (int)errorInfo.Code,
waterfallName: errorInfo?.WaterfallInfo?.Name ?? "")); waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
DelayCall(2.0f, RequestInterstitialAD); DelayCall(2.0f, RequestInterstitialAD);
} }
// iads_imp
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);
Analytics.ADIadsImp(AdParams.Build(adUnitId, category: _iadsCategory)); string reviewCreativeId = GetReviewCreativeId(adInfo.CreativeIdentifier);
Analytics.ADIadsImp(AdParams.Build(adUnitId, adInfo, category: _iadsCategory, reviewCreativeId:reviewCreativeId));
} }
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);
Analytics.ADIadsClick(AdParams.Build(adUnitId, category: _iadsCategory)); string reviewCreativeId = GetReviewCreativeId(adInfo.CreativeIdentifier);
var impressionData = CreateImpressionData(adInfo, reviewCreativeId);
var data = impressionData.BuildEventData();
if(string.IsNullOrEmpty(_iadsCategory)) _iadsCategory = "not_set";
data["item_category"] = _iadsCategory;
data.Remove("ad_format");
Analytics.ADIadsClick(data);
} }
// Close
protected virtual void OnInterstitialDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) protected virtual void OnInterstitialDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{ {
// Interstitial ad is hidden. Pre-load the next ad // Interstitial ad is hidden. Pre-load the next ad
_interCloseAction?.Invoke(); _interCloseAction?.Invoke();
OnInterstitialClosed?.Invoke(); OnInterstitialClosed?.Invoke();
// Analytics.ADIadsClose(adUnitId, _iadsCategory); // Analytics.ADIadsClose(adUnitId, _iadsCategory);
Analytics.ADIadsClose(AdParams.Build(adUnitId, category: _iadsCategory)); Analytics.ADIadsClose(AdParams.Build(adUnitId,
duration:GetActionDuration(_iadsDisplayStartTime),
category: _iadsCategory));
//延时加载下一个广告 //延时加载下一个广告
DelayCall(2.0f, RequestInterstitialAD); DelayCall(2.0f, RequestInterstitialAD);
} }
private void OnInterstitialPaidEvent(AdImpressionData impressionData)
{
var data = impressionData.BuildEventData();
if(string.IsNullOrEmpty(_iadsCategory)) _iadsCategory = "not_set";
data["item_category"] = _iadsCategory;
data.Remove("ad_format");
Analytics.ADIadsPaid(data);
}
#endregion #endregion
#region Rewarded Ads #region Rewarded Ads
private string _rewardCategory = "main"; private string _rewardCategory = "main";
private int _rewardRetryAttempt; private int _rewardRetryAttempt;
protected float _radsLoadStartTime; protected DateTime _radsLoadStartTime;
protected DateTime _radsShowStartTime;
private Action _rvRewardAction; private Action _rvRewardAction;
private Action<string> _rvFailAction; private Action<string> _rvFailAction;
private Action _rvDismissAction; private Action _rvDismissAction;
@ -661,7 +706,7 @@ namespace Guru
public void OnLoadRads() public void OnLoadRads()
{ {
_radsLoadStartTime = Time.realtimeSinceStartup; _radsLoadStartTime = DateTime.UtcNow;
} }
@ -700,6 +745,8 @@ namespace Guru
_rvDismissAction = dismissAction; _rvDismissAction = dismissAction;
MaxSdk.ShowRewardedAd(GetRewardedID()); MaxSdk.ShowRewardedAd(GetRewardedID());
_radsShowStartTime = DateTime.UtcNow;
// RequestRewardedAD(); // RequestRewardedAD();
} }
@ -712,7 +759,7 @@ namespace Guru
// 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.ADRadsLoaded(AdParams.Build(adUnitId,
duration: GetAdsLoadDuration(ref _radsLoadStartTime), category: _iadsCategory)); 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}");
@ -730,7 +777,7 @@ namespace Guru
$"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.ADRadsFailed(AdParams.Build(adUnitId,
duration: GetAdsLoadDuration(ref _radsLoadStartTime), category: _rewardCategory, duration: GetActionDuration(_radsLoadStartTime), category: _rewardCategory,
errorCode: (int)errorInfo.Code, errorCode: (int)errorInfo.Code,
waterfallName: errorInfo?.WaterfallInfo?.Name ?? "")); waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
_rewardRetryAttempt++; _rewardRetryAttempt++;
@ -748,7 +795,7 @@ namespace Guru
$"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.ADRadsFailed(AdParams.Build(adUnitId,
duration: GetAdsLoadDuration(ref _radsLoadStartTime), category: _rewardCategory, duration: GetActionDuration(_radsShowStartTime), category: _rewardCategory,
errorCode: (int)errorInfo.Code, errorCode: (int)errorInfo.Code,
waterfallName: errorInfo?.WaterfallInfo?.Name ?? "")); waterfallName: errorInfo?.WaterfallInfo?.Name ?? ""));
_rvFailAction?.Invoke("OnRewardedAdFailedToDisplayEvent"); _rvFailAction?.Invoke("OnRewardedAdFailedToDisplayEvent");
@ -761,16 +808,23 @@ namespace Guru
{ {
this.Log("OnRewardedAdDisplayedEvent"); this.Log("OnRewardedAdDisplayedEvent");
// Analytics.ADRadsImp(adUnitId, _rewardCategory); // Analytics.ADRadsImp(adUnitId, _rewardCategory);
Analytics.ADRadsImp(AdParams.Build(adUnitId, category: _rewardCategory)); string reviewCreativeId = GetReviewCreativeId(adInfo.CreativeIdentifier);
Analytics.ADRadsImp(AdParams.Build(adUnitId, adInfo, category: _rewardCategory, reviewCreativeId:reviewCreativeId));
} }
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);
Analytics.ADRadsClick(AdParams.Build(adUnitId, category: _rewardCategory)); var impressionData = CreateImpressionData(adInfo, GetReviewCreativeId(adInfo.CreativeIdentifier));
var data = impressionData.BuildEventData();
if(string.IsNullOrEmpty(_rewardCategory)) _rewardCategory = "not_set";
data["item_category"] = _rewardCategory;
data.Remove("ad_format");
Analytics.ADRadsClick(data);
} }
// rads_close
protected virtual void OnRewardedAdDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) protected virtual void OnRewardedAdDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{ {
this.Log("OnRewardedAdDismissedEvent"); this.Log("OnRewardedAdDismissedEvent");
@ -779,24 +833,37 @@ namespace Guru
OnRewardClosed?.Invoke(); OnRewardClosed?.Invoke();
// Analytics.ADRadsClose(adUnitId, _rewardCategory); // Analytics.ADRadsClose(adUnitId, _rewardCategory);
Analytics.ADRadsClose(AdParams.Build(adUnitId, category: _rewardCategory)); Analytics.ADRadsClose(AdParams.Build(adUnitId, duration:GetActionDuration(_radsShowStartTime), category: _rewardCategory));
//延时加载下一个广告 //延时加载下一个广告
DelayCall(2.0f, RequestRewardedAD); DelayCall(2.0f, RequestRewardedAD);
} }
// rads_rewarded
protected virtual void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward, protected virtual void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward,
MaxSdkBase.AdInfo arg3) MaxSdkBase.AdInfo adInfo)
{ {
this.Log("OnRewardedAdReceivedRewardEvent"); this.Log("OnRewardedAdReceivedRewardEvent");
// Analytics.ADRadsRewarded(adUnitId, _rewardCategory); // Analytics.ADRadsRewarded(adUnitId, _rewardCategory);
Analytics.ADRadsRewarded(AdParams.Build(adUnitId, category: _rewardCategory)); var impressionData = CreateImpressionData(adInfo, GetReviewCreativeId(adInfo.CreativeIdentifier));
var data = impressionData.BuildEventData();
if(string.IsNullOrEmpty(_rewardCategory)) _rewardCategory = "not_set";
data["item_category"] = _rewardCategory;
data.Remove("ad_format");
Analytics.ADRadsRewarded(data);
// Rewarded ad was displayed and user should receive the reward // Rewarded ad was displayed and user should receive the reward
_rvRewardAction?.Invoke(); _rvRewardAction?.Invoke();
} }
// rads_paid
private void OnRewardedAdPaidEvent(AdImpressionData impressionData)
{
var data = impressionData.BuildEventData();
if(string.IsNullOrEmpty(_rewardCategory)) _rewardCategory = "not_set";
data["item_category"] = _rewardCategory;
data.Remove("ad_format");
Analytics.ADRadsPaid(data);
}
#endregion #endregion
#region Ad Settings #region Ad Settings
@ -841,6 +908,35 @@ namespace Guru
#region CreativeID #region CreativeID
private string GetReviewCreativeId(string creativeId)
{
if (_reviewCreativeIds == null)
{
return "";
}
if (_reviewCreativeIds.TryGetValue(creativeId, out var reviewCreativeId))
{
return reviewCreativeId;
}
return "";
}
private void SetReviewCreativeId(string creativeId, string reviewCreativeId)
{
if (_reviewCreativeIds == null) _reviewCreativeIds = new Dictionary<string, string>(10);
if (string.IsNullOrEmpty(reviewCreativeId)) return;
_reviewCreativeIds[creativeId] = reviewCreativeId;
}
private void SetImpressionData(MaxSdkBase.AdInfo adInfo, string reviewCreativeId = "", string platform = "")
{
if (string.IsNullOrEmpty(platform)) platform = Analytics.AdMAX;
_impressionCache[adInfo.CreativeIdentifier] = CreateImpressionData(adInfo, reviewCreativeId, platform);
}
/// <summary> /// <summary>
/// 获取 AdReviewCreativeId /// 获取 AdReviewCreativeId
/// </summary> /// </summary>
@ -856,14 +952,8 @@ namespace Guru
return; return;
} }
if (_reviewCreativeIds == null) _reviewCreativeIds = new Dictionary<string, string>(10);
// 尝试直接上报广告收益 (可能存在异步上报的情况) // 尝试直接上报广告收益 (可能存在异步上报的情况)
if (!TryReportImpression(adInfo, reviewCreativeId)) TryReportImpression(adInfo, reviewCreativeId);
{
_reviewCreativeIds[adInfo.CreativeIdentifier] = reviewCreativeId; // 如果上报未成功, 则缓存reviewCreativeId
}
} }
/// <summary> /// <summary>
@ -872,10 +962,9 @@ namespace Guru
/// <param name="adInfo"></param> /// <param name="adInfo"></param>
/// <param name="reviewCreativeId"></param> /// <param name="reviewCreativeId"></param>
/// <returns></returns> /// <returns></returns>
private bool TryReportImpression(MaxSdk.AdInfo adInfo, string reviewCreativeId = "") private void TryReportImpression(MaxSdk.AdInfo adInfo, string reviewCreativeId = "")
{ {
string creativeId = adInfo.CreativeIdentifier; string creativeId = adInfo.CreativeIdentifier;
bool result = false;
List<string> removeList = new List<string>(); List<string> removeList = new List<string>();
if (_impressionCache.TryGetValue(creativeId, out var impressionData)) if (_impressionCache.TryGetValue(creativeId, out var impressionData))
@ -885,7 +974,11 @@ namespace Guru
ReportAdsRevenue(impressionData); ReportAdsRevenue(impressionData);
removeList.Add(creativeId); removeList.Add(creativeId);
result = true; }
else
{
// 如果上报未成功, 则缓存reviewCreativeId
SetReviewCreativeId(adInfo.CreativeIdentifier, reviewCreativeId);
} }
// 清理超过 3 秒未上报的数据 // 清理超过 3 秒未上报的数据
@ -906,8 +999,6 @@ namespace Guru
_reviewCreativeIds.Remove(k); _reviewCreativeIds.Remove(k);
} }
} }
return result;
} }
#endregion #endregion

View File

@ -1,5 +1,7 @@
using System.Collections.Generic;
namespace Guru namespace Guru
{ {
using System; using System;
@ -36,5 +38,23 @@ namespace Guru
} }
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;
}
} }
} }

View File

@ -36,15 +36,37 @@ namespace Guru
if (adParams.duration > 0) if (adParams.duration > 0)
data[ParameterDuration] = adParams.duration; data[ParameterDuration] = adParams.duration;
if (adParams.errorCode != 0) if (adParams.errorCode != 0)
data[ParameterErrorCode] = adParams.errorCode; data[ParameterErrorCode] = adParams.errorCode;
if (!string.IsNullOrEmpty(adParams.networkName)) if (!string.IsNullOrEmpty(adParams.networkName))
data[ParameterNetworkName] = adParams.networkName; data[ParameterNetworkName] = adParams.networkName;
if (!string.IsNullOrEmpty(adParams.networkPlacement)) if (!string.IsNullOrEmpty(adParams.networkPlacement))
{
data[ParameterNetworkPlacement] = adParams.networkPlacement; data[ParameterNetworkPlacement] = adParams.networkPlacement;
data[ParameterAdPlacement] = adParams.networkPlacement;
}
if (!string.IsNullOrEmpty(adParams.waterfallName)) if (!string.IsNullOrEmpty(adParams.waterfallName))
data[ParameterWaterfall] = 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) if (extra != null && extra.Count > 0)
{ {
foreach (var k in extra.Keys) foreach (var k in extra.Keys)
@ -128,7 +150,12 @@ namespace Guru
/// </summary> /// </summary>
public static void ADIadsClick(AdParams adParams) public static void ADIadsClick(AdParams adParams)
{ {
TrackEvent(EventIadsClick, BuildAdEventData(adParams)); ADIadsClick(BuildAdEventData(adParams));
}
public static void ADIadsClick(Dictionary<string, object> data)
{
TrackEvent(EventIadsClick, data);
} }
/// <summary> /// <summary>
@ -139,6 +166,15 @@ namespace Guru
TrackEvent(EventIadsClose, BuildAdEventData(adParams)); TrackEvent(EventIadsClose, BuildAdEventData(adParams));
} }
/// <summary>
/// 插屏广告收到奖励
/// </summary>
/// <param name="data"></param>
public static void ADIadsPaid(Dictionary<string, object> data)
{
TrackEvent(EventIadsPaid, data);
}
//---------------------- REWARDS ------------------------- //---------------------- REWARDS -------------------------
/// <summary> /// <summary>
/// 广告开始加载 /// 广告开始加载
@ -173,7 +209,11 @@ namespace Guru
/// </summary> /// </summary>
public static void ADRadsRewarded(AdParams adParams) public static void ADRadsRewarded(AdParams adParams)
{ {
var data = BuildAdEventData(adParams); ADRadsRewarded(BuildAdEventData(adParams));
}
public static void ADRadsRewarded(Dictionary<string, object> data)
{
TrackEvent(EventRadsRewarded, data); TrackEvent(EventRadsRewarded, data);
if (RadsRewardCount == 0) if (RadsRewardCount == 0)
@ -183,6 +223,15 @@ namespace Guru
} }
} }
/// <summary>
/// 插屏广告收到奖励
/// </summary>
/// <param name="data"></param>
public static void ADRadsPaid(Dictionary<string, object> data)
{
TrackEvent(EventRadsPaid, data);
}
private static int RadsRewardCount private static int RadsRewardCount
{ {
@ -203,7 +252,12 @@ namespace Guru
/// </summary> /// </summary>
public static void ADRadsClick(AdParams adParams) public static void ADRadsClick(AdParams adParams)
{ {
TrackEvent(EventRadsClick, BuildAdEventData(adParams)); ADRadsClick(BuildAdEventData(adParams));
}
public static void ADRadsClick(Dictionary<string, object> data)
{
TrackEvent(EventRadsClick, data);
} }
/// <summary> /// <summary>
@ -260,10 +314,15 @@ namespace Guru
public string category; public string category;
public string networkName; public string networkName;
public string networkPlacement; public string networkPlacement;
public string adPlatform;
public string adSource;
public string adFormat;
public string waterfallName; public string waterfallName;
public string adUnitId; public string adUnitId;
public int errorCode = 0; public int errorCode = 0;
public int duration = 0; public int duration = 0;
public string creativeId;
public string reviewCreativeId;
/// <summary> /// <summary>
@ -275,31 +334,47 @@ namespace Guru
/// <param name="duration"></param> /// <param name="duration"></param>
/// <param name="errorCode"></param> /// <param name="errorCode"></param>
/// <param name="waterfallName"></param> /// <param name="waterfallName"></param>
/// <param name="reviewCreativeId"></param>
/// <param name="adPlatform"></param>
/// <returns></returns> /// <returns></returns>
public static AdParams Build(string adUnitId, MaxSdkBase.AdInfo adInfo = null, string category = "", public static AdParams Build(string adUnitId, MaxSdkBase.AdInfo adInfo = null, string category = "",
int duration = 0, int errorCode = 0, string waterfallName = "") int duration = 0, int errorCode = 0, string waterfallName = "", string reviewCreativeId = "", string adPlatform = "")
{ {
if (string.IsNullOrEmpty(adUnitId) && adInfo != null) adUnitId = adInfo.AdUnitIdentifier; if (string.IsNullOrEmpty(adUnitId) && adInfo != null) adUnitId = adInfo.AdUnitIdentifier;
var networkName = ""; var networkName = "";
var networkPlacement = ""; var networkPlacement = "";
var creativeId = "";
var adSource = "";
var adFormart = "";
if (string.IsNullOrEmpty(adPlatform)) adPlatform = Analytics.AdMAX;
if (adInfo != null) if (adInfo != null)
{ {
networkName = adInfo.NetworkName; networkName = adInfo.NetworkName;
networkPlacement = adInfo.NetworkPlacement; networkPlacement = adInfo.NetworkPlacement;
creativeId = adInfo.CreativeIdentifier;
adSource = adInfo.NetworkName;
adFormart = adInfo.AdFormat;
if (string.IsNullOrEmpty(waterfallName)) if (string.IsNullOrEmpty(waterfallName))
waterfallName = adInfo.WaterfallInfo?.Name ?? ""; waterfallName = adInfo.WaterfallInfo?.Name ?? "";
} }
var p = new AdParams() var p = new AdParams()
{ {
adUnitId = adUnitId, adUnitId = adUnitId,
adPlatform = adPlatform,
adSource = adSource,
adFormat = adFormart,
duration = duration, duration = duration,
networkName = networkName, networkName = networkName,
networkPlacement = networkPlacement, networkPlacement = networkPlacement,
waterfallName = waterfallName, waterfallName = waterfallName,
category = category, category = category,
errorCode = errorCode, errorCode = errorCode,
creativeId = creativeId,
reviewCreativeId = reviewCreativeId,
}; };
return p; return p;
} }

View File

@ -161,7 +161,7 @@ namespace Guru
/// </summary> /// </summary>
public static void SetUserProperty(string propertyName, string propertyValue) public static void SetUserProperty(string propertyName, string propertyValue)
{ {
Log.I(TAG,$"SetUserProperty -> propertyName:{propertyName}, propertyValue:{propertyValue}"); Debug.Log($"{TAG} --- SetUserProperty -> propertyName:{propertyName}, propertyValue:{propertyValue}");
if (!IsReady) if (!IsReady)
return; return;

View File

@ -11,6 +11,24 @@ PluginImporter:
isExplicitlyReferenced: 0 isExplicitlyReferenced: 0
validateReferences: 1 validateReferences: 1
platformData: platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first: - first:
Any: Any:
second: second:
@ -21,13 +39,42 @@ PluginImporter:
second: second:
enabled: 0 enabled: 0
settings: settings:
CPU: AnyCPU
DefaultValueInitialized: true DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first: - first:
iPhone: iOS iPhone: iOS
second: second:
enabled: 1 enabled: 1
settings: settings:
AddToEmbeddedBinaries: true AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ec7317011341a40a1a0ee7ae5f38f270
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a4ccb52ed7f6b4dff8731e9e93293ccb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,6 @@
#if 0 #if 0
#elif defined(__arm64__) && __arm64__ #elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5) // Generated by Apple Swift version 5.9.2 effective-4.1.50 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
#ifndef CONNECTIVITY_SWIFT_H #ifndef CONNECTIVITY_SWIFT_H
#define CONNECTIVITY_SWIFT_H #define CONNECTIVITY_SWIFT_H
#pragma clang diagnostic push #pragma clang diagnostic push
@ -318,7 +318,7 @@ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, copy) NSString * _No
SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, copy) NSString * _Nonnull CONNECTIVITY_OTHER;) SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, copy) NSString * _Nonnull CONNECTIVITY_OTHER;)
+ (NSString * _Nonnull)CONNECTIVITY_OTHER SWIFT_WARN_UNUSED_RESULT; + (NSString * _Nonnull)CONNECTIVITY_OTHER SWIFT_WARN_UNUSED_RESULT;
- (nonnull instancetype)init SWIFT_UNAVAILABLE; - (nonnull instancetype)init SWIFT_UNAVAILABLE;
+ (nonnull instancetype)new SWIFT_UNAVAILABLE_MSG("-init is unavailable"); + (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
- (void)initializeWithCompletion:(void (^ _Nonnull)(BOOL))completion; - (void)initializeWithCompletion:(void (^ _Nonnull)(BOOL))completion;
- (NSArray<NSString *> * _Nonnull)checkConnectionType SWIFT_WARN_UNUSED_RESULT; - (NSArray<NSString *> * _Nonnull)checkConnectionType SWIFT_WARN_UNUSED_RESULT;
@end @end

View File

@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: c7072e499221b489e8a171a746c1d381
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b3be6515c98fc4516b74799d2232851a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 009197294dbfe4bd5b64f833fce7277e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: db929fad7809a40a6af254c5262adb3a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d014052e45f6948db82f9fbecdb02a96
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5a2b967c5b7f944adb348971a0e13c79
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b8637a4450c6b4ca895cd05427db6ffc
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2b7b377a06cfe4472ace76077b0d1e24
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be5b523ba98e649d9938fc7df1e7b55a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 97a465fd6df3b4f72a477ef19bf727a9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1a90376b0826241cf8ed25c4ba2b91fc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -6,15 +6,15 @@
<dict> <dict>
<key>Headers/Connectivity-Swift.h</key> <key>Headers/Connectivity-Swift.h</key>
<data> <data>
yQkPWwZ2klcFBQT3c4PI/gTVVAE= 2jZWRNZEB9lWoT02/WI0gpx8bUY=
</data> </data>
<key>Info.plist</key> <key>Info.plist</key>
<data> <data>
n4FM+14bzgCqiae7BEnOfj78dFA= lVs8E6FtUHvDAsoK7zwpgZ+1m84=
</data> </data>
<key>Modules/Connectivity.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key> <key>Modules/Connectivity.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key>
<data> <data>
KGmpTymRqrX9y4GV/j+eFuhhTYM= 3vRjRUNrw8fWaShfTaH+cBfxfLE=
</data> </data>
<key>Modules/Connectivity.swiftmodule/arm64-apple-ios.abi.json</key> <key>Modules/Connectivity.swiftmodule/arm64-apple-ios.abi.json</key>
<data> <data>
@ -22,11 +22,11 @@
</data> </data>
<key>Modules/Connectivity.swiftmodule/arm64-apple-ios.swiftdoc</key> <key>Modules/Connectivity.swiftmodule/arm64-apple-ios.swiftdoc</key>
<data> <data>
NaKg9acNtBzWngYfwx3Nt50tA5o= HgPMAkcK2+NGvcVfwyFJ9u/nd0k=
</data> </data>
<key>Modules/Connectivity.swiftmodule/arm64-apple-ios.swiftmodule</key> <key>Modules/Connectivity.swiftmodule/arm64-apple-ios.swiftmodule</key>
<data> <data>
TBHp8ndBz6+t9eK5i+Q7XONqD+w= nK9APrK3atZTGuid35+A6Dde02M=
</data> </data>
<key>Modules/module.modulemap</key> <key>Modules/module.modulemap</key>
<data> <data>
@ -39,14 +39,14 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
HIhSgITt+HNjHvu2O1pDvyjgx9HdyI801+Q9Bn92Suc= xwPPIVygOJDaH/CCrDO25Y2645Q/IQYSiJrV3eJJy+M=
</data> </data>
</dict> </dict>
<key>Modules/Connectivity.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key> <key>Modules/Connectivity.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key>
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
HnYY+N0JWfujm6LckQtevFuYEFW4uYx4hcAkaFgCZp0= Qgk/xiutw35xy8VeU5niELPbBEi5gVVuXYai3rhRrbI=
</data> </data>
</dict> </dict>
<key>Modules/Connectivity.swiftmodule/arm64-apple-ios.abi.json</key> <key>Modules/Connectivity.swiftmodule/arm64-apple-ios.abi.json</key>
@ -60,14 +60,14 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
sgsu9CnSXAG3fxoW1HBRLZ9lCTX38BR3y2eik7e37zU= ZNpy4/pGL15IFXpHTav2UvUYM7kQPN/0eTjxtfLqYq8=
</data> </data>
</dict> </dict>
<key>Modules/Connectivity.swiftmodule/arm64-apple-ios.swiftmodule</key> <key>Modules/Connectivity.swiftmodule/arm64-apple-ios.swiftmodule</key>
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
S73u4XvAyezKkKReZVBDl16w7MSeeI6FBXUJ9OirCI4= Et4EI2nA28WHGnFW0ki2IUjCTs703CjwdRvol0loQGo=
</data> </data>
</dict> </dict>
<key>Modules/module.modulemap</key> <key>Modules/module.modulemap</key>

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 158f1aee738db4ad8a07a36e89614060
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: