fix(error-tracking): install autocapture handler by default on first launch#650
Draft
ioannisj wants to merge 1 commit into
Draft
fix(error-tracking): install autocapture handler by default on first launch#650ioannisj wants to merge 1 commit into
ioannisj wants to merge 1 commit into
Conversation
Contributor
|
Contributor
posthog-android Compliance ReportDate: 2026-07-24 07:02:06 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
ioannisj
force-pushed
the
fix/error-tracking-first-launch-648
branch
from
July 24, 2026 06:56
bf14bc3 to
81ce5d7
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.
💡 Motivation and Context
Fixes #648.
On the very first app launch there's no disk-cached remote config yet, so the native crash handler (
PostHogErrorTrackingAutoCaptureIntegration, aThread.UncaughtExceptionHandler) didn't install until the async/flagsremote-config response arrived. Any uncaught exception in that window, from app start to the first config response, was lost. Offline made it worse: a failed first-launch fetch left autocapture off for the whole session.This flips the gate to match the iOS fix. The handler now installs by default at setup when local
errorTrackingConfig.autoCaptureis on, and only skips when a remote config that actually exists (fetched this session or disk-cached from a prior launch) explicitly reportsautocaptureExceptions: false. Remote config becomes a kill-switch rather than a prerequisite: if the freshly-loaded config disables autocapture,onRemoteConfiguninstalls the handler, and a failed fetch leaves the default install in place. LocalautoCapturestays the primary gate, so a host that turned it off still gets no handler.To tell "first launch, no config yet" apart from "config exists and says disabled",
PostHogRemoteConfiggainshasCachedErrorTrackingConfig(), set at startup when the error-tracking config was already on disk. It's the Android analogue of iOS'shasCachedRemoteConfig.This is the Android counterpart of iOS #551, ported from iOS #731. It also covers Flutter-on-Android, which maps
captureNativeExceptionsontoerrorTrackingConfig.autoCaptureand inherited the same gap.💚 How did you test it?
Unit tests mirroring the iOS installation tests, in
PostHogErrorTrackingAutoCaptureIntegrationTest:autoCaptureis off, even with no remote configonRemoteConfiguninstalls the default install when a freshly-loaded config disables autocapture, and keeps it when the config enables autocaptureloaded = false) keeps the default installRan
./gradlew spotlessApply,:posthog:apiCheck, and the full:posthog:testsuite, all green.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
DRI: @ioannisj
Autonomy: Human-driven (agent-assisted)