Skip to content

ref: Convert SentryTransaction to Swift - #9369

Open
donnywals wants to merge 8 commits into
mainfrom
ref/convert-transaction-to-swift
Open

donnywals wants to merge 8 commits into
mainfrom
ref/convert-transaction-to-swift

Conversation

@donnywals

@donnywals donnywals commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Converts SentryTransaction to Swift without adopting Swift best-practices or being concerned with the Swift code being idiomatic.

Compatibility
The Swift implementation should have the exact same visibility as the Objective-C implementation had. Only minimal changes were made to internal code to ensure we don't change public headers and visibility

Verification
Passed formatting, tests, and ran generate-public-api to ensure there are no breaking changes and to ensure that no unexpected public API changes were made.

Fixes #9221

#skip-changelog


Note

Medium Risk
Touches transaction capture, serialization, and trace-correlated profiling with ObjC–Swift bridging (KVC and casts) where behavior regressions would affect performance data.

Overview
Migrates SentryTransaction from Objective-C into a Swift Transaction class (Sources/Swift/Transaction/SentryTransaction.swift) while keeping the same @objc(SentryTransaction) surface (spans, tag merging, serialization, and an internal initWithTrace:children: bridge).

The old public header and implementation (SentryTransaction.h, SentryTransaction.m, SentryTransaction+Private.h) are removed from the Xcode target; umbrella imports in Sentry.h / SentryWithoutUIKit.h no longer pull in a separate transaction header. sdk_api.json is updated so the type is exported from the Swift module.

Objective-C call sites drop SentryTransaction+Private.h and adapt to the Swift type: profiling code reads the tracer via KVC/trace casting and sets startSystemTime / endSystemTime with setValue:forKey:; SentryHub casts transaction.trace to SentryTracer for sampling decisions; profiler envelope building casts to SentryTracer for trace metadata.

Reviewed by Cursor Bugbot for commit 5ad7e89. Configure here.

@donnywals donnywals added the run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request label Oct 16, 2026
@sentry

sentry Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Size Analysis

1 component analyzed

iOS Builds

Name Configuration Version Download Size Install Size
SDK-Size (iOS)
io.sentry.sample.SDK-Size
Release 9.31.0 (1) 1.2 MB (+3.7 KB) 3.1 MB (0 B)

Configure sentry-cocoa status check rules

@sentry

sentry Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.31.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Fix All in Cursor

Bugbot Autofix is ON, but none of the reported issues met your autofix severity threshold.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5ad7e89. Configure here.

Comment thread Sources/Swift/Transaction/SentryTransaction.swift Outdated

@philprime philprime 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.

Almost LGTM, left some feedback to consider

Comment thread Sentry.xcodeproj/project.pbxproj Outdated
Comment thread Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm Outdated
Comment thread Sources/Swift/Transaction/SentryTransaction.swift Outdated
Comment thread Sources/Swift/Transaction/SentryTransaction.swift Outdated
@donnywals
donnywals marked this pull request as draft October 16, 2026 11:00
@donnywals donnywals changed the title Inital pass to convert SentryTransation to Swift ref: Inital pass to convert SentryTransation to Swift Oct 19, 2026
@donnywals
donnywals force-pushed the ref/convert-transaction-to-swift branch 3 times, most recently from 745ecd2 to 53da489 Compare October 20, 2026 09:42
@donnywals donnywals changed the title ref: Inital pass to convert SentryTransation to Swift ref: Convert SentryTransation to Swift Oct 20, 2026
@donnywals
donnywals force-pushed the ref/convert-transaction-to-swift branch from 38d6436 to b99cacb Compare October 20, 2026 12:03
@donnywals
donnywals marked this pull request as ready for review October 21, 2026 09:02
@donnywals
donnywals force-pushed the ref/convert-transaction-to-swift branch from b99cacb to 77d9dca Compare October 21, 2026 09:03
donnywals and others added 4 commits October 21, 2026 17:00
Objective-C++ profiling reads the tracer through the existing
helper, and tests override transaction capture through the
wrapper seam. Record the V10 convenience-initializer flag.

Co-authored-by: Cursor <cursoragent@cursor.com>
Erase the V10 before-send transaction block parameter so Swift
can import the callback from the public headers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@donnywals
donnywals force-pushed the ref/convert-transaction-to-swift branch from 77d9dca to c26016e Compare October 21, 2026 15:01
@donnywals donnywals changed the title ref: Convert SentryTransation to Swift ref: Convert SentryTransaction to Swift Oct 21, 2026
Corrected Transaction to be public and corrected serialization and spans-related code
Applied SENTRY_SWIFT_MIGRATION_ID where relevant

This branch has not been deployed

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

Labels

run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert SentryTransaction to Swift

2 participants