From aad0fd6d7642cb8be1ad30a9907882676f8c795c Mon Sep 17 00:00:00 2001 From: huyufei Date: Wed, 22 May 2024 18:09:17 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=B8=AD=E5=8F=B0=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=89=93=E7=82=B9=20iap=5Fclk,=20=E7=94=B1=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=84=E8=87=AA=E8=A1=8C=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Analytics.cs | 44 ++++++++++++++++++++++----- Runtime/Code/SDK/GuruSDK.Debug.cs | 6 ++-- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index f676b00..779e896 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -201,16 +201,16 @@ namespace Guru /// 玩家(角色)升级事件 /// /// - /// + /// /// 扩展数据 - public static void LogLevelUp(int playerLevel, string playerName, Dictionary extra = null) + public static void LogLevelUp(int playerLevel, string characterName, Dictionary extra = null) { if (!IsInitialSuccess) { UnityEngine.Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call first, before you call ."); return; } - Analytics.LevelUp(playerLevel, playerName, extra); + Analytics.LevelUp(playerLevel, characterName, extra); } /// @@ -358,6 +358,27 @@ namespace Guru #region IAP 打点 + private static string TryGetFirstProductId() + { + if (GuruSettings.Instance != null && (GuruSettings.Instance.Products?.Length ?? 0) > 0) + { + return GuruSettings.Instance.Products[0]?.ProductId ?? ""; + } + + return ""; + } + + private static string TryGetCurrentProductId() + { + if (GuruIAP.Instance != null && IsIAPReady) + { + return GuruIAP.Instance.CurrentBuyingProductId; + } + return ""; + } + + + /// /// 当付费页面打开时调用 /// @@ -367,10 +388,7 @@ namespace Guru { if (string.IsNullOrEmpty(productId)) { - if (GuruSettings.Instance != null && (GuruSettings.Instance.Products?.Length ?? 0) > 0) - { - productId = GuruSettings.Instance.Products[0].ProductId; - } + productId = TryGetFirstProductId(); } Analytics.IAPImp(scene, productId); } @@ -384,12 +402,22 @@ namespace Guru { if (string.IsNullOrEmpty(productId)) { - productId = GuruIAP.Instance.CurrentBuyingProductId; + productId = TryGetCurrentProductId(); } Analytics.IAPClose(scene, productId); } + /// + /// 当点击 IAP 商品按钮的时候调用 + /// + /// + /// + public static void OnIAPClick(string scene = "", string productId = "") + { + Analytics.IAPClick(scene, productId); + } + #endregion #region 经济打点 diff --git a/Runtime/Code/SDK/GuruSDK.Debug.cs b/Runtime/Code/SDK/GuruSDK.Debug.cs index c7b29a7..dd76f57 100644 --- a/Runtime/Code/SDK/GuruSDK.Debug.cs +++ b/Runtime/Code/SDK/GuruSDK.Debug.cs @@ -3,9 +3,9 @@ namespace Guru { public partial class GuruSDK { - private const string K_CMD_NAME_DEBUGGER = "debug.guru.dbg"; - private const string K_CMD_NAME_WATERMARK = "debug.guru.wm"; - private const string K_CMD_NAME_CONSOLE = "debug.guru.con"; + private const string K_CMD_NAME_DEBUGGER = "gurusdk.unity.dbg"; + private const string K_CMD_NAME_WATERMARK = "gurusdk.unity.wm"; + private const string K_CMD_NAME_CONSOLE = "gurusdk.unity.con";