parent
							
								
									d53cdab2e5
								
							
						
					
					
						commit
						19d51274ab
					
				| 
						 | 
					@ -87,9 +87,9 @@ namespace Guru
 | 
				
			||||||
            string category = "", 
 | 
					            string category = "", 
 | 
				
			||||||
            string itemName = "",
 | 
					            string itemName = "",
 | 
				
			||||||
            string levelName = "0",
 | 
					            string levelName = "0",
 | 
				
			||||||
            string scene = "")
 | 
					            string scene = "", Dictionary<string, object> extra = null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var data = new Dictionary<string, dynamic>()
 | 
					            var data = new Dictionary<string, object>()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                { ParameterVirtualCurrencyName, currencyName },
 | 
					                { ParameterVirtualCurrencyName, currencyName },
 | 
				
			||||||
                { ParameterValue, value },
 | 
					                { ParameterValue, value },
 | 
				
			||||||
| 
						 | 
					@ -101,6 +101,7 @@ namespace Guru
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if(!string.IsNullOrEmpty(scene)) data[ParameterScene] = scene; // 获取的虚拟货币或者道具的场景
 | 
					            if(!string.IsNullOrEmpty(scene)) data[ParameterScene] = scene; // 获取的虚拟货币或者道具的场景
 | 
				
			||||||
 | 
					            if (extra != null) data.AddRange(extra, isOverride: true);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            LogEvent(EventEarnVirtualCurrency, data, new EventSetting() { EnableFirebaseAnalytics = true });
 | 
					            LogEvent(EventEarnVirtualCurrency, data, new EventSetting() { EnableFirebaseAnalytics = true });
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
| 
						 | 
					@ -114,9 +115,10 @@ namespace Guru
 | 
				
			||||||
            string category = "", 
 | 
					            string category = "", 
 | 
				
			||||||
            string itemName = "",
 | 
					            string itemName = "",
 | 
				
			||||||
            string levelName = "0",
 | 
					            string levelName = "0",
 | 
				
			||||||
            string scene = "")
 | 
					            string scene = ""
 | 
				
			||||||
 | 
					            , Dictionary<string, object> extra = null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var data = new Dictionary<string, dynamic>()
 | 
					            var data = new Dictionary<string, object>()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                { ParameterVirtualCurrencyName, currencyName },
 | 
					                { ParameterVirtualCurrencyName, currencyName },
 | 
				
			||||||
                { ParameterValue, value },
 | 
					                { ParameterValue, value },
 | 
				
			||||||
| 
						 | 
					@ -125,6 +127,7 @@ namespace Guru
 | 
				
			||||||
                { ParameterItemCategory, category },
 | 
					                { ParameterItemCategory, category },
 | 
				
			||||||
                { ParameterItemName, itemName },
 | 
					                { ParameterItemName, itemName },
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					            if (extra != null) data.AddRange(extra, isOverride: true);
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if(!string.IsNullOrEmpty(scene)) data[ParameterScene] = scene; // 获取的虚拟货币或者道具的场景
 | 
					            if(!string.IsNullOrEmpty(scene)) data[ParameterScene] = scene; // 获取的虚拟货币或者道具的场景
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,30 +9,38 @@ namespace Guru
 | 
				
			||||||
    public static partial class Analytics
 | 
					    public static partial class Analytics
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
	    #region 游戏通用打点
 | 
						    #region 游戏通用打点
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    /// <summary>
 | 
						    /// <summary>
 | 
				
			||||||
	    /// 当玩家在游戏中升级时触发
 | 
						    /// 当玩家在游戏中升级时触发
 | 
				
			||||||
	    /// </summary>
 | 
						    /// </summary>
 | 
				
			||||||
	    /// <param name="level">level (等级)从1开始 标准点</param>
 | 
						    /// <param name="level">level (等级)从1开始 标准点</param>
 | 
				
			||||||
	    /// <param name="character">升级的角色,如果没有可不选</param>
 | 
						    /// <param name="character">升级的角色,如果没有可不选</param>
 | 
				
			||||||
        public static void LevelUp(int level, string character)
 | 
						    /// <param name="extra"></param>
 | 
				
			||||||
 | 
						    public static void LevelUp(int level, string character, Dictionary<string, object> extra = null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            LogEvent(EventLevelUp, new Dictionary<string, object>()
 | 
						        var dict = new Dictionary<string, object>()
 | 
				
			||||||
	        {
 | 
						        {
 | 
				
			||||||
		        { ParameterLevel, level },
 | 
							        { ParameterLevel, level },
 | 
				
			||||||
		        { ParameterCharacter, character }
 | 
							        { ParameterCharacter, character }
 | 
				
			||||||
            });
 | 
						        };
 | 
				
			||||||
 | 
						        if (extra != null) dict.AddRange(extra, isOverride:true);
 | 
				
			||||||
 | 
						        
 | 
				
			||||||
 | 
					            LogEvent(EventLevelUp, dict);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 玩家已完成解锁成就时触发。
 | 
					        /// 玩家已完成解锁成就时触发。
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="achievementID">这里的成就ID值项目方自行定义</param>
 | 
					        /// <param name="achievementID">这里的成就ID值项目方自行定义</param>
 | 
				
			||||||
        public static void UnlockAchievement(string achievementID)
 | 
					        public static void UnlockAchievement(string achievementID, Dictionary<string, object> extra = null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            LogEvent(EventUnlockAchievement, new Dictionary<string, object>()
 | 
						        var dict = new Dictionary<string, object>()
 | 
				
			||||||
	        {
 | 
						        {
 | 
				
			||||||
		        { ParameterAchievementId, achievementID },
 | 
							        { ParameterAchievementId, achievementID },
 | 
				
			||||||
            });
 | 
						        };
 | 
				
			||||||
 | 
						        if (extra != null) dict.AddRange(extra, isOverride:true);
 | 
				
			||||||
 | 
						        
 | 
				
			||||||
 | 
					            LogEvent(EventUnlockAchievement, dict);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
| 
						 | 
					@ -53,24 +61,33 @@ namespace Guru
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 玩家已开始挑战某个关卡时触发。
 | 
					        /// 玩家已开始挑战某个关卡时触发。
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="levelName">关卡名称</param>
 | 
					 | 
				
			||||||
        /// <param name="level">关卡数</param>
 | 
					        /// <param name="level">关卡数</param>
 | 
				
			||||||
        /// <param name="itemCategory"></param>
 | 
					        /// <param name="levelName">关卡名称</param>
 | 
				
			||||||
        /// <param name="itemId"></param>
 | 
					        /// <param name="levelType">关卡类型</param>
 | 
				
			||||||
        /// <param name="startType"></param>
 | 
					        /// <param name="levelConfigId">关卡配置表 ID</param>
 | 
				
			||||||
        /// <param name="isReplay"></param>
 | 
					        /// <param name="startType">启动方式</param>
 | 
				
			||||||
 | 
					        /// <param name="isReplay">是否是重玩</param>
 | 
				
			||||||
 | 
					        /// <param name="extra">额外数据</param>
 | 
				
			||||||
        public static void LogLevelStart(int level, string levelName, 
 | 
					        public static void LogLevelStart(int level, string levelName, 
 | 
				
			||||||
	        string itemCategory = "main", string itemId = "", string startType = "play", bool isReplay = false)
 | 
						        string levelType = "main", string levelConfigId = "", string startType = "play", bool isReplay = false, 
 | 
				
			||||||
 | 
						        Dictionary<string, object> extra = null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
	        LogEvent(EventLevelStart, new Dictionary<string, object>()
 | 
						        Dictionary<string, object> dataDict = new Dictionary<string, object>()
 | 
				
			||||||
	        {
 | 
						        {
 | 
				
			||||||
		        { ParameterLevel, level },
 | 
							        { ParameterLevel, level },
 | 
				
			||||||
		        { ParameterLevelName, levelName },
 | 
							        { ParameterLevelName, levelName },
 | 
				
			||||||
		        { ParameterItemCategory, itemCategory },
 | 
							        { ParameterItemCategory, levelType },
 | 
				
			||||||
		        { ParameterItemId, itemId },
 | 
							        { ParameterItemId, levelConfigId },
 | 
				
			||||||
		        { ParameterStartType, startType },
 | 
							        { ParameterStartType, startType },
 | 
				
			||||||
		        { ParameterReplay, isReplay ? "true" : "false" },
 | 
							        { ParameterReplay, isReplay ? "true" : "false" },
 | 
				
			||||||
	        });
 | 
						        };
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
						        if (extra != null)
 | 
				
			||||||
 | 
						        {
 | 
				
			||||||
 | 
							        dataDict.AddRange(extra, isOverride:true);
 | 
				
			||||||
 | 
						        }
 | 
				
			||||||
 | 
						        
 | 
				
			||||||
 | 
						        LogEvent(EventLevelStart, dataDict);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
         
 | 
					         
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
| 
						 | 
					@ -81,7 +98,7 @@ namespace Guru
 | 
				
			||||||
        /// <param name="levelName">关卡名称</param>
 | 
					        /// <param name="levelName">关卡名称</param>
 | 
				
			||||||
        /// <param name="level">关卡数</param>
 | 
					        /// <param name="level">关卡数</param>
 | 
				
			||||||
        [Obsolete("Obsolete method, please use <LogLevelStart> instead. will be discard in next version.")]
 | 
					        [Obsolete("Obsolete method, please use <LogLevelStart> instead. will be discard in next version.")]
 | 
				
			||||||
        public static void LevelStart(string itemCategory, string itemID, string levelName, int level, bool isReplay, bool isContinue)
 | 
					        internal static void LevelStart(string itemCategory, string itemID, string levelName, int level, bool isReplay, bool isContinue)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	        string startType = "play";
 | 
						        string startType = "play";
 | 
				
			||||||
| 
						 | 
					@ -114,8 +131,10 @@ namespace Guru
 | 
				
			||||||
		/// <param name="step">游戏步数【可选】</param>
 | 
							/// <param name="step">游戏步数【可选】</param>
 | 
				
			||||||
		/// <param name="score">游戏分数【可选】</param>
 | 
							/// <param name="score">游戏分数【可选】</param>
 | 
				
			||||||
		/// <param name="isReplay">重玩标记【可选】</param>
 | 
							/// <param name="isReplay">重玩标记【可选】</param>
 | 
				
			||||||
		public static void LevelEnd(string itemCategory, string itemID, string levelName, int level, 
 | 
							[Obsolete("Obsolete method, please use <LogLevelEnd> instead. will be discard in next version.")]
 | 
				
			||||||
			ELevelResult result, int? duration = null, int? step = null, int? score = null, bool isReplay = false)
 | 
							internal static void LevelEnd(string itemCategory, string itemID, string levelName, int level, 
 | 
				
			||||||
 | 
								ELevelResult result, int? duration = null, int? step = null, int? score = null, bool isReplay = false,
 | 
				
			||||||
 | 
								Dictionary<string, object> extra = null)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			var dict = new Dictionary<string, object>()
 | 
								var dict = new Dictionary<string, object>()
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -135,6 +154,8 @@ namespace Guru
 | 
				
			||||||
			if(score != null)
 | 
								if(score != null)
 | 
				
			||||||
				dict[ParameterScore] = score.Value;
 | 
									dict[ParameterScore] = score.Value;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
 | 
								if(extra != null) dict.AddRange(extra, isOverride:true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			LogEvent(EventLevelEnd, dict);
 | 
								LogEvent(EventLevelEnd, dict);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (result == ELevelResult.success)
 | 
								if (result == ELevelResult.success)
 | 
				
			||||||
| 
						 | 
					@ -146,9 +167,21 @@ namespace Guru
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// 关卡结束(Firebase标准事件)
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
 | 
							/// <param name="level"></param>
 | 
				
			||||||
 | 
							/// <param name="result"></param>
 | 
				
			||||||
 | 
							/// <param name="levelName"></param>
 | 
				
			||||||
 | 
							/// <param name="itemCategory"></param>
 | 
				
			||||||
 | 
							/// <param name="itemId"></param>
 | 
				
			||||||
 | 
							/// <param name="duration"></param>
 | 
				
			||||||
 | 
							/// <param name="step"></param>
 | 
				
			||||||
 | 
							/// <param name="score"></param>
 | 
				
			||||||
 | 
							/// <param name="extra"></param>
 | 
				
			||||||
		public static void LogLevelEnd(int level, string result, 
 | 
							public static void LogLevelEnd(int level, string result, 
 | 
				
			||||||
			string levelName = "", string itemCategory = "main", string itemId = "", 
 | 
								string levelName = "", string itemCategory = "main", string itemId = "", 
 | 
				
			||||||
			int? duration = null, int? step = null, int? score = null )
 | 
								int? duration = null, int? step = null, int? score = null, Dictionary<string, object> extra = null)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			bool isSuccess = result.Equals("success");
 | 
								bool isSuccess = result.Equals("success");
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
| 
						 | 
					@ -169,6 +202,8 @@ namespace Guru
 | 
				
			||||||
			if(score != null)
 | 
								if(score != null)
 | 
				
			||||||
				dict[ParameterScore] = score.Value;
 | 
									dict[ParameterScore] = score.Value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if(extra != null) dict.AddRange(extra, isOverride:true);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
			LogEvent(EventLevelEnd, dict);
 | 
								LogEvent(EventLevelEnd, dict);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (isSuccess)
 | 
								if (isSuccess)
 | 
				
			||||||
| 
						 | 
					@ -235,7 +270,8 @@ namespace Guru
 | 
				
			||||||
		/// <param name="item_category">金币获取的方式,通过IAP购买的方式,固定使用<iap_buy>参数值,其余场景自行定义。</param>
 | 
							/// <param name="item_category">金币获取的方式,通过IAP购买的方式,固定使用<iap_buy>参数值,其余场景自行定义。</param>
 | 
				
			||||||
		/// <param name="balance">玩家当前剩余的虚拟货币数量</param>
 | 
							/// <param name="balance">玩家当前剩余的虚拟货币数量</param>
 | 
				
			||||||
		/// <param name="sku">购买商品的product_id(购买时传参)</param>
 | 
							/// <param name="sku">购买商品的product_id(购买时传参)</param>
 | 
				
			||||||
		public static void EarnVirtualCurrency(string virtual_currency_name, int value, string item_category, int balance, string sku)
 | 
							public static void EarnVirtualCurrency(string virtual_currency_name, int value, string item_category, 
 | 
				
			||||||
 | 
							    int balance, string sku, Dictionary<string, object> extra = null)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			var dict = new Dictionary<string, object>()
 | 
								var dict = new Dictionary<string, object>()
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -245,6 +281,8 @@ namespace Guru
 | 
				
			||||||
				["balance"] = balance,
 | 
									["balance"] = balance,
 | 
				
			||||||
				["sku"] = sku,
 | 
									["sku"] = sku,
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
 | 
								if(extra != null) dict.AddRange(extra, isOverride: true);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
			LogEvent(EventEarnVirtualCurrency, dict);
 | 
								LogEvent(EventEarnVirtualCurrency, dict);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -255,15 +293,19 @@ namespace Guru
 | 
				
			||||||
		/// <param name="value">虚拟货币的数量</param>
 | 
							/// <param name="value">虚拟货币的数量</param>
 | 
				
			||||||
		/// <param name="item_category">虚拟货币花费场景</param>
 | 
							/// <param name="item_category">虚拟货币花费场景</param>
 | 
				
			||||||
		/// <param name="balance">玩家当前剩余的虚拟货币数量</param>
 | 
							/// <param name="balance">玩家当前剩余的虚拟货币数量</param>
 | 
				
			||||||
		public static void SpendVirtualCurrency(string virtual_currency_name, int value, string item_category, int balance)
 | 
							public static void SpendVirtualCurrency(string virtual_currency_name, int value, string item_category, 
 | 
				
			||||||
 | 
								int balance, Dictionary<string, object> extra = null)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			LogEvent(EventSpendVirtualCurrency, new Dictionary<string, object>()
 | 
								var dict = new Dictionary<string, object>()
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				[ParameterVirtualCurrencyName] = virtual_currency_name,
 | 
									[ParameterVirtualCurrencyName] = virtual_currency_name,
 | 
				
			||||||
				[ParameterValue] = value,
 | 
									[ParameterValue] = value,
 | 
				
			||||||
				[ParameterItemCategory] = item_category,
 | 
									[ParameterItemCategory] = item_category,
 | 
				
			||||||
				["balance"] = balance,
 | 
									["balance"] = balance,
 | 
				
			||||||
			});
 | 
								};
 | 
				
			||||||
 | 
								if(extra != null) dict.AddRange(extra, isOverride: true);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								LogEvent(EventSpendVirtualCurrency, dict);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	    #endregion
 | 
						    #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -275,15 +317,18 @@ namespace Guru
 | 
				
			||||||
		/// <param name="hp_before">本次行为变化前体力</param>
 | 
							/// <param name="hp_before">本次行为变化前体力</param>
 | 
				
			||||||
		/// <param name="hp">本次行为带来的体力</param>
 | 
							/// <param name="hp">本次行为带来的体力</param>
 | 
				
			||||||
		/// <param name="hp_after">本次行为变化后体力</param>
 | 
							/// <param name="hp_after">本次行为变化后体力</param>
 | 
				
			||||||
		public static void HitPoints(string item_category, int hp_before, int hp, int hp_after)
 | 
							public static void HitPoints(string item_category, int hp_before, int hp, int hp_after, Dictionary<string, object> extra = null)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			LogEvent("hit_points", new Dictionary<string, object>()
 | 
								var dict = new Dictionary<string, object>()
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				[ParameterItemCategory] = item_category,
 | 
									[ParameterItemCategory] = item_category,
 | 
				
			||||||
				["hp_before"] = hp_before,
 | 
									["hp_before"] = hp_before,
 | 
				
			||||||
				["hp"] = hp,
 | 
									["hp"] = hp,
 | 
				
			||||||
				["hp_after"] = hp_after,
 | 
									["hp_after"] = hp_after,
 | 
				
			||||||
			});
 | 
								};
 | 
				
			||||||
 | 
								if(extra != null) dict.AddRange(extra, isOverride: true);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								LogEvent("hit_points", dict);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	    #endregion
 | 
						    #endregion
 | 
				
			||||||
	    
 | 
						    
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue