Skip to content

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

Open
lucasheriques wants to merge 6 commits into
mainfrom
lucas/surveys-auto-submit
Open

feat(surveys): auto-submit rating and single-choice selections#808
lucasheriques wants to merge 6 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.

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-09 15:47:36 UTC
Duration: 215128ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 2907ms
Format Validation.Event Has Uuid 2776ms
Format Validation.Event Has Lib Properties 2811ms
Format Validation.Distinct Id Is String 2922ms
Format Validation.Token Is Present 2846ms
Format Validation.Custom Properties Preserved 2918ms
Format Validation.Event Has Timestamp 2994ms
Retry Behavior.Retries On 503 5414ms
Retry Behavior.Does Not Retry On 400 4829ms
Retry Behavior.Does Not Retry On 401 2594ms
Retry Behavior.Respects Retry After Header 7762ms
Retry Behavior.Implements Backoff 15498ms
Retry Behavior.Retries On 500 9350ms
Retry Behavior.Retries On 502 9290ms
Retry Behavior.Retries On 504 9342ms
Retry Behavior.Max Retries Respected 15374ms
Deduplication.Generates Unique Uuids 3376ms
Deduplication.Preserves Uuid On Retry 9282ms
Deduplication.Preserves Uuid And Timestamp On Retry 16895ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 8015ms
Deduplication.No Duplicate Events In Batch 3182ms
Deduplication.Different Events Have Different Uuids 2876ms
Compression.Sends Gzip When Enabled 2837ms
Batch Format.Uses Proper Batch Structure 2720ms
Batch Format.Flush With No Events Sends Nothing 245ms
Batch Format.Multiple Events Batched Together 2900ms
Error Handling.Does Not Retry On 403 4778ms
Error Handling.Does Not Retry On 413 4788ms
Error Handling.Retries On 408 9210ms

Feature_Flags Tests

16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 2785ms
Request Payload.Flags Request Uses V2 Query Param 2774ms
Request Payload.Flags Request Hits Flags Path Not Decide 2960ms
Request Payload.Flags Request Omits Authorization Header 2875ms
Request Payload.Token In Flags Body Matches Init 2744ms
Request Payload.Groups Round Trip 2881ms
Request Payload.Groups Default To Empty Object 2815ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 2918ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 2891ms
Request Payload.Disable Geoip Omitted Defaults To False 2851ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 2694ms
Request Lifecycle.No Flags Request On Init Alone 129ms
Request Lifecycle.No Flags Request On Normal Capture 430ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 5616ms
Request Lifecycle.Mock Response Value Is Returned To Caller 2980ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 2995ms

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support auto-submit on selection (skipSubmitButton)

1 participant