diff --git a/Runtime/Code/Config/GuruSDKInitConfig.cs b/Runtime/Code/Config/GuruSDKInitConfig.cs index c57a14c..cfc2f47 100644 --- a/Runtime/Code/Config/GuruSDKInitConfig.cs +++ b/Runtime/Code/Config/GuruSDKInitConfig.cs @@ -44,6 +44,10 @@ namespace Guru /// public bool DebugMode = false; /// + /// Debug模式下开启打点(默认关闭) + /// + public bool EnableDebugLogEvent = false; + /// /// 云控参数的默认配置 /// /// @@ -76,7 +80,8 @@ namespace Guru bool useAdjustDeeplink = false, Dictionary defaultRemoteData = null, byte[] googleKeys = null, - byte[] appleRootCerts = null) + byte[] appleRootCerts = null, + bool debugEnableEventLog = false) { // 创建启动用参数 GuruSDKInitConfig config = new GuruSDKInitConfig() @@ -92,6 +97,7 @@ namespace Guru GoogleKeys = googleKeys, AppleRootCerts = appleRootCerts, DefaultRemoteData = defaultRemoteData ?? new Dictionary(), + EnableDebugLogEvent = debugEnableEventLog, }; #if UNITY_EDITOR config.DebugMode = true; diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 50ddb87..0626f66 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -34,7 +34,6 @@ namespace Guru } private GuruSDKInitConfig _initConfig; - private Action _onCompleteCallback; internal static GuruSDKInitConfig InitConfig => Instance._initConfig; internal static GuruSDKModel Model => GuruSDKModel.Instance; @@ -99,11 +98,12 @@ namespace Guru string bannerColor = "#00000000", Dictionary defaultRemoteData = null, byte[] googleKeys = null, - byte[] appleRootCerts = null) + byte[] appleRootCerts = null, + bool debugEnableEventLog = false) { var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled, autoRecordFinishedLevels, isBuyNoAds, bannerColor, - debugMode, useAdjustDeeplink, defaultRemoteData, googleKeys, appleRootCerts); + debugMode, useAdjustDeeplink, defaultRemoteData, googleKeys, appleRootCerts, debugEnableEventLog); return config; } @@ -144,22 +144,20 @@ namespace Guru IsInitialSuccess = false; _initConfig = config; - _onCompleteCallback = onComplete; _isDebugEnabled = config.DebugMode; - InitAssets(); - } - - - private void InitAssets() - { + if (config.EnableDebugLogEvent) Analytics.EnableDebugAnalytics = true; // 允许 Debug 模式下打点 + InitUpdaters(); // Updaters InitThreadHandler(); // 初始化线程处理器 + InitServices(); + + onComplete?.Invoke(true); } - - void Start() + private void InitServices() { + Analytics.InitAnalytics(); // 打点提前初始化 //---- Start All tools ---- LogI($"#2 --- InitFirebase ---"); //---------- Start Firebase ------------ @@ -167,13 +165,13 @@ namespace Guru LogI($"#2.1 --- InitFacebook ---"); //---------- Start Facebook ------------ - FBService.Instance.StartService(); + FBService.Instance.StartService(Analytics.OnFBInitComplete); - LogI($"#2.2 --- Call SDK init complete -> callback: { (_onCompleteCallback == null ? "Null" : _onCompleteCallback.ToString()) } ---"); IsInitialSuccess = true; - _onCompleteCallback?.Invoke(true); } - + + + /// /// 启动 Firebase 服务 /// @@ -188,7 +186,7 @@ namespace Guru FirebaseUtil.OnAdjustDeeplinkCallback = OnDeeplinkCallback; // 挂载 Deeplink 的回调 } - FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 + FirebaseUtil.InitFirebase(Analytics.OnFirebaseInitCompleted); // 确保所有的逻辑提前被调用到 } private void OnUserAuthResult(bool success) @@ -318,7 +316,7 @@ namespace Guru //---------------------------------------------------------------- // 自打点设置错误上报 - if(enableAnaErrorLog) GuruAnalytics.EnableErrorLog = true; + // if(enableAnaErrorLog) GuruAnalytics.EnableErrorLog = true; // adjust 事件设置 if (null != _appServicesConfig.adjust_settings && null != GuruSettings)