update: 更新属性赋值的优先顺序, 修复丢失属性的 BUG

Signed-off-by: huyufei <yufei.hu@castbox.fm>
胡宇飞 2024-08-11 17:38:37 +08:00
parent 4adffcd4a7
commit 81cb45c46d
1 changed files with 10 additions and 8 deletions

View File

@ -113,12 +113,15 @@ namespace Guru
/// </summary>
private void FlushAll()
{
while(_eventBuffer.Pop(out var trackingEvent))
// #1. 先尝试执行所有预定义的用户属性
foreach (var propertyAction in _predefinedPropertyDelayedActions)
{
Debug.Log($"[ANU][GA] --- FlushAll Events: {trackingEvent.eventName}");
FlushTrackingEvent(trackingEvent);
Debug.Log($"[ANU][GA] --- FlushAll predefined Properties: {propertyAction.key}:{ propertyAction}");
propertyAction.Execute();
}
_predefinedPropertyDelayedActions.Clear();
// #2. 设置所有的用户属性
foreach (var key in _userPropertyMap.Keys)
{
Debug.Log($"[ANU][GA] --- FlushAll Properties: {key}:{ _userPropertyMap[key]}");
@ -126,13 +129,12 @@ namespace Guru
}
_userPropertyMap.Clear();
foreach (var propertyAction in _predefinedPropertyDelayedActions)
// #3. 发送所有的用户事件, 一定要在设置用户属性之后再调用事件, 这样才能携带所有的属性!!
while(_eventBuffer.Pop(out var trackingEvent))
{
Debug.Log($"[ANU][GA] --- FlushAll predefined Properties: {propertyAction.key}:{ propertyAction}");
propertyAction.Execute();
Debug.Log($"[ANU][GA] --- FlushAll Events: {trackingEvent.eventName}");
FlushTrackingEvent(trackingEvent);
}
_predefinedPropertyDelayedActions.Clear();
}
/// <summary>