feat(surveys): auto-submit rating and single-choice selections - #808
Merged
Merged
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-15 23:27:29 UTC
|
| Test | Status | Duration |
|---|---|---|
| Format Validation.Event Has Required Fields | ✅ | 2788ms |
| Format Validation.Event Has Uuid | ✅ | 2616ms |
| Format Validation.Event Has Lib Properties | ✅ | 2713ms |
| Format Validation.Distinct Id Is String | ✅ | 2760ms |
| Format Validation.Token Is Present | ✅ | 2684ms |
| Format Validation.Custom Properties Preserved | ✅ | 2635ms |
| Format Validation.Event Has Timestamp | ✅ | 2777ms |
| Retry Behavior.Retries On 503 | ✅ | 11311ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 4737ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 4631ms |
| Retry Behavior.Respects Retry After Header | ✅ | 7726ms |
| Retry Behavior.Implements Backoff | ✅ | 19143ms |
| Retry Behavior.Retries On 500 | ✅ | 9227ms |
| Retry Behavior.Retries On 502 | ✅ | 9228ms |
| Retry Behavior.Retries On 504 | ✅ | 9225ms |
| Retry Behavior.Max Retries Respected | ❌ | 21252ms |
| Deduplication.Generates Unique Uuids | ✅ | 2994ms |
| Deduplication.Preserves Uuid On Retry | ✅ | 9173ms |
| Deduplication.Preserves Uuid And Timestamp On Retry | ✅ | 16832ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ✅ | 8031ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 2820ms |
| Deduplication.Different Events Have Different Uuids | ✅ | 2810ms |
| Compression.Sends Gzip When Enabled | ✅ | 2731ms |
| Batch Format.Uses Proper Batch Structure | ✅ | 2623ms |
| Batch Format.Flush With No Events Sends Nothing | ✅ | 275ms |
| Batch Format.Multiple Events Batched Together | ✅ | 2728ms |
| Error Handling.Does Not Retry On 403 | ✅ | 4676ms |
| Error Handling.Does Not Retry On 413 | ✅ | 4659ms |
| Error Handling.Retries On 408 | ✅ | 8778ms |
Failures
retry_behavior.max_retries_respected
Expected 4 requests, got 6
Feature_Flags Tests
✅ 16/16 tests passed
View Details
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ✅ | 2641ms |
| Request Payload.Flags Request Uses V2 Query Param | ✅ | 2814ms |
| Request Payload.Flags Request Hits Flags Path Not Decide | ✅ | 2828ms |
| Request Payload.Flags Request Omits Authorization Header | ✅ | 2746ms |
| Request Payload.Token In Flags Body Matches Init | ✅ | 2845ms |
| Request Payload.Groups Round Trip | ✅ | 2782ms |
| Request Payload.Groups Default To Empty Object | ✅ | 2835ms |
| Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It | ✅ | 2705ms |
| Request Payload.Disable Geoip False Propagates As Geoip Disable False | ✅ | 2907ms |
| Request Payload.Disable Geoip Omitted Defaults To False | ✅ | 3030ms |
| Request Payload.Flag Keys To Evaluate Contains Only Requested Key | ✅ | 2910ms |
| Request Lifecycle.No Flags Request On Init Alone | ✅ | 92ms |
| Request Lifecycle.No Flags Request On Normal Capture | ✅ | 2844ms |
| Request Lifecycle.Two Flag Calls Produce Two Remote Requests | ✅ | 5538ms |
| Request Lifecycle.Mock Response Value Is Returned To Caller | ✅ | 2798ms |
| Side Effect Events.Get Feature Flag Captures Feature Flag Called Event | ✅ | 3162ms |
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
Preserve auto-submit selection bindings alongside merged choice shuffling. Keep both survey interaction and presentation masking CI targets. Validation: make format, make test (846 Swift Testing cases plus legacy suite), make lint. Local build and API checks blocked by Xcode/CoreSimulator version mismatch. CodeScene findings are in changes imported from main; no additional refactoring of those unrelated files.
Contributor
|
[suggestion] Flutter will still need a follow-up once this and PostHog/posthog-android#769 are released. Flutter draws its own survey UI from the question data its native bridges pass over, and those bridges don't pass
React Native already supports this on main, so Flutter is the only one left. |
turnipdabeets
approved these changes
Sep 17, 2026
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
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.Updated against current
main, including merged choice shuffling (#811). The single-choice view retains both the auto-submit binding andshuffleOptions; CI retains both survey UI and presentation-masking tests.make testpasses (846 Swift Testing cases plus the legacy suite), and formatting/lint pass. Local build/API rechecks are blocked by mismatched Xcode/CoreSimulator components; CI verifies them. CodeScene merge findings are in code brought in frommain, outside these conflict resolutions.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.