diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index fbd4f73..47a7cb3 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -68,9 +68,10 @@ namespace Guru /// /// /// + /// public static void LogLevelStart(int levelId, string startType = EventLevelStartModePlay, string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", - bool isReplay = false) + bool isReplay = false, Dictionary extra = null) { if (!IsInitialSuccess) { @@ -78,9 +79,9 @@ namespace Guru return; } - Analytics.LogLevelStart(levelId, levelName, levelCategory, levelID, startType, isReplay); + Analytics.LogLevelStart(levelId, levelName, levelCategory, levelID, startType, isReplay, extra); } - + /// /// 游戏点击 Continue 重开始游戏 /// @@ -88,10 +89,11 @@ namespace Guru /// /// /// + /// public static void LogLevelContinue(int levelId, string levelCategory = LevelCategoryMain, - string levelName = "", string levelID = "") + string levelName = "", string levelID = "", Dictionary extra = null) { - LogLevelStart(levelId, EventLevelStartModeContinue, levelCategory, levelName, levelID, true); + LogLevelStart(levelId, EventLevelStartModeContinue, levelCategory, levelName, levelID, true, extra:extra); } /// @@ -102,9 +104,9 @@ namespace Guru /// /// public static void LogLevelReplay(int levelId, string levelCategory = LevelCategoryMain, - string levelName = "", string levelID = "") + string levelName = "", string levelID = "", Dictionary extra = null) { - LogLevelStart(levelId, EventLevelStartModeReplay,levelCategory, levelName, levelID, true); + LogLevelStart(levelId, EventLevelStartModeReplay,levelCategory, levelName, levelID, true, extra:extra); } /// @@ -112,7 +114,7 @@ namespace Guru /// public static void LogLevelEnd(int levelId, string result = EventLevelEndSuccess, string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", - int? duration = null, int? step = null, int? score = null ) + int? duration = null, int? step = null, int? score = null, Dictionary extra = null ) { if (!IsInitialSuccess) { @@ -135,7 +137,7 @@ namespace Guru Analytics.BPlay = Model.TotalPlayedCount; // 记录 BPlay } - Analytics.LogLevelEnd(levelId, result, levelName, levelCategory, levelID, duration, step, score); + Analytics.LogLevelEnd(levelId, result, levelName, levelCategory, levelID, duration, step, score, extra); } @@ -145,9 +147,9 @@ namespace Guru /// public static void LogLevelFail(int levelId, string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", - int? duration = null, int? step = null, int? score = null ) + int? duration = null, int? step = null, int? score = null , Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndFail, levelCategory, levelName, levelID, duration, step, score); + LogLevelEnd(levelId, EventLevelEndFail, levelCategory, levelName, levelID, duration, step, score, extra); } /// @@ -155,9 +157,9 @@ namespace Guru /// public static void LogLevelFailExit(int levelId, string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", - int? duration = null, int? step = null, int? score = null) + int? duration = null, int? step = null, int? score = null, Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndExit, levelCategory, levelName, levelID, duration, step, score); + LogLevelEnd(levelId, EventLevelEndExit, levelCategory, levelName, levelID, duration, step, score, extra); } /// @@ -165,9 +167,9 @@ namespace Guru /// public static void LogLevelFailTimeout(int levelId, string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", - int? duration = null, int? step = null, int? score = null) + int? duration = null, int? step = null, int? score = null, Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndTimeout, levelCategory, levelName, levelID, duration, step, score); + LogLevelEnd(levelId, EventLevelEndTimeout, levelCategory, levelName, levelID, duration, step, score, extra); } @@ -176,28 +178,28 @@ namespace Guru /// /// /// - public static void LogLevelUp(int playerLevel, string playerName) + public static void LogLevelUp(int playerLevel, string playerName, Dictionary extra = null) { if (!IsInitialSuccess) { UnityEngine.Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call first, before you call ."); return; } - Analytics.LevelUp(playerLevel, playerName); + Analytics.LevelUp(playerLevel, playerName, extra); } /// /// 玩家解锁成就 /// /// - public static void LogAchievement(string achievementName) + public static void LogAchievement(string achievementName, Dictionary extra = null) { if (!IsInitialSuccess) { UnityEngine.Debug.LogError($"{Tag} :: LogAchievement {achievementName} :: Please call first, before you call ."); return; } - Analytics.UnlockAchievement(achievementName); + Analytics.UnlockAchievement(achievementName, extra); } #endregion @@ -337,9 +339,9 @@ namespace Guru public static void EarnVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "", - string levelName = "", string scene = "") + string levelName = "", string scene = "", Dictionary extra = null) { - Analytics.EarnVirtualCurrency(currencyName, value, balance, category, itemName,levelName, scene); + Analytics.EarnVirtualCurrency(currencyName, value, balance, category, itemName,levelName, scene, extra); } @@ -359,12 +361,12 @@ namespace Guru int value = 0, int balance = 0, string category = "", string itemName = "", string levelName = "", string scene = Consts.ParameterDefaultScene, - string[] props = null) + string[] props = null, Dictionary extra = null) { //---- Currency ----- if (value > 0) { - EarnVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene); + EarnVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra); } //---- Props -------- if (null != props) @@ -372,7 +374,7 @@ namespace Guru int i = 0; while (i < props.Length) { - EarnVirtualCurrency(props[i], 1, 0, category, itemName, levelName, scene); + EarnVirtualCurrency(props[i], 1, 0, category, itemName, levelName, scene, extra); i++; } } @@ -392,12 +394,12 @@ namespace Guru /// 获取的道具名称列表 public static void EarnVirtualCurrencyBySign(string currencyName, int value = 0, int balance = 0, string levelName = "", - string scene = "home", string[] props = null) + string scene = "home", string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryReward; string itemName = "sign"; - - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props); + + EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } @@ -416,11 +418,11 @@ namespace Guru /// 获取的道具名称列表 public static void EarnVirtualCurrencyByIAP(string currencyName, string productId, int value = 0, int balance = 0, string levelName = "", - string scene = "store", string[] props = null) + string scene = "store", string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryIAP; string itemName = productId; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props); + EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// @@ -437,11 +439,11 @@ namespace Guru /// 获取的道具名称列表 public static void EarnVirtualCurrencyByAds(string currencyName, int value = 0, int balance = 0, string levelName = "", - string scene = "store", string[] props = null) + string scene = "store", string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryReward; string itemName = "ads"; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props); + EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// @@ -458,11 +460,11 @@ namespace Guru /// 获取的道具名称列表 public static void EarnVirtualCurrencyByPaidAds(string currencyName, int value = 0, int balance = 0, string levelName = "", - string scene = Consts.ParameterDefaultScene, string[] props = null) + string scene = Consts.ParameterDefaultScene, string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryBonus; string itemName = "ads"; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props); + EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// @@ -479,11 +481,11 @@ namespace Guru /// 获取的道具名称列表 public static void EarnVirtualCurrencyByLevelComplete(string currencyName, int value = 0, int balance = 0, string levelName = "", - string scene = "store", string[] props = null) + string scene = "store", string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryReward; string itemName = "level"; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props); + EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } @@ -498,11 +500,11 @@ namespace Guru /// 当前关卡名称 public static void EarnPropsByVirtualCurrency(string currencyName, string[] props, string scene = Consts.ParameterDefaultScene, - int value = 1, int balance = 0, string levelName = "") + int value = 1, int balance = 0, string levelName = "", Dictionary extra = null) { string category = Consts.CurrencyCategoryIGC; string itemName = currencyName; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props); + EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// @@ -516,10 +518,10 @@ namespace Guru /// public static void EarnPropByProp(string propName, string otherName, string scene = Consts.ParameterDefaultScene, - int value = 1, int balance = 0, string levelName = "") + int value = 1, int balance = 0, string levelName = "", Dictionary extra = null) { string category = Consts.CurrencyCategoryIGB; - EarnVirtualCurrency(propName, value, balance, category, otherName, levelName, scene); + EarnVirtualCurrency(propName, value, balance, category, otherName, levelName, scene, extra); } @@ -537,11 +539,11 @@ namespace Guru /// 获取的道具名称列表 public static void EarnVirtualCurrencyByLottery(string currencyName, int value = 0, int balance = 0, string levelName = "", - string scene = "store", string[] props = null) + string scene = "store", string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryIGB; string itemName = "lottery"; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props); + EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } @@ -563,9 +565,9 @@ namespace Guru public static void SpendVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "", - string levelName = "", string scene = "") + string levelName = "", string scene = "", Dictionary extra = null) { - Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene); + Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra); } @@ -580,9 +582,9 @@ namespace Guru /// public static void SpendVirtualCurrencyWithProp(string currencyName, string prop, int value, int balance, - string levelName = "", string scene = "") + string levelName = "", string scene = "", Dictionary extra = null) { - SpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene); + SpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene, extra); } /// @@ -596,7 +598,7 @@ namespace Guru /// public static void SpendVirtualCurrencyWithProps(string currencyName, string[] props, int value, int balance, - string levelName = "", string scene = "") + string levelName = "", string scene = "", Dictionary extra = null) { string category = Consts.CurrencyCategoryProp; if (props != null && props.Length > 0) @@ -604,7 +606,7 @@ namespace Guru int i = 0; while (i < props.Length) { - SpendVirtualCurrency(currencyName, value, balance, category, props[i], levelName, scene); + SpendVirtualCurrency(currencyName, value, balance, category, props[i], levelName, scene, extra); i++; } } @@ -621,9 +623,9 @@ namespace Guru /// public static void SpendVirtualCurrencyWithBundle(string currencyName, string bundle, int value, int balance, - string levelName = "", string scene = "") + string levelName = "", string scene = "", Dictionary extra = null) { - SpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene); + SpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene, extra); } /// @@ -637,7 +639,7 @@ namespace Guru /// public static void SpendVirtualCurrencyWithBundles(string currencyName, string[] bundles, int value, int balance, - string levelName = "", string scene = "") + string levelName = "", string scene = "", Dictionary extra = null) { string category = Consts.CurrencyCategoryBundle; if (bundles != null && bundles.Length > 0) @@ -645,7 +647,7 @@ namespace Guru int i = 0; while (i < bundles.Length) { - SpendVirtualCurrency(currencyName, value, balance, category, bundles[i], levelName, scene); + SpendVirtualCurrency(currencyName, value, balance, category, bundles[i], levelName, scene, extra); i++; } } @@ -662,10 +664,10 @@ namespace Guru /// public static void SpendPropWithProp(string propName, string otherName, int value, int balance, - string levelName = "", string scene = "", string extraCategory = "") + string levelName = "", string scene = "", string extraCategory = "", Dictionary extra = null) { string category = string.IsNullOrEmpty(extraCategory) ? Consts.CurrencyCategoryProp : extraCategory; - SpendVirtualCurrency(propName, value, balance, category, otherName, levelName, scene); + SpendVirtualCurrency(propName, value, balance, category, otherName, levelName, scene, extra); }