From e8c17f4cf4a905ab595a2975f5fd228eeadc816d Mon Sep 17 00:00:00 2001 From: huyufei Date: Tue, 25 Jun 2024 10:35:03 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20=E5=AF=B9=E9=BD=90=20SDK=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- .../GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentAndroid.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Runtime/GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentAndroid.cs b/Runtime/GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentAndroid.cs index 50618c0..6364315 100644 --- a/Runtime/GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentAndroid.cs +++ b/Runtime/GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentAndroid.cs @@ -80,7 +80,8 @@ namespace Guru { _isDebug = isDebug; string bundleId = Application.identifier; - CallStatic("init", appId, deviceInfo, bundleId, UseWorker, isDebug, UseCronet, BaseUrl); // 调用接口 + // public static void init(String appId, String deviceInfo, String bundleId, boolean isDebug, boolean useWorker, boolean useCronet, String baseUrl) + CallStatic("init", appId, deviceInfo, bundleId, isDebug, UseWorker, UseCronet, BaseUrl); // 调用接口 } public void SetScreen(string screenName) From b7aacb61e45973da6a5de8fe9cfe7fe3c19ca415 Mon Sep 17 00:00:00 2001 From: huyufei Date: Thu, 27 Jun 2024 18:47:36 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix=EF=BC=9A=20=E4=BF=AE=E5=A4=8D=20AdStatu?= =?UTF-8?q?s=20=E7=9A=84=E6=98=BE=E7=A4=BA=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- .../AdsStatus/MVP/AdStatusPresenter.Ads.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Runtime/GuruDebugger/Runtime/AdsStatus/MVP/AdStatusPresenter.Ads.cs b/Runtime/GuruDebugger/Runtime/AdsStatus/MVP/AdStatusPresenter.Ads.cs index 8ae3439..2f74917 100644 --- a/Runtime/GuruDebugger/Runtime/AdsStatus/MVP/AdStatusPresenter.Ads.cs +++ b/Runtime/GuruDebugger/Runtime/AdsStatus/MVP/AdStatusPresenter.Ads.cs @@ -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(); + } From 85dc4a7ddc425a3f0ff391f08e4414ac2bd62260 Mon Sep 17 00:00:00 2001 From: huyufei Date: Thu, 27 Jun 2024 18:53:24 +0800 Subject: [PATCH 3/6] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=89=93?= =?UTF-8?q?=E5=8D=B0=20DeviceData=20=E7=9A=84=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- Runtime/GuruCore/Runtime/Analytics/Analytics.Ads.cs | 8 ++++---- .../Runtime/IPM/Scripts/RequestData/DeviceData.cs | 2 +- .../IPM/Scripts/Requests/DeviceInfoUploadRequest.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.Ads.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.Ads.cs index 43a235e..776f663 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.Ads.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.Ads.cs @@ -224,17 +224,17 @@ namespace Guru /// /// /// - /// - public static void AttResult(string status, string type = "custom", string others = "") + /// + 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() { { ParameterItemCategory, status }, { "type", type } }; - if(!string.IsNullOrEmpty(others)) dict[ParameterItemName] = others; + if(!string.IsNullOrEmpty(scene)) dict[ParameterItemName] = scene; LogEvent(EventATTResult, dict); } diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/RequestData/DeviceData.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/RequestData/DeviceData.cs index 7d4727c..7166924 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/RequestData/DeviceData.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/RequestData/DeviceData.cs @@ -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}"; } } diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs index 7b7a56b..55e28a8 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs @@ -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(); From e77994d81137fc8df17739351af7ea67492e3b3a Mon Sep 17 00:00:00 2001 From: huyufei Date: Thu, 27 Jun 2024 21:13:57 +0800 Subject: [PATCH 4/6] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=20DeviceInfo?= =?UTF-8?q?=20=E4=B8=8A=E6=8A=A5=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- .../Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs index 55e28a8..1f6ddf1 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/DeviceInfoUploadRequest.cs @@ -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; } - + /// /// 设置是否打开推送 /// From 3d9d027e89c21a7dabd16658f2e40e3f4321b24d Mon Sep 17 00:00:00 2001 From: huyufei Date: Mon, 1 Jul 2024 09:49:52 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Adjust=20?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E9=87=8D=E5=A4=8D=E4=B8=8A=E6=8A=A5=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E4=B8=BA=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20revenue=20=E6=B2=A1=E6=9C=89=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E7=9A=84=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- .../Analytics/Analytics.TemplateDefine.cs | 54 ++++++++++++++----- .../GuruCore/Runtime/Analytics/Analytics.cs | 38 +++++++++++++ 2 files changed, 79 insertions(+), 13 deletions(-) diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs index 764ff56..c8d2486 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs @@ -1,4 +1,4 @@ -using JetBrains.Annotations; + namespace Guru { @@ -621,6 +621,22 @@ 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,12 +647,12 @@ namespace Guru if (orderData.orderType == 1) { // sub_pruchase : Firebase + Guru + Adjust - SubPurchase(usdPrice, productId, orderId, orderDate); + SubPurchase(usdPrice, productId, orderId, orderDate, productToken, receipt); } else { // iap_purchase : Firebase + Guru + Adjust - IAPPurchase(usdPrice, productId, orderId, orderDate); + IAPPurchase(usdPrice, productId, orderId, orderDate, productToken, receipt); } // IAP Ret true : Firebase + Guru + Adjust @@ -655,20 +671,24 @@ 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, + 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() + + var dict = new Dictionary() { [ParameterPlatform] = IAPPlatform, [ParameterValue] = value, @@ -677,11 +697,19 @@ namespace Guru ["order_id"] = orderId, ["order_type"] = orderType, ["trans_ts"] = orderDate - }, new EventSetting() + }; + + // 上报Firebase + 自打点 + LogEvent(eventName, dict, new EventSetting() { EnableFirebaseAnalytics = true, }); + + + // 上报 Adjust 支付事件 + if (value > 0) { - EnableFirebaseAnalytics = true, - EnableAdjustAnalytics = true, - }); + // 根据事件名称来获取对应的事件Token(iap_purchase/sub_purchase) + LogAdjustRevenueEvent(eventName, value, productId, orderId, purchaseToken, receipt, dict); + } + } #endregion diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs index a6dad54..9986dc8 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs @@ -248,6 +248,44 @@ namespace Guru } } + /// + /// 上报 Adjust 事件 + /// + /// + /// + /// + /// + /// + /// + /// + /// + internal static bool LogAdjustRevenueEvent(string eventName, double usdPrice, + string productId = "", string transactionId = "", string purchaseToken = "", string receipt = "", + Dictionary 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 通用打点 From edcc533d33ac7495e5d21b422c92a8519376485e Mon Sep 17 00:00:00 2001 From: huyufei Date: Mon, 1 Jul 2024 12:36:55 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix=EF=BC=9A=20Adjust=20=E6=89=93=E7=82=B9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=94=AF=E4=BB=98=E4=B9=9F=E4=BC=9A=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- .../Runtime/Analytics/Analytics.TemplateDefine.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs index c8d2486..3c976d2 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs @@ -634,9 +634,7 @@ namespace Guru { receipt = adata.receipt; } - - - + // TCH 001 Tch001IAPRev(usdPrice, productId, orderId, orderType, orderDate); // TCH 020 @@ -704,11 +702,11 @@ namespace Guru // 上报 Adjust 支付事件 - if (value > 0) - { - // 根据事件名称来获取对应的事件Token(iap_purchase/sub_purchase) - LogAdjustRevenueEvent(eventName, value, productId, orderId, purchaseToken, receipt, dict); - } + // if (value > 0) + // { + // 根据事件名称来获取对应的事件Token(iap_purchase/sub_purchase) + LogAdjustRevenueEvent(eventName, value, productId, orderId, purchaseToken, receipt, dict); + // } }