update: 修正 AdjustID 获取的回调和时机
--story=1020639 --user=yufei.hu 【Unity】-【BI】Firebase 数据新增上报用户属性 adjust_id https://www.tapd.cn/58098289/s/1157505 Signed-off-by: huyufei <yufei.hu@castbox.fm>main
							parent
							
								
									76fc4f5c26
								
							
						
					
					
						commit
						8a81ed78b4
					
				|  | @ -1,11 +1,14 @@ | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| namespace Guru | namespace Guru | ||||||
| { | { | ||||||
| 	using UnityEngine; | 	using UnityEngine; | ||||||
| 	using com.adjust.sdk; | 	using com.adjust.sdk; | ||||||
|  | 	using System; | ||||||
| 	using System.Collections; | 	using System.Collections; | ||||||
| 	 | 	 | ||||||
| 	public static class AdjustService | 	public class AdjustService | ||||||
| 	{ | 	{ | ||||||
| 		public const string Version = "1.6.1"; | 		public const string Version = "1.6.1"; | ||||||
| 		public const string AdjustVersion = "4.38.0"; // Adjust SDK Version | 		public const string AdjustVersion = "4.38.0"; // Adjust SDK Version | ||||||
|  | @ -14,6 +17,8 @@ namespace Guru | ||||||
| 
 | 
 | ||||||
| 		public const string K_IAP_PURCHASE = "iap_purchase"; // 固定点位事件 | 		public const string K_IAP_PURCHASE = "iap_purchase"; // 固定点位事件 | ||||||
| 		public const string K_SUB_PURCHASE = "sub_purchase"; // 固定点位事件 | 		public const string K_SUB_PURCHASE = "sub_purchase"; // 固定点位事件 | ||||||
|  | 
 | ||||||
|  | 		private static Action<string> _onSessionSuccessCallback; | ||||||
| 		 | 		 | ||||||
| 
 | 
 | ||||||
| 		private static string _adId = ""; | 		private static string _adId = ""; | ||||||
|  | @ -45,7 +50,7 @@ namespace Guru | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="appToken"></param> | 		/// <param name="appToken"></param> | ||||||
| 		/// <param name="fbAppId">MIR 追踪 AppID</param> | 		/// <param name="fbAppId">MIR 追踪 AppID</param> | ||||||
| 		public static void StartService(string appToken, string fbAppId = "") | 		public static void StartService(string appToken, string fbAppId = "", Action<string> onSessionSuccess = null) | ||||||
| 		{ | 		{ | ||||||
| 			if (string.IsNullOrEmpty(appToken)) | 			if (string.IsNullOrEmpty(appToken)) | ||||||
| 			{ | 			{ | ||||||
|  | @ -53,6 +58,8 @@ namespace Guru | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 			_onSessionSuccessCallback = onSessionSuccess; | ||||||
|  | 
 | ||||||
| 			InstallEvent(IPMConfig.FIREBASE_ID, IPMConfig.IPM_DEVICE_ID); // 注入启动参数 | 			InstallEvent(IPMConfig.FIREBASE_ID, IPMConfig.IPM_DEVICE_ID); // 注入启动参数 | ||||||
| 
 | 
 | ||||||
| 			AdjustEnvironment environment = GetAdjustEnvironment(); | 			AdjustEnvironment environment = GetAdjustEnvironment(); | ||||||
|  | @ -61,6 +68,7 @@ namespace Guru | ||||||
| 			config.setDelayStart(DelayTime); | 			config.setDelayStart(DelayTime); | ||||||
|              |              | ||||||
| 			config.setPreinstallTrackingEnabled(true); // Adjust Preinstall | 			config.setPreinstallTrackingEnabled(true); // Adjust Preinstall | ||||||
|  | 			config.setSessionSuccessDelegate(OnSessionSuccessCallback); // SessionSuccess | ||||||
| 
 | 
 | ||||||
| #if UNITY_ANDROID | #if UNITY_ANDROID | ||||||
| 			if (!string.IsNullOrEmpty(fbAppId)) config.setFbAppId(fbAppId); // 注入 MIR ID | 			if (!string.IsNullOrEmpty(fbAppId)) config.setFbAppId(fbAppId); // 注入 MIR ID | ||||||
|  | @ -71,7 +79,7 @@ namespace Guru | ||||||
| 			config.setLogDelegate(log => LogI(LOG_TAG, log)); | 			config.setLogDelegate(log => LogI(LOG_TAG, log)); | ||||||
| 			config.setEventSuccessDelegate(OnEventSuccessCallback); | 			config.setEventSuccessDelegate(OnEventSuccessCallback); | ||||||
| 			config.setEventFailureDelegate(OnEventFailureCallback); | 			config.setEventFailureDelegate(OnEventFailureCallback); | ||||||
| 			config.setSessionSuccessDelegate(OnSessionSuccessCallback); | 			 | ||||||
| 			config.setSessionFailureDelegate(OnSessionFailureCallback); | 			config.setSessionFailureDelegate(OnSessionFailureCallback); | ||||||
| 			config.setAttributionChangedDelegate(OnAttributionChangedCallback); | 			config.setAttributionChangedDelegate(OnAttributionChangedCallback); | ||||||
| #endif | #endif | ||||||
|  | @ -274,25 +282,8 @@ namespace Guru | ||||||
| 		{ | 		{ | ||||||
| 			LogI(LOG_TAG,"Session tracked successfully!"); | 			LogI(LOG_TAG,"Session tracked successfully!"); | ||||||
| 
 | 
 | ||||||
| 			if (sessionSuccessData.Message != null) | 			var adid = sessionSuccessData.Adid; | ||||||
| 			{ | 			_onSessionSuccessCallback?.Invoke(adid); | ||||||
| 				LogI(LOG_TAG,"Message: " + sessionSuccessData.Message); |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			if (sessionSuccessData.Timestamp != null) |  | ||||||
| 			{ |  | ||||||
| 				LogI(LOG_TAG,"Timestamp: " + sessionSuccessData.Timestamp); |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			if (sessionSuccessData.Adid != null) |  | ||||||
| 			{ |  | ||||||
| 				LogI(LOG_TAG, "Adid: " + sessionSuccessData.Adid); |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			if (sessionSuccessData.JsonResponse != null) |  | ||||||
| 			{ |  | ||||||
| 				LogI(LOG_TAG, "JsonResponse: " + sessionSuccessData.GetJsonResponse()); |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		private static void OnSessionFailureCallback(AdjustSessionFailure sessionFailureData) | 		private static void OnSessionFailureCallback(AdjustSessionFailure sessionFailureData) | ||||||
|  |  | ||||||
|  | @ -117,26 +117,21 @@ namespace Guru | ||||||
| 					// 启动 AdjustService | 					// 启动 AdjustService | ||||||
| 					string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? ""; | 					string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? ""; | ||||||
| 					string fbAppId = GuruSettings.Instance.IPMSetting.FacebookAppId; | 					string fbAppId = GuruSettings.Instance.IPMSetting.FacebookAppId; | ||||||
| 					AdjustService.StartService(appToken, fbAppId);   | 					AdjustService.StartService(appToken, fbAppId, adid => | ||||||
|  | 					{ | ||||||
|  | 						// 获取 ADID  | ||||||
|  | 						if (string.IsNullOrEmpty(adid)) | ||||||
|  | 						{ | ||||||
|  | 							adid = "not_set"; | ||||||
|  | 						} | ||||||
|  | 						FirebaseAnalytics.SetUserProperty("adjust_id", adid); // 仅上报 Firebase 用户属性 | ||||||
|  | 						Debug.Log($"[SDK] --- Firebase + Adjust ID: {adid}"); | ||||||
|  | 					});   | ||||||
| 					 | 					 | ||||||
| 					// 上报 AdjustID |  | ||||||
| 					CoroutineHelper.Instance.StartDelayed(new WaitForSeconds(1f), DelayReportAdjustId); |  | ||||||
| 				}); | 				}); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 		private static void DelayReportAdjustId() |  | ||||||
| 		{ |  | ||||||
| 			string adjustId = AdjustService.AdjustId; |  | ||||||
| 			if (string.IsNullOrEmpty(adjustId)) |  | ||||||
| 			{ |  | ||||||
| 				adjustId = "not_set"; |  | ||||||
| 			} |  | ||||||
| 			FirebaseAnalytics.SetUserProperty("adjust_id", adjustId); // 仅上报 Firebase 用户属性 |  | ||||||
| 			Debug.Log($"[SDK] --- Firebase + Adjust ID: {adjustId}"); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 		#endregion | 		#endregion | ||||||
| 
 | 
 | ||||||
| 		 | 		 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue