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);
|
LogEvent(EventLevelEnd, dict);
|
||||||
|
|
||||||
if (isSuccess)
|
// if (isSuccess)
|
||||||
{
|
// {
|
||||||
int lv = BPlay;
|
// int lv = BPlay;
|
||||||
if (lv == 0) lv = level;
|
// if (lv == 0) lv = level;
|
||||||
LevelEndSuccess(lv, levelType, itemId);
|
// LevelEndSuccess(lv, levelType, itemId);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新用户通过第几关(仅记录前n关,根据项目自行确定,不区分关卡类型)[买量用]
|
/// 新用户通过第几关(仅记录前n关,根据项目自行确定,不区分关卡类型)[买量用]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="level">总计完成的管卡数 (b_play)</param>
|
/// <param name="level">总计完成的管卡数 (b_play)</param>
|
||||||
/// <param name="levelType"></param>
|
/// <param name="extra"></param>
|
||||||
/// <param name="itemId">棋局id /图片id</param>
|
public static void LevelEndSuccess( int level, Dictionary<string, object> extra = null)
|
||||||
public static void LevelEndSuccess( int level, string levelType = "", string itemId = "")
|
|
||||||
{
|
{
|
||||||
if (level > GuruSettings.Instance.AnalyticsSetting.LevelEndSuccessNum)
|
if (level > GuruSettings.Instance.AnalyticsSetting.LevelEndSuccessNum)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string eventName = $"level_end_success_{level}";
|
string eventName = $"level_end_success_{level}";
|
||||||
var dict = new Dictionary<string, object>()
|
LogEvent(eventName, extra, new EventSetting()
|
||||||
{
|
|
||||||
{ ParameterLevel, level },
|
|
||||||
};
|
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(levelType))
|
|
||||||
dict[ParameterItemCategory] = levelType;
|
|
||||||
if(!string.IsNullOrEmpty(itemId))
|
|
||||||
dict[ParameterItemId] = itemId;
|
|
||||||
|
|
||||||
LogEvent(eventName, dict, new EventSetting()
|
|
||||||
{
|
{
|
||||||
EnableFirebaseAnalytics = true,
|
EnableFirebaseAnalytics = true,
|
||||||
EnableFacebookAnalytics = true,
|
EnableFacebookAnalytics = true,
|
||||||
|
|
@ -177,7 +165,7 @@ namespace Guru
|
||||||
/// 第一次通关打点
|
/// 第一次通关打点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LevelFirstEnd(string levelType, string levelName, int level,
|
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>()
|
var dict = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
|
|
@ -188,8 +176,8 @@ namespace Guru
|
||||||
{ ParameterResult, result },
|
{ ParameterResult, result },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (duration != null)
|
if (duration > 0)
|
||||||
dict[ParameterDuration] = duration.Value;
|
dict[ParameterDuration] = duration;
|
||||||
if (extra != null)
|
if (extra != null)
|
||||||
dict.AddRange(extra, isOverride: true);
|
dict.AddRange(extra, isOverride: true);
|
||||||
|
|
||||||
|
|
@ -455,45 +443,60 @@ namespace Guru
|
||||||
#region Analytics Game IAP 游戏内购打点
|
#region Analytics Game IAP 游戏内购打点
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// app 内弹出的付费引导
|
/// 当付费页面打开时调用(iap_imp)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="itemCategory">界面跳转的来源</param>
|
/// <param name="scene">界面跳转的来源</param>
|
||||||
/// <param name="productID">product id,多个产品用逗号分隔,第一个商品id放主推商品id</param>
|
/// <param name="extra">扩展参数</param>
|
||||||
public static void IAPImp(string itemCategory, string productID)
|
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 },
|
{ ParameterItemCategory, scene },
|
||||||
{ ParameterItemName, productID },
|
};
|
||||||
});
|
if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
|
||||||
|
|
||||||
|
LogEvent(EventIAPImp, dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// app 内弹出的付费引导
|
/// 当付费页面关闭时调用(iap_close)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="itemCategory">界面跳转的来源</param>
|
/// <param name="scene"></param>
|
||||||
/// <param name="productID">product id,多个产品用逗号分隔,第一个商品id放主推商品id</param>
|
/// <param name="extra"></param>
|
||||||
public static void IAPClose(string itemCategory, string productID)
|
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 },
|
{ ParameterItemCategory, scene },
|
||||||
{ ParameterItemName, productID },
|
};
|
||||||
});
|
if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
|
||||||
|
|
||||||
|
LogEvent(EventIAPClose, dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// app 内弹出的付费引导
|
/// 点击付费按钮时调用 (iap_clk)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="itemCategory">界面跳转的来源</param>
|
/// <param name="scene">支付场景</param>
|
||||||
/// <param name="productID">product id,多个产品用逗号分隔,第一个商品id放主推商品id</param>
|
/// <param name="productId">道具的 sku</param>
|
||||||
public static void IAPClick(string itemCategory, string productID)
|
/// <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 },
|
sku = $"{productId}:{basePlanId}:{offerId}"; // 上报三连 ID
|
||||||
{ ParameterItemName, productID },
|
}
|
||||||
});
|
var dict = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ ParameterItemCategory, scene },
|
||||||
|
{ ParameterItemName, sku },
|
||||||
|
};
|
||||||
|
if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
|
||||||
|
|
||||||
|
LogEvent(EventIAPClick, dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -690,6 +693,10 @@ namespace Guru
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,15 +217,26 @@ namespace Guru
|
||||||
FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
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)
|
if (eventSetting.EnableAdjustAnalytics)
|
||||||
{
|
{
|
||||||
AdjustEvent adjustEvent = Analytics.CreateAdjustEvent(eventName);
|
AdjustEvent adjustEvent = Analytics.CreateAdjustEvent(eventName);
|
||||||
if (adjustEvent != null)
|
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);
|
Adjust.trackEvent(adjustEvent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public static class GuruSDKUtils
|
public static class GuruSDKUtils
|
||||||
{
|
{
|
||||||
|
|
@ -22,5 +24,28 @@ namespace Guru
|
||||||
}
|
}
|
||||||
return new Color(r, g, b, a);
|
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