Skip to content

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

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

feat(surveys): auto-submit rating and single-choice selections#769
lucasheriques wants to merge 2 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 Android Compose 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. Existing JVM display-question constructor signatures are preserved.

Partial-response collection and persistent resume are covered separately in #768.

Review path

  1. Interaction tests: real taps, button visibility, answer values and next-question state.
  2. Raw question and display models: flag propagation and constructor compatibility.
  3. SurveySheet and choice eligibility: submission and manual fallback.

💚 How did you test it?

Passed: make testSurveyUI (27 Compose tests, including 10 mounted cases), CI=true make compile, formatting checks and CodeScene. Tests cover decoding/mapping, eligible/manual paths, open-choice text, returned branching destinations and exact answer sequences. Disabling auto-submit callbacks made the eligible interaction cases fail.

Tests mount the real Compose sheet in Robolectric with a response recorder. Before combining with #768, reconcile Makefile/CI conflicts and test auto-submit through persistent resume and partial-event capture together.

Sample app screenshots

Captured from this PR's SDK (bd4008e) running in the sample app on Pixel 7 emulator, Android 16 / API 36. 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 preserve it in public display questions. Submit
eligible Compose selections immediately and hide the submit button. Keep
explicit submission for multi-select and questions with an open option.
Preserve existing display-question JVM constructors with @jvmoverloads.

Validation: parameterized decoding/mapping and eligibility tests passed;
make format, make api, and CI=true make compile passed. CodeScene safeguard
passed: SurveySheet improved; the existing complex display mapper stayed
stable and is intentionally not broadly refactored. Interaction behavior
still requires renderer-level coverage.
@lucasheriques
lucasheriques requested a review from a team as a code owner September 8, 2026 20:10
@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
posthog-android-surveys-compose/src/test/java/com/posthog/android/surveys/compose/internal/ui/SurveyAutoSubmitTest.kt:17-28
**Renderer behavior remains untested**

This parameterized test only checks the `shouldAutoSubmit` eligibility rule. It does not render or interact with `SurveySheet`, so regressions where selecting an eligible rating or choice fails to submit exactly once, advance the survey, or hide the submit button would pass this suite. Adding an interaction test for that new flow would close this non-blocking coverage gap.

---

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

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-09-09 14:23:06 UTC
Duration: 118427ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 391ms
Format Validation.Event Has Uuid 29ms
Format Validation.Event Has Lib Properties 33ms
Format Validation.Distinct Id Is String 28ms
Format Validation.Token Is Present 24ms
Format Validation.Custom Properties Preserved 30ms
Format Validation.Event Has Timestamp 23ms
Retry Behavior.Retries On 503 7027ms
Retry Behavior.Does Not Retry On 400 4025ms
Retry Behavior.Does Not Retry On 401 4028ms
Retry Behavior.Respects Retry After Header 7028ms
Retry Behavior.Implements Backoff 17025ms
Retry Behavior.Retries On 500 7019ms
Retry Behavior.Retries On 502 7020ms
Retry Behavior.Retries On 504 7020ms
Retry Behavior.Max Retries Respected 17039ms
Deduplication.Generates Unique Uuids 39ms
Deduplication.Preserves Uuid On Retry 7013ms
Deduplication.Preserves Uuid And Timestamp On Retry 12021ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7020ms
Deduplication.No Duplicate Events In Batch 36ms
Deduplication.Different Events Have Different Uuids 23ms
Compression.Sends Gzip When Enabled 20ms
Batch Format.Uses Proper Batch Structure 20ms
Batch Format.Flush With No Events Sends Nothing 12ms
Batch Format.Multiple Events Batched Together 31ms
Error Handling.Does Not Retry On 403 4020ms
Error Handling.Does Not Retry On 413 4022ms
Error Handling.Retries On 408 5029ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 35ms
Request Payload.Flags Request Uses V2 Query Param 23ms
Request Payload.Flags Request Hits Flags Path Not Decide 20ms
Request Payload.Flags Request Omits Authorization Header 36ms
Request Payload.Token In Flags Body Matches Init 23ms
Request Payload.Groups Round Trip 25ms
Request Payload.Groups Default To Empty Object 22ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 21ms
Request Payload.Disable Geoip Omitted Defaults To False 19ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 19ms
Request Lifecycle.No Flags Request On Init Alone 10ms
Request Lifecycle.No Flags Request On Normal Capture 26ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 42ms
Request Lifecycle.Mock Response Value Is Returned To Caller 26ms
Retry Behavior.Retries Flags On 502 325ms
Retry Behavior.Retries Flags On 504 324ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 28ms

Mount SurveySheet and tap numeric/emoji ratings and choice controls to
verify immediate submission, manual fallbacks, branching, payloads,
exactly-once callbacks, and clearing selection between questions.

Run these debug-host tests explicitly in CI because the normal CI build
disables debug variants. Lock the new test-only dependencies.

Validation: make testSurveyUI (27 tests), make format, make checkFormat,
CI=true make compile, local publishing, and CodeScene pre-commit passed.
Disabling auto-submit callbacks temporarily failed exactly the three
eligible interaction cases; restoring the implementation passed.
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.

1 participant