update: 更新 ABTest 内的类型校验BUG, 完善打点接口
parent
c0936f094e
commit
60b503fe3d
|
|
@ -88,7 +88,8 @@ namespace Guru
|
|||
{
|
||||
if (!string.IsNullOrEmpty(value) && value.Contains("guru_ab_"))
|
||||
{
|
||||
_params.Add(ABParamData.Parse(value)); // 添加参数
|
||||
var p = ABParamData.Parse(value);
|
||||
if(p != null) _params.Add(p); // 添加参数
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -128,32 +129,39 @@ namespace Guru
|
|||
public static ABParamData Parse(string value)
|
||||
{
|
||||
Debug.Log($"--- ABParamData.Parse: {value}");
|
||||
var p = new ABParamData();
|
||||
p.value = value;
|
||||
|
||||
// 发现Guru AB测试标志位
|
||||
var dict = JsonMapper.ToObject<Dictionary<string, JsonData>>(value);
|
||||
if (null != dict)
|
||||
try
|
||||
{
|
||||
foreach (var k in dict.Keys)
|
||||
// 发现Guru AB测试标志位
|
||||
var dict = JsonMapper.ToObject<Dictionary<string, JsonData>>(value);
|
||||
if (null != dict)
|
||||
{
|
||||
if (k.StartsWith("guru_ab"))
|
||||
foreach (var k in dict.Keys)
|
||||
{
|
||||
p.id = GetItemKey(k);
|
||||
p.group = dict[k].ToString();
|
||||
// Debug.Log($"[AB] add property {k}: {dict[k]}");
|
||||
break;
|
||||
if (k.StartsWith("guru_ab"))
|
||||
{
|
||||
return new ABParamData()
|
||||
{
|
||||
id = GetItemKey(k),
|
||||
group = dict[k].ToString(),
|
||||
value = value
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
catch (Exception e)
|
||||
{
|
||||
string msg = $"[AB] --- Parse AB Param Error -> Value: {value}\n{e.Message}";
|
||||
Analytics.LogCrashlytics(msg);
|
||||
Debug.Log(msg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetItemKey(string raw)
|
||||
{
|
||||
var h = raw.Replace("guru_", "");
|
||||
var key = h.Substring(0, Mathf.Min(PARAM_NAME_LENGTH, h.Length)); // 最大长度23
|
||||
int ln = "guru_".Length;
|
||||
var key = raw.Substring(ln, Mathf.Min(PARAM_NAME_LENGTH, raw.Length - ln)); // 最大长度23
|
||||
return key;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using com.adjust.sdk;
|
||||
using Facebook.Unity;
|
||||
using Firebase.Analytics;
|
||||
|
||||
|
||||
namespace Guru
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using com.adjust.sdk;
|
||||
using Facebook.Unity;
|
||||
using Firebase.Analytics;
|
||||
using Firebase.Crashlytics;
|
||||
|
||||
//打点模块初始化和基础接口封装
|
||||
public static partial class Analytics
|
||||
{
|
||||
|
|
@ -47,10 +50,10 @@ namespace Guru
|
|||
|
||||
public static void InitAnalytics()
|
||||
{
|
||||
if (_isInited)
|
||||
return;
|
||||
|
||||
if (_isInited) return;
|
||||
_isInited = true;
|
||||
Crashlytics.IsCrashlyticsCollectionEnabled = true;
|
||||
|
||||
if (_defaultEventSetting == null)
|
||||
{
|
||||
var analyticsSetting = GuruSettings.Instance.AnalyticsSetting;
|
||||
|
|
@ -232,6 +235,32 @@ namespace Guru
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Crashlytics 上报
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="isException"></param>
|
||||
public static void LogCrashlytics(string msg, bool isException = true)
|
||||
{
|
||||
if (!_isInited) return;
|
||||
if (isException)
|
||||
{
|
||||
LogCrashlytics(new Exception(msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
Crashlytics.Log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void LogCrashlytics(Exception exp)
|
||||
{
|
||||
if (!_isInited) return;
|
||||
Crashlytics.LogException(exp);
|
||||
Crashlytics.SetUserId(IPMConfig.IPM_UID);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue