-
-
Notifications
You must be signed in to change notification settings - Fork 282
internal(flutter): Add SDK features metadata for SPM vs CocoaPods tracking #3508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds SDK build-time metadata support for tracking iOS integration type (Swift Package Manager vs CocoaPods) by introducing sdk.features and wiring it through Dart/Flutter and the native iOS plugin.
Changes:
- Extend
SdkVersion(Dart) withfeatures, JSON (de)serialization, andaddFeature()deduplication. - Merge native-reported
featuresinto the event SDK inLoadContextsIntegration. - Report iOS build type via native plugin (
SwiftPackageManagervs CocoaPods) and adjust iOS package naming for SPM vs CocoaPods.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/flutter/test/integrations/load_contexts_integration_test.dart | Adds coverage for merging/deduplicating sdk.features from native contexts. |
| packages/flutter/lib/src/sentry_flutter.dart | Ensures features are preserved when the Flutter SDK info is set on options. |
| packages/flutter/lib/src/integrations/load_contexts_integration.dart | Merges features from native loadContexts into event.sdk using addFeature(). |
| packages/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift | Emits iOS feature (SwiftPackageManager/CocoaPods) and merges Flutter sdk.features into native event SDK. |
| packages/flutter/ios/sentry_flutter/Package.swift | Defines SENTRY_FLUTTER_SPM for SwiftPM builds to drive conditional reporting. |
| packages/dart/test/protocol/sdk_version_test.dart | Updates SDK JSON fixtures and adds tests for addFeature() dedup behavior. |
| packages/dart/lib/src/protocol/sdk_version.dart | Introduces features field, serialization, and addFeature() helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift
Outdated
Show resolved
Hide resolved
packages/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
packages/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift
Outdated
Show resolved
Hide resolved
Android Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| cba2765 | 405.98 ms | 422.02 ms | 16.04 ms |
| f872f8e | 402.38 ms | 416.20 ms | 13.82 ms |
| e2d675d | 457.92 ms | 529.17 ms | 71.25 ms |
| 3f47ea3 | 368.20 ms | 388.14 ms | 19.94 ms |
| a2c8611 | 384.89 ms | 371.41 ms | -13.48 ms |
| f761369 | 462.73 ms | 563.80 ms | 101.06 ms |
| 6f47800 | 451.04 ms | 509.64 ms | 58.60 ms |
| e04b24b | 504.72 ms | 516.43 ms | 11.71 ms |
| a909995 | 383.55 ms | 370.78 ms | -12.77 ms |
| cf443d2 | 464.64 ms | 479.04 ms | 14.40 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| cba2765 | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| f872f8e | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| e2d675d | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| 3f47ea3 | 13.93 MiB | 15.18 MiB | 1.25 MiB |
| a2c8611 | 14.09 MiB | 15.28 MiB | 1.19 MiB |
| f761369 | 6.54 MiB | 7.70 MiB | 1.16 MiB |
| 6f47800 | 6.54 MiB | 7.69 MiB | 1.15 MiB |
| e04b24b | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| a909995 | 14.09 MiB | 15.28 MiB | 1.19 MiB |
| cf443d2 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
Previous results on branch: internal/spm-vs-cocoapods
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 07ddb75 | 371.33 ms | 367.13 ms | -4.20 ms |
| f361bc4 | 365.48 ms | 368.48 ms | 3.00 ms |
| 67ee1b9 | 374.09 ms | 363.98 ms | -10.11 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 07ddb75 | 14.09 MiB | 15.28 MiB | 1.19 MiB |
| f361bc4 | 14.09 MiB | 15.28 MiB | 1.19 MiB |
| 67ee1b9 | 14.09 MiB | 15.28 MiB | 1.19 MiB |
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 40c8f93 | 1234.27 ms | 1261.98 ms | 27.71 ms |
| e1ab497 | 1260.92 ms | 1260.22 ms | -0.69 ms |
| 6b69699 | 1254.80 ms | 1273.31 ms | 18.52 ms |
| 4ff8a1b | 1233.71 ms | 1240.21 ms | 6.49 ms |
| 3ddf010 | 1243.78 ms | 1241.74 ms | -2.04 ms |
| a5b28db | 1260.16 ms | 1260.08 ms | -0.08 ms |
| e5b87f8 | 1257.94 ms | 1261.90 ms | 3.96 ms |
| 73a3c38 | 1263.37 ms | 1277.90 ms | 14.53 ms |
| 6f47800 | 1247.52 ms | 1259.37 ms | 11.85 ms |
| cf443d2 | 1255.79 ms | 1248.38 ms | -7.40 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 40c8f93 | 5.53 MiB | 6.00 MiB | 479.94 KiB |
| e1ab497 | 5.53 MiB | 6.01 MiB | 487.96 KiB |
| 6b69699 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 4ff8a1b | 5.53 MiB | 5.96 MiB | 444.85 KiB |
| 3ddf010 | 5.53 MiB | 6.02 MiB | 501.22 KiB |
| a5b28db | 5.53 MiB | 6.02 MiB | 501.31 KiB |
| e5b87f8 | 5.53 MiB | 6.02 MiB | 502.11 KiB |
| 73a3c38 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 6f47800 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| cf443d2 | 5.53 MiB | 6.00 MiB | 479.99 KiB |
Previous results on branch: internal/spm-vs-cocoapods
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 67ee1b9 | 1247.71 ms | 1255.29 ms | 7.58 ms |
| 07ddb75 | 1254.27 ms | 1266.63 ms | 12.37 ms |
| f361bc4 | 1248.24 ms | 1254.13 ms | 5.89 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 67ee1b9 | 5.66 MiB | 6.10 MiB | 452.21 KiB |
| 07ddb75 | 5.66 MiB | 6.10 MiB | 452.22 KiB |
| f361bc4 | 5.66 MiB | 6.10 MiB | 452.21 KiB |
|
e2e tests failing with 403 still, probably the auth token is invalid .. |
denrase
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some questions regarding dedupe.
| } | ||
| if let features = flutterSdk!["features"] as? [String] { | ||
| if let sdkFeatures = sdk["features"] as? [String] { | ||
| sdk["features"] = sdkFeatures + features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we even need this, but shouldn't we do de-duplication here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can, I just didnt add it because theres almost no chance for a dupe to happen - imo we don't really need it
| final sdk = event.sdk ?? _options.sdk; | ||
|
|
||
| for (final feature in features) { | ||
| sdk.addFeature(feature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here should the merged de-duplication be done, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah when adding/merging to the dart features it already dedupes (addFeature only adds if unique)
| expect(event?.sdk?.features.contains('SwiftPackageManager'), true); | ||
| }); | ||
|
|
||
| test('does not duplicate feature if already present', () async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Summary
featureslist toSdkVersion(alongsideintegrationsandpackages) for additional SDK metadataSwiftPackageManagerorCocoaPodsas an SDK feature on iOS based on build typespm:sentry-cocoavscocoapods:sentry-cocoaThis allows us to internally query usage data
Note: features metadata was introduced here getsentry/team-sdks#83 and is currently used in sentry cocoa as well
Motivation
Closes #3492
Test plan
SdkVersionserialization roundtrip (toJson/fromJson) includes featuresaddFeature()deduplication works correctlyLoadContextsIntegrationmerges native features into event SDK"features": ["SwiftPackageManager"]in event payload🤖 Generated with Claude Code