Skip to content

fix(surveys): exclude web-only surveys on Android - #690

Open
dustinbyrne wants to merge 1 commit into
mainfrom
posthog-code/exclude-web-only-surveys
Open

fix(surveys): exclude web-only surveys on Android#690
dustinbyrne wants to merge 1 commit into
mainfrom
posthog-code/exclude-web-only-surveys

Conversation

@dustinbyrne

@dustinbyrne dustinbyrne commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Why: Surveys scoped to the web via a CSS selector or url display condition were leaking onto native Android and rendering as inert prompts with non-functional targeting.

PostHogSurveysIntegration.getActiveMatchingSurveys() did not check conditions.url or conditions.selector. Android cannot evaluate either condition, so matching native device-type or event targeting is not enough to make such a survey eligible.

This brings posthog-android in line with the canonical surveys contract in PostHog/sdk-specs and the behavior already shipped in posthog-ios and posthog-react-native.

Analogous of PostHog/posthog-ios#733

What changed

  • Added a filter to exclude surveys with any non-empty url or selector condition.
  • Kept surveys without web conditions eligible for the existing native targeting checks.
  • Added regression coverage for URL, selector, device-type, and event-targeting combinations.

💚 How did you test it?

  • ./gradlew :posthog-android:testDebugUnitTest --tests 'com.posthog.android.surveys.PostHogSurveysWebConditionsTest'
  • make test
  • make checkFormat

📝 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

🤖 Agent context

Autonomy: Fully autonomous

Authored by PostHog Code. A Changeset entry was added since the repo uses Changesets rather than direct CHANGELOG edits.


Created with PostHog Code

@posthog

posthog Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦔 ReviewHog reviewed this pull request

Found 1 must fix, 0 should fix, 0 consider.

Published 1 finding (view the review).

@posthog

posthog Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

ReviewHog Alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏

@posthog posthog Bot left a comment

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.

ReviewHog Report

Changes

Issues: 1 issue

Files (2)
  • .changeset/exclude-web-only-surveys.md
  • posthog-android/src/main/java/com/posthog/android/surveys/PostHogSurveysIntegration.kt

Surveys scoped to the web via a CSS `selector` or `url` display condition were
leaking onto native Android because those conditions were not checked during
survey matching.

Exclude every survey with a non-empty `url` or `selector`, including surveys
that also have device-type or event targeting. Android cannot evaluate the web
condition, so native targeting alone must not make the survey eligible. This
matches the behavior in posthog-ios and posthog-react-native.

Generated-By: PostHog Code
Task-Id: 0fc1a1b9-118e-48f1-8c40-d399f533d150
@dustinbyrne
dustinbyrne force-pushed the posthog-code/exclude-web-only-surveys branch from e5fc46d to 8ee7722 Compare August 11, 2026 16:05
@dustinbyrne
dustinbyrne marked this pull request as ready for review August 11, 2026 16:56
@dustinbyrne
dustinbyrne requested a review from a team as a code owner August 11, 2026 16:56
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(surveys): exclude web-only surveys o..." | Re-trigger Greptile

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