From 20938c5678873dff579e292422e3e476b3c06d58 Mon Sep 17 00:00:00 2001 From: huyufei Date: Mon, 13 May 2024 17:20:45 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=20IAP=20=E6=89=93?= =?UTF-8?q?=E7=82=B9=E5=8F=82=E6=95=B0,=20=E6=9B=B4=E6=96=B0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/GuruManager/Manager/GuruSDKManager.cs | 8 -- Runtime/Code/SDK/GuruSDK.Analytics.cs | 95 +++++++++++++++----- 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/Editor/GuruManager/Manager/GuruSDKManager.cs b/Editor/GuruManager/Manager/GuruSDKManager.cs index f4d4f76..3d54baf 100644 --- a/Editor/GuruManager/Manager/GuruSDKManager.cs +++ b/Editor/GuruManager/Manager/GuruSDKManager.cs @@ -607,14 +607,6 @@ namespace Guru.Editor } } - n = so.FindProperty("AnalyticsSetting"); - if (null != n) - { - // levelEndSuccessNum - p = n.serializedObject.FindProperty("AnalyticsSetting.levelEndSuccessNum"); - p.intValue = _serviceConfig.LevelEndSuccessNum(); - } - //---------- AMAZON ----------------------- n = so.FindProperty("AmazonSetting"); if (null != n) diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index 47a7cb3..d285158 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -16,7 +16,7 @@ namespace Guru /// 主线关卡类型 /// 只有传入此类型时才会进行 Blevel 的累加 /// - public const string LevelCategoryMain = "main"; + public const string LevelTypeMain = "main"; //----------------- 关卡开始类型 --------------------- public const string EventLevelStartModePlay = "play"; @@ -64,13 +64,13 @@ namespace Guru /// /// /// - /// + /// /// /// /// /// public static void LogLevelStart(int levelId, string startType = EventLevelStartModePlay, - string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", + string levelType = LevelTypeMain, string levelName = "", string levelID = "", bool isReplay = false, Dictionary extra = null) { if (!IsInitialSuccess) @@ -79,41 +79,41 @@ namespace Guru return; } - Analytics.LogLevelStart(levelId, levelName, levelCategory, levelID, startType, isReplay, extra); + Analytics.LogLevelStart(levelId, levelName, levelType, levelID, startType, isReplay, extra); } /// /// 游戏点击 Continue 重开始游戏 /// /// - /// + /// /// /// /// - public static void LogLevelContinue(int levelId, string levelCategory = LevelCategoryMain, + public static void LogLevelContinue(int levelId, string levelType = LevelTypeMain, string levelName = "", string levelID = "", Dictionary extra = null) { - LogLevelStart(levelId, EventLevelStartModeContinue, levelCategory, levelName, levelID, true, extra:extra); + LogLevelStart(levelId, EventLevelStartModeContinue, levelType, levelName, levelID, true, extra:extra); } /// /// 游戏点击 Continue 重开始游戏 /// /// - /// + /// /// /// - public static void LogLevelReplay(int levelId, string levelCategory = LevelCategoryMain, + public static void LogLevelReplay(int levelId, string levelType = LevelTypeMain, string levelName = "", string levelID = "", Dictionary extra = null) { - LogLevelStart(levelId, EventLevelStartModeReplay,levelCategory, levelName, levelID, true, extra:extra); + LogLevelStart(levelId, EventLevelStartModeReplay,levelType, levelName, levelID, true, extra:extra); } /// /// 游戏胜利打点 /// public static void LogLevelEnd(int levelId, string result = EventLevelEndSuccess, - string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", + string levelType = LevelTypeMain, string levelName = "", string levelID = "", int? duration = null, int? step = null, int? score = null, Dictionary extra = null ) { if (!IsInitialSuccess) @@ -121,11 +121,11 @@ namespace Guru UnityEngine.Debug.LogError($"{Tag} :: LogLevelEnd {levelId} :: Please call first, before you call ."); return; } - + if (InitConfig.AutoRecordFinishedLevels) { if(result == EventLevelEndSuccess){ - if(levelCategory == LevelCategoryMain) + if(levelType == LevelTypeMain) { if (levelId > Model.SuccessLevelId) Model.SuccessLevelId = levelId; // 自动记录关卡完成次数 } @@ -137,39 +137,54 @@ namespace Guru Analytics.BPlay = Model.TotalPlayedCount; // 记录 BPlay } - Analytics.LogLevelEnd(levelId, result, levelName, levelCategory, levelID, duration, step, score, extra); + Analytics.LogLevelEnd(levelId, result, levelName, levelType, levelID, duration, step, score, extra); } - - + + /// + /// 关卡首次通关 + /// + /// + /// + /// + /// + /// + /// + public static void LevelFirstEnd(string levelType, string levelName, int level, + string result = EventLevelEndSuccess, int? duration = null, Dictionary extra = null) + { + Analytics.LevelFirstEnd(levelType, levelName, level, result, duration, extra); + } + + /// /// 游戏失败打点 /// 需要为游戏记录详细的失败原因 /// public static void LogLevelFail(int levelId, - string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", + string levelType = LevelTypeMain, string levelName = "", string levelID = "", int? duration = null, int? step = null, int? score = null , Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndFail, levelCategory, levelName, levelID, duration, step, score, extra); + LogLevelEnd(levelId, EventLevelEndFail, levelType, levelName, levelID, duration, step, score, extra); } /// /// 因退出关卡导致游戏失败 /// public static void LogLevelFailExit(int levelId, - string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", + string levelType = LevelTypeMain, string levelName = "", string levelID = "", int? duration = null, int? step = null, int? score = null, Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndExit, levelCategory, levelName, levelID, duration, step, score, extra); + LogLevelEnd(levelId, EventLevelEndExit, levelType, levelName, levelID, duration, step, score, extra); } /// /// 因关卡超时导致游戏失败 /// public static void LogLevelFailTimeout(int levelId, - string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", + string levelType = LevelTypeMain, string levelName = "", string levelID = "", int? duration = null, int? step = null, int? score = null, Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndTimeout, levelCategory, levelName, levelID, duration, step, score, extra); + LogLevelEnd(levelId, EventLevelEndTimeout, levelType, levelName, levelID, duration, step, score, extra); } @@ -314,6 +329,42 @@ namespace Guru #endregion + #region IAP 打点 + + /// + /// 当付费页面打开时调用 + /// + /// 付费页面名称, 默认为 Store + /// 列表中首个商品的 ProductId + public static void OnIAPPageOpen(string scene = "Store", string productId = "") + { + if (string.IsNullOrEmpty(productId)) + { + if (GuruSettings.Instance != null && (GuruSettings.Instance.Products?.Length ?? 0) > 0) + { + productId = GuruSettings.Instance.Products[0].ProductId; + } + } + Analytics.IAPImp(scene, productId); + } + + /// + /// 当付费页面关闭时调用 + /// + /// + /// + public static void OnIAPPageClose(string scene = "Store", string productId = "") + { + if (string.IsNullOrEmpty(productId)) + { + productId = GuruIAP.Instance.CurrentBuyingProductId; + } + + Analytics.IAPClose(scene, productId); + } + + #endregion + #region 经济打点 // ************************************************************************************************