fix(replay): warn when PostHogWidget mounts before setup - #572
Open
marandaneto wants to merge 2 commits into
Open
fix(replay): warn when PostHogWidget mounts before setup#572marandaneto wants to merge 2 commits into
marandaneto wants to merge 2 commits into
Conversation
marandaneto
commented
Sep 11, 2026
|
Reviews (1): Last reviewed commit: "fix(replay): warn when PostHogWidget mou..." | Re-trigger Greptile |
Contributor
posthog-flutter Compliance ReportDate: 2026-09-11 10:29:51 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
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 #571.
When
PostHogWidgetmounts beforePosthog().setup(), it silently skips replay initialization and listener registration. Later setup or recording commands cannot start capture for that widget instance.This adds a warning that explains the required setup order and the option to remount the widget after setup. Because replay intent is unknown before setup, the message makes this advice conditional and says it can be ignored when replay is not intended. The warning is not emitted on web, where replay uses posthog-js. Replay initialization behavior is unchanged.
💚 How did you test it?
flutter test --no-pub --reporter expanded.posthog_widget_test.dartandposthog_widget_web_test.dart. These cover warning suppression on web and after setup with replay enabled or disabled.dart analyze ., formatting checks, andgit diff --checkpassed.9301682againstorigin/mainreported no actionable findings.No emulator run was needed for this Dart-only logging change. Widget tests exercise the affected mount path with a mocked native channel.
📝 Checklist
If releasing new changes
pnpm changeset.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi investigated the issue and implemented the change in a dedicated worktree using Git, GitHub CLI, Flutter tests, Dart analysis, and the isolated autoreview helper. The session transcript is not published.
The change follows the issue's request for a diagnostic rather than adding support for late setup. Remounting after setup restores capture within the same app launch. Review feedback prompted conditional wording because mounting the widget does not prove that replay is intended. Human review is required.