sentry-dotnet icon indicating copy to clipboard operation
sentry-dotnet copied to clipboard

User assigned values for `CrashedLastRun`, `EnableScopeSync` and `ScopeObserver` are ignored

Open jamescrosswell opened this issue 3 months ago • 3 comments

Originally posted by @jamescrosswell in https://github.com/getsentry/sentry-dotnet/pull/4521#discussion_r2350765015

CrashedLastRun, EnableScopeSync and ScopeObserver get overwritten when initialising the Native, iOS and Android integrations... e.g. https://github.com/getsentry/sentry-dotnet/blob/cc613c901d5cbac3a4856156128a26847456e6ec/src/Sentry/Platforms/Cocoa/SentrySdk.cs#L154-L158

https://github.com/getsentry/sentry-dotnet/blob/aab708ffc0c3d26babaedae12beead3aa3b8754e/src/Sentry/Platforms/Android/SentrySdk.cs#L177-L179

Any user configured values for these will get overwritten/ignored.

If that's what we want, those options should probably be internal (not public).

Alternatively we should respect the value that the user assigns to EnableScopeSync and chain/wrap the CrashedLastRun and ScopeObserver delegates so that both the user's code and ours get executed.

jamescrosswell avatar Sep 16 '25 04:09 jamescrosswell

We are thinking about removing SentryOptions.EnableScopeSync from the public API surface area, and instead have it implicitly enabled by user code setting a SentryOptions.ScopeObserver, or our Native/Android/iOS implementations setting a respective platform IScopeObserver, or an aggregate of both a User and Sentry IScopeObserver.

Flash0ver avatar Sep 17 '25 11:09 Flash0ver

Discussed again: We keep all options, but will add wrappers/combiners/aggregators for both CrashedLastRun and ScopeObserver, so that user-provided instances/delegates will not overwrite the ones that we set.

Flash0ver avatar Dec 03 '25 08:12 Flash0ver