diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs
index 85710f0..e11ba07 100644
--- a/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs
+++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs
@@ -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);
+ // }
}
-
///
/// 新用户通过第几关(仅记录前n关,根据项目自行确定,不区分关卡类型)[买量用]
///
/// 总计完成的管卡数 (b_play)
- ///
- /// 棋局id /图片id
- public static void LevelEndSuccess( int level, string levelType = "", string itemId = "")
+ ///
+ public static void LevelEndSuccess( int level, Dictionary extra = null)
{
if (level > GuruSettings.Instance.AnalyticsSetting.LevelEndSuccessNum)
return;
string eventName = $"level_end_success_{level}";
- var dict = new Dictionary()
- {
- { 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
/// 第一次通关打点
///
public static void LevelFirstEnd(string levelType, string levelName, int level,
- string result, int? duration = null, Dictionary extra = null)
+ string result, int duration = 0, Dictionary extra = null)
{
var dict = new Dictionary()
{
@@ -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 游戏内购打点
///
- /// app 内弹出的付费引导
+ /// 当付费页面打开时调用(iap_imp)
///
- /// 界面跳转的来源
- /// product id,多个产品用逗号分隔,第一个商品id放主推商品id
- public static void IAPImp(string itemCategory, string productID)
+ /// 界面跳转的来源
+ /// 扩展参数
+ public static void IAPImp(string scene, Dictionary extra = null)
{
- LogEvent(EventIAPImp, new Dictionary()
+ var dict = new Dictionary()
{
- { ParameterItemCategory, itemCategory },
- { ParameterItemName, productID },
- });
+ { ParameterItemCategory, scene },
+ };
+ if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
+
+ LogEvent(EventIAPImp, dict);
}
///
- /// app 内弹出的付费引导
+ /// 当付费页面关闭时调用(iap_close)
///
- /// 界面跳转的来源
- /// product id,多个产品用逗号分隔,第一个商品id放主推商品id
- public static void IAPClose(string itemCategory, string productID)
+ ///
+ ///
+ public static void IAPClose(string scene, Dictionary extra = null)
{
- LogEvent(EventIAPClose, new Dictionary()
+ var dict = new Dictionary()
{
- { ParameterItemCategory, itemCategory },
- { ParameterItemName, productID },
- });
+ { ParameterItemCategory, scene },
+ };
+ if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
+
+ LogEvent(EventIAPClose, dict);
}
///
- /// app 内弹出的付费引导
+ /// 点击付费按钮时调用 (iap_clk)
///
- /// 界面跳转的来源
- /// product id,多个产品用逗号分隔,第一个商品id放主推商品id
- public static void IAPClick(string itemCategory, string productID)
+ /// 支付场景
+ /// 道具的 sku
+ /// offer 的 basePlanId
+ /// offer 的 offerId
+ /// 扩展参数
+ public static void IAPClick(string scene, string productId, string basePlanId = "", string offerId = "", Dictionary extra = null)
{
- LogEvent(EventIAPClick, new Dictionary()
+ string sku = productId;
+ if (!string.IsNullOrEmpty(offerId) && !string.IsNullOrEmpty(basePlanId))
{
- { ParameterItemCategory, itemCategory },
- { ParameterItemName, productID },
- });
+ sku = $"{productId}:{basePlanId}:{offerId}"; // 上报三连 ID
+ }
+ var dict = new Dictionary()
+ {
+ { ParameterItemCategory, scene },
+ { ParameterItemName, sku },
+ };
+ if(extra != null) dict = GuruSDKUtils.MergeDictionary(dict, extra);
+
+ LogEvent(EventIAPClick, dict);
}
///
@@ -690,6 +693,10 @@ namespace Guru
}
#endregion
+
+
+
+
}
}
diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs
index 36df1d0..4f997bb 100644
--- a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs
+++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs
@@ -217,15 +217,26 @@ namespace Guru
FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
}
- Dictionary dict = new Dictionary(extras);
+ Dictionary dict = new Dictionary();
+ 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);
}
diff --git a/Runtime/Utils/Runtime/GuruSDKUtils.cs b/Runtime/Utils/Runtime/GuruSDKUtils.cs
index f900c0a..adf6636 100644
--- a/Runtime/Utils/Runtime/GuruSDKUtils.cs
+++ b/Runtime/Utils/Runtime/GuruSDKUtils.cs
@@ -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 MergeDictionary(Dictionary source, Dictionary other)
+ {
+ int len = source?.Count ?? 0 + other?.Count ?? 0;
+ if (len == 0) len = 10;
+ var newDict = new Dictionary(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;
+ }
}
}
\ No newline at end of file