update: 更新 ABTest 内的类型校验BUG, 完善打点接口
parent
c0936f094e
commit
60b503fe3d
|
|
@ -88,7 +88,8 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(value) && value.Contains("guru_ab_"))
|
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)
|
public static ABParamData Parse(string value)
|
||||||
{
|
{
|
||||||
Debug.Log($"--- ABParamData.Parse: {value}");
|
Debug.Log($"--- ABParamData.Parse: {value}");
|
||||||
var p = new ABParamData();
|
try
|
||||||
p.value = value;
|
|
||||||
|
|
||||||
// 发现Guru AB测试标志位
|
|
||||||
var dict = JsonMapper.ToObject<Dictionary<string, JsonData>>(value);
|
|
||||||
if (null != dict)
|
|
||||||
{
|
{
|
||||||
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);
|
if (k.StartsWith("guru_ab"))
|
||||||
p.group = dict[k].ToString();
|
{
|
||||||
// Debug.Log($"[AB] add property {k}: {dict[k]}");
|
return new ABParamData()
|
||||||
break;
|
{
|
||||||
|
id = GetItemKey(k),
|
||||||
|
group = dict[k].ToString(),
|
||||||
|
value = value
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
return p;
|
{
|
||||||
|
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)
|
private static string GetItemKey(string raw)
|
||||||
{
|
{
|
||||||
var h = raw.Replace("guru_", "");
|
int ln = "guru_".Length;
|
||||||
var key = h.Substring(0, Mathf.Min(PARAM_NAME_LENGTH, h.Length)); // 最大长度23
|
var key = raw.Substring(ln, Mathf.Min(PARAM_NAME_LENGTH, raw.Length - ln)); // 最大长度23
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using com.adjust.sdk;
|
|
||||||
using Facebook.Unity;
|
|
||||||
using Firebase.Analytics;
|
|
||||||
|
|
||||||
namespace Guru
|
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
|
public static partial class Analytics
|
||||||
{
|
{
|
||||||
|
|
@ -47,10 +50,10 @@ namespace Guru
|
||||||
|
|
||||||
public static void InitAnalytics()
|
public static void InitAnalytics()
|
||||||
{
|
{
|
||||||
if (_isInited)
|
if (_isInited) return;
|
||||||
return;
|
|
||||||
|
|
||||||
_isInited = true;
|
_isInited = true;
|
||||||
|
Crashlytics.IsCrashlyticsCollectionEnabled = true;
|
||||||
|
|
||||||
if (_defaultEventSetting == null)
|
if (_defaultEventSetting == null)
|
||||||
{
|
{
|
||||||
var analyticsSetting = GuruSettings.Instance.AnalyticsSetting;
|
var analyticsSetting = GuruSettings.Instance.AnalyticsSetting;
|
||||||
|
|
@ -231,6 +234,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
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue