Skip to content

Commit 4f98f7b

Browse files
JoshuaMoelansweb-flowclaude
authored
fix(metrics): Sync EnableMetrics setting to native SDK and default to true (#2635)
* chore: update modules/sentry-native to 0.13.5 * Sync EnableMetrics setting to native SDK and default to true The sentry-native 0.13.5 update changed metrics to be enabled by default. This syncs the Unity EnableMetrics option to the native layer via sentry_options_set_enable_metrics and aligns the Unity default to true, matching the cross-SDK standard from develop docs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * changelog update * actually point at the PR * add stub for switch --------- Co-authored-by: GitHub <noreply@github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e2f2db4 commit 4f98f7b

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Behavioral Changes
66

77
- 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))
8+
- 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))
89

910
### Fixes
1011

package-dev/Plugins/Switch/sentry_native_stubs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ void sentry_options_set_attach_screenshot(void* options, int attach)
108108
(void)attach;
109109
}
110110

111+
void sentry_options_set_enable_metrics(void* options, int enable_metrics)
112+
{
113+
(void)options;
114+
(void)enable_metrics;
115+
}
116+
111117
void sentry_options_set_logger(void* options, void* logger, void* userdata)
112118
{
113119
(void)options;

src/Sentry.Unity.Native/SentryNativeBridge.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ is RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsServer
9393
}
9494
#endif
9595

96+
Logger?.LogDebug("Setting EnableMetrics: {0}", options.EnableMetrics);
97+
sentry_options_set_enable_metrics(cOptions, options.EnableMetrics ? 1 : 0);
98+
9699
if (options.UnityInfo.IL2CPP)
97100
{
98101
Logger?.LogDebug("Setting the native logger");
@@ -166,6 +169,9 @@ internal static string GetDatabasePath(SentryUnityOptions options, IApplication?
166169
[DllImport(SentryLib)]
167170
private static extern void sentry_options_set_attach_screenshot(IntPtr options, int attachScreenshot);
168171

172+
[DllImport(SentryLib)]
173+
private static extern void sentry_options_set_enable_metrics(IntPtr options, int enable_metrics);
174+
169175
[UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
170176
private delegate void sentry_logger_function_t(int level, IntPtr message, IntPtr argsAddress, IntPtr userData);
171177

src/Sentry.Unity/ScriptableSentryUnityOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null)
130130
[field: SerializeField] public bool PlayStationNativeSupportEnabled { get; set; } = true;
131131
[field: SerializeField] public bool SwitchNativeSupportEnabled { get; set; } = true;
132132
[field: SerializeField] public bool Il2CppLineNumberSupportEnabled { get; set; } = true;
133-
[field: SerializeField] public bool EnableMetrics { get; set; } = false;
133+
[field: SerializeField] public bool EnableMetrics { get; set; } = true;
134134
[field: SerializeField] public SentryOptionsConfiguration? OptionsConfiguration { get; set; }
135135

136136
[field: SerializeField] public bool Debug { get; set; } = true;

0 commit comments

Comments
 (0)