-
-
Notifications
You must be signed in to change notification settings - Fork 372
ref: SentryOptions in Swift #6628
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6628 +/- ##
=============================================
+ Coverage 85.131% 85.189% +0.058%
=============================================
Files 453 453
Lines 27689 27649 -40
Branches 12113 12119 +6
=============================================
- Hits 23572 23554 -18
+ Misses 4071 4049 -22
Partials 46 46
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
5169bbd to
1b852ec
Compare
031e40c to
3581fc0
Compare
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 7bd90de | 1233.48 ms | 1249.47 ms | 15.99 ms |
| d1c4916 | 1236.25 ms | 1266.76 ms | 30.51 ms |
| 7aaa0b6 | 1230.49 ms | 1263.78 ms | 33.29 ms |
| e3ebff3 | 1223.47 ms | 1249.27 ms | 25.80 ms |
| 1a34ddc | 1218.94 ms | 1251.86 ms | 32.92 ms |
| ec3fc3a | 1212.92 ms | 1245.06 ms | 32.14 ms |
| daf8077 | 1202.78 ms | 1235.52 ms | 32.74 ms |
| b045d0a | 1227.48 ms | 1252.22 ms | 24.75 ms |
| 4a7a005 | 1229.15 ms | 1243.35 ms | 14.20 ms |
| d48a247 | 1243.59 ms | 1273.27 ms | 29.67 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 7bd90de | 23.75 KiB | 933.33 KiB | 909.58 KiB |
| d1c4916 | 23.75 KiB | 981.15 KiB | 957.40 KiB |
| 7aaa0b6 | 23.75 KiB | 989.97 KiB | 966.23 KiB |
| e3ebff3 | 23.75 KiB | 878.48 KiB | 854.73 KiB |
| 1a34ddc | 23.75 KiB | 919.88 KiB | 896.13 KiB |
| ec3fc3a | 23.74 KiB | 1022.75 KiB | 999.01 KiB |
| daf8077 | 23.75 KiB | 971.82 KiB | 948.07 KiB |
| b045d0a | 23.75 KiB | 880.21 KiB | 856.46 KiB |
| 4a7a005 | 23.75 KiB | 979.96 KiB | 956.22 KiB |
| d48a247 | 23.75 KiB | 994.73 KiB | 970.99 KiB |
796b619 to
29baa9f
Compare
897e7cb to
e2fb674
Compare
e2fb674 to
42da6fb
Compare
d078a0f to
26bfb46
Compare
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.
Bug: Inconsistent beforeSendLog exposure Across Swift Packages
The beforeSendLog callback is still conditionally excluded from dictionary initialization when SWIFT_PACKAGE is defined (#if !SWIFT_PACKAGE), but the new Swift Options class (introduced in this PR) always exposes the beforeSendLog property without any conditional compilation. This creates an inconsistency where dictionary-based initialization (via SentryOptionsInternal.initWithDict) will not properly set the beforeSendLog callback when using Swift Package Manager, even though the property exists and is accessible on the Swift Options class. The #if !SWIFT_PACKAGE guard should be removed to match the Swift implementation.
Sources/Sentry/SentryOptionsInternal.m#L116-L120
sentry-cocoa/Sources/Sentry/SentryOptionsInternal.m
Lines 116 to 120 in 26bfb46
| #if !SWIFT_PACKAGE | |
| if ([self isBlock:options[@"beforeSendLog"]]) { | |
| sentryOptions.beforeSendLog = options[@"beforeSendLog"]; | |
| } | |
| #endif // !SWIFT_PACKAGE |
f2f0e74 to
d0ea6bc
Compare
2c25073 to
e29a276
Compare
e29a276 to
4238cf0
Compare
🚨 Detected changes in high risk code 🚨High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:
|
This converts SentryOptions.h/.m to SentryOptions.swift and in doing so removes the last blocker for using SPM. It also cleans up a lot of gross bridging we had to do, like with SentryExperimentalOptions and the beforeSendLog callback. This is now replaced with one piece of cross bridging, which I'll get to later...
Almost all the relevant implementation here is in
Options.swift. This matches the old ObjC API almost exactly, except that the class is nowfinal. The API json file changed a lot structurally just because it represents Swift and ObjC differently, not because the actual API changed.The tricky part of this is that we can't call an objc header that uses a swift type from Swift code. (This works in xcodebuild but not cocoapods/SPM) To work around this the value that gets passed to
SentrySDKInternalneeds to be type-erased. This is the same as what we had to do with types defined in Swift on SentryOptions.h prior to this PR. To make it easy to follow this change I've kept the Swift type almost everywhere, but in a few header files I had to useSentryOptionsObjcwhich is just an alias forNSObject. There are extensions at the end ofOptions.swiftthat explains what is done in more detail.#skip-changelog
Closes #6690