Conversation
Sources/SuperwallKit/Analytics/Superwall Placement/SuperwallEvent.swift
Outdated
Show resolved
Hide resolved
Sources/SuperwallKit/Paywall/View Controller/Web View/Message Handling/PaywallMessage.swift
Show resolved
Hide resolved
…attern Add PaywallPageViewInfo struct to expose pageNodeId, pageIndex, pageName, and navigationType to SDK consumers. Align pageView message decoding with the try?/if-let pattern used by all other PaywallMessage cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace PaywallPageViewInfo with public PageViewData, used for decoding, internal tracking, and the public delegate event. Removes redundant field-by-field passing throughout the chain. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
yusuftor
reviewed
Mar 16, 2026
Sources/SuperwallKit/Analytics/Internal Tracking/Trackable Events/TrackableSuperwallEvent.swift
Show resolved
Hide resolved
Add CodingKeys to map from JSON "type" to navigationType property. Document all possible values: entry, forward, back, auto_transition. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
yusuftor
approved these changes
Mar 16, 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.
Changes in this pull request
paywall_page_viewevent, which contains information about the page view.Checklist
CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.swiftlintin the main directory and fixed any issues.Greptile Summary
This PR adds multi-page paywall navigation tracking by introducing a
paywall_page_viewevent. It wires a newpage_viewWebView message through the existingPaywallMessage→PaywallMessageHandler→InternalSuperwallEvent→SuperwallEventpipeline, and introduces apresentationId(UUID assigned once per network fetch) that is threaded through all paywall lifecycle events to allow analytics consumers to correlate every event within a single presentation.Key changes:
PageViewDatapublic struct carries page-specific context (pageNodeId,flowPosition,pageName,navigationNodeId,navigationType, optional previous-page fields)SuperwallEvent.paywallPageView(paywallInfo:data:)case and matching ObjC enum valuepaywallPageViewpresentationId: String?added to bothPaywall(client-sidevar, not inCodingKeys) andPaywallInfo(publiclet), assigned viaUUID().uuidStringingetRawPaywalland propagated throughPaywall.update(from:)for cached VC re-use scenarios4.14.2acrossConstants.swift, podspec, andCHANGELOG.mdWebEntitlementRedeemerTests: captures a baseline call count before the operation rather than resetting it, and extends the settlement sleep to 200 msConfidence Score: 4/5
presentationIdlifecycle (set at fetch, propagated throughupdate(from:), excluded fromCodingKeys) is correct. ThePageViewDatadecoding correctly uses the top-level decoder withJSONDecoder.fromSnakeCase. The only notable concern is thetypeproperty name inPageViewDatadiverging from its analytics key"navigation_type", and theWebEntitlementRedeemerTeststiming fix being pragmatic rather than structurally sound. Neither is a blocker.typeproperty naming vs. analytics key inconsistencyImportant Files Changed
typeproperty is semantically the navigation type but named generically.pageView(PageViewData)case. Decoding usestry? PageViewData(from: decoder)(top-level decoder) instead of the keyed containervalues— correct because all page-view fields are at the root JSON level andJSONDecoder.fromSnakeCaseis used in production. Follows the existing try?/if-let error-handling pattern.PaywallPageViewinternal event struct. Mapsdata.typeto"navigation_type"analytics key — inconsistent with the Swift property name.presentationIdafter paywall fetch and beforetrackResponseLoaded, so all subsequent events within the presentation carry this ID.presentationIdas avarnot included inCodingKeys, so it is never persisted to/from JSON.update(from:)correctly propagates the ID on re-presentation.Sequence Diagram
sequenceDiagram participant WV as WebView (paywall.js) participant RW as RawWebMessageHandler participant PM as PaywallMessage decoder participant MH as PaywallMessageHandler participant SW as Superwall.shared WV->>RW: postMessage({ event_name: "page_view", page_node_id, flow_position, ... }) RW->>PM: JSONDecoder.fromSnakeCase.decode(PaywallMessage.self) PM-->>RW: .pageView(PageViewData) RW->>MH: handle(.pageView(data)) MH->>MH: guard delegate != nil MH->>MH: let paywallInfo = delegate.info (includes presentationId) MH->>SW: Task { track(PaywallPageView(paywallInfo, data)) } SW-->>SW: fire SuperwallEvent.paywallPageView<br/>params: page_node_id, flow_position,<br/>page_name, navigation_node_id,<br/>navigation_type, presentation_id, ...Prompt To Fix All With AI
Last reviewed commit: 5ac3e13