Skip to content

fix(mobile): stop AppsFlyer connector calls before create - #5050

Merged
iscekic merged 2 commits into
mainfrom
fix/appsflyer-connector-not-configured
Aug 5, 2026
Merged

fix(mobile): stop AppsFlyer connector calls before create#5050
iscekic merged 2 commits into
mainfrom
fix/appsflyer-connector-not-configured

Conversation

@iscekic

@iscekic iscekic commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Sentry shows Connector not configured, did you call \create` first?`.

resetAppsFlyerState() called AppsFlyerPurchaseConnector.stopObservingTransactions() on every iOS reset. The consent gate runs that reset on a signed-out cold start, before initAppsFlyer() ever calls create(). Native PCAppsFlyer rejects when its static connector is nil, and react-native-appsflyer discards the promise that start/stopObservingTransactions return — so the rejection escaped as an unhandled rejection and reached Sentry.

Fix

  • Memoize the create() outcome in connectorReady.
  • Gate startObservingTransactions and stopObservingTransactions on it. Both are skipped on Android and before the first create().
  • Chain startObservingTransactions off the same promise, which removes the race where the initSdk success callback could start observing before create() settled.
  • Drop the purchaseConnectorCreateStarted flag; the memoized promise is the re-entry guard.

Tests

src/lib/appsflyer.test.ts:

  • New: reset does not call stopObservingTransactions when the connector was never created. This test fails on main.
  • New: a failed create() never starts observing.
  • The former "calls stopObservingTransactions on iOS" test asserted the buggy behavior. It now inits first.

pnpm test (121 passed), pnpm lint, pnpm format, pnpm check:unused are green. pnpm typecheck has 4 pre-existing errors in mobile-session-page-adapter.ts and kilo-chat/* from a stale @kilocode/trpc dist; they are present on main too.

`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.
@iscekic iscekic self-assigned this Aug 5, 2026
@iscekic
iscekic requested a review from pandemicsyn August 5, 2026 17:24
Comment thread apps/mobile/src/lib/appsflyer.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental commit resolves the previous SUGGESTION by correcting the doc comment to reference createPurchaseConnector (verified at apps/mobile/src/lib/appsflyer.ts:87); no new issues found in the changed code.

Files Reviewed (2 files)
  • apps/mobile/src/lib/appsflyer.ts
  • apps/mobile/src/lib/appsflyer.test.ts
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 Summary

The AppsFlyer connector gating fix is correct and race-safe; the only finding is a stale doc comment pointing to a nonexistent ensurePurchaseConnector function.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
apps/mobile/src/lib/appsflyer.ts 16 Doc comment references ensurePurchaseConnector, which does not exist; the function is createPurchaseConnector
Files Reviewed (2 files)
  • apps/mobile/src/lib/appsflyer.ts - 1 issue
  • apps/mobile/src/lib/appsflyer.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 34.9K · Output: 3.2K · Cached: 172K

Review guidance: REVIEW.md from base branch main

Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
@iscekic
iscekic enabled auto-merge (squash) August 5, 2026 17:26
@iscekic
iscekic merged commit 6f28520 into main Aug 5, 2026
20 checks passed
@iscekic
iscekic deleted the fix/appsflyer-connector-not-configured branch August 5, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants