diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.Const.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.Const.cs index 7b575c7..c960a0b 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.Const.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.Const.cs @@ -132,7 +132,9 @@ namespace Guru public const string PropertyGDPR = "gdpr"; // GDPR状态 public const string PropertySignUpMethod = "sign_up_method"; // 用户登录方式 public const string PropertyFirebaseId = "firebase_id"; // FirebaseID - public const string PropertyGoogleAdId = "ad_id"; // FirebaseID + public const string PropertyGoogleAdId = "ad_id"; // Google AdId + public const string PropertyAnalyticsExperimentalGroup = "guru_analytics_exp"; // Analytics Experimental Group + public static HashSet PredefinedMidWareProperties = new HashSet() { diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs index d884666..0d49b1c 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs @@ -39,7 +39,7 @@ namespace Guru { OnGuruAnalyticsInitComplete(); Debug.Log($"{TAG} [guru_analytic]--- Guru EXP: GroupId: {GuruAnalytics.Instance.ExperimentGroupId}"); - SetUserProperty(GuruAnalyticsConfigManager.KEY_GURU_ANALYTICS_EXP, GuruAnalytics.Instance.ExperimentGroupId); + SetAnalyticsExperimentGroup(GuruAnalytics.Instance.ExperimentGroupId); ApplyAllMidWareProperties(); }, IsDebug, firebaseId); // Android 初始化 diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.Property.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.Property.cs index 14f62dd..ed16af0 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.Property.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.Property.cs @@ -72,7 +72,41 @@ namespace Guru { MidWarePropertiesManager.Instance.ReportUid(uid); } + + /// + /// 设置用户ID + /// + public static void SetBLevel(int bLevel) + { + MidWarePropertiesManager.Instance.ReportBLevel($"{bLevel}"); + } + + /// + /// 设置用户ID + /// + public static void SetBPlay(int bPlay) + { + MidWarePropertiesManager.Instance.ReportBPlay($"{bPlay}"); + } + /// + /// 设置Analytics 实验分组 + /// (Firebase, Guru) + /// + private static void SetAnalyticsExperimentGroup(string groupName) + { + MidWarePropertiesManager.Instance.ReportAnalyticsExperimentGroup(groupName); + } + + /// + /// 设置账号登录方法 + /// (Firebase, Guru) + /// + internal static void SetSignUpMethod(string methodName) + { + MidWarePropertiesManager.Instance.ReportSignUpMethod(methodName); + } + /// /// 设置设备ID /// (Firebase, Guru) @@ -241,6 +275,64 @@ namespace Guru } } /// + /// BLevel + /// + private class MidWarePropertyBLevel : AbstractMidWareProperty + { + public MidWarePropertyBLevel(string value) + : base(PropertyLevel, value, ReportPropertyTarget.Both) + { + } + + protected override void BeforeReportProperty() + { + } + } + /// + /// BLevel + /// + private class MidWarePropertyBPlay : AbstractMidWareProperty + { + public MidWarePropertyBPlay(string value) + : base(PropertyPlay, value, ReportPropertyTarget.Both) + { + } + + protected override void BeforeReportProperty() + { + } + } + + + /// + /// SignUpMethod + /// + private class MidWarePropertySignUpMethod : AbstractMidWareProperty + { + public MidWarePropertySignUpMethod(string value) + : base(PropertySignUpMethod, value, ReportPropertyTarget.Both) + { + + } + protected override void BeforeReportProperty() + { + } + } + /// + /// AnalyticsExperimentGroup + /// + private class MidWarePropertyAnalyticsExperimentGroup : AbstractMidWareProperty + { + public MidWarePropertyAnalyticsExperimentGroup(string value) + : base(PropertyAnalyticsExperimentalGroup, value, ReportPropertyTarget.Both) + { + + } + protected override void BeforeReportProperty() + { + } + } + /// /// DeviceId /// private class MidWarePropertyDeviceId : AbstractMidWareProperty @@ -475,7 +567,33 @@ namespace Guru _propertyMap.TryAdd(prop.key, prop); prop.Report(); } + public void ReportBLevel(string bLevel) + { + var prop = new MidWarePropertyBLevel(bLevel); + _propertyMap.TryAdd(prop.key, prop); + prop.Report(); + } + public void ReportBPlay(string bPlay) + { + var prop = new MidWarePropertyBPlay(bPlay); + _propertyMap.TryAdd(prop.key, prop); + prop.Report(); + } + public void ReportAnalyticsExperimentGroup(string groupName) + { + var prop = new MidWarePropertyAnalyticsExperimentGroup(groupName); + _propertyMap.TryAdd(prop.key, prop); + prop.Report(); + } + + public void ReportSignUpMethod(string methodName) + { + var prop = new MidWarePropertySignUpMethod(methodName); + _propertyMap.TryAdd(prop.key, prop); + prop.Report(); + } + public void ReportDeviceId(string deviceId) { var prop = new MidWarePropertyDeviceId(deviceId); diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs index 05bcb2e..20185e2 100644 --- a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs +++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs @@ -87,7 +87,7 @@ namespace Guru FirebaseAnalytics.SetSessionTimeoutDuration(new TimeSpan(0, 30, 0)); // --- 上报用户事件 --- - SetUserProperty(PropertyDeviceID, IPMConfig.IPM_DEVICE_ID); + SetDeviceId(IPMConfig.IPM_DEVICE_ID); // SetUserProperty(PropertyFirstOpenTime, FirstOpenTime); _firebaseEventDriver.TriggerFlush(); @@ -158,6 +158,7 @@ namespace Guru Crashlytics.SetUserId(uid); } + /// /// 设置用户属性 /// @@ -194,10 +195,9 @@ namespace Guru Debug.Log($"Catch Error: {ex}"); } } - - - } + + /// diff --git a/Runtime/GuruCore/Runtime/Firebase/FirebaseUtil.Auth.cs b/Runtime/GuruCore/Runtime/Firebase/FirebaseUtil.Auth.cs index 3a65488..a63d2d6 100644 --- a/Runtime/GuruCore/Runtime/Firebase/FirebaseUtil.Auth.cs +++ b/Runtime/GuruCore/Runtime/Firebase/FirebaseUtil.Auth.cs @@ -78,7 +78,8 @@ namespace Guru bool success = FirebaseUser != null; onLoginResult?.Invoke(success); _retryDelayTime = LOGIN_RETRY_INTERVAL; - Analytics.SetUserProperty(Analytics.PropertySignUpMethod, "google"); // 上报用户登录属性 + + Analytics.SetSignUpMethod("google"); // 上报用户登录属性 }); } diff --git a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs index d2c412a..9e83a40 100644 --- a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs +++ b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs @@ -923,7 +923,7 @@ namespace Guru { Instance._model.SetIsIapUser(value); // 用户属性 } - Analytics.SetUserProperty(Analytics.PropertyIsIAPUser, value ? "true" : "false"); + Analytics.SetIsIapUser(value); }