update: 为公用打点接口 暴露 extra 属性方便项目扩展
							parent
							
								
									4cd2e5ff19
								
							
						
					
					
						commit
						0e4a0a68cb
					
				|  | @ -68,9 +68,10 @@ namespace Guru | |||
|         /// <param name="levelID"></param> | ||||
|         /// <param name="startType"></param> | ||||
|         /// <param name="isReplay"></param> | ||||
|         /// <param name="extra"></param> | ||||
|         public static void LogLevelStart(int levelId, string startType = EventLevelStartModePlay,  | ||||
|             string levelCategory = LevelCategoryMain, string levelName = "", string levelID = "", | ||||
|             bool isReplay = false) | ||||
|             bool isReplay = false, Dictionary<string, object> extra = null) | ||||
|         { | ||||
|             if (!IsInitialSuccess) | ||||
|             { | ||||
|  | @ -78,7 +79,7 @@ namespace Guru | |||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             Analytics.LogLevelStart(levelId, levelName, levelCategory, levelID, startType, isReplay); | ||||
|             Analytics.LogLevelStart(levelId, levelName, levelCategory, levelID, startType, isReplay, extra); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -88,10 +89,11 @@ namespace Guru | |||
|         /// <param name="levelCategory"></param> | ||||
|         /// <param name="levelName"></param> | ||||
|         /// <param name="levelID"></param> | ||||
|         /// <param name="extra"></param> | ||||
|         public static void LogLevelContinue(int levelId, string levelCategory = LevelCategoryMain, | ||||
|             string levelName = "", string levelID = "") | ||||
|             string levelName = "", string levelID = "", Dictionary<string, object> extra = null) | ||||
|         { | ||||
|             LogLevelStart(levelId, EventLevelStartModeContinue, levelCategory, levelName, levelID,  true); | ||||
|             LogLevelStart(levelId, EventLevelStartModeContinue, levelCategory, levelName, levelID,  true, extra:extra); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|  | @ -102,9 +104,9 @@ namespace Guru | |||
|         /// <param name="levelName"></param> | ||||
|         /// <param name="levelID"></param> | ||||
|         public static void LogLevelReplay(int levelId, string levelCategory = LevelCategoryMain, | ||||
|             string levelName = "", string levelID = "") | ||||
|             string levelName = "", string levelID = "", Dictionary<string, object> extra = null) | ||||
|         { | ||||
|             LogLevelStart(levelId, EventLevelStartModeReplay,levelCategory, levelName, levelID,  true); | ||||
|             LogLevelStart(levelId, EventLevelStartModeReplay,levelCategory, levelName, levelID,  true, extra:extra); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|  | @ -112,7 +114,7 @@ namespace Guru | |||
|         /// </summary> | ||||
|         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<string, object> 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 | |||
|         /// </summary> | ||||
|         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<string, object> extra = null) | ||||
|         { | ||||
|             LogLevelEnd(levelId, EventLevelEndFail, levelCategory, levelName, levelID, duration, step, score); | ||||
|             LogLevelEnd(levelId, EventLevelEndFail, levelCategory, levelName, levelID, duration, step, score, extra); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -155,9 +157,9 @@ namespace Guru | |||
|         /// </summary> | ||||
|         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<string, object> extra = null) | ||||
|         { | ||||
|             LogLevelEnd(levelId, EventLevelEndExit, levelCategory, levelName, levelID, duration, step, score); | ||||
|             LogLevelEnd(levelId, EventLevelEndExit, levelCategory, levelName, levelID, duration, step, score, extra); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -165,9 +167,9 @@ namespace Guru | |||
|         /// </summary> | ||||
|         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<string, object> 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 | |||
|         /// </summary> | ||||
|         /// <param name="playerLevel"></param> | ||||
|         /// <param name="playerName"></param> | ||||
|         public static void LogLevelUp(int playerLevel, string playerName) | ||||
|         public static void LogLevelUp(int playerLevel, string playerName, Dictionary<string, object> extra = null) | ||||
|         { | ||||
|             if (!IsInitialSuccess) | ||||
|             { | ||||
|                 UnityEngine.Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call <GuruSDK.Start()> first, before you call <LogLevelUp>."); | ||||
|                 return; | ||||
|             } | ||||
|             Analytics.LevelUp(playerLevel, playerName); | ||||
|             Analytics.LevelUp(playerLevel, playerName, extra); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// 玩家解锁成就 | ||||
|         /// </summary> | ||||
|         /// <param name="achievementName"></param> | ||||
|         public static void LogAchievement(string achievementName) | ||||
|         public static void LogAchievement(string achievementName, Dictionary<string, object> extra = null) | ||||
|         { | ||||
|             if (!IsInitialSuccess) | ||||
|             { | ||||
|                 UnityEngine.Debug.LogError($"{Tag} :: LogAchievement {achievementName} :: Please call <GuruSDK.Start()> first, before you call <LogAchievement>."); | ||||
|                 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<string, object> 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<string, object> 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 | |||
|         /// <param name="props">获取的道具名称列表</param> | ||||
|         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<string, object> 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 | |||
|         /// <param name="props">获取的道具名称列表</param> | ||||
|         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<string, object> 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); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -437,11 +439,11 @@ namespace Guru | |||
|         /// <param name="props">获取的道具名称列表</param> | ||||
|         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<string, object> 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); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|  | @ -458,11 +460,11 @@ namespace Guru | |||
|         /// <param name="props">获取的道具名称列表</param> | ||||
|         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<string, object> 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); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -479,11 +481,11 @@ namespace Guru | |||
|         /// <param name="props">获取的道具名称列表</param> | ||||
|         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<string, object> 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 | |||
|         /// <param name="levelName">当前关卡名称</param> | ||||
|         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<string, object> 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); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|  | @ -516,10 +518,10 @@ namespace Guru | |||
|         /// <param name="levelName"></param> | ||||
|         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<string, object> 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 | |||
|         /// <param name="props">获取的道具名称列表</param> | ||||
|         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<string, object> 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<string, object> 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 | |||
|         /// <param name="scene"></param> | ||||
|         public static void SpendVirtualCurrencyWithProp(string currencyName, string prop, | ||||
|             int value, int balance, | ||||
|             string levelName = "", string scene = "") | ||||
|             string levelName = "", string scene = "", Dictionary<string, object> extra = null) | ||||
|         { | ||||
|             SpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene); | ||||
|             SpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene, extra); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -596,7 +598,7 @@ namespace Guru | |||
|         /// <param name="scene"></param> | ||||
|         public static void SpendVirtualCurrencyWithProps(string currencyName, string[] props, | ||||
|             int value, int balance,  | ||||
|             string levelName = "", string scene = "") | ||||
|             string levelName = "", string scene = "", Dictionary<string, object> 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 | |||
|         /// <param name="scene"></param> | ||||
|         public static void SpendVirtualCurrencyWithBundle(string currencyName, string bundle, | ||||
|             int value, int balance, | ||||
|             string levelName = "", string scene = "") | ||||
|             string levelName = "", string scene = "", Dictionary<string, object> extra = null) | ||||
|         { | ||||
|             SpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene); | ||||
|             SpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene, extra); | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -637,7 +639,7 @@ namespace Guru | |||
|         /// <param name="scene"></param> | ||||
|         public static void SpendVirtualCurrencyWithBundles(string currencyName, string[] bundles, | ||||
|             int value, int balance,  | ||||
|             string levelName = "", string scene = "") | ||||
|             string levelName = "", string scene = "", Dictionary<string, object> 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 | |||
|         /// <param name="scene"></param> | ||||
|         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<string, object> 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);  | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue