Repository navigation
fix(surveys): show a survey once PosthogObserver has a context - #631
Merged
Merged
Conversation
Contributor
posthog-flutter Compliance ReportDate: 2026-10-01 14:33:49 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
|
lucasheriques
approved these changes
Sep 30, 2026
lucasheriques
left a comment
Contributor
There was a problem hiding this comment.
LGTM. I traced both native bridges: hideSurveys cancels the wait, and a new renderSurvey replaces it. One optional simplification inline.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merged
4 of 5 tasks
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
Surveys are rendered in Dart and need the
BuildContextthatPosthogObserverpicks up on navigation. If a survey arrived while there was no context (before the first route, or afterPosthog().close()cleared it), we logged and dropped it. The native SDK still held it as its active survey, so no other survey could show until the app restarted.Telling native the survey was closed is not an option: it marks the survey seen and sends
survey dismissedfor a survey nobody saw.Now
SurveyService.showSurveywaits for the observer's next context and shows the survey then.hideSurvey()cancels the wait, and a newer survey replaces the waiting one. Nothing is sent to native while waiting. posthog-android's own survey UI does the same when it has no activity to present on.If
PosthogObserveris never installed the survey still never shows, as before; the debug log now says so.Note for #627 (popup delay): it touches the same lines of
showSurvey, so whichever lands second needs a small rebase.💚 How did you test it?
survey_wait_for_context_test.dart: survey arrives before the app has a context, context cleared then next navigation, hidden while waiting, replaced while waiting. Full suite passes (735 tests); analyze and format are clean.survey shown; after closing it, a second survey showed normally.didReplace, and a realclose()thensetup()(the context was cleared directly).📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
surveysspec says missing render targets "log and return without emitting interaction events". This still logs and emits nothing, but waits for a target instead of returning.🤖 Generated with Claude Code