Skip to content

feat: add connection type and effective type to the device context - #5745

Merged
alwx merged 3 commits into
mainfrom
alwx/feature/device-connection-type
Oct 20, 2026
Merged

alwx merged 3 commits into
mainfrom
alwx/feature/device-connection-type

Conversation

@alwx

@alwx alwx commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Device now has two internal fields, ConnectionType and ConnectionEffectiveType. They serialize as connection_type and connection_effective_type, the same keys that sentry-java 8.60.0 and sentry-cocoa 9.30.0 write.

sentry-unity needs these fields to copy the values from the native SDKs to C# events, because Device is sealed and cannot carry extra keys. The fields are internal because the keys are not settled yet. sentry-unity reaches them through InternalsVisibleTo in Sentry.Unity.props. Nothing in sentry-dotnet sets them.

#skip-changelog

Issues

Related to getsentry/sentry-unity#1932

Device now has ConnectionType and ConnectionEffectiveType. They map to
connection_type and connection_effective_type in the device context.
sentry-java 8.60.0 and sentry-cocoa 9.30.0 report the same keys.

Hybrid SDKs, for example sentry-unity, need typed fields to copy the
values from the native SDK to managed events. Device is sealed and has
no slot for extra keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.82%. Comparing base (84eaf9f) to head (7910bb6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5745      +/-   ##
==========================================
+ Coverage   75.60%   75.82%   +0.21%     
==========================================
  Files         519      519              
  Lines       19223    19235      +12     
  Branches     3737     3741       +4     
==========================================
+ Hits        14533    14584      +51     
+ Misses       3820     3782      -38     
+ Partials      870      869       -1     

☔ View full report in Codecov by Harness.
📢 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.

@alwx
alwx marked this pull request as ready for review October 19, 2026 14:58
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 19, 2026

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small thing about the changelog. The title would show up under Features, but the .NET SDK doesn't set either key, so there's no new feature for .NET users here. Could you add #skip-changelog to the description?

Comment thread src/Sentry/Protocol/Device.cs Outdated
Comment on lines +91 to +99
public string? ConnectionType { get; set; }

/// <summary>
/// The generation of the cellular network technology, if the connection is cellular.
/// </summary>
/// <example>
/// 2g, 3g, 4g, 5g
/// </example>
public string? ConnectionEffectiveType { get; set; }

@ric-oliv ric-oliv Oct 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making these internal? Nothing in sentry-dotnet sets them, and Unity would still be able to use them. Unity builds sentry-dotnet from its submodule, and src/Sentry/Platforms/Unity/Sentry.Unity.props adds InternalsVisibleTo Sentry.Unity for that build. src/Sentry.Unity already uses a few Sentry.Internal types too.

I'd rather keep them out of the public API because neither key is settled yet. Relay has no typed field for them, the device context spec doesn't list them, and sentry-conventions marks the device.connection_type attribute as deprecated in favor of network.connection.type. Once they're public, we're stuck with them until the next major, even if the keys move.

Later on, we could move these into an internal bag for unknown keys, together with the other device keys only the native SDKs send. Java's JsonUnknown and Dart's unknown map already work that way, and it'd let new native keys reach events without touching Device every time.

As a bonus, the four ApiApprovalTests.Run.*.verified.txt edits can go away.

Suggested change
public string? ConnectionType { get; set; }
/// <summary>
/// The generation of the cellular network technology, if the connection is cellular.
/// </summary>
/// <example>
/// 2g, 3g, 4g, 5g
/// </example>
public string? ConnectionEffectiveType { get; set; }
internal string? ConnectionType { get; set; }
/// <summary>
/// The generation of the cellular network technology, if the connection is cellular.
/// </summary>
/// <example>
/// 2g, 3g, 4g, 5g
/// </example>
internal string? ConnectionEffectiveType { get; set; }

@alwx alwx Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The fields are internal now and the API approval edits are gone. I checked that sentry-unity still builds against the internal fields and that its processor tests pass. I also added UpdateFrom tests for both fields.

The keys are not settled. Relay has no typed field for them, the device
context spec does not list them, and sentry-conventions deprecates
device.connection_type in favor of network.connection.type. Internal
fields keep them out of the public API. sentry-unity can still use
them through InternalsVisibleTo in Sentry.Unity.props.

Also add UpdateFrom tests for both fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alwx

alwx commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. I added #skip-changelog to the description.

@alwx
alwx requested a review from ric-oliv October 20, 2026 09:25

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks, @alwx!

@alwx
alwx merged commit c9ad2be into main Oct 20, 2026
46 checks passed
@alwx
alwx deleted the alwx/feature/device-connection-type branch October 20, 2026 10:07
alwx added a commit to getsentry/sentry-unity that referenced this pull request Oct 22, 2026
C# events do not pass through the native SDK, so they did not get
device.connection_type or device.connection_effective_type, which
sentry-java 8.60.0 and sentry-cocoa 9.30.0 report on native events.

UnityEventProcessor now reads both values from the native SDK on the
main thread. On Android, SentryJava reads the cached connection from
AndroidConnectionStatusProvider through JNI, and new ProGuard rules keep
the class names. On iOS and macOS, a new bridge function reads the
device entry of the Cocoa extra context.

This needs the Device fields from getsentry/sentry-dotnet#5745.
alwx added a commit to getsentry/sentry-unity that referenced this pull request Oct 22, 2026
The feature needs Device.ConnectionType and Device.ConnectionEffectiveType
from getsentry/sentry-dotnet#5745, which is merged but not released.
sentry-dotnet main needs .NET SDK 10.0.402, so global.json moves too.

Replace this commit with the update to the next sentry-dotnet release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants