update: 优化Adjust启动逻辑和参数
							parent
							
								
									d7b6362302
								
							
						
					
					
						commit
						b03c29a1bb
					
				|  | @ -53,18 +53,17 @@ namespace Guru | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         private static bool _autoSyncProperties = false; | ||||
| 
 | ||||
|         #region 公用接口 | ||||
|          | ||||
|         /// <summary> | ||||
|         /// 初始化接口 | ||||
|         /// </summary> | ||||
|         public static void Init(string appId, string deviceInfo, bool isDebug = false) | ||||
|         public static void Init(string appId, string deviceInfo, bool isDebug = false, bool syncProperties = false) | ||||
|         { | ||||
|             _autoSyncProperties = syncProperties; | ||||
|             Agent?.Init(appId, deviceInfo, isDebug); | ||||
| #if UNITY_IOS | ||||
|             // AnalyticsAgentIOS.TestCrashEvent(); // 测试触发一下崩溃事件 | ||||
| #endif | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -149,7 +148,8 @@ namespace Guru | |||
|         /// <param name="data">INT类型的值</param> | ||||
|         public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null) | ||||
|         { | ||||
|             UpdateAllUserProperties(); // 每次打点更新用户属性 | ||||
|             if(_autoSyncProperties) | ||||
|                 UpdateAllUserProperties(); // 每次打点更新用户属性 | ||||
|              | ||||
|             string raw = ""; | ||||
|             if (data != null && data.Count > 0) | ||||
|  | @ -241,7 +241,10 @@ namespace Guru | |||
|         /// <param name="value"></param> | ||||
|         private static void CacheUserProperty(string key, string value) | ||||
|         { | ||||
|             bool needUpdate = !UserProperties.ContainsKey(key) || UserProperties[key] != value; | ||||
|             UserProperties[key] = value; | ||||
| 
 | ||||
|             // if (needUpdate) UpdateAllUserProperties(); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,9 +30,8 @@ namespace Guru | |||
| 		/// Adjust启动服务 | ||||
| 		/// </summary> | ||||
| 		/// <param name="fbAppId">MIR 追踪 AppID</param> | ||||
| 		public static void StartService(string fbAppId = "") | ||||
| 		public static void StartService(string appToken, string fbAppId = "") | ||||
| 		{ | ||||
| 			string appToken = GuruSettings.Instance.AdjustSetting.GetAppToken(); | ||||
| 			if (string.IsNullOrEmpty(appToken)) | ||||
| 			{ | ||||
| 				Log.E(LOG_TAG, "Adjust没有设置token,无法进行初始化"); | ||||
|  | @ -140,6 +139,7 @@ namespace Guru | |||
| 				Debug.LogWarning($">> Device ID is Empty, skip install event reporting"); | ||||
| 				return; | ||||
| 			} | ||||
| 			Debug.LogWarning($"{LOG_TAG} --- addSessionCallbackParameter:  user_pseudo_id:{pseudoId}, device_id:{deviceId}"); | ||||
| 			Adjust.addSessionCallbackParameter("user_pseudo_id", pseudoId); | ||||
| 			Adjust.addSessionCallbackParameter("device_id", deviceId); | ||||
| 		} | ||||
|  |  | |||
|  | @ -19,7 +19,6 @@ namespace Guru | |||
| 				DependencyStatus = task.Result; | ||||
| 				if (DependencyStatus == DependencyStatus.Available)  | ||||
| 				{ | ||||
| 					LinkFirebaseID2Adjust(); // 上报FirebaseID | ||||
| 					InitializeFirebaseComp(); | ||||
| 					callback?.Invoke(); | ||||
| 				}  | ||||
|  | @ -35,6 +34,7 @@ namespace Guru | |||
| 			InitRemoteConfig();	// 老项目沿用此逻辑 | ||||
| 			Analytics.InstallGuruAnalytics(_isDebug); // 初始化Guru自打点 | ||||
| 			Analytics.InitAnalytics(); | ||||
| 			InitAdjustService(); | ||||
| 			 | ||||
| 			if (IPMConfig.IPM_UID.IsNullOrEmpty()) | ||||
| 			{ | ||||
|  | @ -79,7 +79,7 @@ namespace Guru | |||
| 		/// <summary> | ||||
| 		/// 关联FirebaseID到Adjust | ||||
| 		/// </summary> | ||||
| 		private static void LinkFirebaseID2Adjust() | ||||
| 		private static void InitAdjustService() | ||||
| 		{ | ||||
| 			FirebaseAnalytics.GetAnalyticsInstanceIdAsync() | ||||
| 				.ContinueWithOnMainThread(task => | ||||
|  | @ -88,7 +88,6 @@ namespace Guru | |||
| 					{ | ||||
| 						// 保存本地ID备份 | ||||
| 						string fid = task.Result; | ||||
| 						StandardProperties.FirebaseId = fid; // 保存本次非空ID | ||||
| 						IPMConfig.FIREBASE_ID = fid; // 保存FirebaseID | ||||
| 					} | ||||
| 					else | ||||
|  | @ -96,7 +95,9 @@ namespace Guru | |||
| 						UnityEngine.Debug.LogError($"Fetch FirebaseID failed on start!"); | ||||
| 					} | ||||
| 					 | ||||
| 					AdjustService.StartService();  // 关联启动AdjustService | ||||
| 					// 启动 AdjustService | ||||
| 					string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? ""; | ||||
| 					AdjustService.StartService(appToken);   | ||||
| 				}); | ||||
| 		} | ||||
| 		 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue