Merge branch 'hotfix/1.0.12.1' into hotfix/1.0.13
Signed-off-by: huyufei <yufei.hu@castbox.fm> # Conflicts: # Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.csmain 1.0.13
						commit
						c0c557b34e
					
				|  | @ -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 通用打点 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue