From 31cb08b6dfea43ea717637cd48101f3f9cdcad84 Mon Sep 17 00:00:00 2001 From: huyufei Date: Thu, 30 May 2024 20:53:50 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E5=AE=8C=E5=96=84=E6=A0=87=E5=87=86?= =?UTF-8?q?=E5=8C=96=E6=89=93=E7=82=B9=E6=8E=A5=E5=8F=A3,=20=E8=A1=A5?= =?UTF-8?q?=E5=85=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E4=BA=8B=E4=BB=B6=E5=B0=81?= =?UTF-8?q?=E8=A3=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1020273 --user=yufei.hu 【中台】【BI】 中台打点标准化, 更新原有的打点和用户属性上报逻辑 https://www.tapd.cn/33527076/s/1147868 --- Runtime/Code/SDK/GuruSDK.Analytics.cs | 570 ++++++++++++++++++++------ Runtime/Code/SDK/GuruSDK.Const.cs | 22 +- 2 files changed, 473 insertions(+), 119 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index 47bd7df..2e8e253 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -60,17 +60,17 @@ namespace Guru #region 游戏打点 /// - /// 游戏启动打点 + /// 游戏启动打点 (level_start) /// /// 关卡Id /// 关卡名称: main_01_9001, daily_challenge_81011 /// 关卡类型: 主线:main - /// 配置/谜题/图片/自定义Id: 101120 + /// 配置/谜题/图片/自定义Id: 101120 /// 关卡开始类型: play:开始游戏;replay:重玩;continue:继续游戏 /// 是否重新开始: true/false /// 扩展数据 public static void LogLevelStart(int levelId, string startType = EventLevelStartModePlay, - string levelType = LevelTypeMain, string levelName = "", string puzzleId = "", + string levelType = LevelTypeMain, string levelName = "", string itemId = "", bool isReplay = false, Dictionary extra = null) { if (!IsInitialSuccess) @@ -79,74 +79,80 @@ namespace Guru return; } - Analytics.LogLevelStart(levelId, levelName, levelType, puzzleId, startType, isReplay, extra); + Analytics.LogLevelStart(levelId, levelName, levelType, itemId, startType, isReplay, extra); } /// - /// 游戏点击 Continue 继续游戏 + /// 游戏点击 Continue 继续游戏 (level_start) (continue) /// /// /// /// - /// + /// /// public static void LogLevelContinue(int levelId, string levelType = LevelTypeMain, - string levelName = "", string puzzleId = "", Dictionary extra = null) + string levelName = "", string itemId = "", Dictionary extra = null) { - LogLevelStart(levelId, EventLevelStartModeContinue, levelType, levelName, puzzleId, true, extra:extra); + LogLevelStart(levelId, EventLevelStartModeContinue, levelType, levelName, itemId, true, extra:extra); } /// - /// 游戏点击 Replay 重玩关卡 + /// 游戏点击 Replay 重玩关卡 (level_start) (replay) /// /// /// /// - /// + /// public static void LogLevelReplay(int levelId, string levelType = LevelTypeMain, - string levelName = "", string puzzleId = "", Dictionary extra = null) + string levelName = "", string itemId = "", Dictionary extra = null) { - LogLevelStart(levelId, EventLevelStartModeReplay,levelType, levelName, puzzleId, true, extra:extra); + LogLevelStart(levelId, EventLevelStartModeReplay,levelType, levelName, itemId, true, extra:extra); } - + /// - /// 关卡结束打点 + /// 关卡结束打点 (level_end) /// /// 关卡Id /// success:成功;fail:失败;exit:退出;timeout:超时;replay:重玩... /// 关卡类型: 主线:main /// 关卡名称: main_01_9001, daily_challenge_81011 - /// 配置/谜题/图片/自定义Id: 101120 + /// 配置/谜题/图片/自定义Id: 101120 /// 关卡完成时长(单位:毫秒) /// 步数(有则上报) /// 分数(有则上报) /// 扩展数据 - public static void LogLevelEnd(int levelId, string result = EventLevelEndSuccess, - string levelType = LevelTypeMain, string levelName = "", string puzzleId = "", - int duration = 0, int? step = null, int? score = null, Dictionary extra = null ) + public static void LogLevelEnd(int levelId, string result = EventLevelEndSuccess, + string levelType = LevelTypeMain, string levelName = "", string itemId = "", + int duration = 0, int? step = null, int? score = null, Dictionary extra = null) { if (!IsInitialSuccess) { - UnityEngine.Debug.LogError($"{Tag} :: LogLevelEnd {levelId} :: Please call first, before you call ."); + UnityEngine.Debug.LogError( + $"{Tag} :: LogLevelEnd {levelId} :: Please call first, before you call ."); return; } - + // 优先打 level_end 事件 + Analytics.LogLevelEnd(levelId, result, levelName, levelType, itemId, duration, step, score, extra); + + // 自动记录关卡属性 if (InitConfig.AutoRecordFinishedLevels) { - if(result == EventLevelEndSuccess){ - if(levelType == LevelTypeMain) + if (result == EventLevelEndSuccess) + { + if (levelType == LevelTypeMain) { if (levelId > Model.SuccessLevelId) Model.SuccessLevelId = levelId; // 自动记录关卡完成次数 } + Model.TotalPlayedCount++; // 自动记录关卡总次数 + + Analytics.LevelEndSuccess(Model.TotalPlayedCount); // 自动 level_end_success } - Analytics.BLevel = Model.SuccessLevelId; // 记录 BLevel Analytics.BPlay = Model.TotalPlayedCount; // 记录 BPlay } - - Analytics.LogLevelEnd(levelId, result, levelName, levelType, puzzleId, duration, step, score, extra); + } /// @@ -158,47 +164,80 @@ namespace Guru /// /// /// - public static void LevelFirstEnd(string levelType, string levelName, int level, - string result = EventLevelEndSuccess, int? duration = null, Dictionary extra = null) + public static void LogLevelFirstEnd(string levelType, string levelName, int level, + string result = EventLevelEndSuccess, int duration = 0, Dictionary extra = null) { Analytics.LevelFirstEnd(levelType, levelName, level, result, duration, extra); } + /// + /// 关卡总胜利次数打点 (level_end_success_{num}) + /// + /// 完成总关数累计值 + /// /// 扩展参数 + public static void LogLevelEndSuccess(int bPlay, Dictionary extra = null) + { + if (InitConfig.AutoRecordFinishedLevels) return; + Analytics.LevelEndSuccess(bPlay, extra); + } /// - /// 游戏失败打点 - /// 需要为游戏记录详细的失败原因 + /// 游戏失败打点 (level_end) (fail) /// + /// + /// + /// + /// + /// + /// + /// + /// public static void LogLevelFail(int levelId, - string levelType = LevelTypeMain, string levelName = "", string puzzleId = "", + string levelType = LevelTypeMain, string levelName = "", string itemId = "", int duration = 0, int? step = null, int? score = null , Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndFail, levelType, levelName, puzzleId, duration, step, score, extra); + LogLevelEnd(levelId, EventLevelEndFail, levelType, levelName, itemId, duration, step, score, extra); } /// - /// 因退出关卡导致游戏失败 + /// 游戏失败退出 (level_end) (exit) /// + /// + /// + /// + /// + /// + /// + /// + /// public static void LogLevelFailExit(int levelId, - string levelType = LevelTypeMain, string levelName = "", string puzzleId = "", + string levelType = LevelTypeMain, string levelName = "", string itemId = "", int duration = 0, int? step = null, int? score = null, Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndExit, levelType, levelName, puzzleId, duration, step, score, extra); + LogLevelEnd(levelId, EventLevelEndExit, levelType, levelName, itemId, duration, step, score, extra); } /// - /// 因关卡超时导致游戏失败 + /// 关卡超时失败 (level_end) (timeout) /// + /// + /// + /// + /// + /// + /// + /// + /// public static void LogLevelFailTimeout(int levelId, - string levelType = LevelTypeMain, string levelName = "", string puzzleId = "", + string levelType = LevelTypeMain, string levelName = "", string itemId = "", int duration = 0, int? step = null, int? score = null, Dictionary extra = null) { - LogLevelEnd(levelId, EventLevelEndTimeout, levelType, levelName, puzzleId, duration, step, score, extra); + LogLevelEnd(levelId, EventLevelEndTimeout, levelType, levelName, itemId, duration, step, score, extra); } /// - /// 玩家(角色)升级事件 + /// 玩家(角色)升级事件 (level_up) /// /// /// @@ -214,20 +253,58 @@ namespace Guru } /// - /// 玩家解锁成就 + /// 玩家解锁成就 (unlock_achievement) /// - /// + /// /// 扩展数据 - public static void LogAchievement(string achievementName, Dictionary extra = null) + public static void LogAchievement(string achievementId, Dictionary extra = null) { if (!IsInitialSuccess) { - UnityEngine.Debug.LogError($"{Tag} :: LogAchievement {achievementName} :: Please call first, before you call ."); + UnityEngine.Debug.LogError($"{Tag} :: LogAchievement {achievementId} :: Please call first, before you call ."); return; } - Analytics.UnlockAchievement(achievementName, extra); + Analytics.UnlockAchievement(achievementId, extra); } - + + /// + /// 玩家体力变化 (hp_points) + /// + /// 场景 + /// HP 增量值 + /// HP 初始值 + /// HP 结算值 + /// 额外数据 + public static void LogHpPoints(string scene, int hp, int hpBefore, int hpAfter, + Dictionary extra = null) + { + if (!IsInitialSuccess) + { + UnityEngine.Debug.LogError( + $"{Tag} :: LogHpPoints {hp} :: Please call first, before you call ."); + return; + } + + var dict = new Dictionary() + { + [Consts.ParameterItemCategory] = scene, + ["hp"] = hp, + ["hp_before"] = hpBefore, + ["hp_after"] = hpAfter, + }; + + if (extra != null) + { + foreach (var k in extra.Keys) + { + dict[k] = extra[k]; + } + } + + LogEvent(Consts.EventHpPoints, dict); + } + + #endregion #region 用户属性 @@ -291,28 +368,38 @@ namespace Guru public static void SetUserBLevel(int blevel) { + if (!InitConfig.AutoRecordFinishedLevels) + { + Model.SuccessLevelId = blevel; + } + SetUserProperty(Consts.PropertyLevel, $"{blevel}"); } public static void SetUserBPlay(int bplay) { + if (!InitConfig.AutoRecordFinishedLevels) + { + Model.TotalPlayedCount = bplay; + } + SetUserProperty(Consts.PropertyPlay, $"{bplay}"); } /// /// 上报用户全部的 Coin (当前值) /// - /// - public static void SetUserTotalCoins(int totalCoins) + /// + public static void SetUserCoins(int coins) { - SetUserProperty(Consts.PropertyCoin, $"{totalCoins}"); + SetUserProperty(Consts.PropertyCoin, $"{coins}"); } /// /// 上报用户免费金币的 数量 (累加值) /// /// - public static void SetUserFreeCoins(int freeCoins) + public static void SetUserNonIapCoins(int freeCoins) { SetUserProperty(Consts.PropertyNonIAPCoin, $"{freeCoins}"); } @@ -390,10 +477,10 @@ namespace Guru SetUserPaidCoins(0); // iap_coin if(!HasUserPropertyKey(Consts.PropertyNonIAPCoin)) - SetUserFreeCoins(0); // non_iap_coin + SetUserNonIapCoins(0); // non_iap_coin if(!HasUserPropertyKey(Consts.PropertyCoin)) - SetUserTotalCoins(0);// coin + SetUserCoins(0);// coin if (!HasUserPropertyKey(Consts.PropertyGrade)) SetUserGrade(0); // grade @@ -465,42 +552,34 @@ namespace Guru /// - /// 当付费页面打开时调用 iap_imp + /// 当付费页面打开时调用 (iap_imp) /// /// 付费页场景名称 /// 列表中首个商品的 ProductId - public static void OnIAPImp(string scene, string productId = "") + public static void LogIAPImp(string scene, Dictionary extra = null) { - if (string.IsNullOrEmpty(productId)) - { - productId = TryGetFirstProductId(); - } - Analytics.IAPImp(scene, productId); + Analytics.IAPImp(scene, extra); } /// - /// 当付费页面关闭时调用 iap_close + /// 当付费页面关闭时调用 (iap_close) /// /// /// - public static void OnIAPClose(string scene, string productId = "") + public static void LogIAPClose(string scene, Dictionary extra = null) { - if (string.IsNullOrEmpty(productId)) - { - productId = TryGetCurrentProductId(); - } - - Analytics.IAPClose(scene, productId); + Analytics.IAPClose(scene, extra); } /// - /// 当点击 IAP 商品按钮的时候调用 iap_clk + /// 当点击 IAP 商品按钮的时候调用 (iap_clk) /// /// /// - public static void OnIAPClick(string scene = "", string productId = "") + /// + public static void LogIAPClick(string scene, string productId, string basePlan = "", string offerId = "", Dictionary extra = null) { - Analytics.IAPClick(scene, productId); + Analytics.IAPClick(scene, productId, basePlan, offerId, extra); } #endregion @@ -516,7 +595,8 @@ namespace Guru //---------------------------------------- EARN ---------------------------------------- /// - /// 基础收入接口. 可直接调用此接口上报相关参数 + /// 基础收入接口 (earn_virtual_currency) + /// 可直接调用此接口上报相关参数 /// 获取虚拟货币/道具. /// 基础接口, 不推荐项目组直接调用 /// 请直接调用其他对应场景的统计接口 @@ -528,7 +608,7 @@ namespace Guru /// 当前关卡或者人物等级名称 /// 购买道具名称 /// 购买场景如 Store, Workbench, Sign, Ads.... - public static void EarnVirtualCurrency(string currencyName, + public static void LogEarnVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "", string levelName = "", string scene = "", Dictionary extra = null) @@ -539,7 +619,7 @@ namespace Guru /// - /// 赚取组合: 货币+道具 + /// 赚取组合: 货币+道具 (earn_virtual_currency) (props) /// /// /// @@ -549,7 +629,7 @@ namespace Guru /// /// /// - private static void EarnVirtualCurrencyAndProps(string currencyName, + private static void LogEarnVirtualCurrencyAndProps(string currencyName, int value = 0, int balance = 0, string category = "", string itemName = "", string levelName = "", string scene = Consts.ParameterDefaultScene, @@ -558,7 +638,7 @@ namespace Guru //---- Currency ----- if (value > 0) { - EarnVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra); + LogEarnVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra); } //---- Props -------- if (null != props) @@ -566,14 +646,14 @@ namespace Guru int i = 0; while (i < props.Length) { - EarnVirtualCurrency(props[i], 1, 0, category, itemName, levelName, scene, extra); + LogEarnVirtualCurrency(props[i], 1, 0, category, itemName, levelName, scene, extra); i++; } } } /// - /// 签到奖励. 获得货币/道具 + /// 签到奖励. 获得货币/道具 (earn_virtual_currency) (reward:sign) ///
  • 通常类型: Coin 收入
  • ///
  • 特殊类型: Coin + Props (道具列表)
  • ///
  • 特殊类型: Props (道具列表)
  • @@ -584,19 +664,19 @@ namespace Guru /// 当前关卡名称 /// 应用场景 /// 获取的道具名称列表 - public static void EarnVirtualCurrencyBySign(string currencyName, + public static void LogEarnVirtualCurrencyBySign(string currencyName, int value = 0, int balance = 0, string levelName = "", - string scene = "home", string[] props = null, Dictionary extra = null) + string scene = "home_page", string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryReward; string itemName = "sign"; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); + LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// - /// IAP 付费购买. 获得货币/道具 + /// IAP 付费购买. 获得货币/道具 (earn_virtual_currency) (iap_buy:sku) ///
  • 通常类型: Coin 收入
  • ///
  • 特殊类型: Coin + Props (道具列表)
  • ///
  • 特殊类型: Props (道具列表)
  • @@ -608,18 +688,18 @@ namespace Guru /// 当前关卡名称 /// 应用场景 /// 获取的道具名称列表 - public static void EarnVirtualCurrencyByIAP(string currencyName, string productId, + public static void LogEarnVirtualCurrencyByIAP(string currencyName, string productId, int value = 0, int balance = 0, string levelName = "", string scene = "store", string[] props = null, Dictionary extra = null) { string category = Consts.CurrencyCategoryIAP; // string itemName = productId; string itemName = "sku"; - EarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); + LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// - /// 看广告获取到货币/道具 + /// 看广告获取到货币/道具 (earn_virtual_currency) (reward:ads) ///
  • 通常类型: Coin 收入
  • ///
  • 特殊类型: Coin + Props (道具列表)
  • ///
  • 特殊类型: Props (道具列表)
  • @@ -630,17 +710,17 @@ namespace Guru /// 当前关卡名称 /// 应用场景 /// 获取的道具名称列表 - public static void EarnVirtualCurrencyByAds(string currencyName, + public static void LogEarnVirtualCurrencyByAds(string currencyName, int value = 0, int balance = 0, string levelName = "", 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, extra); + LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// - /// 使用了金币半价 + 看广告获取到货币/道具 + /// 使用了金币半价 + 看广告获取到货币/道具 (earn_virtual_currency) (bonus:ads) ///
  • 通常类型: Coin 收入
  • ///
  • 特殊类型: Coin + Props (道具列表)
  • ///
  • 特殊类型: Props (道具列表)
  • @@ -651,17 +731,17 @@ namespace Guru /// 当前关卡名称 /// 应用场景 /// 获取的道具名称列表 - public static void EarnVirtualCurrencyByPaidAds(string currencyName, + public static void LogEarnVirtualCurrencyByPaidAds(string currencyName, int value = 0, int balance = 0, string levelName = "", 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, extra); + LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// - /// 过关奖励获取到货币/道具 + /// 过关奖励获取到货币/道具 (earn_virtual_currency) (reward:level) ///
  • 通常类型: Coin 收入
  • ///
  • 特殊类型: Coin + Props (道具列表)
  • ///
  • 特殊类型: Props (道具列表)
  • @@ -672,18 +752,19 @@ namespace Guru /// 当前关卡名称 /// 应用场景 /// 获取的道具名称列表 - public static void EarnVirtualCurrencyByLevelComplete(string currencyName, + public static void LogEarnVirtualCurrencyByLevelComplete(string currencyName, int value = 0, int balance = 0, string levelName = "", 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, extra); + LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// - /// 通过使用 Currency 购买获得 Prop (记录 Prop 增加的打点, 消费游戏内货币) + /// 通过使用 Currency 购买获得 Prop (earn_virtual_currency) (reward:level) + /// 记录 Prop 增加的打点, 消费游戏内货币 /// /// 货币名称 /// 获取的道具名称列表 @@ -691,17 +772,17 @@ namespace Guru /// 赚取金额 /// 货币总量(累加后) /// 当前关卡名称 - public static void EarnPropsByVirtualCurrency(string currencyName, string[] props, + public static void LogEarnPropsByVirtualCurrency(string currencyName, string[] props, string scene = Consts.ParameterDefaultScene, 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, extra); + LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } /// - /// 通过道具交换/合成或得了其他道具 + /// 通过道具交换/合成或得了其他道具 (earn_virtual_currency) (igb:coin) /// /// /// @@ -709,17 +790,17 @@ namespace Guru /// /// /// - public static void EarnPropByProp(string propName, string otherName, + public static void LogEarnPropByProp(string propName, string otherName, string scene = Consts.ParameterDefaultScene, int value = 1, int balance = 0, string levelName = "", Dictionary extra = null) { string category = Consts.CurrencyCategoryIGB; - EarnVirtualCurrency(propName, value, balance, category, otherName, levelName, scene, extra); + LogEarnVirtualCurrency(propName, value, balance, category, otherName, levelName, scene, extra); } /// - /// 通过转盘或者抽奖, 获取货币/道具 + /// 通过转盘或者抽奖, 获取货币/道具 (earn_virtual_currency) (igb:lottery) ///
  • 通常类型: Coin 收入
  • ///
  • 特殊类型: Coin + Props (道具列表)
  • ///
  • 特殊类型: Props (道具列表)
  • @@ -730,13 +811,13 @@ namespace Guru /// 当前关卡名称 /// 应用场景 /// 获取的道具名称列表 - public static void EarnVirtualCurrencyByLottery(string currencyName, + public static void LogEarnVirtualCurrencyByLottery(string currencyName, int value = 0, int balance = 0, string levelName = "", 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, extra); + LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); } @@ -744,7 +825,7 @@ namespace Guru /// - /// 基础花费虚拟货币/道具 + /// 基础花费虚拟货币/道具 (spend_virtual_currency) /// 基础接口, 不推荐项目组直接调用 /// 请直接调用其他对应场景的统计接口 /// @@ -755,7 +836,7 @@ namespace Guru /// 当前关卡或者人物等级名称 /// 购买道具名称 /// 购买场景如 Store, Workbench, Sign, Ads.... - public static void SpendVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "", + public static void LogSpendVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "", string levelName = "", string scene = "", Dictionary extra = null) { Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra); @@ -763,7 +844,7 @@ namespace Guru /// - /// 消耗货币购买道具 + /// 消耗货币购买道具 (spend_virtual_currency) (props) /// /// /// @@ -771,15 +852,15 @@ namespace Guru /// /// /// - public static void SpendVirtualCurrencyWithProp(string currencyName, string prop, + public static void LogSpendVirtualCurrencyWithProp(string currencyName, string prop, int value, int balance, string levelName = "", string scene = "", Dictionary extra = null) { - SpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene, extra); + LogSpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene, extra); } /// - /// 消耗货币购买道具 (含多个) + /// 消耗货币购买道具 (含多个) (spend_virtual_currency) (props) /// /// /// @@ -787,24 +868,24 @@ namespace Guru /// /// /// - public static void SpendVirtualCurrencyWithProps(string currencyName, string[] props, + public static void LogSpendVirtualCurrencyWithProps(string currencyName, string[] props, int value, int balance, string levelName = "", string scene = "", Dictionary extra = null) { - string category = Consts.CurrencyCategoryProp; + string category = Consts.CurrencyCategoryProps; if (props != null && props.Length > 0) { int i = 0; while (i < props.Length) { - SpendVirtualCurrency(currencyName, value, balance, category, props[i], levelName, scene, extra); + LogSpendVirtualCurrency(currencyName, value, balance, category, props[i], levelName, scene, extra); i++; } } } /// - /// 消耗货币购买礼包或组合 + /// 消耗货币购买礼包或组合 (spend_virtual_currency) (bundle) /// /// /// @@ -812,15 +893,15 @@ namespace Guru /// /// /// - public static void SpendVirtualCurrencyWithBundle(string currencyName, string bundle, + public static void LogSpendVirtualCurrencyWithBundle(string currencyName, string bundle, int value, int balance, string levelName = "", string scene = "", Dictionary extra = null) { - SpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene, extra); + LogSpendVirtualCurrencyWithBundles(currencyName, new string[] {bundle}, value, balance, levelName, scene, extra); } /// - /// 消耗货币购买礼包或组合 (含多个) + /// 消耗货币购买礼包或组合 (复数) (spend_virtual_currency) (bundle) /// /// /// @@ -828,7 +909,7 @@ namespace Guru /// /// /// - public static void SpendVirtualCurrencyWithBundles(string currencyName, string[] bundles, + public static void LogSpendVirtualCurrencyWithBundles(string currencyName, string[] bundles, int value, int balance, string levelName = "", string scene = "", Dictionary extra = null) { @@ -838,14 +919,14 @@ namespace Guru int i = 0; while (i < bundles.Length) { - SpendVirtualCurrency(currencyName, value, balance, category, bundles[i], levelName, scene, extra); + LogSpendVirtualCurrency(currencyName, value, balance, category, bundles[i], levelName, scene, extra); i++; } } } /// - /// 消耗物品, 交换其他物品 + /// 消耗物品, 交换其他物品 (spend_virtual_currency) (prop) /// /// /// @@ -853,12 +934,267 @@ namespace Guru /// /// /// - public static void SpendPropWithProp(string propName, string otherName, + public static void LogSpendPropWithProp(string propName, string otherName, int value, int balance, 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, extra); + LogSpendVirtualCurrency(propName, value, balance, category, otherName, levelName, scene, extra); + } + + + #endregion + + #region ATT 二次引导弹窗 + + /// + /// ATT 二次引导弹窗展示 (att_reguide_imp) + /// + /// 引导样式名称 + /// 第几次展示 + /// 举例安装日期的天数 + /// 扩展数据 + public static void LogAttReguideImp(string type, + int showTimes = 1, int installDays = 0, Dictionary extra = null) + { + var dict = new Dictionary() + { + ["type"] = type, + ["show_times"] = showTimes, + ["install_days"] = installDays, + }; + + if (extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra); + LogEvent(Consts.EventAttReguideImp, dict); + } + + /// + /// ATT 二次引导弹窗点击 (att_reguide_clk) + /// + /// 引导样式名称 + /// 第几次展示 + /// 举例安装日期的天数 + /// 点击引导页的动作:dissmiss/go + /// 扩展数据 + public static void LogAttReguideClick(string type, string action, + int showTimes = 1, int installDays = 0, Dictionary extra = null) + { + var dict = new Dictionary() + { + ["type"] = type, + ["show_times"] = showTimes, + ["install_days"] = installDays, + ["action"] = action, + }; + + if (extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra); + LogEvent(Consts.EventAttReguideClk, dict); + } + + /// + /// ATT 二次引导弹窗展示结果 (att_reguide_result) + /// + /// 引导样式名称 + /// 第几次展示 + /// 举例安装日期的天数 + /// 点击引导页的动作:dissmiss/go + /// 结果字段:authorized, denied, restricted, notDetermined + /// 扩展数据 + public static void LogAttReguideResult(string type, string action, string result, + int showTimes = 1, int installDays = 0, Dictionary extra = null) + { + var dict = new Dictionary() + { + ["type"] = type, + ["show_times"] = showTimes, + ["install_days"] = installDays, + ["action"] = action, + [Consts.ParameterItemCategory] = result, + }; + + if (extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra); + LogEvent(Consts.EventAttReguideResult, dict); + } + + + #endregion + + #region 教程引导 + + /// + /// 教程开始 + /// + /// 扩展数据 + public static void LogTutorialBegin(Dictionary extra = null) + { + LogEvent(Consts.EventTutorialBegin, extra); + } + + /// + /// 教程开始 + /// + /// 教程步骤 + /// 扩展数据 + public static void LogTutorialImp(int step, Dictionary extra = null) + { + string key = Consts.EventTutorialImp.Replace("{0}", step.ToString()); + LogEvent(key, extra); + } + + /// + /// 教程开始 + /// + /// 教程步骤 + /// 扩展数据 + public static void LogTutorialNextClick(int step, Dictionary extra = null) + { + string key = Consts.EventTutorialNextClick.Replace("{0}", step.ToString()); + LogEvent(key, extra); + } + + /// + /// 教程结束 + /// + /// 扩展数据 + public static void LogTutorialComplete(Dictionary extra = null) + { + LogEvent(Consts.EventTutorialComplete, extra); + } + + /// + /// 教程页面关闭 + /// + /// 扩展数据 + public static void LogTutorialClose(Dictionary extra = null) + { + LogEvent(Consts.EventTutorialClose, extra); + } + #endregion + + #region 消息权限弹窗打点 + + /// + /// 通知栏请求权限展示时触发 (noti_perm_imp) + /// + /// 弹窗样式 + /// 请求弹窗的次数 + /// 展现弹窗的次数 + /// 点击 deny 的次数 + /// 弹窗触发来源 + /// 弹窗场景 + /// 扩展参数 + public static void LogNotiPermImp(int requestTimes, int showTimes, int deniedTimes, string promptTrigger,string style = "default", string scene = "", Dictionary extra = null) + { + var dict = new Dictionary() + { + [Consts.ParameterItemCategory] = style, + ["request_times"] = requestTimes, + ["show_times"] = showTimes, + ["denied_times"] = deniedTimes, + ["prompt_trigger"] = promptTrigger, + }; + + if (!string.IsNullOrEmpty(scene)) + dict[Consts.ParameterItemName] = scene; + + if (extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra); + LogEvent(Consts.EventNotiPermImp, dict); + } + + /// + /// 得到权限结果时触发 (noti_perm_result) + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void LogNotiPermResult( int requestTimes, int showTimes, int deniedTimes, string result, string promptTrigger, string style = "default", string scene = "", Dictionary extra = null) + { + var dict = new Dictionary() + { + ["request_times"] = requestTimes, + ["show_times"] = showTimes, + ["denied_times"] = deniedTimes, + ["prompt_trigger"] = promptTrigger, + ["result"] = result, + [Consts.ParameterItemCategory] = style, + }; + + if (!string.IsNullOrEmpty(scene)) + dict[Consts.ParameterItemName] = scene; + + if (extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra); + LogEvent(Consts.EventNotiPermResult, dict); + } + + /// + /// 说明性通知栏权限引导展示时触发 (noti_perm_rationale_imp) + /// + /// 引导页的名称,自定义 + /// + /// + public static void LogNotiPermRationaleImp(string pageName, string scene = "", Dictionary extra = null) + { + var dict = new Dictionary() + { + [Consts.ParameterItemCategory] = pageName, + }; + + if (!string.IsNullOrEmpty(scene)) + dict[Consts.ParameterItemName] = scene; + + if (extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra); + LogEvent(Consts.EventNotiPermRationaleImp, dict); + } + + /// + /// 说明性通知栏权限引导结果时触发 (noti_perm_rationale_result) + /// + /// + /// + /// + /// + public static void LogNotiPermRationaleResult(string result, string pageName, string scene = "", Dictionary extra = null) + { + var dict = new Dictionary() + { + ["result"] = result, + [Consts.ParameterItemCategory] = pageName, + }; + + if (!string.IsNullOrEmpty(scene)) + dict[Consts.ParameterItemName] = scene; + + if (extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra); + LogEvent(Consts.EventNotiPermRationaleResult, dict); + } + + #endregion + + #region 错误时间上报 + + /// + /// 上报错误事件 + /// + /// + /// + /// + /// + public static void LogDevAudit(string errorCode, string err, string country = "", string network = "") + { + var dict = new Dictionary() + { + [Consts.ParameterItemCategory] = "error_event", + [Consts.ParameterItemName] = errorCode, + ["err"] = err, + ["country"] = country, + ["network"] = network, + }; + LogEvent(Consts.EventDevAudit, dict); } diff --git a/Runtime/Code/SDK/GuruSDK.Const.cs b/Runtime/Code/SDK/GuruSDK.Const.cs index 4d02956..cf36410 100644 --- a/Runtime/Code/SDK/GuruSDK.Const.cs +++ b/Runtime/Code/SDK/GuruSDK.Const.cs @@ -36,9 +36,26 @@ namespace Guru public const string EventShare = "share"; public const string EventSignUp = "sign_up"; public const string EventSpendVirtualCurrency = "spend_virtual_currency"; - public const string EventTutorialBegin = "tutorial_begin"; - public const string EventTutorialComplete = "tutorial_complete"; public const string EventUnlockAchievement = "unlock_achievement"; + public const string EventHpPoints = "hp_points"; + + public const string EventAttReguideImp = "att_reguide_imp"; + public const string EventAttReguideClk = "att_reguide_clk"; + public const string EventAttReguideResult = "att_reguide_result"; + + public const string EventTutorialBegin = "tutorial_begin"; + public const string EventTutorialImp= "tutorial_{0}_imp"; + public const string EventTutorialNextClick= "tutorial_{0}_next_clk"; + public const string EventTutorialComplete= "tutorial_complete"; + public const string EventTutorialClose = "tutorial_close"; + + public const string EventNotiPermImp = "noti_perm_imp"; + public const string EventNotiPermResult = "noti_perm_result"; + public const string EventNotiPermRationaleImp = "noti_perm_rationale_imp"; + public const string EventNotiPermRationaleResult = "noti_perm_rationale_result"; + + public const string EventDevAudit = "dev_audit"; + public const string EventViewCart = "view_cart"; public const string EventViewItem = "view_item"; public const string EventViewItemList = "view_item_list"; @@ -228,6 +245,7 @@ namespace Guru public const string CurrencyCategoryIGC = "igc"; // In game currency public const string CurrencyCategoryIGB = "igb"; // In game barter public const string CurrencyCategoryProp = "prop"; // prop + public const string CurrencyCategoryProps = "props"; // props public const string CurrencyCategoryBundle = "bundle"; // prop groups