update: GuruSDK 内部不再调用 SetUserProperty
							parent
							
								
									2494bd2748
								
							
						
					
					
						commit
						af1ec1e04f
					
				|  | @ -18,7 +18,7 @@ namespace Guru | ||||||
|             _adInitSpec = spec; |             _adInitSpec = spec; | ||||||
|             if (InitConfig.UseCustomConsent) |             if (InitConfig.UseCustomConsent) | ||||||
|             { |             { | ||||||
|                 UnityEngine.Debug.Log($"{Tag} --- Call <color=orange>StartAdsWithCustomConsent</color> when you use custom consent, and pass the result (boolean) to the method."); |                 Debug.Log($"{Tag} --- Call <color=orange>StartAdsWithCustomConsent</color> when you use custom consent, and pass the result (boolean) to the method."); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|              |              | ||||||
|  | @ -59,7 +59,7 @@ namespace Guru | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 UnityEngine.Debug.Log($"{Tag} --- User refuse to provide ads Id, Ads Service will be cancelled"); |                 Debug.Log($"{Tag} --- User refuse to provide ads Id, Ads Service will be cancelled"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -244,7 +244,7 @@ namespace Guru | ||||||
|             // bool hasNotiGranted = false; |             // bool hasNotiGranted = false; | ||||||
|             _notiStatue = "no_determined"; |             _notiStatue = "no_determined"; | ||||||
|             NotificationService.Initialize(); // 初始化 Noti 服务 |             NotificationService.Initialize(); // 初始化 Noti 服务 | ||||||
|             SetNotiPerm(NotificationService.GetStatus()); |             Analytics.SetNotiPerm(NotificationService.GetStatus()); | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         /// <summary> |         /// <summary> | ||||||
|  | @ -266,7 +266,7 @@ namespace Guru | ||||||
|             if (isGranted) |             if (isGranted) | ||||||
|             { |             { | ||||||
|                 Debug.Log($"[SDK] ---- Set Notification Permission: {status}"); |                 Debug.Log($"[SDK] ---- Set Notification Permission: {status}"); | ||||||
|                 SetNotiPerm(status); |                 Analytics.SetNotiPerm(status); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | @ -285,7 +285,7 @@ namespace Guru | ||||||
|             NotificationService.RequestPermission(status => |             NotificationService.RequestPermission(status => | ||||||
|             { |             { | ||||||
|                 Debug.Log($"[SDK] ---- Set Notification Permission: {status}"); |                 Debug.Log($"[SDK] ---- Set Notification Permission: {status}"); | ||||||
|                 if(!string.IsNullOrEmpty(status)) SetNotiPerm(status); |                 if(!string.IsNullOrEmpty(status)) Analytics.SetNotiPerm(status); | ||||||
|                  |                  | ||||||
|                 callback?.Invoke(status); |                 callback?.Invoke(status); | ||||||
|             }); |             }); | ||||||
|  | @ -326,7 +326,7 @@ namespace Guru | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// 启动广告服务 |         /// 启动广告服务 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         internal static void StartAdService(AdsInitSpec spec = null) |         private static void StartAdService(AdsInitSpec spec = null) | ||||||
|         { |         { | ||||||
|              |              | ||||||
|             //---------- Using InitConfig ---------- |             //---------- Using InitConfig ---------- | ||||||
|  |  | ||||||
|  | @ -10,7 +10,6 @@ namespace Guru | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     public partial class GuruSDK |     public partial class GuruSDK | ||||||
|     { |     { | ||||||
|          |  | ||||||
|         #region 通用接口 |         #region 通用接口 | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|  | @ -37,6 +36,20 @@ namespace Guru | ||||||
| 
 | 
 | ||||||
|         #endregion |         #endregion | ||||||
|          |          | ||||||
|  |         #region 设置用户属性 | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// 设置用户属性 | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="key"></param> | ||||||
|  |         /// <param name="value"></param> | ||||||
|  |         public static void SetUserProperty(string key, string value) | ||||||
|  |         { | ||||||
|  |             Analytics.SetUserProperty(key, value); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         #endregion | ||||||
|  |          | ||||||
|         #region 游戏打点 |         #region 游戏打点 | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|  | @ -283,183 +296,8 @@ namespace Guru | ||||||
|             LogEvent(Consts.EventHpPoints, dict); |             LogEvent(Consts.EventHpPoints, dict); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|         #endregion |         #endregion | ||||||
| 
 |  | ||||||
|         #region 用户属性 |  | ||||||
| 
 |  | ||||||
|         /// <summary> |  | ||||||
|         /// 提前调用用户属性 |  | ||||||
|         /// </summary> |  | ||||||
|         private static void InitUserProperties() |  | ||||||
|         { |  | ||||||
|             if (!IsInitialSuccess) |  | ||||||
|             { |  | ||||||
|                 Debug.LogError($"{Tag} :: InitUserProperties :: Please call <GuruSDK.Start()> first, before you call <InitUserProperties>."); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|              |  | ||||||
|             Debug.Log($"[SDK] --- PurchasedCount:{Model.PurchasedCount}"); |  | ||||||
|             Debug.Log($"[SDK] --- IsIapUser:{Model.IsIapUser}"); |  | ||||||
|              |  | ||||||
|             SetUserIsIAP(Model.IsIapUser); // 预先设置用户的 IAP User 属性 |  | ||||||
|             SetUserBLevel(Model.SuccessLevelId); // 预先设置用户的 BLevel 属性 |  | ||||||
|             SetUserBPlay(Model.TotalPlayedCount);  // 预先设置用户的 BPlay 属性 |  | ||||||
|             if (Model.IsNoAds) SetBuyNoAds(true); // 设置用户已经购买了去广告 |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         /// <summary> |  | ||||||
|         /// 设置用户属性 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="key"></param> |  | ||||||
|         /// <param name="value"></param> |  | ||||||
|         public static void SetUserProperty(string key, string value) |  | ||||||
|         { |  | ||||||
|             Analytics.SetUserProperty(key, value); |  | ||||||
|         } |  | ||||||
|          |          | ||||||
|         public static void SetUID(string uid) |  | ||||||
|         { |  | ||||||
|             Analytics.SetUid(uid); |  | ||||||
|             SetUserProperty(Consts.PropertyUserID, uid); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public static void SetUserBLevel(int blevel) |  | ||||||
|         { |  | ||||||
|             if (!InitConfig.AutoRecordFinishedLevels) |  | ||||||
|             { |  | ||||||
|                 Model.SetBLevelValue(blevel); |  | ||||||
|                 Analytics.BLevel = blevel; |  | ||||||
|             } |  | ||||||
|             SetUserProperty(Consts.PropertyLevel, $"{blevel}"); |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         public static void SetUserBPlay(int bplay) |  | ||||||
|         { |  | ||||||
|             if (!InitConfig.AutoRecordFinishedLevels) |  | ||||||
|             { |  | ||||||
|                 Model.SetBPlayValue(bplay); |  | ||||||
|                 Analytics.BPlay = bplay; |  | ||||||
|             } |  | ||||||
|             SetUserProperty(Consts.PropertyPlay, $"{bplay}"); |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         /// <summary> |  | ||||||
|         /// 上报用户全部的 Coin (当前值) |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="coins"></param> |  | ||||||
|         public static void SetUserCoin(int coins) |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyCoin, $"{coins}");         |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         /// <summary> |  | ||||||
|         /// 上报用户免费金币的 数量 (累加值) |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="freeCoins"></param> |  | ||||||
|         public static void SetUserNonIapCoin(int freeCoins) |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyNonIAPCoin, $"{freeCoins}");         |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         /// <summary> |  | ||||||
|         /// 上报用户付费金币的 数量 (累加值) |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="paidCoins"></param> |  | ||||||
|         public static void SetUserIapCoin(int paidCoins) |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyIAPCoin, $"{paidCoins}");         |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         public static void SetUserExp(int exp) |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyExp, $"{exp}");         |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         public static void SetUserHp(int hp) |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyHp, $"{hp}");         |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public static void SetUserGrade(int grade) |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyGrade, $"{grade}");         |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public static void SetUserIsIAP(bool isIapUser) |  | ||||||
|         { |  | ||||||
|             // SetUserProperty(Consts.PropertyIsIAPUser, isIapUser? "true" : "false"); |  | ||||||
|             Analytics.SetIsIapUser(isIapUser); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public static void SetFirstOpenTime(string timestamp) |  | ||||||
|         { |  | ||||||
|             if (string.IsNullOrEmpty(timestamp)) |  | ||||||
|             { |  | ||||||
|                 timestamp = IPMConfig.FIRST_OPEN_TIME; |  | ||||||
|                 Model.FirstOpenTime = timestamp; |  | ||||||
|             } |  | ||||||
|             SetUserProperty(Analytics.PropertyFirstOpenTime, timestamp); |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         public static void SetNotiPerm(string status) |  | ||||||
|         { |  | ||||||
|             // SetUserProperty(Consts.PropertyNotiPerm, status); |  | ||||||
|             Analytics.SetNotiPerm(status); |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         public static void SetATTStatus(string status) |  | ||||||
|         { |  | ||||||
|             // SetUserProperty(Consts.PropertyATTStatus, status); |  | ||||||
|             Analytics.SetAttStatus(status); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public static void SetAdjustId(string adjustId) |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyAdjustId, adjustId); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         public static void SetNetworkStatus() |  | ||||||
|         { |  | ||||||
|             SetUserProperty(Consts.PropertyNetwork, Instance.GetNetworkStatus()); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         private static bool _hasUserPropertiesInitiallyUpdated = false; |  | ||||||
|         /// <summary> |  | ||||||
|         /// 初始化时补全一下所有的属性打点  |  | ||||||
|         /// 如果用户已经设置过 Key, 则不会再次设置 |  | ||||||
|         /// <a href="https://docs.google.com/spreadsheets/d/1N47rXgjatRHFvzWWx0Hqv5C1D9NHHGbggi6pQ65c-zQ/edit#gid=1858695240">用户属性文档</a> |  | ||||||
|         /// </summary> |  | ||||||
|         private static void InitiallyUpdateUserProperties() |  | ||||||
|         { |  | ||||||
|             if (_hasUserPropertiesInitiallyUpdated) return; |  | ||||||
|             _hasUserPropertiesInitiallyUpdated = true; |  | ||||||
|              |  | ||||||
|             SetFirstOpenTime(Model?.FirstOpenTime ?? "");    //  first_open_time  |  | ||||||
|             SetUserIsIAP(Model?.IsIapUser ?? false);    // is_iap_user |  | ||||||
|             SetUserBLevel(Model?.SuccessLevelId ?? 0);  // b_level |  | ||||||
|             SetUserBPlay(Model?.TotalPlayedCount ?? 0); // b_play |  | ||||||
|             SetUserProperty(Consts.PropertyDeviceID, DeviceId); // device_id |  | ||||||
|          |  | ||||||
|             // SetUserIapCoin(0); // iap_coin |  | ||||||
|             // SetUserNonIapCoin(0); // non_iap_coin |  | ||||||
|             // SetUserCoin(0);// coin |  | ||||||
|             // SetUserGrade(0); // grade |  | ||||||
|             // SetUserExp(0); // exp |  | ||||||
|             // SetUserHp(0); // hp |  | ||||||
|              |  | ||||||
|             if(!string.IsNullOrEmpty(UID)) |  | ||||||
|                 SetUID(UID); // user_id |  | ||||||
|              |  | ||||||
| #if UNITY_IOS |  | ||||||
|             SetATTStatus("notDetermined"); // att_status |  | ||||||
| #endif |  | ||||||
|             SetNotiPerm("not_determined"); // noti_perm |  | ||||||
|             SetNetworkStatus(); // NetworkStatus |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         #endregion |  | ||||||
| 
 |  | ||||||
|         #region SDK 打点 |         #region SDK 打点 | ||||||
|          |          | ||||||
|         /// <summary> |         /// <summary> | ||||||
|  | @ -478,8 +316,6 @@ namespace Guru | ||||||
|             { |             { | ||||||
|                 EnableFirebaseAnalytics = true, |                 EnableFirebaseAnalytics = true, | ||||||
|             }); |             }); | ||||||
|              |  | ||||||
|             SetUserProperty("sdk_version", Version); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|  |  | ||||||
|  | @ -75,8 +75,7 @@ namespace Guru | ||||||
|         { |         { | ||||||
|             Model.IsNoAds = value; |             Model.IsNoAds = value; | ||||||
|             ADService.Instance.IsBuyNoAds = value; |             ADService.Instance.IsBuyNoAds = value; | ||||||
|             SetUserProperty(Consts.PropertyNoAds, value? "true" : "false"); |             if(value) Analytics.SetIsIapUser(true); | ||||||
|             if(value) SetUserIsIAP(true); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|  |  | ||||||
|  | @ -125,7 +125,6 @@ namespace Guru | ||||||
|             InitThreadHandler(); // 初始化线程处理器 |             InitThreadHandler(); // 初始化线程处理器 | ||||||
|             InitServices(); // 初始化所有的服务 |             InitServices(); // 初始化所有的服务 | ||||||
|             InitNetworkMonitor(); // 网络状态 |             InitNetworkMonitor(); // 网络状态 | ||||||
|             InitiallyUpdateUserProperties(); // 上报所有初始化用户属性 |  | ||||||
|              |              | ||||||
|             onComplete?.Invoke(true); |             onComplete?.Invoke(true); | ||||||
|         } |         } | ||||||
|  | @ -189,7 +188,6 @@ namespace Guru | ||||||
|         private void InitAllGuruServices() |         private void InitAllGuruServices() | ||||||
|         { |         { | ||||||
|             // -------- Init Analytics --------- |             // -------- Init Analytics --------- | ||||||
|             InitUserProperties(); |  | ||||||
|             SetSDKEventPriority(); |             SetSDKEventPriority(); | ||||||
|             // -------- Init Notification ----------- |             // -------- Init Notification ----------- | ||||||
|             InitNotiPermission(); |             InitNotiPermission(); | ||||||
|  | @ -419,12 +417,12 @@ namespace Guru | ||||||
| 
 | 
 | ||||||
|         private void OnBLevelChanged(int bLevel) |         private void OnBLevelChanged(int bLevel) | ||||||
|         { |         { | ||||||
|             SetUserBLevel(bLevel); |             Analytics.SetBLevel(bLevel); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private void OnBPlayChanged(int bPlay) |         private void OnBPlayChanged(int bPlay) | ||||||
|         { |         { | ||||||
|             SetUserBPlay(bPlay); |             Analytics.SetBPlay(bPlay); | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         #endregion |         #endregion | ||||||
|  | @ -726,8 +724,6 @@ namespace Guru | ||||||
|         { |         { | ||||||
|             if (success) |             if (success) | ||||||
|             { |             { | ||||||
|                 Analytics.ShouldFlushGuruEvents(); |  | ||||||
|                  |  | ||||||
|                 Model.UserId = IPMConfig.IPM_UID; |                 Model.UserId = IPMConfig.IPM_UID; | ||||||
|                 if (GuruIAP.Instance != null) |                 if (GuruIAP.Instance != null) | ||||||
|                 { |                 { | ||||||
|  | @ -736,7 +732,9 @@ namespace Guru | ||||||
|                 } |                 } | ||||||
|                  |                  | ||||||
|                 // 自打点设置用户 ID |                 // 自打点设置用户 ID | ||||||
|                 SetUID(UID); |                 Analytics.SetUid(UID); | ||||||
|  |                 // 上报所有的事件 | ||||||
|  |                 Analytics.ShouldFlushGuruEvents(); | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             Callbacks.SDK.InvokeOnGuruUserAuthResult(success); |             Callbacks.SDK.InvokeOnGuruUserAuthResult(success); | ||||||
|  | @ -792,7 +790,7 @@ namespace Guru | ||||||
|             // if (!string.IsNullOrEmpty(IPMConfig.ADJUST_ID)) |             // if (!string.IsNullOrEmpty(IPMConfig.ADJUST_ID)) | ||||||
|             //     Analytics.SetAdjustId(IPMConfig.ADJUST_ID); // 二次启动后,若有值则立即上报属性 |             //     Analytics.SetAdjustId(IPMConfig.ADJUST_ID); // 二次启动后,若有值则立即上报属性 | ||||||
|              |              | ||||||
|             AdjustService.Instance.StartService(appToken, fbAppId, firebaseId, DeviceId, |             AdjustService.Instance.Start(appToken, fbAppId, firebaseId, DeviceId, | ||||||
|                 OnAdjustInitComplete, onDeeplinkCallback ,OnGetGoogleAdId ); |                 OnAdjustInitComplete, onDeeplinkCallback ,OnGetGoogleAdId ); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue