Skip to content

feat(surveys): add optional intro screen before the first question - #677

Open
jakesciotto wants to merge 4 commits into
mainfrom
posthog-code/survey-intro-screen
Open

feat(surveys): add optional intro screen before the first question#677
jakesciotto wants to merge 4 commits into
mainfrom
posthog-code/survey-intro-screen

Conversation

@jakesciotto

Copy link
Copy Markdown

💡 Motivation and Context

Surveys can show a confirmation ("thank you") screen after the last question, but there is no equivalent screen before the first one.

This is the posthog-android part of the cross-SDK intro screen rollout tracked in PostHog/posthog#74064. The web/RN renderer shipped in PostHog/posthog-js#4436; this PR brings the Android model layer and the Compose UI module to parity.

What it does:

  • New SurveyAppearance fields (appended last so existing positional copy()/componentN() usages keep their meaning): displayIntroScreen, introScreenHeader, introScreenDescription, introScreenDescriptionContentType, introScreenButtonText. Mapped onto PostHogDisplaySurveyAppearance for custom delegates.
  • New IntroScreen composable in posthog-android-surveys-compose, the leading mirror of ConfirmationScreen, shown by SurveySheet before the first question when displayIntroScreen is on. The description follows the module's existing TEXT-only rendering rule (HTML stays a known gap).
  • Advancing past the intro flips local sheet state only: no onSubmit call, no response recorded, no survey event. The X button keeps dismissing the whole survey with the normal survey dismissed event, and the confirmation branch still wins for completed surveys.
  • Intro copy is translatable (introScreenHeader / introScreenDescription / introScreenButtonText), wired through SurveyTranslation, the translation applier's change gate, and the display mapping.
  • For custom (non-Compose) delegates, reading the new fields off survey.appearance is all that's needed; no delegate interface changes.

💚 How did you test it?

Unit tests added/extended:

  • SurveyAppearanceMappingTest: intro fields map onto the display appearance; missing fields default to disabled.
  • SurveyTranslationsTest: JSON fixture now carries intro fields; translated header/button apply with untranslated description falling back, and the untranslated path renders originals.

Written on Linux without a JVM/Android SDK, so Gradle did not run locally — please rely on CI (make compile). ⚠️ posthog/api/posthog.api was updated by hand following the binary-compatibility-validator format; if apiCheck disagrees, make api will produce the canonical dump.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file (.changeset/survey-intro-screen.md, minor for posthog + posthog-android-surveys-compose)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)


Created with PostHog Code

Adds the leading mirror of the confirmation screen: an optional intro screen shown before question 1, configured via the new displayIntroScreen / introScreenHeader / introScreenDescription / introScreenDescriptionContentType / introScreenButtonText appearance fields. Exposed on the display model for custom delegates and rendered natively by the Compose UI module. Advancing past it records no response and sends no survey event. Intro copy is translatable like the thank-you message.

Generated-By: PostHog Code
Task-Id: 50ceca51-4b90-4b94-8e72-e01bce50073c
@jakesciotto jakesciotto self-assigned this Aug 6, 2026
@jakesciotto
jakesciotto marked this pull request as ready for review August 6, 2026 18:51
@jakesciotto
jakesciotto requested a review from a team as a code owner August 6, 2026 18:51
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
posthog/src/main/java/com/posthog/internal/surveys/SurveyTranslationApplier.kt:80-90
**Disabled intro sets survey language**

When `displayIntroScreen` is false or omitted but its translation contains different intro copy, these checks still set `matchedKey`, causing survey events to include `$survey_language` even though none of that translated content was displayed.

```suggestion
    if (appearance?.displayIntroScreen == true) {
        if (translation.introScreenHeader != null && translation.introScreenHeader != appearance.introScreenHeader) return true
        if (translation.introScreenDescription != null &&
            translation.introScreenDescription != appearance.introScreenDescription
        ) {
            return true
        }
        if (translation.introScreenButtonText != null &&
            translation.introScreenButtonText != appearance.introScreenButtonText
        ) {
            return true
        }
    }
```

---

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): add optional intro screen..." | Re-trigger Greptile

Parity with the web renderer: the intro has no default header, so an intro with neither header nor description would draw an empty sheet with a lone button. Skips straight to question 1 instead; resolve() already normalizes blank intro copy to null, now locked by a test.

Generated-By: PostHog Code
Task-Id: 50ceca51-4b90-4b94-8e72-e01bce50073c
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-08-19 21:26:31 UTC
Duration: 118505ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 357ms
Format Validation.Event Has Uuid 32ms
Format Validation.Event Has Lib Properties 29ms
Format Validation.Distinct Id Is String 31ms
Format Validation.Token Is Present 26ms
Format Validation.Custom Properties Preserved 28ms
Format Validation.Event Has Timestamp 34ms
Retry Behavior.Retries On 503 7027ms
Retry Behavior.Does Not Retry On 400 4023ms
Retry Behavior.Does Not Retry On 401 4029ms
Retry Behavior.Respects Retry After Header 7030ms
Retry Behavior.Implements Backoff 17039ms
Retry Behavior.Retries On 500 7020ms
Retry Behavior.Retries On 502 7021ms
Retry Behavior.Retries On 504 7020ms
Retry Behavior.Max Retries Respected 17022ms
Deduplication.Generates Unique Uuids 38ms
Deduplication.Preserves Uuid On Retry 7017ms
Deduplication.Preserves Uuid And Timestamp On Retry 12029ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7021ms
Deduplication.No Duplicate Events In Batch 44ms
Deduplication.Different Events Have Different Uuids 29ms
Compression.Sends Gzip When Enabled 24ms
Batch Format.Uses Proper Batch Structure 25ms
Batch Format.Flush With No Events Sends Nothing 18ms
Batch Format.Multiple Events Batched Together 43ms
Error Handling.Does Not Retry On 403 4026ms
Error Handling.Does Not Retry On 413 4024ms
Error Handling.Retries On 408 5033ms

Feature_Flags Tests

17/17 tests passed

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

@marandaneto
marandaneto requested a review from a team August 10, 2026 10:13
@marandaneto

Copy link
Copy Markdown
Member

moving to draft until we hear from @PostHog/team-surveys

@marandaneto
marandaneto marked this pull request as draft August 10, 2026 10:13
@github-actions

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@github-actions github-actions Bot added the stale label Aug 18, 2026
Generated-By: PostHog Desktop
Task-Id: de8974e0-537f-4189-a799-66a7bc98cb10
SurveyAppearance now has 33 constructor parameters, so Kotlin emits a second int bitmask argument on the synthetic constructor and copy$default. Update the checked-in API dump to match, fixing the binary-compatibility check.

Generated-By: PostHog Desktop
Task-Id: de8974e0-537f-4189-a799-66a7bc98cb10
@jakesciotto
jakesciotto marked this pull request as ready for review August 19, 2026 21:42
@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "chore(surveys): refresh API dump for Sur..." | Re-trigger Greptile

@github-actions github-actions Bot removed the stale label Aug 20, 2026
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.

2 participants