diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs index 764ff56..2ffd998 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs @@ -1,3 +1,4 @@ +using System.Data.Odbc; using JetBrains.Annotations; namespace Guru @@ -603,15 +604,19 @@ namespace Guru /// /// /// - /// - /// - /// - /// - /// - /// - /// - public static void ReportIAPSuccessEvent(double usdPrice, string productId, BaseOrderData orderData) + /// + /// + public static void ReportIAPSuccessEvent(BaseOrderData orderData, double usdPrice, bool isTest = false) { + if (orderData == null) return; + + if (!isTest && usdPrice == 0) + { + Debug.Log($"[SDK] --- Pruchase value is 0, skip report orders"); + return; + } + + string productId = orderData.productId; string userCurrency = orderData.userCurrency; double payPrice = orderData.payPrice; string orderType = orderData.OrderType(); @@ -631,12 +636,12 @@ namespace Guru if (orderData.orderType == 1) { // sub_pruchase : Firebase + Guru + Adjust - SubPurchase(usdPrice, productId, orderId, orderDate); + SubPurchase(usdPrice, productId, orderId, orderDate, isTest); } else { // iap_purchase : Firebase + Guru + Adjust - IAPPurchase(usdPrice, productId, orderId, orderDate); + IAPPurchase(usdPrice, productId, orderId, orderDate, isTest); } // IAP Ret true : Firebase + Guru + Adjust @@ -655,18 +660,18 @@ namespace Guru /// /// /// - public static void IAPPurchase(double value, string productId, string orderId, string orderDate) + public static void IAPPurchase(double value, string productId, string orderId, string orderDate, bool isSandbox = false) { - IAPPurchaseReport(EventIAPPurchase, value, productId, orderId, "IAP", orderDate); + IAPPurchaseReport(EventIAPPurchase, value, productId, orderId, "IAP", orderDate, isSandbox); } - public static void SubPurchase(double value, string productId, string orderId, string orderDate) + public static void SubPurchase(double value, string productId, string orderId, string orderDate, bool isSandbox = false) { - IAPPurchaseReport(EventSubPurchase, value, productId, orderId, "SUB", orderDate); + IAPPurchaseReport(EventSubPurchase, value, productId, orderId, "SUB", orderDate, isSandbox); } - 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, bool isSandbox = false) { LogEvent(eventName, new Dictionary() { @@ -676,7 +681,8 @@ namespace Guru [ParameterProductId] = productId, ["order_id"] = orderId, ["order_type"] = orderType, - ["trans_ts"] = orderDate + ["trans_ts"] = orderDate, + ["sandbox"] = isSandbox? "true": "false" }, new EventSetting() { EnableFirebaseAnalytics = true, diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/IPMConfig.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/IPMConfig.cs index 3899bdf..8d57a29 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/IPMConfig.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/IPMConfig.cs @@ -50,6 +50,7 @@ namespace Guru { GenDeviceId(); } + return SavedDeviceId; // 优先使用缓存的 DeviceID } } diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs index 73c5b59..20bf4c5 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs @@ -34,19 +34,14 @@ namespace Guru { try { + Debug.Log($"[IAP] --- Apple Order Response: {response}"); ResponseData responseData = JsonUtility.FromJson>(response); if (responseData != null && responseData.data != null) - { - double usdPrice = responseData.data.usdPrice; - string productId = orderData.productId; + { + double usdPrice = responseData.data.usdPrice; + bool isTest = responseData.data.test; - // Analytics.Tch001IAPRev(usdPrice, productId, orderData.orderId, orderData.OrderType(), orderData.payedDate); - // Analytics.Tch02IAPRev(usdPrice); - // - // AdjustService.TrackSubPurchase(usdPrice, productId); - // Analytics.SubPurchase(usdPrice, productId); - - Analytics.ReportIAPSuccessEvent(usdPrice, productId, orderData); + Analytics.ReportIAPSuccessEvent(orderData, usdPrice, isTest); } } catch (Exception ex) diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs index 54a63f4..036c608 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs @@ -31,21 +31,14 @@ namespace Guru { try { + Debug.Log($"[IAP] --- Google Order Response: {response}"); ResponseData responseData = JsonUtility.FromJson>(response); if (responseData != null && responseData.data != null) { double usdPrice = responseData.data.usdPrice; - string productId = orderData.RealProductId; + bool isTest = responseData.data.test; - // Analytics.Tch001IAPRev(usdPrice, productId, orderId, orderType, orderDate); // TCH 001 - // // Analytics.Tch02IAPRev(usdPrice, productId, orderId, orderTypeString, timestamp); - // Analytics.Tch02IAPRev(usdPrice); // TCH 020 - // - // // Adjust Track IAP Purchase - // AdjustService.TrackIAPPurchase(usdPrice, productId); // 上报 IAP 支付事件 - // Analytics.IAPPurchase(usdPrice, productId); - - Analytics.ReportIAPSuccessEvent(usdPrice, productId, orderData); + Analytics.ReportIAPSuccessEvent(orderData, usdPrice, isTest); } } catch (Exception ex) diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/ResponseData/OrderResponse.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/ResponseData/OrderResponse.cs index 0fb2f78..03ef3f2 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/ResponseData/OrderResponse.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/ResponseData/OrderResponse.cs @@ -6,10 +6,11 @@ namespace Guru public class OrderResponse { public double usdPrice; + public bool test; public override string ToString() { - return $"{nameof(usdPrice)}: {usdPrice}"; + return $"{nameof(usdPrice)}: {usdPrice} {nameof(test)}: {test}"; } } } \ No newline at end of file