Fix delegate events from Compose paywalls#410
Open
AndroidPoet wants to merge 1 commit into
Open
Conversation
f837e31 to
2e74bb4
Compare
2e74bb4 to
74a8e19
Compare
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.
Summary
onViewCreated()when the ComposeAndroidViewis created soPaywallOpenis fired forPaywallComposablecustomer_infodoes not break delegate event deliveryFixes #405
Testing
./gradlew :superwall:testDebugUnitTest --tests com.superwall.sdk.analytics.internal.TrackingLogicTest./gradlew :superwall-compose:compileDebugKotlinGreptile Summary
This PR fixes two separate bugs affecting Compose-hosted paywalls:
PaywallOpennever firing becauseonViewCreated()was previously scheduled throughLaunchedEffect(which runs asynchronously after composition) rather than the synchronousAndroidView.factory; and delegate event delivery silently breaking when nested params likecustomer_infocontained unsupported types, because theclean()function returned nested maps verbatim without sanitising their contents.PaywallComposable.kt:onViewCreated()is moved intoAndroidView.factoryso it runs synchronously when the view is created, ensuringPaywallOpenand thedidPresentPaywalldelegate callback fire reliably.TrackingLogic.kt: AddscleanMap,cleanList, andcleanNestedhelpers and wires them intoclean()forMap<*,*>values, so deeply nested structures are recursively stripped of unsupported or null entries before reaching the delegate.TrackingLogicTest.kt: Adds a regression test covering nestedcustomer_infowith mixed supported/unsupported/null values at multiple nesting levels.Confidence Score: 4/5
Safe to merge with minor caveats — both fixes are well-scoped and the new test provides good regression coverage.
The TrackingLogic recursion is correct and the test validates the key scenario. The one open question is whether
onViewCreated()relies on the view being window-attached; if any code path inside it readswindowTokenor similar, calling it fromfactorybefore the view is in the hierarchy could surface a subtle timing issue. Worth a quick manual smoke test on a Compose paywall, but nothing that blocks the merge outright.PaywallComposable.kt— the timing ofonViewCreated()relative to window attachment deserves a focused manual test on a real device or emulator.Important Files Changed
onViewCreated()fromLaunchedEffecttoAndroidView.factoryto ensure synchronous execution; fixesPaywallOpennot firing on Compose paywallscleanMap/cleanList/cleanNestedhelpers and wires them intoclean()so nested maps likecustomer_infoare sanitised before being sent to delegate; empty map edge case is benign improvement over previous unsupported-value passthroughcustomer_infoFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["PaywallComposable\nPaywallBuilder.build()"] --> B["viewState set"] B --> C["AndroidView factory lambda"] C --> D["onViewCreated() ← MOVED HERE"] D --> E["viewCreatedCompletion invoke"] D --> F["storePresentationObject (ioScope)"] D --> G["SetPresentedAndFinished"] D --> H["delegate.didPresentPaywall(info)"] C --> I["Return viewToRender"] subgraph "TrackingLogic.clean() — param sanitisation" J["clean(value)"] -->|"Map<*,*>"| K["cleanMap(value) NEW"] K --> L["cleanNested(nestedValue)"] L -->|"List"| M["cleanList recursive"] L -->|"Map"| K L -->|"other"| J J -->|"List"| N["null dropped"] J -->|"primitive / JsonElement"| O["value kept"] endPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "Fix delegate events from Compose paywall..." | Re-trigger Greptile