fix: 优化用户属性打点逻辑
parent
4246251295
commit
314aaaa88b
|
|
@ -59,8 +59,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
if (!IsInitialSuccess)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"{Tag} :: SetScreen {screen} has been cached before SDK init!");
|
UnityEngine.Debug.LogWarning($"{Tag} :: SetScreen {screen} can not be set before SDK init!");
|
||||||
CacheUserProperty(KeyCachedScreen, $"{screen},{extra}");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Analytics.SetCurrentScreen(screen, extra);
|
Analytics.SetCurrentScreen(screen, extra);
|
||||||
|
|
@ -363,33 +362,6 @@ namespace Guru
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void ConsumeAllCachedUserProperty()
|
|
||||||
{
|
|
||||||
if (_userPropertyCacheData == null || _userPropertyCacheData.Count == 0) return;
|
|
||||||
var keys = _userPropertyCacheData.Keys.ToArray();
|
|
||||||
int i = 0;
|
|
||||||
int count = keys.Length;
|
|
||||||
var key = "";
|
|
||||||
while (i < count)
|
|
||||||
{
|
|
||||||
key = keys[i];
|
|
||||||
if (key == KeyCachedScreen)
|
|
||||||
{
|
|
||||||
var arr = _userPropertyCacheData[key].Split(',');
|
|
||||||
string screenName = "", className = "";
|
|
||||||
if(arr.Length > 0) screenName = arr[0];
|
|
||||||
if(arr.Length > 1) className = arr[1];
|
|
||||||
SetScreen(screenName, className);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
InternalSetUserProperty(key, _userPropertyCacheData[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
_userPropertyCacheData.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -399,21 +371,7 @@ namespace Guru
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public static void SetUserProperty(string key, string value)
|
public static void SetUserProperty(string key, string value)
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
RecordUserPropertyKey(key); // 记录属性打点
|
||||||
{
|
|
||||||
CacheUserProperty(key , value);
|
|
||||||
UnityEngine.Debug.LogWarning($"{Tag} :: SetUserProperty {key}:{value} Has been cached before SDK init!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConsumeAllCachedUserProperty(); // 消耗所有的缓存值
|
|
||||||
|
|
||||||
InternalSetUserProperty(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void InternalSetUserProperty(string key, string value)
|
|
||||||
{
|
|
||||||
RecordUserPropertyKey(key); // 补全属性打点
|
|
||||||
Analytics.SetUserProperty(key, value);
|
Analytics.SetUserProperty(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue