feat(surveys): auto-submit rating and single-choice selections - #808
Open
lucasheriques wants to merge 6 commits into
Open
feat(surveys): auto-submit rating and single-choice selections#808lucasheriques wants to merge 6 commits into
lucasheriques wants to merge 6 commits into
Conversation
Decode skipSubmitButton and expose it on public display questions. Hide the submit button and advance when a rating or eligible single choice is selected. Retain explicit submission for multi-select and open-choice questions, matching posthog-js. Reset selection state between consecutive eligible questions. Verified red/green mapping and eligibility tests; 79 survey tests on macOS; 84 survey tests on iOS 26.5 simulator; make lint; updated public API snapshot. CodeScene quality gate passed; legacy test-file health remains stable.
Contributor
Prompt To Fix All With AI### Issue 1
PostHog/Surveys/QuestionTypes.swift:155-159
**Auto-submit wiring lacks coverage**
The new tests verify decoding and eligibility, but they do not exercise the SwiftUI behavior added here. There is no interaction test confirming that selecting a rating or single choice calls `onNextQuestion` exactly once with the correct answer, hides the submit button, and resets selection state when the question changes. A regression in this core behavior could therefore pass the test suite. Please add an interaction test that hosts the affected question views or `SurveySheet` and verifies these behaviors.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(surveys): auto-submit rating and si..." | Re-trigger Greptile |
CI exposed a race between forced survey loading and the remote-config listener's flag refresh. Seed survey data separately and await flag loading, matching the neighboring feature-flag eligibility test. The matching suite passes (10 tests), and the previously failing test passes 10 consecutive runs. CodeScene gate passed with stable test-file health.
Contributor
posthog-ios Compliance ReportDate: 2026-09-09 15:47:36 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
|
Submit from the selection bindings used by numeric/emoji ratings and single-choice controls. This makes auto-submit synchronous with selection and allows direct callback regression tests without new dependencies. Cover eligible and disabled flags, open options, answer values, and clearing a selection. Keep explicit submission and per-question view identity. Verification: make testOniOSSimulator and make lint passed. CodeScene gate passed; the existing large survey test file stayed stable. Tests exercise the production bindings, not automated taps or visual button visibility.
Add a small host for the SDK's SurveySheet and SurveyDisplayController, and XCUITest coverage for rating and choice taps, manual/open-choice fallbacks, exactly-once responses, branching, and selection reset. Run the UI suite explicitly in CI through make testSurveyUI. Validation: seven UI tests passed, including six manual flag/type cases. A temporary removal of the question identity reset failed the numeric stale-selection assertion; the restored implementation passed. make test, make format, make lint, make apiCheck, and CodeScene passed.
The following custom-distinct-ID test could receive the preceding test's asynchronous identify upload after its batch recorder was reset. Wait for and assert that upload before the preceding fixture ends. Validation: all 25 identity tests and the full SPM suite passed.
2 tasks
Give the survey primary action a stable accessibility identifier and query that identifier in the mounted tests. Label-only Continue queries can match another control after the keyboard opens, which failed the open choice interaction in CI. Verification: make testSurveyUI (7 tests), make format, make lint, make apiCheck, git diff checks and CodeScene safeguard. No public API snapshot changes; no CodeScene findings.
3 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
Honor
skipSubmitButtonin iOS surveys, moving toward survey feature parity across all PostHog SDKs, with posthog-js as the reference. Eligible selections submit through the existing response/navigation callback without an extra tap.skipSubmitButton: trueThe raw flag is exposed to custom renderers and defaults to false. Each selection forwards its answer once; the next question starts without the previous selection.
Closes #448. Partial-response collection and persistent resume are covered separately in #807.
Review path
💚 How did you test it?
Passed:
make testSurveyUI(7 XCUITests),make test, formatting/lint, API checks and CodeScene. Tests cover eligible/manual paths, open-choice text, multiple choice, optional manual skip, returned branching destinations and exact answer sequences. Removing the question identity reset made the stale-selection regression fail.The test host mounts the real sheet/controller with a response recorder. Before combining with #807, reconcile the Xcode project conflict and test auto-submit through persistent resume and partial-event capture together.
Sample app screenshots
Captured from this PR's SDK (
786fee5) running in the sample app on iPhone 17 Pro simulator, iOS 26.5. A local HTTP fixture supplies the survey; SDK fetching, event targeting and native presentation run through the normal app integration.Tapping 4, then Easy to use, advanced without a submit tap. Entering Better search under Other required Submit; the local receiver recorded one
survey sentevent with all three answers.📝 Checklist
🤖 Agent context
Autonomy: Human-driven (agent-assisted). Codex implemented the changes with independent QA agents; human review is required.