2023-12-26 04:22:19 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using com.adjust.sdk;
|
|
|
|
|
|
|
|
|
|
namespace Guru
|
|
|
|
|
{
|
|
|
|
|
//Adjust上报事件封装
|
|
|
|
|
public static partial class Analytics
|
|
|
|
|
{
|
|
|
|
|
private static Dictionary<string, string> AdjustEventTokenDict;
|
|
|
|
|
|
|
|
|
|
private static void InitAdjustEventTokenDict()
|
|
|
|
|
{
|
|
|
|
|
AdjustEventTokenDict = new Dictionary<string, string>();
|
|
|
|
|
|
|
|
|
|
foreach (var adjustEvent in GuruSettings.Instance.AnalyticsSetting.AdjustEventList)
|
|
|
|
|
{
|
|
|
|
|
#if UNITY_ANDROID || UNITY_EDITOR
|
|
|
|
|
AdjustEventTokenDict[adjustEvent.EventName] = adjustEvent.AndroidToken;
|
|
|
|
|
#elif UNITY_IOS
|
|
|
|
|
AdjustEventTokenDict[adjustEvent.EventName] = adjustEvent.IOSToken;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static AdjustEvent CreateAdjustEvent(string eventName)
|
|
|
|
|
{
|
|
|
|
|
string tokenID = GetAdjustEventToken(eventName);
|
|
|
|
|
if (string.IsNullOrEmpty(tokenID))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2024-06-18 09:00:15 +00:00
|
|
|
UnityEngine.Debug.Log($"{TAG} --- Send Adjust Event: {eventName}({tokenID})");
|
2023-12-26 04:22:19 +00:00
|
|
|
return new AdjustEvent(tokenID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static AdjustEvent AddEventParameter(this AdjustEvent adjustEvent, string key, string value)
|
|
|
|
|
{
|
|
|
|
|
adjustEvent.addCallbackParameter(key, value);
|
|
|
|
|
adjustEvent.addPartnerParameter(key, value);
|
|
|
|
|
return adjustEvent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetAdjustEventToken(string eventName)
|
|
|
|
|
{
|
|
|
|
|
if (AdjustEventTokenDict == null)
|
|
|
|
|
{
|
|
|
|
|
InitAdjustEventTokenDict();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (AdjustEventTokenDict.ContainsKey(eventName))
|
|
|
|
|
{
|
|
|
|
|
return AdjustEventTokenDict[eventName];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Log.W(AdjustService.LOG_TAG,$"AdjustEventTokenDict 没有添加 event:{eventName}的Token值");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|