Skip to content

Conversation

@antonis
Copy link
Contributor

@antonis antonis commented Dec 1, 2025

📜 Description

Converts SentryDsn to swift

💡 Motivation and Context

See getsentry/sentry-react-native#5273 (comment)

💚 How did you test it?

Ci checks, Sample apps

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 89.58333% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.055%. Comparing base (b2295d4) to head (ac7ef01).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
Sources/Swift/SentryDsn.swift 89.583% 10 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6942       +/-   ##
=============================================
- Coverage   85.076%   85.055%   -0.021%     
=============================================
  Files          453       453               
  Lines        27674     27710       +36     
  Branches     12166     12173        +7     
=============================================
+ Hits         23544     23569       +25     
- Misses        4087      4096        +9     
- Partials        43        45        +2     
Files with missing lines Coverage Δ
Sources/Sentry/SentryBaggage.m 100.000% <ø> (ø)
Sources/Sentry/SentryClient.m 97.416% <ø> (ø)
Sources/Sentry/SentryFileManagerHelper.m 88.666% <ø> (+0.444%) ⬆️
Sources/Sentry/SentryHttpTransport.m 96.634% <ø> (ø)
Sources/Sentry/SentryNSURLRequestBuilder.m 100.000% <ø> (ø)
Sources/Sentry/SentryNetworkTracker.m 100.000% <ø> (ø)
Sources/Sentry/SentryOptionsInternal.m 99.465% <ø> (ø)
Sources/Sentry/SentryTraceContext.m 96.078% <ø> (ø)
Sources/Swift/SentryDsn.swift 89.583% <89.583%> (ø)

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2295d4...ac7ef01. Read the comment docs.

/// Generates a SHA1 hash of the DSN URL.
/// - Returns: A hexadecimal string representation of the hash.
@objc
public func getHash() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC this function isn't used, maybe we can delete it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is called from objective-c here

@antonis
Copy link
Contributor Author

antonis commented Dec 2, 2025

@sentry review

@antonis antonis added the ready-to-merge Use this label to trigger all PR workflows label Dec 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1219.81 ms 1251.72 ms 31.91 ms
Size 24.14 KiB 1.02 MiB 1023.31 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
32f2329 1224.36 ms 1257.33 ms 32.98 ms
df94923 1217.35 ms 1247.44 ms 30.09 ms
e3ebff3 1223.47 ms 1249.27 ms 25.80 ms
dba2de8 1231.45 ms 1251.88 ms 20.43 ms
ee1f2ca 1227.47 ms 1251.58 ms 24.12 ms
fc6557e 1226.40 ms 1249.88 ms 23.48 ms
7cc23cf 1203.15 ms 1232.11 ms 28.96 ms
cda95fc 1231.42 ms 1247.18 ms 15.77 ms
535ebd9 1194.59 ms 1219.84 ms 25.26 ms
26f7b17 1218.47 ms 1253.82 ms 35.35 ms

App size

Revision Plain With Sentry Diff
32f2329 23.75 KiB 1.01 MiB 1016.02 KiB
df94923 24.15 KiB 1.01 MiB 1014.90 KiB
e3ebff3 23.75 KiB 878.48 KiB 854.73 KiB
dba2de8 23.75 KiB 969.25 KiB 945.50 KiB
ee1f2ca 24.15 KiB 1.01 MiB 1015.24 KiB
fc6557e 23.75 KiB 866.68 KiB 842.93 KiB
7cc23cf 23.75 KiB 913.62 KiB 889.87 KiB
cda95fc 23.75 KiB 912.77 KiB 889.02 KiB
535ebd9 23.75 KiB 1008.67 KiB 984.92 KiB
26f7b17 23.75 KiB 960.93 KiB 937.19 KiB

Previous results on branch: antonis/ref-sentrydsn-swift

Startup times

Revision Plain With Sentry Diff
84f383d 1216.06 ms 1259.74 ms 43.68 ms
013d4db 1201.14 ms 1226.33 ms 25.19 ms
6d23dcf 1212.77 ms 1248.32 ms 35.55 ms
0db71b7 1225.65 ms 1258.75 ms 33.10 ms

App size

Revision Plain With Sentry Diff
84f383d 24.14 KiB 1.02 MiB 1020.14 KiB
013d4db 24.14 KiB 1.02 MiB 1017.01 KiB
6d23dcf 24.14 KiB 1.02 MiB 1020.13 KiB
0db71b7 24.14 KiB 1.02 MiB 1020.13 KiB

@antonis antonis marked this pull request as ready for review December 2, 2025 09:24
@antonis antonis removed the ready-to-merge Use this label to trigger all PR workflows label Dec 2, 2025
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've run make generate-public-api with xcode 16.4

@antonis antonis added the ready-to-merge Use this label to trigger all PR workflows label Dec 3, 2025
Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

Almost LGTM

@antonis antonis requested a review from philprime December 3, 2025 16:12
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

🚨 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:

  • Sources/Sentry/SentryNetworkTracker.m

@philprime
Copy link
Member

@philipphofmann @itaybre I had a quick discussion on this with @antonis and @noahsmartin in person and we believe this is a breaking change because everyone importing SentryDsn.h will not find the header anymore and manually change their code base. We just shipped the v9 major release so I think going for a v10 because it's a breaking change is overkill and we should just quickly ship v9.0.1, and consider it as a change we missed for the major release.

Do you agree with this approach?

@_implementationOnly import _SentryPrivate
import Foundation

import CommonCrypto
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to replace this with CryptoKit and use Insecure.SHA1.hash(data:) rather than the C functions that aren't very Swift friendly. But not a blocker for this PR, we can follow up with that later

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good 👍 I've actually tested it out earlier (related discussion).
I'll follow up with a separate PR on this.

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

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants