update: 完善标准化打点接口, 补全自定义事件封装接口
--story=1020273 --user=yufei.hu 【中台】【BI】 中台打点标准化, 更新原有的打点和用户属性上报逻辑 https://www.tapd.cn/33527076/s/1147868 Signed-off-by: huyufei <yufei.hu@castbox.fm>hotfix/v1.0.12.2
parent
aca914ab02
commit
5882d213c3
|
|
@ -133,39 +133,27 @@ namespace Guru
|
|||
|
||||
LogEvent(EventLevelEnd, dict);
|
||||
|
||||
if (isSuccess)
|
||||
{
|
||||
int lv = BPlay;
|
||||
if (lv == 0) lv = level;
|
||||
LevelEndSuccess(lv, levelType, itemId);
|
||||
}
|
||||
// if (isSuccess)
|
||||
// {
|
||||
// int lv = BPlay;
|
||||
// if (lv == 0) lv = level;
|
||||
// LevelEndSuccess(lv, levelType, itemId);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新用户通过第几关(仅记录前n关,根据项目自行确定,不区分关卡类型)[买量用]
|
||||
/// </summary>
|
||||
/// <param name="level">总计完成的管卡数 (b_play)</param>
|
||||
/// <param name="levelType"></param>
|
||||
/// <param name="itemId">棋局id /图片id</param>
|
||||
public static void LevelEndSuccess( int level, string levelType = "", string itemId = "")
|
||||
/// <param name="extra"></param>
|
||||
public static void LevelEndSuccess( int level, Dictionary<string, object> extra = null)
|
||||
{
|
||||
if (level > GuruSettings.Instance.AnalyticsSetting.LevelEndSuccessNum)
|
||||
return;
|
||||
|
||||
string eventName = $"level_end_success_{level}";
|
||||
var dict = new Dictionary<string, object>()
|
||||
{
|
||||
{ ParameterLevel, level },
|
||||
};
|
||||
|
||||
if(!string.IsNullOrEmpty(levelType))
|
||||
dict[ParameterItemCategory] = levelType;
|
||||
if(!string.IsNullOrEmpty(itemId))
|
||||
dict[ParameterItemId] = itemId;
|
||||
|
||||
LogEvent(eventName, dict, new EventSetting()
|
||||
LogEvent(eventName, extra, new EventSetting()
|
||||
{
|
||||
EnableFirebaseAnalytics = true,
|
||||
EnableFacebookAnalytics = true,
|
||||
|
|
@ -177,7 +165,7 @@ namespace Guru
|
|||
/// 第一次通关打点
|
||||
/// </summary>
|
||||
public static void LevelFirstEnd(string levelType, string levelName, int level,
|
||||
string result, int? duration = null, Dictionary<string, object> extra = null)
|
||||
string result, int duration = 0, Dictionary<string, object> extra = null)
|
||||
{
|
||||
var dict = new Dictionary<string, object>()
|
||||
{
|
||||
|
|
@ -188,8 +176,8 @@ namespace Guru
|
|||
{ ParameterResult, result },
|
||||
};
|
||||
|
||||
if (duration != null)
|
||||
dict[ParameterDuration] = duration.Value;
|
||||
if (duration > 0)
|
||||
dict[ParameterDuration] = duration;
|
||||
if (extra != null)
|
||||
dict.AddRange(extra, isOverride: true);
|
||||
|
||||
|
|
@ -455,45 +443,60 @@ namespace Guru
|
|||
#region Analytics Game IAP 游戏内购打点
|
||||
|
||||
/// <summary>
|
||||
/// app 内弹出的付费引导
|
||||
/// 当付费页面打开时调用(iap_imp)
|
||||
/// </summary>
|
||||
/// <param name="itemCategory">界面跳转的来源</param>
|
||||
/// <param name="productID">product id,多个产品用逗号分隔,第一个商品id放主推商品id</param>
|
||||
public static void IAPImp(string itemCategory, string productID)
|
||||
/// <param name="scene">界面跳转的来源</param>
|
||||
/// <param name="extra">扩展参数</param>
|
||||
public static void IAPImp(string scene, Dictionary<string, object> extra = null)
|
||||
{
|
||||
LogEvent(EventIAPImp, new Dictionary<string, object>()
|
||||
var dict = new Dictionary<string, object>()
|
||||
{
|
||||
{ ParameterItemCategory, itemCategory },
|
||||
{ ParameterItemName, productID },
|
||||
});
|
||||
{ ParameterItemCategory, scene },
|
||||
};
|
||||
if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
|
||||
|
||||
LogEvent(EventIAPImp, dict);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// app 内弹出的付费引导
|
||||
/// 当付费页面关闭时调用(iap_close)
|
||||
/// </summary>
|
||||
/// <param name="itemCategory">界面跳转的来源</param>
|
||||
/// <param name="productID">product id,多个产品用逗号分隔,第一个商品id放主推商品id</param>
|
||||
public static void IAPClose(string itemCategory, string productID)
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="extra"></param>
|
||||
public static void IAPClose(string scene, Dictionary<string, object> extra = null)
|
||||
{
|
||||
LogEvent(EventIAPClose, new Dictionary<string, object>()
|
||||
var dict = new Dictionary<string, object>()
|
||||
{
|
||||
{ ParameterItemCategory, itemCategory },
|
||||
{ ParameterItemName, productID },
|
||||
});
|
||||
{ ParameterItemCategory, scene },
|
||||
};
|
||||
if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
|
||||
|
||||
LogEvent(EventIAPClose, dict);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// app 内弹出的付费引导
|
||||
/// 点击付费按钮时调用 (iap_clk)
|
||||
/// </summary>
|
||||
/// <param name="itemCategory">界面跳转的来源</param>
|
||||
/// <param name="productID">product id,多个产品用逗号分隔,第一个商品id放主推商品id</param>
|
||||
public static void IAPClick(string itemCategory, string productID)
|
||||
/// <param name="scene">支付场景</param>
|
||||
/// <param name="productId">道具的 sku</param>
|
||||
/// <param name="basePlanId">offer 的 basePlanId</param>
|
||||
/// <param name="offerId">offer 的 offerId</param>
|
||||
/// <param name="extra">扩展参数</param>
|
||||
public static void IAPClick(string scene, string productId, string basePlanId = "", string offerId = "", Dictionary<string, object> extra = null)
|
||||
{
|
||||
LogEvent(EventIAPClick, new Dictionary<string, object>()
|
||||
string sku = productId;
|
||||
if (!string.IsNullOrEmpty(offerId) && !string.IsNullOrEmpty(basePlanId))
|
||||
{
|
||||
{ ParameterItemCategory, itemCategory },
|
||||
{ ParameterItemName, productID },
|
||||
});
|
||||
sku = $"{productId}:{basePlanId}:{offerId}"; // 上报三连 ID
|
||||
}
|
||||
var dict = new Dictionary<string, object>()
|
||||
{
|
||||
{ ParameterItemCategory, scene },
|
||||
{ ParameterItemName, sku },
|
||||
};
|
||||
if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
|
||||
|
||||
LogEvent(EventIAPClick, dict);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -690,6 +693,10 @@ namespace Guru
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,15 +217,26 @@ namespace Guru
|
|||
FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
||||
}
|
||||
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>(extras);
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
if (extras != null)
|
||||
{
|
||||
foreach (var k in extras.Keys)
|
||||
{
|
||||
dict.Add(k, extras[k]);
|
||||
}
|
||||
}
|
||||
|
||||
if (eventSetting.EnableAdjustAnalytics)
|
||||
{
|
||||
AdjustEvent adjustEvent = Analytics.CreateAdjustEvent(eventName);
|
||||
if (adjustEvent != null)
|
||||
{
|
||||
foreach (var kv in dict)
|
||||
if (dict.Count > 0)
|
||||
{
|
||||
adjustEvent.AddEventParameter(kv.Key, kv.Value.ToString());
|
||||
foreach (var kv in dict)
|
||||
{
|
||||
adjustEvent.AddEventParameter(kv.Key, kv.Value.ToString());
|
||||
}
|
||||
}
|
||||
Adjust.trackEvent(adjustEvent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
|
||||
namespace Guru
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class GuruSDKUtils
|
||||
{
|
||||
|
|
@ -22,5 +24,28 @@ namespace Guru
|
|||
}
|
||||
return new Color(r, g, b, a);
|
||||
}
|
||||
|
||||
public static Dictionary<string, object> MergeDictionary(Dictionary<string, object> source, Dictionary<string, object> other)
|
||||
{
|
||||
int len = source?.Count ?? 0 + other?.Count ?? 0;
|
||||
if (len == 0) len = 10;
|
||||
var newDict = new Dictionary<string, object>(len);
|
||||
if (source != null)
|
||||
{
|
||||
foreach (var k in source.Keys)
|
||||
{
|
||||
newDict[k] = source[k];
|
||||
}
|
||||
}
|
||||
|
||||
if (other != null)
|
||||
{
|
||||
foreach (var k in other.Keys)
|
||||
{
|
||||
newDict[k] = other[k];
|
||||
}
|
||||
}
|
||||
return newDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue