Add checkout diagnostics for Swift - #642
Open
markmur wants to merge 1 commit into
Open
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Install this buildOpen Tophat, select your target device, then click Install. Links open on the Mac running Tophat.
Checkout Kit E2E results
|
markmur
force-pushed
the
swift-checkout-diagnostics
branch
from
August 14, 2026 09:55
0733f3e to
b19daf0
Compare
markmur
commented
Aug 14, 2026
Comment on lines
+49
to
+53
| /// Keep the subscription for as long as diagnostics should be observed. | ||
| /// Observation stops when the subscription is cancelled or released. | ||
| @MainActor | ||
| public final class Subscription { | ||
| private var listener: (@MainActor (CheckoutDiagnosticEvent) -> Void)? |
Contributor
Author
There was a problem hiding this comment.
I was tempted to implement an AsyncStream here instead but decided to align with the existing subscribe pattern for preload observability. Also, implementing async streams in Kotlin required the coroutines dependency.
markmur
force-pushed
the
swift-checkout-diagnostics
branch
from
August 14, 2026 10:27
b19daf0 to
2f487d4
Compare
This was referenced Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What changes are you making?
Introduce SDK-wide Swift diagnostics subscriptions and move incoming checkout-message trust decisions out of
Configurationcallbacks.ShopifyCheckoutKit.diagnostics.subscribe { ... }with a retained, cancellable subscription handle.CheckoutDiagnosticEvent.messageRejectedwith typedCheckoutMessageRejection.Reasonvalues.CheckoutMessageIngressPolicyso WebKit transport metadata is admitted before protocol dispatch.Configuration.onMessageRejectedand the raw rejected message body from the public API.How message admission works
CheckoutMessageIngressPolicyis the trust boundary between WebKit transport and checkout protocol handling. WebKit provides the authoritative source origin, frame, and request URL alongside the untrusted message body. The WebView packages those values into anIncomingCheckoutMessageand asks the policy for an.acceptedor.rejected(...)decision before attempting to parse or dispatch the protocol message.The policy applies the transport-level rules in one place:
allowedMessageOriginsand the loaded checkout URL.An accepted message continues into
CheckoutProtocolparsing and client dispatch. A rejected message never reaches the protocol client; the WebView emits.messageRejectedwith the trusted origin metadata and typed rejection reason, then stops processing it. This lets the protocol client assume it only handles admitted checkout messages without making it responsible for WebKit-specific trust decisions.Consumer API
Consumers retain one SDK-wide subscription for as long as they want to observe diagnostics:
Subscriptions are hot and do not replay. Subscribe before calling
preload(checkout:)if the application needs diagnostics emitted by a background checkout WebView. Listeners are delivered on the main actor, and releasing the subscription also stops observation.The raw rejected message body is intentionally unavailable because it is untrusted and may contain sensitive or arbitrarily large data.
React Native consumer API
React Native would expose the same typed subscription model without requiring
async/awaitor direct access to the native module:The event is a typed
CheckoutDiagnosticEvent, withmessageRejectedcarrying the rejected origin and achildFrame,unsupportedPort, ororiginNotAllowedreason. Subscriptions are hot and non-replaying, matching Swift and Kotlin behavior.Before you merge
Important
platforms/swift/README.mdand/orplatforms/android/README.md)