fix(mobile): stop AppsFlyer connector calls before create - #5050
Merged
Conversation
`resetAppsFlyerState()` called `stopObservingTransactions()` on every iOS reset, including the signed-out cold start where `create()` never ran. Native rejects with "Connector not configured, did you call `create` first?", and the library discards that promise, so it surfaced in Sentry as an unhandled rejection. Memoize the `create()` result and gate both `startObservingTransactions` and `stopObservingTransactions` on it. This also removes the race where the `initSdk` success callback started observing before `create()` settled.
pandemicsyn
approved these changes
Aug 5, 2026
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit resolves the previous SUGGESTION by correcting the doc comment to reference Files Reviewed (2 files)
Previous Review Summary (commit b46be00)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit b46be00)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe AppsFlyer connector gating fix is correct and race-safe; the only finding is a stale doc comment pointing to a nonexistent Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Reviewed by kimi-k3 · Input: 34.9K · Output: 3.2K · Cached: 172K Review guidance: REVIEW.md from base branch |
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
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.
Problem
Sentry shows
Connector not configured, did you call \create` first?`.resetAppsFlyerState()calledAppsFlyerPurchaseConnector.stopObservingTransactions()on every iOS reset. The consent gate runs that reset on a signed-out cold start, beforeinitAppsFlyer()ever callscreate(). NativePCAppsFlyerrejects when its static connector is nil, andreact-native-appsflyerdiscards the promise thatstart/stopObservingTransactionsreturn — so the rejection escaped as an unhandled rejection and reached Sentry.Fix
create()outcome inconnectorReady.startObservingTransactionsandstopObservingTransactionson it. Both are skipped on Android and before the firstcreate().startObservingTransactionsoff the same promise, which removes the race where theinitSdksuccess callback could start observing beforecreate()settled.purchaseConnectorCreateStartedflag; the memoized promise is the re-entry guard.Tests
src/lib/appsflyer.test.ts:stopObservingTransactionswhen the connector was never created. This test fails onmain.create()never starts observing.pnpm test(121 passed),pnpm lint,pnpm format,pnpm check:unusedare green.pnpm typecheckhas 4 pre-existing errors inmobile-session-page-adapter.tsandkilo-chat/*from a stale@kilocode/trpcdist; they are present onmaintoo.