Skip to content

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

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

feat(surveys): add optional intro screen before the first question#677
jakesciotto wants to merge 2 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-06 22:57:02 UTC
Duration: 118390ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 392ms
Format Validation.Event Has Uuid 27ms
Format Validation.Event Has Lib Properties 28ms
Format Validation.Distinct Id Is String 30ms
Format Validation.Token Is Present 25ms
Format Validation.Custom Properties Preserved 27ms
Format Validation.Event Has Timestamp 30ms
Retry Behavior.Retries On 503 7025ms
Retry Behavior.Does Not Retry On 400 4023ms
Retry Behavior.Does Not Retry On 401 4026ms
Retry Behavior.Respects Retry After Header 7028ms
Retry Behavior.Implements Backoff 17030ms
Retry Behavior.Retries On 500 7016ms
Retry Behavior.Retries On 502 7019ms
Retry Behavior.Retries On 504 7020ms
Retry Behavior.Max Retries Respected 17034ms
Deduplication.Generates Unique Uuids 37ms
Deduplication.Preserves Uuid On Retry 7012ms
Deduplication.Preserves Uuid And Timestamp On Retry 12030ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7018ms
Deduplication.No Duplicate Events In Batch 36ms
Deduplication.Different Events Have Different Uuids 21ms
Compression.Sends Gzip When Enabled 19ms
Batch Format.Uses Proper Batch Structure 18ms
Batch Format.Flush With No Events Sends Nothing 11ms
Batch Format.Multiple Events Batched Together 32ms
Error Handling.Does Not Retry On 403 4020ms
Error Handling.Does Not Retry On 413 4021ms
Error Handling.Retries On 408 5028ms

Feature_Flags Tests

17/17 tests passed

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

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