Compare commits
	
		
			2 Commits 
		
	
	
		
			23eb7ff7b4
			...
			7e499aa26c
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								
									
								
								 | 
						7e499aa26c | |
| 
							
							
								
									
								
								 | 
						a67185679b | 
| 
						 | 
					@ -1,3 +1,5 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Guru.Editor
 | 
					namespace Guru.Editor
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	using System.Linq;
 | 
						using System.Linq;
 | 
				
			||||||
| 
						 | 
					@ -21,6 +23,10 @@ namespace Guru.Editor
 | 
				
			||||||
	    private const string GuruKeystorePass = "guru0622";
 | 
						    private const string GuruKeystorePass = "guru0622";
 | 
				
			||||||
	    private const string GuruAliasName = "guru";
 | 
						    private const string GuruAliasName = "guru";
 | 
				
			||||||
	    private const string GuruAliasPass = "guru0622";
 | 
						    private const string GuruAliasPass = "guru0622";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    private const string UnityGradlePath_2021_3_41 =
 | 
				
			||||||
 | 
							    "/Applications/Unity/Hub/Editor/2021.3.41f1/PlaybackEngines/AndroidPlayer/Tools/gradle";
 | 
				
			||||||
 | 
						    
 | 
				
			||||||
	    private static string GuruKeystorePath => Application.dataPath + $"/Plugins/Android/{GuruKeystoreName}";
 | 
						    private static string GuruKeystorePath => Application.dataPath + $"/Plugins/Android/{GuruKeystoreName}";
 | 
				
			||||||
	    private static string ProguardName => "proguard-user.txt";
 | 
						    private static string ProguardName => "proguard-user.txt";
 | 
				
			||||||
	    private static string ProguardPath => Application.dataPath + $"/Plugins/Android/{ProguardName}";
 | 
						    private static string ProguardPath => Application.dataPath + $"/Plugins/Android/{ProguardName}";
 | 
				
			||||||
| 
						 | 
					@ -70,6 +76,8 @@ namespace Guru.Editor
 | 
				
			||||||
		    SwitchBuildPlatform(BuildTarget.Android);
 | 
							    SwitchBuildPlatform(BuildTarget.Android);
 | 
				
			||||||
		    // 打包通用设置
 | 
							    // 打包通用设置
 | 
				
			||||||
		    ChangeBuildPlayerCommonSetting(buildParam, BuildTargetGroup.Android);
 | 
							    ChangeBuildPlayerCommonSetting(buildParam, BuildTargetGroup.Android);
 | 
				
			||||||
 | 
							    // Set GradlePath
 | 
				
			||||||
 | 
							    SetGradlePath();
 | 
				
			||||||
		    
 | 
							    
 | 
				
			||||||
		    var isDebug = !buildParam.IsBuildRelease;
 | 
							    var isDebug = !buildParam.IsBuildRelease;
 | 
				
			||||||
		    var useMinify = buildParam.AndroidUseMinify;
 | 
							    var useMinify = buildParam.AndroidUseMinify;
 | 
				
			||||||
| 
						 | 
					@ -141,7 +149,18 @@ namespace Guru.Editor
 | 
				
			||||||
	        return apkPath;
 | 
						        return apkPath;
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/// <summary>
 | 
						    private static void SetGradlePath()
 | 
				
			||||||
 | 
						    {
 | 
				
			||||||
 | 
					#if UNITY_ANDROID && UNITY_2021_3_41
 | 
				
			||||||
 | 
							    if (Directory.Exists(UnityGradlePath_2021_3_41))
 | 
				
			||||||
 | 
							    {
 | 
				
			||||||
 | 
								    UnityEditor.Android.AndroidExternalToolsSettings.gradlePath = UnityGradlePath_2021_3_41;
 | 
				
			||||||
 | 
							    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    /// <summary>
 | 
				
			||||||
		/// 部署 Guru 专用的 Keystore
 | 
							/// 部署 Guru 专用的 Keystore
 | 
				
			||||||
		/// </summary> 
 | 
							/// </summary> 
 | 
				
			||||||
        private static bool DeployAndroidKeystore()
 | 
					        private static bool DeployAndroidKeystore()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -370,24 +370,22 @@ namespace Guru
 | 
				
			||||||
		/// <summary>
 | 
							/// <summary>
 | 
				
			||||||
		/// 广告收入上报 (Adjust 特有的接口)
 | 
							/// 广告收入上报 (Adjust 特有的接口)
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		/// <param name="adInfo"></param>
 | 
							/// <param name="value"></param>
 | 
				
			||||||
		public static void TrackADRevenue(AdImpressionData impressionData)
 | 
							/// <param name="currency"></param>
 | 
				
			||||||
 | 
							/// <param name="adSource"></param>
 | 
				
			||||||
 | 
							/// <param name="adUnitId"></param>
 | 
				
			||||||
 | 
							/// <param name="adPlacement"></param>
 | 
				
			||||||
 | 
							public static void TrackADRevenue(double value, string currency, string adSource, string adUnitId, string adPlacement)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (impressionData == null)
 | 
					 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			var adRevenue = new AdjustAdRevenue(AdjustConfig.AdjustAdRevenueSourceAppLovinMAX);
 | 
								var adRevenue = new AdjustAdRevenue(AdjustConfig.AdjustAdRevenueSourceAppLovinMAX);
 | 
				
			||||||
			adRevenue.setRevenue(impressionData.value, "USD");
 | 
								if (string.IsNullOrEmpty(currency)) currency = "USD";
 | 
				
			||||||
			adRevenue.setAdRevenueNetwork(impressionData.ad_source);
 | 
								adRevenue.setRevenue(value, currency);
 | 
				
			||||||
			adRevenue.setAdRevenueUnit(impressionData.ad_unit_name);
 | 
								adRevenue.setAdRevenueNetwork(adSource);
 | 
				
			||||||
			adRevenue.setAdRevenuePlacement(impressionData.ad_placement);
 | 
								adRevenue.setAdRevenueUnit(adUnitId);
 | 
				
			||||||
 | 
								adRevenue.setAdRevenuePlacement(adPlacement);
 | 
				
			||||||
			Adjust.trackAdRevenue(adRevenue);
 | 
								Adjust.trackAdRevenue(adRevenue);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		#endregion
 | 
							#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		#region 关键属性上报
 | 
							#region 关键属性上报
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,7 @@ namespace Guru
 | 
				
			||||||
    using System;
 | 
					    using System;
 | 
				
			||||||
    using UnityEngine;
 | 
					    using UnityEngine;
 | 
				
			||||||
    using System.Collections.Generic;
 | 
					    using System.Collections.Generic;
 | 
				
			||||||
 | 
					    using Guru.Ads;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public abstract class ADServiceBase<T> : IADService where T : new()
 | 
					    public abstract class ADServiceBase<T> : IADService where T : new()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -44,11 +45,13 @@ namespace Guru
 | 
				
			||||||
        public static Action OnRewardClosed;
 | 
					        public static Action OnRewardClosed;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        private Dictionary<string, string> _reviewCreativeIds = new Dictionary<string, string>(10); // Creative ID 缓存: Cid : RCid
 | 
					        private Dictionary<string, string> _reviewCreativeIds = new Dictionary<string, string>(10); // Creative ID 缓存: Cid : RCid
 | 
				
			||||||
        private Dictionary<string, AdImpressionData> _impressionCache = new Dictionary<string, AdImpressionData>(10);
 | 
					        private Dictionary<string, List<AdImpressionData>> _impressionCache = new Dictionary<string, List<AdImpressionData>>(10);
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
        protected AdsModel _model;
 | 
					        protected AdsModel _model;
 | 
				
			||||||
        protected AdsInitSpec _initSpec = null;
 | 
					        protected AdsInitSpec _initSpec = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private AdImpressionDriver _impressionDriver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public AdsModel Model
 | 
					        public AdsModel Model
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get
 | 
					            get
 | 
				
			||||||
| 
						 | 
					@ -79,6 +82,9 @@ 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(); // 内部继承接口
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -90,15 +96,15 @@ namespace Guru
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //--------------  初始化回调 ------------------
 | 
					            //--------------  初始化回调 ------------------
 | 
				
			||||||
            MaxSdkCallbacks.OnSdkInitializedEvent += OnMaxSdkInitializedCallBack;
 | 
					            MaxSdkCallbacks.OnSdkInitializedEvent += OnMaxSdkInitializedCallBack;
 | 
				
			||||||
            MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
 | 
					            
 | 
				
			||||||
            MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
 | 
					            //--------------- MRec 回调 -----------------
 | 
				
			||||||
            MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnBannerRevenuePaidEvent;
 | 
					            // 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.OnAdRevenuePaidEvent += OnBannerRevenuePaidEvent;
 | 
				
			||||||
            MaxSdkCallbacks.Banner.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
 | 
					            MaxSdkCallbacks.Banner.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
 | 
				
			||||||
            //--------------- IV 回调 -----------------
 | 
					            //--------------- IV 回调 -----------------
 | 
				
			||||||
            MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
 | 
					            MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
 | 
				
			||||||
| 
						 | 
					@ -107,6 +113,7 @@ namespace Guru
 | 
				
			||||||
            MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterstitialClickEvent;
 | 
					            MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterstitialClickEvent;
 | 
				
			||||||
            MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayEvent;
 | 
					            MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayEvent;
 | 
				
			||||||
            MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialDismissedEvent;
 | 
					            MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialDismissedEvent;
 | 
				
			||||||
 | 
					            MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnInterstitialPaidEvent;
 | 
				
			||||||
            MaxSdkCallbacks.Interstitial.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
 | 
					            MaxSdkCallbacks.Interstitial.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
 | 
				
			||||||
            //--------------- RV 回调 -----------------
 | 
					            //--------------- RV 回调 -----------------
 | 
				
			||||||
            MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
 | 
					            MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
 | 
				
			||||||
| 
						 | 
					@ -116,6 +123,7 @@ namespace Guru
 | 
				
			||||||
            MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
 | 
					            MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
 | 
				
			||||||
            MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdDismissedEvent;
 | 
					            MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdDismissedEvent;
 | 
				
			||||||
            MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
 | 
					            MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
 | 
				
			||||||
 | 
					            MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdPaidEvent;
 | 
				
			||||||
            MaxSdkCallbacks.Rewarded.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
 | 
					            MaxSdkCallbacks.Rewarded.OnAdReviewCreativeIdGeneratedEvent += OnAdReviewCreativeIdGeneratedEvent;
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            //--------------- Creative 回调 -----------------
 | 
					            //--------------- Creative 回调 -----------------
 | 
				
			||||||
| 
						 | 
					@ -126,6 +134,8 @@ namespace Guru
 | 
				
			||||||
            MaxSdk.SetExtraParameter("enable_black_screen_fixes", "true"); // 修复黑屏
 | 
					            MaxSdk.SetExtraParameter("enable_black_screen_fixes", "true"); // 修复黑屏
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected virtual void InitService()
 | 
					        protected virtual void InitService()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -206,89 +216,23 @@ namespace Guru
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="adInfo"></param>
 | 
					        /// <param name="adInfo"></param>
 | 
				
			||||||
        /// <param name="reviewedCreativeId"></param>
 | 
					        /// <param name="reviewedCreativeId"></param>
 | 
				
			||||||
        private void ReportAdsRevenue(AdImpressionData impressionData)
 | 
					        private void ReportAdsRevenue(AdImpressionData data)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // #1 ad_impression
 | 
					            // #1 ad_impression
 | 
				
			||||||
            Analytics.ADImpression(impressionData);
 | 
					            Analytics.ADImpression(data);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // #2 tch_001
 | 
					            // #2 tch_001 和 tch_02
 | 
				
			||||||
            double revenue = impressionData.value;
 | 
					            double revenue = data.value;
 | 
				
			||||||
            CalcTch001Value(revenue);
 | 
					            CalcTch001Value(revenue);
 | 
				
			||||||
            CalcTch02Value(revenue);
 | 
					            CalcTch02Value(revenue);
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
            // #3 adjust_ad_revenue
 | 
					            // #3 adjust_ad_revenue
 | 
				
			||||||
            AdjustService.TrackADRevenue(impressionData);
 | 
					            AdjustService.TrackADRevenue(data.value, data.currency, data.ad_source, data.ad_unit_name, data.ad_placement);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            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);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (adInfo == null) return;
 | 
					 | 
				
			||||||
            Debug.Log( $"{Tag} --- [Revenue] > [{adInfo.AdFormat}] --- adUnitId:{adUnitId}: UnitID:{adInfo.AdUnitIdentifier}   Revenue:{adInfo.Revenue}    CreativeId:{adInfo.CreativeIdentifier}");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            try
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (_reviewCreativeIds.TryGetValue(adInfo.CreativeIdentifier, out var reviewCreativeId))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 找到 RCid 的话则直接上报广告收益
 | 
					 | 
				
			||||||
                    TryReportImpression(adInfo, reviewCreativeId);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 找不到的话会缓存 adInfo, 等待获取 RCid
 | 
					 | 
				
			||||||
                    SetImpressionData(adInfo);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            catch (Exception ex)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Analytics.LogCrashlytics(ex);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 构建 Impression 数据
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        /// <param name="adInfo"></param>
 | 
					 | 
				
			||||||
        /// <param name="reviewCreativeId"></param>
 | 
					 | 
				
			||||||
        /// <param name="platform"></param>
 | 
					 | 
				
			||||||
        /// <returns></returns>
 | 
					 | 
				
			||||||
        private AdImpressionData CreateImpressionData(MaxSdkBase.AdInfo adInfo, string reviewCreativeId = "", string platform = "")
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (string.IsNullOrEmpty(platform)) platform = Analytics.AdMAX;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            var impression = new AdImpressionData()
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                value = adInfo.Revenue,
 | 
					 | 
				
			||||||
                currency = Analytics.USD,
 | 
					 | 
				
			||||||
                ad_platform = platform,
 | 
					 | 
				
			||||||
                ad_format = adInfo.AdFormat,
 | 
					 | 
				
			||||||
                ad_unit_name = adInfo.AdUnitIdentifier,
 | 
					 | 
				
			||||||
                ad_source = adInfo.NetworkName,
 | 
					 | 
				
			||||||
                ad_placement = adInfo.NetworkPlacement,
 | 
					 | 
				
			||||||
                ad_creative_id = adInfo.CreativeIdentifier,
 | 
					 | 
				
			||||||
                review_creative_id = reviewCreativeId
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            return impression;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 计算太极001收益
 | 
					        /// 计算太极001收益
 | 
				
			||||||
| 
						 | 
					@ -339,7 +283,6 @@ namespace Guru
 | 
				
			||||||
        private int _badsloadedNum = 0;
 | 
					        private int _badsloadedNum = 0;
 | 
				
			||||||
        private int _badsLoadFailNum = 0;
 | 
					        private int _badsLoadFailNum = 0;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 获取动作间隔之间的毫秒数
 | 
					        /// 获取动作间隔之间的毫秒数
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
| 
						 | 
					@ -495,7 +438,8 @@ namespace Guru
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (_bannerVisible)
 | 
					            if (_bannerVisible)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                OnAdRevenuePaidEvent(adUnitId, adInfo); // Banner 只有显示时才上报收益值
 | 
					                // Banner 只有显示时才上报收益值
 | 
				
			||||||
 | 
					                AppendImpressionData(adInfo, eventName:Analytics.EventBadsPaid, itemCategory:_badsCategory);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -617,7 +561,7 @@ namespace Guru
 | 
				
			||||||
            Analytics.ADIadsFailed(AdParams.Build(adUnitId,
 | 
					            Analytics.ADIadsFailed(AdParams.Build(adUnitId,
 | 
				
			||||||
                duration: GetActionDuration(_iadsDisplayStartTime), 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);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
| 
						 | 
					@ -625,20 +569,16 @@ 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);
 | 
				
			||||||
            string reviewCreativeId = GetReviewCreativeId(adInfo.CreativeIdentifier);
 | 
					            AppendImpressionData(adInfo, eventName:Analytics.EventIadsImp, itemCategory:_iadsCategory);
 | 
				
			||||||
            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);
 | 
				
			||||||
            string reviewCreativeId = GetReviewCreativeId(adInfo.CreativeIdentifier);
 | 
					 | 
				
			||||||
            var impressionData = CreateImpressionData(adInfo, reviewCreativeId);
 | 
					 | 
				
			||||||
            var data = impressionData.BuildEventData();
 | 
					 | 
				
			||||||
            if(string.IsNullOrEmpty(_iadsCategory)) _iadsCategory = "not_set";
 | 
					            if(string.IsNullOrEmpty(_iadsCategory)) _iadsCategory = "not_set";
 | 
				
			||||||
            data["item_category"] = _iadsCategory;
 | 
					            AppendImpressionData(adInfo, 
 | 
				
			||||||
            data.Remove("ad_format");
 | 
					                eventName:Analytics.EventIadsClick,
 | 
				
			||||||
            Analytics.ADIadsClick(data);
 | 
					                itemCategory:_iadsCategory);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // Close 
 | 
					        // Close 
 | 
				
			||||||
| 
						 | 
					@ -648,21 +588,21 @@ namespace Guru
 | 
				
			||||||
            _interCloseAction?.Invoke();
 | 
					            _interCloseAction?.Invoke();
 | 
				
			||||||
            OnInterstitialClosed?.Invoke();
 | 
					            OnInterstitialClosed?.Invoke();
 | 
				
			||||||
            // Analytics.ADIadsClose(adUnitId, _iadsCategory);
 | 
					            // Analytics.ADIadsClose(adUnitId, _iadsCategory);
 | 
				
			||||||
            Analytics.ADIadsClose(AdParams.Build(adUnitId, 
 | 
					            Analytics.ADIadsClose(new Dictionary<string, object>()
 | 
				
			||||||
                duration:GetActionDuration(_iadsDisplayStartTime), 
 | 
					            {
 | 
				
			||||||
                category: _iadsCategory));
 | 
					                [Analytics.ParameterItemCategory] = _iadsCategory,
 | 
				
			||||||
 | 
					                [Analytics.ParameterDuration] = GetActionDuration(_iadsDisplayStartTime),
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            _impressionDriver.CleanCreativeId(adInfo.CreativeIdentifier);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            //延时加载下一个广告
 | 
					            //延时加载下一个广告
 | 
				
			||||||
            DelayCall(2.0f, RequestInterstitialAD);
 | 
					            DelayCall(2.0f, RequestInterstitialAD);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void OnInterstitialPaidEvent(AdImpressionData impressionData)
 | 
					        private void OnInterstitialPaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var data = impressionData.BuildEventData();
 | 
					            AppendImpressionData(adInfo, eventName:Analytics.EventIadsPaid, itemCategory: _iadsCategory);
 | 
				
			||||||
            if(string.IsNullOrEmpty(_iadsCategory)) _iadsCategory = "not_set";
 | 
					 | 
				
			||||||
            data["item_category"] = _iadsCategory;
 | 
					 | 
				
			||||||
            data.Remove("ad_format");
 | 
					 | 
				
			||||||
            Analytics.ADIadsPaid(data);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -808,20 +748,14 @@ namespace Guru
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.Log("OnRewardedAdDisplayedEvent");
 | 
					            this.Log("OnRewardedAdDisplayedEvent");
 | 
				
			||||||
            // Analytics.ADRadsImp(adUnitId, _rewardCategory);
 | 
					            // Analytics.ADRadsImp(adUnitId, _rewardCategory);
 | 
				
			||||||
            string reviewCreativeId = GetReviewCreativeId(adInfo.CreativeIdentifier);
 | 
					            AppendImpressionData(adInfo, eventName:Analytics.EventRadsImp, itemCategory: _rewardCategory);
 | 
				
			||||||
            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);
 | 
				
			||||||
            var impressionData = CreateImpressionData(adInfo, GetReviewCreativeId(adInfo.CreativeIdentifier));
 | 
					            AppendImpressionData(adInfo, eventName:Analytics.EventRadsClick, itemCategory: _rewardCategory);
 | 
				
			||||||
            var data = impressionData.BuildEventData();
 | 
					 | 
				
			||||||
            if(string.IsNullOrEmpty(_rewardCategory)) _rewardCategory = "not_set";
 | 
					 | 
				
			||||||
            data["item_category"] = _rewardCategory;
 | 
					 | 
				
			||||||
            data.Remove("ad_format");
 | 
					 | 
				
			||||||
            Analytics.ADRadsClick(data);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // rads_close
 | 
					        // rads_close
 | 
				
			||||||
| 
						 | 
					@ -833,7 +767,13 @@ namespace Guru
 | 
				
			||||||
            OnRewardClosed?.Invoke();
 | 
					            OnRewardClosed?.Invoke();
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // Analytics.ADRadsClose(adUnitId, _rewardCategory);
 | 
					            // Analytics.ADRadsClose(adUnitId, _rewardCategory);
 | 
				
			||||||
            Analytics.ADRadsClose(AdParams.Build(adUnitId, duration:GetActionDuration(_radsShowStartTime), category: _rewardCategory));
 | 
					            Analytics.ADRadsClose(new Dictionary<string, object>()
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                [Analytics.ParameterItemCategory] = _rewardCategory,
 | 
				
			||||||
 | 
					                [Analytics.ParameterDuration] = GetActionDuration(_radsShowStartTime),
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            _impressionDriver.CleanCreativeId(adInfo.CreativeIdentifier);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            //延时加载下一个广告
 | 
					            //延时加载下一个广告
 | 
				
			||||||
            DelayCall(2.0f, RequestRewardedAD);
 | 
					            DelayCall(2.0f, RequestRewardedAD);
 | 
				
			||||||
| 
						 | 
					@ -845,25 +785,18 @@ namespace Guru
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.Log("OnRewardedAdReceivedRewardEvent");
 | 
					            this.Log("OnRewardedAdReceivedRewardEvent");
 | 
				
			||||||
            // Analytics.ADRadsRewarded(adUnitId, _rewardCategory);
 | 
					            // Analytics.ADRadsRewarded(adUnitId, _rewardCategory);
 | 
				
			||||||
            var impressionData = CreateImpressionData(adInfo, GetReviewCreativeId(adInfo.CreativeIdentifier)); 
 | 
					            AppendImpressionData(adInfo, eventName:Analytics.EventRadsRewarded, itemCategory: _rewardCategory);
 | 
				
			||||||
            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
 | 
					 | 
				
			||||||
            _rvRewardAction?.Invoke();
 | 
					            _rvRewardAction?.Invoke();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // rads_paid
 | 
					        // rads_paid
 | 
				
			||||||
        private void OnRewardedAdPaidEvent(AdImpressionData impressionData)
 | 
					        private void OnRewardedAdPaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var data = impressionData.BuildEventData();
 | 
					            this.Log("OnRewardedAdReceivedRewardEvent");
 | 
				
			||||||
            if(string.IsNullOrEmpty(_rewardCategory)) _rewardCategory = "not_set";
 | 
					            AppendImpressionData(adInfo, eventName:Analytics.EventRadsPaid, itemCategory: _rewardCategory);
 | 
				
			||||||
            data["item_category"] = _rewardCategory;
 | 
					 | 
				
			||||||
            data.Remove("ad_format");
 | 
					 | 
				
			||||||
            Analytics.ADRadsPaid(data);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region Ad Settings
 | 
					        #region Ad Settings
 | 
				
			||||||
| 
						 | 
					@ -906,39 +839,54 @@ namespace Guru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region CreativeID
 | 
					        #region ImpressionData
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        private string GetReviewCreativeId(string creativeId)
 | 
					        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)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (_reviewCreativeIds == null)
 | 
					            var impression = AdImpressionDriver.Build(adInfo.Revenue, Analytics.USD, platform,
 | 
				
			||||||
            {
 | 
					                adInfo.NetworkName,
 | 
				
			||||||
                return "";
 | 
					                adInfo.AdFormat,
 | 
				
			||||||
            }
 | 
					                adInfo.AdUnitIdentifier,
 | 
				
			||||||
 | 
					                adInfo.NetworkPlacement,
 | 
				
			||||||
 | 
					                adInfo.CreativeIdentifier, reviewCreativeId, 
 | 
				
			||||||
 | 
					                eventName, itemCategory, duration);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if (_reviewCreativeIds.TryGetValue(creativeId, out var reviewCreativeId))
 | 
					            return impression;
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                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
 | 
					        /// 添加一条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>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="adUnitId"></param>
 | 
					        /// <param name="adUnitId"></param>
 | 
				
			||||||
        /// <param name="reviewCreativeId"></param>
 | 
					        /// <param name="reviewCreativeId"></param>
 | 
				
			||||||
| 
						 | 
					@ -946,61 +894,31 @@ namespace Guru
 | 
				
			||||||
        private void OnAdReviewCreativeIdGeneratedEvent(string adUnitId, string reviewCreativeId, MaxSdkBase.AdInfo adInfo)
 | 
					        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}");
 | 
					            Debug.Log($"{Tag} --- ReviewCreativeId:{reviewCreativeId}  adUnitId: {adUnitId}  Type:{adInfo?.AdFormat ?? "NULL"}  CreativeId: {adInfo?.CreativeIdentifier ?? "NULL"}    Revenue:{adInfo.Revenue}");
 | 
				
			||||||
            if (adInfo == null || string.IsNullOrEmpty(adInfo.CreativeIdentifier))
 | 
					            if (string.IsNullOrEmpty(adInfo.CreativeIdentifier))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Debug.LogError($"{Tag} --- Get ReviewCreativeId:{reviewCreativeId} but CreativeIdentifier is null");
 | 
					                Debug.LogError($"{Tag} --- Get ReviewCreativeId:{reviewCreativeId} but CreativeIdentifier is null");
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 尝试直接上报广告收益 (可能存在异步上报的情况)
 | 
					            _impressionDriver.SetReviewCreativeId(adInfo.CreativeIdentifier, reviewCreativeId); // 缓存 ReviewCreateId
 | 
				
			||||||
            TryReportImpression(adInfo, reviewCreativeId);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					            if (adUnitId == GetBannerID() || adInfo.AdFormat.ToUpper().Contains("BANNER"))
 | 
				
			||||||
        /// 尝试上报数据
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        /// <param name="adInfo"></param>
 | 
					 | 
				
			||||||
        /// <param name="reviewCreativeId"></param>
 | 
					 | 
				
			||||||
        /// <returns></returns>
 | 
					 | 
				
			||||||
        private void TryReportImpression(MaxSdk.AdInfo adInfo, string reviewCreativeId = "")
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            string creativeId = adInfo.CreativeIdentifier;
 | 
					 | 
				
			||||||
            List<string> removeList = new List<string>();
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            if (_impressionCache.TryGetValue(creativeId, out var impressionData))
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if(string.IsNullOrEmpty(impressionData.review_creative_id)) 
 | 
					                // 清理 BADS CID 缓存
 | 
				
			||||||
                    impressionData.review_creative_id = reviewCreativeId;
 | 
					                _badsCreativeIds.Add(adInfo.CreativeIdentifier);
 | 
				
			||||||
                
 | 
					                if (_badsCreativeIds.Count > MAX_BADS_CID_NUMBER)
 | 
				
			||||||
                ReportAdsRevenue(impressionData);
 | 
					 | 
				
			||||||
                removeList.Add(creativeId);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 如果上报未成功, 则缓存reviewCreativeId 
 | 
					 | 
				
			||||||
                SetReviewCreativeId(adInfo.CreativeIdentifier, reviewCreativeId);  
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 清理超过 3 秒未上报的数据
 | 
					 | 
				
			||||||
            foreach (var imp in _impressionCache.Values)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (imp.GetPassedSecond() > 3.0)
 | 
					 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    ReportAdsRevenue(imp);
 | 
					                    var cid = _badsCreativeIds[0];
 | 
				
			||||||
                    removeList.Add(imp.ad_creative_id);
 | 
					                    _badsCreativeIds.Remove(cid);
 | 
				
			||||||
                }
 | 
					                    _impressionDriver.CleanCreativeId(cid);
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (removeList.Count > 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                foreach (var k in removeList)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _impressionCache.Remove(k);
 | 
					 | 
				
			||||||
                    _reviewCreativeIds.Remove(k);
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					fileFormatVersion: 2
 | 
				
			||||||
 | 
					guid: 1866d6a2a7d7447b867e491b9354a49b
 | 
				
			||||||
 | 
					timeCreated: 1722313457
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,185 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,251 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					fileFormatVersion: 2
 | 
				
			||||||
 | 
					guid: 7194cdd8ed1447508011264371e2c23d
 | 
				
			||||||
 | 
					timeCreated: 1722313472
 | 
				
			||||||
| 
						 | 
					@ -1,60 +0,0 @@
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Guru
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    using System;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    /// <summary>
 | 
					 | 
				
			||||||
    /// AdImpression 对象
 | 
					 | 
				
			||||||
    /// </summary>
 | 
					 | 
				
			||||||
    public class AdImpressionData
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        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 DateTime createTime;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public AdImpressionData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            createTime = DateTime.UtcNow;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <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;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -142,7 +142,12 @@ namespace Guru
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		public static void ADIadsImp(AdParams adParams)
 | 
							public static void ADIadsImp(AdParams adParams)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			TrackEvent(EventIadsImp, BuildAdEventData(adParams));
 | 
								ADIadsImp(BuildAdEventData(adParams));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							public static void ADIadsImp(Dictionary<string, dynamic> data)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								TrackEvent(EventIadsImp, data);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/// <summary>
 | 
							/// <summary>
 | 
				
			||||||
| 
						 | 
					@ -163,7 +168,12 @@ namespace Guru
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		public static void ADIadsClose(AdParams adParams)
 | 
							public static void ADIadsClose(AdParams adParams)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			TrackEvent(EventIadsClose, BuildAdEventData(adParams));
 | 
								ADIadsClose(BuildAdEventData(adParams));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							public static void ADIadsClose(Dictionary<string, object> data)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								TrackEvent(EventIadsClose, data);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		/// <summary>
 | 
							/// <summary>
 | 
				
			||||||
| 
						 | 
					@ -202,8 +212,16 @@ namespace Guru
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		public static void ADRadsImp(AdParams adParams)
 | 
							public static void ADRadsImp(AdParams adParams)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			TrackEvent(EventRadsImp, BuildAdEventData(adParams));
 | 
								ADRadsImp(BuildAdEventData(adParams));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							public static void ADRadsImp(Dictionary<string, dynamic> data)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								TrackEvent(EventRadsImp, data);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		/// <summary>
 | 
							/// <summary>
 | 
				
			||||||
		/// 广告完成观看发奖励
 | 
							/// 广告完成观看发奖励
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
| 
						 | 
					@ -265,7 +283,12 @@ namespace Guru
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
		public static void ADRadsClose(AdParams adParams)
 | 
							public static void ADRadsClose(AdParams adParams)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			TrackEvent(EventRadsClose, BuildAdEventData(adParams));
 | 
								ADRadsClose( BuildAdEventData(adParams));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							public static void ADRadsClose(Dictionary<string, dynamic> data)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								TrackEvent(EventRadsClose, data);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	    #endregion
 | 
						    #endregion
 | 
				
			||||||
        	
 | 
					        	
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,118 +11,119 @@ namespace Guru
 | 
				
			||||||
	//打点常量定义
 | 
						//打点常量定义
 | 
				
			||||||
	public static partial class Analytics
 | 
						public static partial class Analytics
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		public static readonly string TAG = "Analytics";
 | 
							public const string TAG = "Analytics";
 | 
				
			||||||
		// 美元符号
 | 
							// 美元符号
 | 
				
			||||||
		public static readonly string USD = "USD"; 
 | 
							public const string USD = "USD"; 
 | 
				
			||||||
		// 广告平台
 | 
							// 广告平台
 | 
				
			||||||
		public static readonly string AdMAX = "MAX";
 | 
							public const string AdMAX = "MAX";
 | 
				
			||||||
		public static readonly string AdIronSource = "IronSource";
 | 
							public const string AdIronSource = "IronSource";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//IAP打点事件
 | 
							//IAP打点事件
 | 
				
			||||||
		public static readonly string EventIAPFirst = "first_iap";
 | 
							public const string EventIAPFirst = "first_iap";
 | 
				
			||||||
		public static readonly string EventIAPImp = "iap_imp";
 | 
							public const string EventIAPImp = "iap_imp";
 | 
				
			||||||
		public static readonly string EventIAPClose = "iap_close";
 | 
							public const string EventIAPClose = "iap_close";
 | 
				
			||||||
		public static readonly string EventIAPClick = "iap_clk";
 | 
							public const string EventIAPClick = "iap_clk";
 | 
				
			||||||
		public static readonly string EventIAPReturnTrue = "iap_ret_true";
 | 
							public const string EventIAPReturnTrue = "iap_ret_true";
 | 
				
			||||||
		public static readonly string EventIAPReturnFalse = "iap_ret_false";
 | 
							public const string EventIAPReturnFalse = "iap_ret_false";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// 关卡打点
 | 
							// 关卡打点
 | 
				
			||||||
		public static readonly string EventLevelFirstEnd = "level_first_end";
 | 
							public const string EventLevelFirstEnd = "level_first_end";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//横幅广告打点事件
 | 
							//横幅广告打点事件
 | 
				
			||||||
		public static readonly string EventBadsLoad = "bads_load";
 | 
							public const string EventBadsLoad = "bads_load";
 | 
				
			||||||
		public static readonly string EventBadsLoaded = "bads_loaded";
 | 
							public const string EventBadsLoaded = "bads_loaded";
 | 
				
			||||||
		public static readonly string EventBadsFailed = "bads_failed";
 | 
							public const string EventBadsFailed = "bads_failed";
 | 
				
			||||||
		public static readonly string EventBadsClick = "bads_clk";
 | 
							public const string EventBadsClick = "bads_clk";
 | 
				
			||||||
		public static readonly string EventBadsImp = "bads_imp";
 | 
							public const string EventBadsImp = "bads_imp";
 | 
				
			||||||
		public static readonly string EventBadsHide = "bads_hide";
 | 
							public const string EventBadsHide = "bads_hide";
 | 
				
			||||||
 | 
							public const string EventBadsPaid = "bads_paid";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//插屏广告打点事件
 | 
							//插屏广告打点事件
 | 
				
			||||||
		public static readonly string EventIadsLoad = "iads_load";
 | 
							public const string EventIadsLoad = "iads_load";
 | 
				
			||||||
		public static readonly string EventIadsLoaded = "iads_loaded";
 | 
							public const string EventIadsLoaded = "iads_loaded";
 | 
				
			||||||
		public static readonly string EventIadsFailed = "iads_failed";
 | 
							public const string EventIadsFailed = "iads_failed";
 | 
				
			||||||
		public static readonly string EventIadsImp = "iads_imp";
 | 
							public const string EventIadsImp = "iads_imp";
 | 
				
			||||||
		public static readonly string EventIadsClick = "iads_clk";
 | 
							public const string EventIadsClick = "iads_clk";
 | 
				
			||||||
		public static readonly string EventIadsPaid = "iads_paid";
 | 
							public const string EventIadsClose = "iads_close";
 | 
				
			||||||
		public static readonly string EventIadsClose = "iads_close";
 | 
							public const string EventIadsPaid = "iads_paid";
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
		//激励视频广告打点事件
 | 
							//激励视频广告打点事件
 | 
				
			||||||
		public static readonly string EventRadsLoad = "rads_load";
 | 
							public const string EventRadsLoad = "rads_load";
 | 
				
			||||||
		public static readonly string EventRadsLoaded = "rads_loaded";
 | 
							public const string EventRadsLoaded = "rads_loaded";
 | 
				
			||||||
		public static readonly string EventRadsFailed = "rads_failed";
 | 
							public const string EventRadsFailed = "rads_failed";
 | 
				
			||||||
		public static readonly string EventRadsImp = "rads_imp";
 | 
							public const string EventRadsImp = "rads_imp";
 | 
				
			||||||
		public static readonly string EventRadsRewarded = "rads_rewarded";
 | 
							public const string EventRadsRewarded = "rads_rewarded";
 | 
				
			||||||
		public static readonly string EventRadsClick = "rads_clk";
 | 
							public const string EventRadsClick = "rads_clk";
 | 
				
			||||||
		public static readonly string EventRadsPaid = "rads_paid";
 | 
							public const string EventRadsClose = "rads_close";
 | 
				
			||||||
		public static readonly string EventRadsClose = "rads_close";
 | 
							public const string EventRadsPaid = "rads_paid";
 | 
				
			||||||
		public static readonly string EventFirstRadsRewarded = "first_rads_rewarded";
 | 
							public const string EventFirstRadsRewarded = "first_rads_rewarded";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//广告收益打点事件
 | 
							//广告收益打点事件
 | 
				
			||||||
		public static readonly string EventTchAdRev001Impression = "tch_ad_rev_roas_001";
 | 
							public const string EventTchAdRev001Impression = "tch_ad_rev_roas_001";
 | 
				
			||||||
		public static readonly string EventTchAdRev02Impression = "tch_ad_rev_roas_02";
 | 
							public const string EventTchAdRev02Impression = "tch_ad_rev_roas_02";
 | 
				
			||||||
		public static readonly string EventTchAdRevAbnormal = "tch_ad_rev_value_abnormal";
 | 
							public const string EventTchAdRevAbnormal = "tch_ad_rev_value_abnormal";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//内购成功事件上报
 | 
							//内购成功事件上报
 | 
				
			||||||
		public static readonly string EventIAPPurchase = "iap_purchase";
 | 
							public const string EventIAPPurchase = "iap_purchase";
 | 
				
			||||||
		public static readonly string EventSubPurchase = "sub_purchase";
 | 
							public const string EventSubPurchase = "sub_purchase";
 | 
				
			||||||
		public static readonly string IAPStoreCategory = "Store";
 | 
							public const string IAPStoreCategory = "Store";
 | 
				
			||||||
		public static readonly string IAPTypeProduct = "product";
 | 
							public const string IAPTypeProduct = "product";
 | 
				
			||||||
		public static readonly string IAPTypeSubscription = "subscription";
 | 
							public const string IAPTypeSubscription = "subscription";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//打点参数名
 | 
							//打点参数名
 | 
				
			||||||
		public static readonly string ParameterResult = "result";
 | 
							public const string ParameterResult = "result";
 | 
				
			||||||
		public static readonly string ParameterStep = "step";
 | 
							public const string ParameterStep = "step";
 | 
				
			||||||
		public static readonly string ParameterDuration = "duration";
 | 
							public const string ParameterDuration = "duration";
 | 
				
			||||||
		public static readonly string ParameterErrorCode = "error_code";
 | 
							public const string ParameterErrorCode = "error_code";
 | 
				
			||||||
		public static readonly string ParameterProductId = "product_id";
 | 
							public const string ParameterProductId = "product_id";
 | 
				
			||||||
		public static readonly string ParameterPlatform = "platform";
 | 
							public const string ParameterPlatform = "platform";
 | 
				
			||||||
		public static readonly string ParameterStartType = "start_type"; // 游戏启动类型
 | 
							public const string ParameterStartType = "start_type"; // 游戏启动类型
 | 
				
			||||||
		public static readonly string ParameterReplay =  "replay"; // 游戏重玩
 | 
							public const string ParameterReplay =  "replay"; // 游戏重玩
 | 
				
			||||||
		public static readonly string ParameterContinue = "continue"; // 游戏继续
 | 
							public const string ParameterContinue = "continue"; // 游戏继续
 | 
				
			||||||
		public static readonly string ParameterAdUnitName = "ad_unit_name";
 | 
							public const string ParameterAdUnitName = "ad_unit_name";
 | 
				
			||||||
		public static readonly string ParameterAdPlacement = "ad_placement";
 | 
							public const string ParameterAdPlacement = "ad_placement";
 | 
				
			||||||
		public static readonly string ParameterAdCreativeId = "ad_creative_id";
 | 
							public const string ParameterAdCreativeId = "ad_creative_id";
 | 
				
			||||||
		public static readonly string ParameterReviewCreativeId = "review_creative_id";
 | 
							public const string ParameterReviewCreativeId = "review_creative_id";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// 评价参数
 | 
							// 评价参数
 | 
				
			||||||
		public static readonly string EventRateImp = "rate_imp"; // 评价弹窗展示
 | 
							public const string EventRateImp = "rate_imp"; // 评价弹窗展示
 | 
				
			||||||
		public static readonly string EventRateNow = "rate_now"; // 点击评分引导弹窗中的评分
 | 
							public const string EventRateNow = "rate_now"; // 点击评分引导弹窗中的评分
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//打点内部执行错误
 | 
							//打点内部执行错误
 | 
				
			||||||
		public static string ParameterEventError => "event_error";
 | 
							public static string ParameterEventError => "event_error";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//ios ATT打点
 | 
							//ios ATT打点
 | 
				
			||||||
		public static readonly string ATTGuideShow = "att_guide_show";
 | 
							public const string ATTGuideShow = "att_guide_show";
 | 
				
			||||||
		public static readonly string ATTGuideOK = "att_guide_ok";
 | 
							public const string ATTGuideOK = "att_guide_ok";
 | 
				
			||||||
		public static readonly string ATTWindowShow = "att_window_show";
 | 
							public const string ATTWindowShow = "att_window_show";
 | 
				
			||||||
		public static readonly string ATTOptIn = "att_opt_in";
 | 
							public const string ATTOptIn = "att_opt_in";
 | 
				
			||||||
		public static readonly string ATTOpOut = "att_opt_out";
 | 
							public const string ATTOpOut = "att_opt_out";
 | 
				
			||||||
		public static readonly string ParameterATTStatus = "att_status";
 | 
							public const string ParameterATTStatus = "att_status";
 | 
				
			||||||
		public static readonly string EventATTResult = "att_result";
 | 
							public const string EventATTResult = "att_result";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// 用户属性
 | 
							// 用户属性
 | 
				
			||||||
		public static readonly string PropertyFirstOpenTime = "first_open_time"; 		//用户第一次first_open的时间
 | 
							public const string PropertyFirstOpenTime = "first_open_time"; 		//用户第一次first_open的时间
 | 
				
			||||||
		public static readonly string PropertyDeviceID = "device_id"; //用户的设备ID
 | 
							public const string PropertyDeviceID = "device_id"; //用户的设备ID
 | 
				
			||||||
		public static readonly string PropertyUserID = "user_id";
 | 
							public const string PropertyUserID = "user_id";
 | 
				
			||||||
		public static readonly string PropertyLevel = "b_level"; //"每次完成通关上升一次,显示用户完成的最大关卡数。只针对主关卡和主玩法的局数做累加,初始值为0。"
 | 
							public const string PropertyLevel = "b_level"; //"每次完成通关上升一次,显示用户完成的最大关卡数。只针对主关卡和主玩法的局数做累加,初始值为0。"
 | 
				
			||||||
		public static readonly string PropertyPlay = "b_play"; //每完成一局或者游戏触发,
 | 
							public const string PropertyPlay = "b_play"; //每完成一局或者游戏触发,
 | 
				
			||||||
		public static readonly string PropertyLastPlayedLevel = "last_played_level";
 | 
							public const string PropertyLastPlayedLevel = "last_played_level";
 | 
				
			||||||
		public static readonly string PropertyGrade = "grade"; //当游戏玩家角色升级时触发
 | 
							public const string PropertyGrade = "grade"; //当游戏玩家角色升级时触发
 | 
				
			||||||
		public static readonly string PropertyIsIAPUser = "is_iap_user"; 		//付费成功后设置属性参数为true,如果没有发生付费可以不用设置该属性
 | 
							public const string PropertyIsIAPUser = "is_iap_user"; 		//付费成功后设置属性参数为true,如果没有发生付费可以不用设置该属性
 | 
				
			||||||
		public static readonly string PropertyIAPCoin = "iap_coin"; //付费所得的总金币数(iap获取累计值)\
 | 
							public const string PropertyIAPCoin = "iap_coin"; //付费所得的总金币数(iap获取累计值)\
 | 
				
			||||||
		public static readonly string PropertyNonIAPCoin = "noniap_coin"; //非付费iap获取累计值
 | 
							public const string PropertyNonIAPCoin = "noniap_coin"; //非付费iap获取累计值
 | 
				
			||||||
		public static readonly string PropertyCoin = "coin"; //当前金币数
 | 
							public const string PropertyCoin = "coin"; //当前金币数
 | 
				
			||||||
		public static readonly string PropertyExp = "exp"; // 经验值
 | 
							public const string PropertyExp = "exp"; // 经验值
 | 
				
			||||||
		public static readonly string PropertyHp = "hp"; // 生命值/体力
 | 
							public const string PropertyHp = "hp"; // 生命值/体力
 | 
				
			||||||
		public static readonly string PropertyAndroidID = "android_id"; // Android 平台 AndroidID
 | 
							public const string PropertyAndroidID = "android_id"; // Android 平台 AndroidID
 | 
				
			||||||
		public static readonly string PropertyIDFV = "idfv"; // iOS  平台 IDFV
 | 
							public const string PropertyIDFV = "idfv"; // iOS  平台 IDFV
 | 
				
			||||||
		public static readonly string PropertyIDFA = "idfa"; // iOS  平台 IDFA
 | 
							public const string PropertyIDFA = "idfa"; // iOS  平台 IDFA
 | 
				
			||||||
		public static readonly string PropertyPicture = "picture"; // 玩家在主线的mapid
 | 
							public const string PropertyPicture = "picture"; // 玩家在主线的mapid
 | 
				
			||||||
		public static readonly string PropertyNoAds = "no_ads"; // 玩家是否去广告
 | 
							public const string PropertyNoAds = "no_ads"; // 玩家是否去广告
 | 
				
			||||||
		public static readonly string PropertyATTStatus = "att_status";  // ATT 状态
 | 
							public const string PropertyATTStatus = "att_status";  // ATT 状态
 | 
				
			||||||
		public static readonly string PropertyGDPR = "gdpr"; // GDPR状态
 | 
							public const string PropertyGDPR = "gdpr"; // GDPR状态
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// 经济相关
 | 
							// 经济相关
 | 
				
			||||||
		public const string ParameterBalance = "balance"; // 用于余额
 | 
							public const string ParameterBalance = "balance"; // 用于余额
 | 
				
			||||||
| 
						 | 
					@ -130,6 +131,6 @@ namespace Guru
 | 
				
			||||||
		public const string ParameterVirtualCurrencyName = "virtual_currency_name"; // 虚拟货币名称
 | 
							public const string ParameterVirtualCurrencyName = "virtual_currency_name"; // 虚拟货币名称
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// 中台
 | 
							// 中台
 | 
				
			||||||
		public static readonly string EventDevAudit = "dev_audit"; // 中台事件异常
 | 
							public const string EventDevAudit = "dev_audit"; // 中台事件异常
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -5,104 +5,104 @@ namespace Guru
 | 
				
			||||||
	//Firebase内置定义事件名称和参数名称
 | 
						//Firebase内置定义事件名称和参数名称
 | 
				
			||||||
	public static partial class Analytics
 | 
						public static partial class Analytics
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		internal static readonly string EventAdImpression = "ad_impression";
 | 
							internal const string EventAdImpression = "ad_impression";
 | 
				
			||||||
		internal static readonly string EventAddPaymentInfo = "add_payment_info";
 | 
							internal const string EventAddPaymentInfo = "add_payment_info";
 | 
				
			||||||
		internal static readonly string EventAddShippingInfo = "add_shipping_info";
 | 
							internal const string EventAddShippingInfo = "add_shipping_info";
 | 
				
			||||||
		internal static readonly string EventAddToCart = "add_to_cart";
 | 
							internal const string EventAddToCart = "add_to_cart";
 | 
				
			||||||
		internal static readonly string EventAddToWishlist = "add_to_wishlist";
 | 
							internal const string EventAddToWishlist = "add_to_wishlist";
 | 
				
			||||||
		internal static readonly string EventAppOpen = "app_open";
 | 
							internal const string EventAppOpen = "app_open";
 | 
				
			||||||
		internal static readonly string EventBeginCheckout = "begin_checkout";
 | 
							internal const string EventBeginCheckout = "begin_checkout";
 | 
				
			||||||
		internal static readonly string EventCampaignDetails = "campaign_details";
 | 
							internal const string EventCampaignDetails = "campaign_details";
 | 
				
			||||||
		internal static readonly string EventEarnVirtualCurrency = "earn_virtual_currency";
 | 
							internal const string EventEarnVirtualCurrency = "earn_virtual_currency";
 | 
				
			||||||
		internal static readonly string EventGenerateLead = "generate_lead";
 | 
							internal const string EventGenerateLead = "generate_lead";
 | 
				
			||||||
		internal static readonly string EventJoinGroup = "join_group";
 | 
							internal const string EventJoinGroup = "join_group";
 | 
				
			||||||
		internal static readonly string EventLevelEnd = "level_end";
 | 
							internal const string EventLevelEnd = "level_end";
 | 
				
			||||||
		internal static readonly string EventLevelStart = "level_start";
 | 
							internal const string EventLevelStart = "level_start";
 | 
				
			||||||
		internal static readonly string EventLevelUp = "level_up";
 | 
							internal const string EventLevelUp = "level_up";
 | 
				
			||||||
		internal static readonly string EventLogin = "login";
 | 
							internal const string EventLogin = "login";
 | 
				
			||||||
		internal static readonly string EventPostScore = "post_score";
 | 
							internal const string EventPostScore = "post_score";
 | 
				
			||||||
		internal static readonly string EventPurchase = "purchase";
 | 
							internal const string EventPurchase = "purchase";
 | 
				
			||||||
		internal static readonly string EventRefund = "refund";
 | 
							internal const string EventRefund = "refund";
 | 
				
			||||||
		internal static readonly string EventRemoveFromCart = "remove_from_cart";
 | 
							internal const string EventRemoveFromCart = "remove_from_cart";
 | 
				
			||||||
		internal static readonly string EventScreenView = "screen_view";
 | 
							internal const string EventScreenView = "screen_view";
 | 
				
			||||||
		internal static readonly string EventSearch = "search";
 | 
							internal const string EventSearch = "search";
 | 
				
			||||||
		internal static readonly string EventSelectContent = "select_content";
 | 
							internal const string EventSelectContent = "select_content";
 | 
				
			||||||
		internal static readonly string EventSelectItem = "select_item";
 | 
							internal const string EventSelectItem = "select_item";
 | 
				
			||||||
		internal static readonly string EventSelectPromotion = "select_promotion";
 | 
							internal const string EventSelectPromotion = "select_promotion";
 | 
				
			||||||
		internal static readonly string EventShare = "share";
 | 
							internal const string EventShare = "share";
 | 
				
			||||||
		internal static readonly string EventSignUp = "sign_up";
 | 
							internal const string EventSignUp = "sign_up";
 | 
				
			||||||
		internal static readonly string EventSpendVirtualCurrency = "spend_virtual_currency";
 | 
							internal const string EventSpendVirtualCurrency = "spend_virtual_currency";
 | 
				
			||||||
		internal static readonly string EventTutorialBegin = "tutorial_begin";
 | 
							internal const string EventTutorialBegin = "tutorial_begin";
 | 
				
			||||||
		internal static readonly string EventTutorialComplete = "tutorial_complete";
 | 
							internal const string EventTutorialComplete = "tutorial_complete";
 | 
				
			||||||
		internal static readonly string EventUnlockAchievement = "unlock_achievement";
 | 
							internal const string EventUnlockAchievement = "unlock_achievement";
 | 
				
			||||||
		internal static readonly string EventViewCart = "view_cart";
 | 
							internal const string EventViewCart = "view_cart";
 | 
				
			||||||
		internal static readonly string EventViewItem = "view_item";
 | 
							internal const string EventViewItem = "view_item";
 | 
				
			||||||
		internal static readonly string EventViewItemList = "view_item_list";
 | 
							internal const string EventViewItemList = "view_item_list";
 | 
				
			||||||
		internal static readonly string EventViewPromotion = "view_promotion";
 | 
							internal const string EventViewPromotion = "view_promotion";
 | 
				
			||||||
		internal static readonly string EventViewSearchResults = "view_search_results";
 | 
							internal const string EventViewSearchResults = "view_search_results";
 | 
				
			||||||
		internal static readonly string ParameterAchievementId = "achievement_id";
 | 
							internal const string ParameterAchievementId = "achievement_id";
 | 
				
			||||||
		internal static readonly string ParameterAdFormat = "ad_format";
 | 
							internal const string ParameterAdFormat = "ad_format";
 | 
				
			||||||
		internal static readonly string ParameterAdNetworkClickID = "aclid";
 | 
							internal const string ParameterAdNetworkClickID = "aclid";
 | 
				
			||||||
		internal static readonly string ParameterAdPlatform = "ad_platform";
 | 
							internal const string ParameterAdPlatform = "ad_platform";
 | 
				
			||||||
		internal static readonly string ParameterAdSource = "ad_source";
 | 
							internal const string ParameterAdSource = "ad_source";
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		internal static readonly string ParameterAffiliation = "affiliation";
 | 
							internal const string ParameterAffiliation = "affiliation";
 | 
				
			||||||
		internal static readonly string ParameterCP1 = "cp1";
 | 
							internal const string ParameterCP1 = "cp1";
 | 
				
			||||||
		internal static readonly string ParameterCampaign =  "campaign";
 | 
							internal const string ParameterCampaign =  "campaign";
 | 
				
			||||||
		internal static readonly string ParameterCharacter = "character";
 | 
							internal const string ParameterCharacter = "character";
 | 
				
			||||||
		internal static readonly string ParameterContent = "content";
 | 
							internal const string ParameterContent = "content";
 | 
				
			||||||
		internal static readonly string ParameterContentType = "content_type";
 | 
							internal const string ParameterContentType = "content_type";
 | 
				
			||||||
		internal static readonly string ParameterCoupon = "coupon";
 | 
							internal const string ParameterCoupon = "coupon";
 | 
				
			||||||
		internal static readonly string ParameterCreativeName = "creative_name";
 | 
							internal const string ParameterCreativeName = "creative_name";
 | 
				
			||||||
		internal static readonly string ParameterCreativeSlot = "creative_slot";
 | 
							internal const string ParameterCreativeSlot = "creative_slot";
 | 
				
			||||||
		internal static readonly string ParameterCurrency = "currency";
 | 
							internal const string ParameterCurrency = "currency";
 | 
				
			||||||
		internal static readonly string ParameterDestination = "destination";
 | 
							internal const string ParameterDestination = "destination";
 | 
				
			||||||
		internal static readonly string ParameterDiscount = "discount";
 | 
							internal const string ParameterDiscount = "discount";
 | 
				
			||||||
		internal static readonly string ParameterEndDate = "end_date";
 | 
							internal const string ParameterEndDate = "end_date";
 | 
				
			||||||
		internal static readonly string ParameterExtendSession = "extend_session";
 | 
							internal const string ParameterExtendSession = "extend_session";
 | 
				
			||||||
		internal static readonly string ParameterFlightNumber =  "flight_number";
 | 
							internal const string ParameterFlightNumber =  "flight_number";
 | 
				
			||||||
		internal static readonly string ParameterGroupId = "group_id";
 | 
							internal const string ParameterGroupId = "group_id";
 | 
				
			||||||
		internal static readonly string ParameterIndex = "index";
 | 
							internal const string ParameterIndex = "index";
 | 
				
			||||||
		internal static readonly string ParameterItemBrand =  "item_brand";
 | 
							internal const string ParameterItemBrand =  "item_brand";
 | 
				
			||||||
		internal static readonly string ParameterItemCategory = "item_category";
 | 
							internal const string ParameterItemCategory = "item_category";
 | 
				
			||||||
		internal static readonly string ParameterItemCategory2 = "item_category2";
 | 
							internal const string ParameterItemCategory2 = "item_category2";
 | 
				
			||||||
		internal static readonly string ParameterItemCategory3 = "item_category3";
 | 
							internal const string ParameterItemCategory3 = "item_category3";
 | 
				
			||||||
		internal static readonly string ParameterItemCategory4 = "item_category4";
 | 
							internal const string ParameterItemCategory4 = "item_category4";
 | 
				
			||||||
		internal static readonly string ParameterItemCategory5 = "item_category5";
 | 
							internal const string ParameterItemCategory5 = "item_category5";
 | 
				
			||||||
		internal static readonly string ParameterItemId = "item_id";
 | 
							internal const string ParameterItemId = "item_id";
 | 
				
			||||||
		internal static readonly string ParameterItemList = "item_list";
 | 
							internal const string ParameterItemList = "item_list";
 | 
				
			||||||
		internal static readonly string ParameterItemListID = "item_list_id";
 | 
							internal const string ParameterItemListID = "item_list_id";
 | 
				
			||||||
		internal static readonly string ParameterItemListName = "item_list_name";
 | 
							internal const string ParameterItemListName = "item_list_name";
 | 
				
			||||||
		internal static readonly string ParameterItemName = "item_name";
 | 
							internal const string ParameterItemName = "item_name";
 | 
				
			||||||
		internal static readonly string ParameterLevel =  "level";
 | 
							internal const string ParameterLevel =  "level";
 | 
				
			||||||
		internal static readonly string ParameterLevelName = "level_name";
 | 
							internal const string ParameterLevelName = "level_name";
 | 
				
			||||||
		internal static readonly string ParameterLocation = "location";
 | 
							internal const string ParameterLocation = "location";
 | 
				
			||||||
		internal static readonly string ParameterLocationID = "location_id";
 | 
							internal const string ParameterLocationID = "location_id";
 | 
				
			||||||
		internal static readonly string ParameterMedium =  "medium";
 | 
							internal const string ParameterMedium =  "medium";
 | 
				
			||||||
		internal static readonly string ParameterMethod = "method";
 | 
							internal const string ParameterMethod = "method";
 | 
				
			||||||
		internal static readonly string ParameterNumberOfNights = "number_of_nights";
 | 
							internal const string ParameterNumberOfNights = "number_of_nights";
 | 
				
			||||||
		internal static readonly string ParameterNumberOfPassengers = "number_of_passengers";
 | 
							internal const string ParameterNumberOfPassengers = "number_of_passengers";
 | 
				
			||||||
		internal static readonly string ParameterNumberOfRooms = "number_of_rooms";
 | 
							internal const string ParameterNumberOfRooms = "number_of_rooms";
 | 
				
			||||||
		internal static readonly string ParameterOrigin = "origin";
 | 
							internal const string ParameterOrigin = "origin";
 | 
				
			||||||
		internal static readonly string ParameterPaymentType = "payment_type";
 | 
							internal const string ParameterPaymentType = "payment_type";
 | 
				
			||||||
		internal static readonly string ParameterPrice = "price";
 | 
							internal const string ParameterPrice = "price";
 | 
				
			||||||
		internal static readonly string ParameterPromotionID = "promotion_id";
 | 
							internal const string ParameterPromotionID = "promotion_id";
 | 
				
			||||||
		internal static readonly string ParameterPromotionName = "promotion_name";
 | 
							internal const string ParameterPromotionName = "promotion_name";
 | 
				
			||||||
		internal static readonly string ParameterQuantity = "quantity";
 | 
							internal const string ParameterQuantity = "quantity";
 | 
				
			||||||
		internal static readonly string ParameterScore = "score";
 | 
							internal const string ParameterScore = "score";
 | 
				
			||||||
		internal static readonly string ParameterScreenClass = "screen_class";
 | 
							internal const string ParameterScreenClass = "screen_class";
 | 
				
			||||||
		internal static readonly string ParameterScreenName = "screen_name";
 | 
							internal const string ParameterScreenName = "screen_name";
 | 
				
			||||||
		internal static readonly string ParameterSearchTerm = "search_term";
 | 
							internal const string ParameterSearchTerm = "search_term";
 | 
				
			||||||
		internal static readonly string ParameterShipping = "shipping";
 | 
							internal const string ParameterShipping = "shipping";
 | 
				
			||||||
		internal static readonly string ParameterShippingTier = "shipping_tier";
 | 
							internal const string ParameterShippingTier = "shipping_tier";
 | 
				
			||||||
		internal static readonly string ParameterSignUpMethod =  "sign_up_method";
 | 
							internal const string ParameterSignUpMethod =  "sign_up_method";
 | 
				
			||||||
		internal static readonly string ParameterSource = "source";
 | 
							internal const string ParameterSource = "source";
 | 
				
			||||||
		internal static readonly string ParameterStartDate = "start_date";
 | 
							internal const string ParameterStartDate = "start_date";
 | 
				
			||||||
		internal static readonly string ParameterSuccess = "success";
 | 
							internal const string ParameterSuccess = "success";
 | 
				
			||||||
		internal static readonly string ParameterTax = "tax";
 | 
							internal const string ParameterTax = "tax";
 | 
				
			||||||
		internal static readonly string ParameterTerm = "term";
 | 
							internal const string ParameterTerm = "term";
 | 
				
			||||||
		internal static readonly string ParameterTransactionId = "transaction_id";
 | 
							internal const string ParameterTransactionId = "transaction_id";
 | 
				
			||||||
		internal static readonly string ParameterTravelClass = "travel_class";
 | 
							internal const string ParameterTravelClass = "travel_class";
 | 
				
			||||||
		internal static readonly string ParameterValue = "value"; 
 | 
							internal const string ParameterValue = "value"; 
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@ 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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue