Compare commits
	
		
			6 Commits 
		
	
	
		
			e8c17f4cf4
			...
			c0c557b34e
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								
									
								
								 | 
						c0c557b34e | |
| 
							
							
								
									
								
								 | 
						edcc533d33 | |
| 
							
							
								
									
								
								 | 
						3d9d027e89 | |
| 
							
							
								
									
								
								 | 
						e77994d811 | |
| 
							
							
								
									
								
								 | 
						85dc4a7ddc | |
| 
							
							
								
									
								
								 | 
						b7aacb61e4 | 
| 
						 | 
				
			
			@ -224,17 +224,17 @@ namespace Guru
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="status"></param>
 | 
			
		||||
        /// <param name="channel"></param>
 | 
			
		||||
        /// <param name="others"></param>
 | 
			
		||||
        public static void AttResult(string status, string type = "custom", string others = "")
 | 
			
		||||
        /// <param name="scene"></param>
 | 
			
		||||
        public static void AttResult(string status, string type = "custom", string scene = "")
 | 
			
		||||
        {
 | 
			
		||||
	        SetAttProperty(status);
 | 
			
		||||
	        Debug.Log($"{TAG} AttResult: {status}    type:{type}    others:{others}");
 | 
			
		||||
	        Debug.Log($"{TAG} AttResult: {status}    type:{type}    others:{scene}");
 | 
			
		||||
	        var dict = new Dictionary<string, dynamic>()
 | 
			
		||||
	        {
 | 
			
		||||
		        { ParameterItemCategory, status },
 | 
			
		||||
		        { "type", type }
 | 
			
		||||
	        };
 | 
			
		||||
	        if(!string.IsNullOrEmpty(others)) dict[ParameterItemName] = others;
 | 
			
		||||
	        if(!string.IsNullOrEmpty(scene)) dict[ParameterItemName] = scene;
 | 
			
		||||
            LogEvent(EventATTResult, dict);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
using JetBrains.Annotations;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace Guru
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -621,6 +621,20 @@ namespace Guru
 | 
			
		|||
			string scene = orderData.scene;
 | 
			
		||||
			bool isFree = orderData.isFree;
 | 
			
		||||
			string offerId = orderData.offerId;
 | 
			
		||||
 | 
			
		||||
			string transactionId = "";
 | 
			
		||||
			string productToken = "";
 | 
			
		||||
			string receipt = "";
 | 
			
		||||
 | 
			
		||||
			if (orderData is GoogleOrderData gdata)
 | 
			
		||||
			{
 | 
			
		||||
				productToken = gdata.token;
 | 
			
		||||
			}
 | 
			
		||||
			else if (orderData is AppleOrderData adata)
 | 
			
		||||
			{
 | 
			
		||||
				receipt = adata.receipt;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			// TCH 001
 | 
			
		||||
			Tch001IAPRev(usdPrice, productId, orderId, orderType, orderDate); 
 | 
			
		||||
			// TCH 020
 | 
			
		||||
| 
						 | 
				
			
			@ -631,14 +645,12 @@ namespace Guru
 | 
			
		|||
			if (orderData.orderType == 1)
 | 
			
		||||
			{
 | 
			
		||||
				// sub_pruchase : Firebase + Guru + Adjust
 | 
			
		||||
				Debug.Log($"{TAG} --- {productId}:{usdPrice} report SubPurchase");
 | 
			
		||||
				SubPurchase(usdPrice, productId, orderId, orderDate);
 | 
			
		||||
				SubPurchase(usdPrice, productId, orderId, orderDate, productToken, receipt);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				// iap_purchase : Firebase + Guru + Adjust
 | 
			
		||||
				Debug.Log($"{TAG} --- {productId}:{usdPrice} report IAPPurchase");
 | 
			
		||||
				IAPPurchase(usdPrice, productId, orderId, orderDate);
 | 
			
		||||
				IAPPurchase(usdPrice, productId, orderId, orderDate, productToken, receipt);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			// IAP Ret true : Firebase + Guru + Adjust
 | 
			
		||||
| 
						 | 
				
			
			@ -657,20 +669,24 @@ namespace Guru
 | 
			
		|||
		/// <param name="productId"></param>
 | 
			
		||||
		/// <param name="orderId"></param>
 | 
			
		||||
		/// <param name="orderDate"></param>
 | 
			
		||||
		public static void IAPPurchase(double value, string productId, string orderId, string orderDate)
 | 
			
		||||
		public static void IAPPurchase(double value, string productId, string orderId, string orderDate,
 | 
			
		||||
			string purchaseToken = "", string receipt = "")
 | 
			
		||||
		{
 | 
			
		||||
			IAPPurchaseReport(EventIAPPurchase, value, productId, orderId, "IAP", orderDate);
 | 
			
		||||
			IAPPurchaseReport(EventIAPPurchase, value, productId, orderId, "IAP", orderDate, purchaseToken, receipt);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public static void SubPurchase(double value, string productId, string orderId, string orderDate)
 | 
			
		||||
		public static void SubPurchase(double value, string productId, string orderId, string orderDate, 
 | 
			
		||||
			string purchaseToken = "", string receipt = "")
 | 
			
		||||
		{
 | 
			
		||||
			IAPPurchaseReport(EventSubPurchase, value, productId, orderId, "SUB", orderDate);
 | 
			
		||||
			IAPPurchaseReport(EventSubPurchase, value, productId, orderId, "SUB", orderDate, purchaseToken, receipt);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		private static void IAPPurchaseReport(string eventName, double value, string productId, string orderId, string orderType, string orderDate)
 | 
			
		||||
		private static void IAPPurchaseReport(string eventName, double value, string productId, string orderId, string orderType, string orderDate,
 | 
			
		||||
			string purchaseToken = "", string receipt = "")	
 | 
			
		||||
		{
 | 
			
		||||
			LogEvent(eventName, new Dictionary<string, dynamic>()
 | 
			
		||||
			
 | 
			
		||||
			var dict = new Dictionary<string, dynamic>()
 | 
			
		||||
			{
 | 
			
		||||
				[ParameterPlatform] = IAPPlatform,
 | 
			
		||||
				[ParameterValue] = value,
 | 
			
		||||
| 
						 | 
				
			
			@ -679,11 +695,19 @@ namespace Guru
 | 
			
		|||
				["order_id"] = orderId,
 | 
			
		||||
				["order_type"] = orderType,
 | 
			
		||||
				["trans_ts"] = orderDate
 | 
			
		||||
			}, new EventSetting()
 | 
			
		||||
			{
 | 
			
		||||
				EnableFirebaseAnalytics = true,
 | 
			
		||||
				EnableAdjustAnalytics = true,
 | 
			
		||||
			});
 | 
			
		||||
			};
 | 
			
		||||
			
 | 
			
		||||
			// 上报Firebase + 自打点
 | 
			
		||||
			LogEvent(eventName, dict, new EventSetting() { EnableFirebaseAnalytics = true, });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			// 上报 Adjust 支付事件
 | 
			
		||||
			// if (value > 0)
 | 
			
		||||
			// {
 | 
			
		||||
			// 根据事件名称来获取对应的事件Token(iap_purchase/sub_purchase)
 | 
			
		||||
			LogAdjustRevenueEvent(eventName, value, productId, orderId, purchaseToken, receipt, dict);
 | 
			
		||||
			// }
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		#endregion
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -247,6 +247,44 @@ namespace Guru
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 上报 Adjust 事件
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <param name="eventName"></param>
 | 
			
		||||
		/// <param name="productId"></param>
 | 
			
		||||
		/// <param name="receipt"></param>
 | 
			
		||||
		/// <param name="data"></param>
 | 
			
		||||
		/// <param name="usdPrice"></param>
 | 
			
		||||
		/// <param name="transactionId"></param>
 | 
			
		||||
		/// <param name="purchaseToken"></param>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		internal static bool LogAdjustRevenueEvent(string eventName, double usdPrice, 
 | 
			
		||||
			string productId = "", string transactionId = "", string purchaseToken = "", string receipt = "", 
 | 
			
		||||
			Dictionary<string, object> data = null )
 | 
			
		||||
		{
 | 
			
		||||
			AdjustEvent adjustEvent = Analytics.CreateAdjustEvent(eventName);
 | 
			
		||||
			if (adjustEvent != null)
 | 
			
		||||
			{ 
 | 
			
		||||
				adjustEvent.setRevenue(usdPrice, USD);
 | 
			
		||||
				if (!string.IsNullOrEmpty(productId)) adjustEvent.setProductId(productId);
 | 
			
		||||
				if (!string.IsNullOrEmpty(transactionId)) adjustEvent.setTransactionId(transactionId);
 | 
			
		||||
				if (!string.IsNullOrEmpty(purchaseToken)) adjustEvent.setPurchaseToken(purchaseToken);
 | 
			
		||||
				if (!string.IsNullOrEmpty(receipt)) adjustEvent.setReceipt(receipt);
 | 
			
		||||
 | 
			
		||||
				if (data != null && data.Count > 0)
 | 
			
		||||
				{
 | 
			
		||||
					foreach (var kv in data)
 | 
			
		||||
					{
 | 
			
		||||
						adjustEvent.AddEventParameter(kv.Key, kv.Value.ToString());
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
				Adjust.trackEvent(adjustEvent);
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		#endregion
 | 
			
		||||
		
 | 
			
		||||
		#region 通用打点
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ namespace Guru
 | 
			
		|||
			       $"{nameof(language)}: {language}, {nameof(locale)}: {locale}, {nameof(deviceToken)}: {deviceToken}, {nameof(deviceType)}: {deviceType}, " +
 | 
			
		||||
			       $"{nameof(pushType)}: {pushType}, {nameof(appIdentifier)}: {appIdentifier}, {nameof(appVersion)}: {appVersion}, {nameof(brand)}: {brand}, " +
 | 
			
		||||
			       $"{nameof(model)}: {model}, {nameof(timezone)}: {timezone}, {nameof(pushNotificationEnable)}: {pushNotificationEnable}, " +
 | 
			
		||||
			       $"{nameof(firebaseAppInstanceId)}: {firebaseAppInstanceId}, {nameof(idfa)}: {idfa}, {nameof(adid)}: {adid}, {nameof(gpsAdid)}: {gpsAdid}";
 | 
			
		||||
			       $"{nameof(firebaseAppInstanceId)}: {firebaseAppInstanceId}, {nameof(idfa)}: {idfa}, {nameof(adid)}: {adid}, {nameof(gpsAdid)}: {gpsAdid}, {nameof(userUuid)}: {userUuid}";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ namespace Guru
 | 
			
		|||
		{
 | 
			
		||||
			DeviceData deviceData = new DeviceData();
 | 
			
		||||
			deviceData.pushNotificationEnable = _isPushEnabled;
 | 
			
		||||
			this.Log($"send deviceData:{deviceData}");
 | 
			
		||||
			UnityEngine.Debug.Log($"[SDK] --- Send DeviceData:{deviceData}");
 | 
			
		||||
			var request = new UnityWebRequest(RequestURL, "POST");
 | 
			
		||||
			request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(JsonUtility.ToJson(deviceData)));
 | 
			
		||||
			request.downloadHandler = new DownloadHandlerBuffer();
 | 
			
		||||
| 
						 | 
				
			
			@ -31,10 +31,10 @@ namespace Guru
 | 
			
		|||
 | 
			
		||||
		protected override void RequestSuccessCallBack(string response)
 | 
			
		||||
		{
 | 
			
		||||
			this.Log("@@@ Send OK!");
 | 
			
		||||
			UnityEngine.Debug.Log("[SDK] --- Send DeviceData Success");
 | 
			
		||||
			IPMConfig.IS_UPLOAD_DEVICE_SUCCESS = true;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 设置是否打开推送
 | 
			
		||||
		/// </summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,22 +99,22 @@ namespace Guru
 | 
			
		|||
            UpdateView(); // 刷新视图
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // 字段缓冲
 | 
			
		||||
        private StringBuilder _infoBuff;
 | 
			
		||||
        private string CreateMonitorInfo()
 | 
			
		||||
        {
 | 
			
		||||
            string msg = "";
 | 
			
		||||
            bool loaded = false;
 | 
			
		||||
            
 | 
			
		||||
            
 | 
			
		||||
            
 | 
			
		||||
            StringBuilder sb = new StringBuilder();
 | 
			
		||||
 | 
			
		||||
            if (!ADService.Instance.IsInitialized)
 | 
			
		||||
            {
 | 
			
		||||
                msg = ColoredText("AdService not initialized...", Consts.ColorRed);
 | 
			
		||||
                return msg;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            if (_infoBuff == null) _infoBuff = new StringBuilder();
 | 
			
		||||
            _infoBuff.Clear();
 | 
			
		||||
            
 | 
			
		||||
            if (_curBadsInfo == null)
 | 
			
		||||
            {
 | 
			
		||||
                msg = $"BADS: {ColoredText("not ready", Consts.ColorRed)}\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -137,7 +137,7 @@ namespace Guru
 | 
			
		|||
                        msg = $"BADS: {ColoredText("loading...", Consts.ColorYellow)}\n\tformat: {_curBadsInfo.format}\n";
 | 
			
		||||
                        break;
 | 
			
		||||
                    case AdStatusType.Paid:
 | 
			
		||||
                        msg = $"BADS: {ColoredText("display", Consts.ColorGreen)}\n\tnetwork: {_curIadsInfo.network}\n\trevenue: {_curBadsInfo.revenue}\n";
 | 
			
		||||
                        msg = $"BADS: {ColoredText("display", Consts.ColorGreen)}\n\tnetwork: {_curBadsInfo.network}\n\trevenue: {_curBadsInfo.revenue}\n";
 | 
			
		||||
                        break;
 | 
			
		||||
                    case AdStatusType.NotReady:
 | 
			
		||||
                        msg = $"BADS: {ColoredText("not ready", Consts.ColorGray)}\n\t{ColoredText("---", Consts.ColorGray)}\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ namespace Guru
 | 
			
		|||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            sb.Append(msg);
 | 
			
		||||
            _infoBuff.Append(msg);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if (_curIadsInfo == null)
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ namespace Guru
 | 
			
		|||
                switch (_curIadsInfo.status)
 | 
			
		||||
                {
 | 
			
		||||
                    case AdStatusType.Loaded:
 | 
			
		||||
                        msg = $"IADS: {ColoredText("loaded", Consts.ColorGreen)}\n\tnetwork: {_curIadsInfo.network}\n\twaterfall: {_curBadsInfo.waterfall}\n";
 | 
			
		||||
                        msg = $"IADS: {ColoredText("loaded", Consts.ColorGreen)}\n\tnetwork: {_curIadsInfo.network}\n\twaterfall: {_curIadsInfo.waterfall}\n";
 | 
			
		||||
                        break;
 | 
			
		||||
                    case AdStatusType.LoadFailed:
 | 
			
		||||
                        msg = $"IADS: {ColoredText("loading failed", Consts.ColorRed)}\n\tmessage: {_curIadsInfo.info}\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +181,7 @@ namespace Guru
 | 
			
		|||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            sb.Append(msg);
 | 
			
		||||
            _infoBuff.Append(msg);
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            if (_curRadsInfo == null)
 | 
			
		||||
| 
						 | 
				
			
			@ -215,10 +215,11 @@ namespace Guru
 | 
			
		|||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            sb.Append(msg);
 | 
			
		||||
            _infoBuff.Append(msg);
 | 
			
		||||
            
 | 
			
		||||
            
 | 
			
		||||
            return sb.ToString();
 | 
			
		||||
            return _infoBuff.ToString();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue