Skip to content

fix: sync default tags to native layer#5214

Open
bitsandfoxes wants to merge 2 commits intomainfrom
fix/default-tags-native-sync
Open

fix: sync default tags to native layer#5214
bitsandfoxes wants to merge 2 commits intomainfrom
fix/default-tags-native-sync

Conversation

@bitsandfoxes
Copy link
Copy Markdown
Contributor

@bitsandfoxes bitsandfoxes commented May 8, 2026

Came up through and resolves getsentry/sentry-unity#2668

The Problem

When a user sets DefaultTags on the options, these tags do not make it to native events from Android or iOS. This is not only an issue for Unity but affects C# Android and iOS app as well.
The comment seems to be out of date and prior to the addition of the extensive native support the SDK has now.

// NOTE: Tags in options.DefaultTags should not be passed down, because we already call SetTag on each
//       one when sending events, which is relayed through the scope observer.

Context

When a user sets the DefaultTags on the options, in the regular processing pipeline, these get applied by the Enricher on each individual event.

_options.ApplyDefaultTags(eventLike);

I don't know what the grand design here was, and why tags are not getting applied to the scope instead. Maybe this comes from one of the other integrations, or behaviour outside of having a GlobalScope? If not, we could move it out of the Enricher in general. Happy to follow up on this if that's the case.

Proposal

During initialization, and if scope sync is enabled, and if there is a ScopeObserver, we set those tags, making them available on the native layer. The regular flow inside the C# processing stays preserved.

Sample events taken from the Unity SDK with options.DefaultTags.Add("my", "tag");:

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.14%. Comparing base (af4ebc3) to head (04bf992).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5214   +/-   ##
=======================================
  Coverage   74.14%   74.14%           
=======================================
  Files         506      506           
  Lines       18292    18295    +3     
  Branches     3576     3578    +2     
=======================================
+ Hits        13562    13565    +3     
  Misses       3859     3859           
  Partials      871      871           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DefaultTags from SentryUnityOptions are not propagated to native crash events

1 participant