From c719eb2edbc5247a861d024fc8594c322b0a4b1d Mon Sep 17 00:00:00 2001 From: huyufei Date: Mon, 5 Aug 2024 23:21:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E9=80=92=E5=BD=92=E7=9A=84=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- .../Runtime/Analytics/Analytics.Custom.cs | 71 ++++++++----------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs index 8644bcd..2a79633 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs @@ -73,20 +73,15 @@ namespace Guru { if (_hasSetUid) return; if (string.IsNullOrEmpty(uid)) return; - Debug.Log($"---[ANA] UID: {uid}"); - bool flag1 = false, flag2 = false; - if (GuruAnalytics.IsReady) - { - GuruAnalytics.Instance.SetUid(uid); - flag1 = true; - } - if (IsFirebaseReady) - { - FirebaseAnalytics.SetUserId(uid); - flag2 = true; - } - _hasSetUid = flag1 && flag2; + if (!IsFirebaseReady) return; + SetFirebaseUserId(uid); + + if (!GuruAnalytics.IsReady) return; + GuruAnalytics.Instance.SetUid(uid); + + Debug.Log($"---[ANA] UID: {uid}"); + _hasSetUid = true; } /// @@ -95,13 +90,11 @@ namespace Guru private static void SetDeviceId(string deviceId) { if (_hasSetDeviceId) return; + if (string.IsNullOrEmpty(deviceId)) return; - if (!string.IsNullOrEmpty(deviceId)) - { - GuruAnalytics.Instance.SetDeviceId(deviceId); - FirebaseAnalytics.SetUserProperty(PropertyDeviceID, deviceId); - _hasSetDeviceId = true; - } + if (!GuruAnalytics.IsReady) return; + GuruAnalytics.Instance.SetDeviceId(deviceId); + _hasSetDeviceId = true; } /// @@ -110,16 +103,12 @@ namespace Guru private static void SetAdjustId(string adjustId) { if (_hasSetAdjustId) return; + if (string.IsNullOrEmpty(adjustId)) return; + if (!GuruAnalytics.IsReady) return; + + GuruAnalytics.Instance.SetAdjustId(adjustId); + _hasSetAdjustId = true; - if (!string.IsNullOrEmpty(adjustId)) - { - GuruAnalytics.Instance.SetAdjustId(adjustId); - _hasSetAdjustId = true; - } - else - { - Debug.Log($"--- [ANA] AdjustId is Empty.."); - } } @@ -129,29 +118,23 @@ namespace Guru private static void SetAdId(string adId) { if (_hasSetAdId) return; - if (string.IsNullOrEmpty(adId)) return; + if (!GuruAnalytics.IsReady) return; GuruAnalytics.Instance.SetAdId(adId); _hasSetAdId = true; } - - - - - + /// /// 设置FirebaseId /// private static void SetFirebaseId(string firebaseId) { if (_hasSetFirebaseId) return; - - if (!string.IsNullOrEmpty(firebaseId)) - { - GuruAnalytics.Instance.SetFirebaseId(firebaseId); - _hasSetFirebaseId = true; - } + if (string.IsNullOrEmpty(firebaseId)) return; + if (!GuruAnalytics.IsReady) return; + GuruAnalytics.Instance.SetFirebaseId(firebaseId); + _hasSetFirebaseId = true; } /// @@ -188,16 +171,19 @@ namespace Guru private static void SetIDFV(string idfv) { - if(_hasSetIDFV) return; + if (_hasSetIDFV) return; if (string.IsNullOrEmpty(idfv)) return; + if (!GuruAnalytics.IsReady) return; GuruAnalytics.Instance.SetIDFV(idfv); _hasSetIDFV = true; } private static void SetIDFA(string idfa) { - if(_hasSetIDFA) return; + if (_hasSetIDFA) return; if (string.IsNullOrEmpty(idfa)) return; + if (!GuruAnalytics.IsReady) return; + GuruAnalytics.Instance.SetIDFA(idfa); _hasSetIDFA = true; } @@ -211,6 +197,7 @@ namespace Guru { if (_hasSetAndroidId) return; if (string.IsNullOrEmpty(androidId)) return; + if (!GuruAnalytics.IsReady) return; GuruAnalytics.Instance.SetAndroidID(androidId); _hasSetAndroidId = true; }