61 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
| 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;
 | |
| 			}
 | |
| 			UnityEngine.Debug.Log($"{TAG} --- Send Adjust Event: {eventName}({tokenID})");
 | |
| 			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;
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| } |