diff --git a/Runtime/Code/Config/GuruServicesConfig.cs b/Runtime/Code/Config/GuruServicesConfig.cs index fa0963e..0f43e98 100644 --- a/Runtime/Code/Config/GuruServicesConfig.cs +++ b/Runtime/Code/Config/GuruServicesConfig.cs @@ -54,6 +54,7 @@ namespace Guru //-------------------------------- Parameters -------------------------------- public double Tch02Value() => parameters?.tch_020 ?? 0; public bool IsAppReview() => parameters?.apple_review ?? false; + public bool EnableErrorLog() => parameters?.enable_errorlog ?? false; public bool DMACountryCheck() => parameters?.dma_country_check ?? false; public string DMAMapRule() => parameters?.dma_map_rule ?? ""; public bool UseUUID() => parameters?.using_uuid ?? false; @@ -93,6 +94,7 @@ namespace Guru public string dma_map_rule = ""; public bool dma_country_check = false; public bool apple_review = false; // 苹果审核标志位 + public bool enable_errorlog = false; } [Serializable] diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 9aee671..02ee0f0 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -46,11 +46,8 @@ namespace Guru return _guruSettings; } } - - + private static DateTime _initTime; - - private static bool _isDebugEnabled = false; /// /// Debug Mode @@ -104,7 +101,7 @@ namespace Guru public static void Init(GuruSDKInitConfig config, Action onComplete) { _initTime = DateTime.Now.ToUniversalTime(); - LogI($"---- Guru SDK init ----\n{config.ToString()}"); + LogI($"#1 ---- Guru SDK init ----\n{config.ToString()}"); Instance.StartWithConfig(config, onComplete); } @@ -123,25 +120,21 @@ namespace Guru _initConfig = config; _onCompleteCallback = onComplete; _isDebugEnabled = config.DebugMode; - GuruRepoter.Install(); // Install Crashlytics Logger - - bool isDebug = false; -#if DEBUG - isDebug = true; -#endif - Analytics.InstallGuruAnalytics(isDebug); // 提前初始化 GuruAnalytics - //--- 之后的逻辑放在 Start 方法内 --- } void Start() { //---- Init All tools ---- - LogI($"--- InitFirebase ---"); + LogI($"#2 --- InitFirebase ---"); //---------- Start Firebase ------------ - FirebaseUtil.InitFirebase(OnFirebaseReady); - // FirebaseUtil.OnFetchRemoteSuccess+= OnFetchRemoteCallback; + FirebaseUtil.InitFirebase(OnFirebaseReady); // 确保所有的逻辑提前被调用到 + + LogI($"#2.1 --- InitFacebook ---"); //---------- Start Facebook ------------ FBService.Instance.StartService(); + + LogI($"#2.2 --- Call SDK init complete -> callback: { (_onCompleteCallback == null ? "Null" : _onCompleteCallback.ToString()) } ---"); + _onCompleteCallback?.Invoke(true); } @@ -150,28 +143,21 @@ namespace Guru /// private void OnFirebaseReady() { - LogI($"--- OnFirebaseReady ---"); + LogI($"#3 --- On FirebaseReady ---"); IsInitialSuccess = true; - if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID); - LogI($"--- UID:{IPMConfig.IPM_UID} ---"); + if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID); ; - LogI($"--- Init RemoteConfig ---"); + LogI($"#3.5 --- Call InitRemoteConfig ---"); // 开始Remote Manager初始化 RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData)); RemoteConfigManager.OnFetchCompleted += OnFetchRemoteCallback; - // 延迟执行 SDK 回调 - // Delay(0, () => - // { - LogI($"--- SDK Init Complete -> Callback: { (_onCompleteCallback == null ? "Null" : "NotNull") } ---"); - _onCompleteCallback?.Invoke(true); - // }); - - LogI($"--- Apply online services config ---"); - // 根据上次的云控配置来初始化参数 - SetupServicesConfig(); + LogI($"#4 --- Apply remote services config ---"); + // 根据缓存的云控配置来初始化参数 + InitAllServices(); + LogI($"#5 --- sync sdk time ---"); var sp = DateTime.Now.ToUniversalTime() - _initTime; LogSDKInitTime(sp.TotalSeconds); } @@ -198,7 +184,7 @@ namespace Guru /// private void OnFetchRemoteCallback(bool success) { - LogI($"--- Remote fetch complete: {success} ---"); + LogI($"#6 --- Remote fetch complete: {success} ---"); ABTestManager.Init(); // 启动AB测试解析器 Callbacks.Remote._onRemoteFetchComplete?.Invoke(success); } @@ -210,7 +196,7 @@ namespace Guru /// /// Apply Cloud guru-service configs for sdk assets /// - private void SetupServicesConfig() + private void InitAllServices() { bool useKeywords = false; bool useIAP = true; @@ -226,9 +212,13 @@ namespace Guru Try(() => { - LogI($"--- Init apply services ---"); - //-------------------------------- + LogI($"#4.1 --- Init apply services ---"); + //---------------------------------------------------------------- + + // 自打点设置错误上报 + GuruAnalytics.EnableErrorLog = _appServicesConfig.EnableErrorLog(); + // adjust 事件设置 if (null != _appServicesConfig.adjust_settings && null != GuruSettings) { // 更新 Adjust Tokens @@ -239,6 +229,8 @@ namespace Guru GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events); } + LogI($"#4.2 --- Init GuruSttings ---"); + // GuruSettings 设置 if (null != _appServicesConfig.app_settings) { if (_appServicesConfig.Tch02Value() > 0) @@ -251,6 +243,9 @@ namespace Guru if (_appServicesConfig.UseUUID()) { IPMConfig.UsingUUID = true; // 开始使用 UUID 作为 DeviceID 标识 + + + } #if UNITY_IOS @@ -285,7 +280,7 @@ namespace Guru // InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP Try(() => { - LogI($"--- Init IAP ---"); + LogI($"#4.3 --- Init IAP ---"); InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP }, ex => { @@ -299,7 +294,7 @@ namespace Guru // KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 Try(() => { - LogI($"--- Init Keywords ---"); + LogI($"#4.4 --- Init Keywords ---"); KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 }, ex => { @@ -313,7 +308,7 @@ namespace Guru // StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程 Try(() => { - LogI($"--- StartAppleReviewFlow ---"); + LogI($"#4.5.0 --- StartAppleReviewFlow ---"); StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程 }, ex => { @@ -328,7 +323,7 @@ namespace Guru // StartConsentFlow(); Try(() => { - LogI($"--- #1. StartConsentFlow ---"); + LogI($"#4.5 --- StartConsentFlow ---"); StartConsentFlow(); }, ex => { @@ -452,7 +447,7 @@ namespace Guru /// public static void Report(string message) { - GuruRepoter.Log(message); + Analytics.LogCrashlytics(message, false); } /// @@ -461,7 +456,7 @@ namespace Guru /// public static void ReportException(string message) { - GuruRepoter.LogException(message); + Analytics.LogCrashlytics(message); } /// @@ -470,7 +465,7 @@ namespace Guru /// public static void ReportException(Exception ex) { - GuruRepoter.LogException(ex); + Analytics.LogCrashlytics(ex); } #endregion