diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fdd4db1a..89a271126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Behavioral Changes - The SDK no longer relies on UnityEngine.Analytics.AnalyticsSessionInfo to determine unique users but uses SDK-internal mechanisms instead. ([#2625](https://github.com/getsentry/sentry-unity/pull/2625)) +- Metrics are now enabled by default, matching the cross-SDK standard. The `EnableMetrics` setting is now also synced to the native SDK on Windows, Linux, and consoles. ([#2635](https://github.com/getsentry/sentry-unity/pull/2635)) ### Fixes diff --git a/package-dev/Plugins/Switch/sentry_native_stubs.c b/package-dev/Plugins/Switch/sentry_native_stubs.c index 91a2479f8..c8b21851d 100644 --- a/package-dev/Plugins/Switch/sentry_native_stubs.c +++ b/package-dev/Plugins/Switch/sentry_native_stubs.c @@ -108,6 +108,12 @@ void sentry_options_set_attach_screenshot(void* options, int attach) (void)attach; } +void sentry_options_set_enable_metrics(void* options, int enable_metrics) +{ + (void)options; + (void)enable_metrics; +} + void sentry_options_set_logger(void* options, void* logger, void* userdata) { (void)options; diff --git a/src/Sentry.Unity.Native/SentryNativeBridge.cs b/src/Sentry.Unity.Native/SentryNativeBridge.cs index 66dc18fcd..18ea06305 100644 --- a/src/Sentry.Unity.Native/SentryNativeBridge.cs +++ b/src/Sentry.Unity.Native/SentryNativeBridge.cs @@ -93,6 +93,9 @@ is RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsServer } #endif + Logger?.LogDebug("Setting EnableMetrics: {0}", options.EnableMetrics); + sentry_options_set_enable_metrics(cOptions, options.EnableMetrics ? 1 : 0); + if (options.UnityInfo.IL2CPP) { Logger?.LogDebug("Setting the native logger"); @@ -166,6 +169,9 @@ internal static string GetDatabasePath(SentryUnityOptions options, IApplication? [DllImport(SentryLib)] private static extern void sentry_options_set_attach_screenshot(IntPtr options, int attachScreenshot); + [DllImport(SentryLib)] + private static extern void sentry_options_set_enable_metrics(IntPtr options, int enable_metrics); + [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)] private delegate void sentry_logger_function_t(int level, IntPtr message, IntPtr argsAddress, IntPtr userData); diff --git a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs index 87e93fbb4..e357b6724 100644 --- a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs +++ b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs @@ -130,7 +130,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null) [field: SerializeField] public bool PlayStationNativeSupportEnabled { get; set; } = true; [field: SerializeField] public bool SwitchNativeSupportEnabled { get; set; } = true; [field: SerializeField] public bool Il2CppLineNumberSupportEnabled { get; set; } = true; - [field: SerializeField] public bool EnableMetrics { get; set; } = false; + [field: SerializeField] public bool EnableMetrics { get; set; } = true; [field: SerializeField] public SentryOptionsConfiguration? OptionsConfiguration { get; set; } [field: SerializeField] public bool Debug { get; set; } = true;