Skip to content

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

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

feat(surveys): auto-submit rating and single-choice selections#808
lucasheriques wants to merge 3 commits into
mainfrom
lucas/surveys-auto-submit

Conversation

@lucasheriques

@lucasheriques lucasheriques commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

A survey question configured with skipSubmitButton now advances when the user selects a rating or a single choice, without an extra submit tap. The setting was previously discarded during decoding.

Match posthog-js: retain the submit button for multi-select questions and for any single-choice question with an open-ended option. Expose the raw setting to custom delegates, default missing settings to false, and reset rating/single-choice selection state between question IDs so consecutive questions do not inherit answers.

Closes #448. Independent of the partial-response change in #807.

Testing

  • Added parameterized decoding/display-mapping and eligibility tests for true/false/absent settings, numeric/emoji ratings, single/multiple choice, and open choices. They failed before implementation and passed after.
  • make test filter=PostHogSurveysTest: 79 tests passed.
  • iOS 26.5 simulator: 84 survey tests passed via xcodebuild test -only-testing:PostHogTests/PostHogSurveysTest (includes the iOS-specific build).
  • Selection-binding callback tests cover numeric/emoji ratings and single-choice answers, disabled flags, open options, and clearing a selection. Submission happens synchronously in the binding setter.
  • make testOniOSSimulator passed with the added callback tests. These exercise production bindings; automated view tapping and visual button visibility remain outside this coverage.
  • make lint passed; public API snapshot updated and checked.
  • CodeScene quality gate passed; the existing large survey test file remains at stable health.

Includes a minor release changeset. Compatibility-table minimum versions can be updated after release.

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
Comment on lines 155 to 159
.onChange(of: rating) { value in
if question.skipSubmitButton, let value {
onNextQuestion(value)
}
.disabled(!canSubmit)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Prompt To Fix With AI
This is a comment left during a code review.
Path: PostHog/Surveys/QuestionTypes.swift
Line: 155-159

Comment:
**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.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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-08 20:35:55 UTC
Duration: 219660ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 2805ms
Format Validation.Event Has Uuid 2752ms
Format Validation.Event Has Lib Properties 2752ms
Format Validation.Distinct Id Is String 2777ms
Format Validation.Token Is Present 2850ms
Format Validation.Custom Properties Preserved 2883ms
Format Validation.Event Has Timestamp 2713ms
Retry Behavior.Retries On 503 5443ms
Retry Behavior.Does Not Retry On 400 4759ms
Retry Behavior.Does Not Retry On 401 4767ms
Retry Behavior.Respects Retry After Header 7797ms
Retry Behavior.Implements Backoff 15294ms
Retry Behavior.Retries On 500 8742ms
Retry Behavior.Retries On 502 9108ms
Retry Behavior.Retries On 504 9148ms
Retry Behavior.Max Retries Respected 21788ms
Deduplication.Generates Unique Uuids 2947ms
Deduplication.Preserves Uuid On Retry 9276ms
Deduplication.Preserves Uuid And Timestamp On Retry 13707ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7920ms
Deduplication.No Duplicate Events In Batch 2769ms
Deduplication.Different Events Have Different Uuids 2963ms
Compression.Sends Gzip When Enabled 2996ms
Batch Format.Uses Proper Batch Structure 2857ms
Batch Format.Flush With No Events Sends Nothing 241ms
Batch Format.Multiple Events Batched Together 2905ms
Error Handling.Does Not Retry On 403 4726ms
Error Handling.Does Not Retry On 413 4747ms
Error Handling.Retries On 408 9334ms

Feature_Flags Tests

16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 2812ms
Request Payload.Flags Request Uses V2 Query Param 2681ms
Request Payload.Flags Request Hits Flags Path Not Decide 2770ms
Request Payload.Flags Request Omits Authorization Header 2794ms
Request Payload.Token In Flags Body Matches Init 2784ms
Request Payload.Groups Round Trip 2737ms
Request Payload.Groups Default To Empty Object 2836ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 2844ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 2716ms
Request Payload.Disable Geoip Omitted Defaults To False 2686ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 2866ms
Request Lifecycle.No Flags Request On Init Alone 88ms
Request Lifecycle.No Flags Request On Normal Capture 2811ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 5609ms
Request Lifecycle.Mock Response Value Is Returned To Caller 2902ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 3122ms

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.
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