Repository navigation
feat: add connection type and effective type to the device context - #5745
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
ric-oliv
left a comment
There was a problem hiding this comment.
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?
| 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; } |
There was a problem hiding this comment.
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.
| 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; } |
There was a problem hiding this comment.
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>
|
Thanks. I added |
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.
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.
Description
Devicenow has two internal fields,ConnectionTypeandConnectionEffectiveType. They serialize asconnection_typeandconnection_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
Deviceis sealed and cannot carry extra keys. The fields are internal because the keys are not settled yet. sentry-unity reaches them throughInternalsVisibleToinSentry.Unity.props. Nothing in sentry-dotnet sets them.#skip-changelog
Issues
Related to getsentry/sentry-unity#1932