Skip to content

feat(surveys): auto-submit rating and single-choice selections - #808

Merged
lucasheriques merged 7 commits into
mainfrom
lucas/surveys-auto-submit
Sep 17, 2026
Merged

lucasheriques merged 7 commits into
mainfrom
lucas/surveys-auto-submit

Conversation

@lucasheriques

@lucasheriques lucasheriques commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Honor skipSubmitButton in 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.

Question skipSubmitButton: true False or absent
Numeric/emoji rating Submit on selection Explicit submit
Single choice without an open option Submit on selection Explicit submit
Single choice with an open option Explicit submit Explicit submit
Multiple choice Explicit submit Explicit submit

The 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

  1. Interaction tests: real taps, button visibility, answer values and next-question state.
  2. Display mapping and question models: flag propagation and eligibility.
  3. Question views and SurveySheet: submission and selection reset.

💚 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 and shuffleOptions; CI retains both survey UI and presentation-masking tests. make test passes (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 from main, 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.

Rating: no submit button After tapping 4: next question Other: explicit submit
Rating question Automatically advanced to single choice Other text requires Submit

Tapping 4, then Easy to use, advanced without a submit tap. Entering Better search under Other required Submit; the local receiver recorded one survey sent event with all three answers.

📝 Checklist

  • Interaction tests and independent review completed.
  • API compatibility and changesets covered.

🤖 Agent context

Autonomy: Human-driven (agent-assisted). Codex implemented the changes with independent QA agents; human review is required.

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.
@lucasheriques
lucasheriques requested a review from a team as a code owner September 8, 2026 19:51
@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
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

Comment thread PostHog/Surveys/QuestionTypes.swift Outdated
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.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

posthog-ios Compliance Report

Date: 2026-09-15 23:27:29 UTC
Duration: 230675ms

⚠️ Some Tests Failed

44/45 tests passed, 1 failed


Capture Tests

⚠️ 28/29 tests passed, 1 failed

View Details
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.
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.
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.
@turnipdabeets

Copy link
Copy Markdown
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 skipSubmitButton yet (PostHogDisplaySurveyExt.kt, PostHogDisplaySurvey+Dict.swift), so Flutter users will keep seeing the Submit button. The follow-up would:

  • pass skipSubmitButton through both bridges
  • add it to the Dart question models
  • submit on tap and hide the button in the rating and choice widgets, using the same rules as here
  • bump the native SDK versions

React Native already supports this on main, so Flutter is the only one left.

@lucasheriques
lucasheriques merged commit 215f3e0 into main Sep 17, 2026
47 checks passed
@lucasheriques
lucasheriques deleted the lucas/surveys-auto-submit branch September 17, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support auto-submit on selection (skipSubmitButton)

2 participants