You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Native integrations should sync the contexts when they're started. Currently, this is not possible because contexts are only filled in when a first managed event is being processed.
If I get that right, the .NET SDK is holding off on it as to avoid any unnecessary work? But in case of a native event it's too late to provide the missing context.
A plan for this, now that #5671 has added ScopeDefaults on version7.
What changed.ScopeDefaults computes the OS, runtime and device boot-time contexts once, in SentrySdk.Init, so they exist before the first managed event. Sending them to the native SDKs at init no longer costs anything extra, so an opt-in option shouldn't be needed.
What to send. Only what the native SDKs can't collect themselves. Cocoa and Android already gather richer OS and device data, and sending ours would overwrite it. That's the same problem fixed in review on #5671, where a partial Xbox OS context picked up the host's macOS version. That probably leaves the .NET runtime context, but each SDK needs checking:
native: does sentry-native add its own os context?
cocoa
android
How.IScopeObserver has no context member, and it's public because Unity's ScopeObserver implements it, so adding one would be breaking. Instead, the built-in observers can implement a small internal interface. SentrySdk.InitHub calls it once after native init, next to the existing default-tags push:
native: sentry_set_context
cocoa: setContextValue on the scope
android: setContexts on the Java scope
These values are the same for the whole process, so they're safe on a native SDK's single global scope, even in server apps that have a scope per request. The concern raised in #5052 for attachments doesn't apply.
Testing. Unit tests with a substitute observer, and ideally the iOS and Android crash integration tests checking that a native crash carries the .NET runtime context.
This is additive, so it isn't needed for 7.0 and can ship in any 7.x release.
Activity
bitsandfoxes commentedon Sep 6, 2024
If I get that right, the .NET SDK is holding off on it as to avoid any unnecessary work? But in case of a native event it's too late to provide the missing context.
jamescrosswell commentedon May 19, 2026
We could add an option
PreloadEventContextor something like that... folks that want this could opt in.jamescrosswell commentedon Oct 6, 2026
A plan for this, now that #5671 has added
ScopeDefaultsonversion7.What changed.
ScopeDefaultscomputes the OS, runtime and device boot-time contexts once, inSentrySdk.Init, so they exist before the first managed event. Sending them to the native SDKs at init no longer costs anything extra, so an opt-in option shouldn't be needed.What to send. Only what the native SDKs can't collect themselves. Cocoa and Android already gather richer OS and device data, and sending ours would overwrite it. That's the same problem fixed in review on #5671, where a partial
XboxOS context picked up the host's macOS version. That probably leaves the .NETruntimecontext, but each SDK needs checking:oscontext?How.
IScopeObserverhas no context member, and it's public because Unity'sScopeObserverimplements it, so adding one would be breaking. Instead, the built-in observers can implement a small internal interface.SentrySdk.InitHubcalls it once after native init, next to the existing default-tags push:sentry_set_contextsetContextValueon the scopesetContextson the Java scopeThese values are the same for the whole process, so they're safe on a native SDK's single global scope, even in server apps that have a scope per request. The concern raised in #5052 for attachments doesn't apply.
Testing. Unit tests with a substitute observer, and ideally the iOS and Android crash integration tests checking that a native crash carries the .NET runtime context.
This is additive, so it isn't needed for 7.0 and can ship in any 7.x release.