Skip to content

Conversation

@adboio
Copy link
Contributor

@adboio adboio commented Nov 18, 2025

Problem

survey adoption is incredibly low. my hypothesis is that "surveys" in the sidebar/nav is meaningless to users, and surveys will generally continue to be meaningless until we tell users why they need surveys, what to ask in them, and how to build them.

Changes

⚠️ this change is behind the feature flag survey-funnels-cross-sell, which is currently disabled

original PR: #41574

this PR introduces a new "Ask users why" button on up to 1 funnel insight per dashboard that launches PostHog AI with context about the insight, and a prompt to create a survey.

new survey field: linked_insight_id

added this new field to the survey model so that we don't show the "ask users why" button if the user has already created a survey from this insight

(this PR just adds an index to the db, three previous PRs were merged with additional migrations)

opportunity logic

very simple right now:

  • get a list of all insights on the current dashboard
  • filter out non-funnel insights
  • filter out insights with associated surveys (via surveys.linked_insight_id)
  • return funnel with lowest conversion rate

this logic caps "low conversion rate" at <50%, so if there are no funnels with worse than 50% conversion, nothing will be returned.

behavior

  • user visits dashboard
  • we use above opportunity logic to find a target insight
  • if found, "ask users why" button appears
  • clicking button launches PostHog AI with prompt & context

survey-funnel-cross-sell-demo

Screenshot 2025-11-14 at 3 04 53 PM Screenshot 2025-11-17 at 11 59 53 AM

How did you test this code?

tested locally

Changelog: (features only) Is this feature complete?

not yet :)

Copy link
Contributor Author

adboio commented Nov 18, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

Migration SQL Changes

Hey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:

posthog/migrations/0917_alter_survey_linked_insight.py

--
-- Custom state/database change combination
--

                    CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_survey_linked_insight_id_586524f3" ON "posthog_survey" ("linked_insight_id"); -- existing-table-constraint-ignore
                    ;

Last updated: 2025-11-21 21:33 UTC (c640776)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

🔍 Migration Risk Analysis

We've analyzed your migrations for potential risks.

Summary: 0 Safe | 1 Needs Review | 0 Blocked

⚠️ Needs Review

Requires brief lock, review for high-traffic tables

posthog.0917_alter_survey_linked_insight
  └─ #1 ✅ SeparateDatabaseAndState
     Wrapper operation - see nested operations for risk: RunSQL
     database_operations: RunSQL
     └─ #2 ⚠️ RunSQL: CREATE INDEX CONCURRENTLY is safe (non-blocking)

Last updated: 2025-11-21 21:34 UTC (c640776)

@adboio adboio changed the base branch from 11-18-feat_surveys_add_linked_insight_id_field to graphite-base/41703 November 18, 2025 19:36
@adboio adboio changed the base branch from graphite-base/41703 to 11-18-feat_surveys_add_linked_insight_id_field November 18, 2025 19:36
@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch from 1fb0030 to a475441 Compare November 18, 2025 19:37
@adboio adboio changed the base branch from 11-18-feat_surveys_add_linked_insight_id_field to graphite-base/41703 November 18, 2025 19:37
@adboio adboio changed the base branch from graphite-base/41703 to 11-18-feat_surveys_add_fk_constraint November 18, 2025 19:37
@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch from a475441 to bc9b976 Compare November 18, 2025 20:00
@adboio adboio force-pushed the 11-18-feat_surveys_add_fk_constraint branch 2 times, most recently from 755e84f to d2d3fa8 Compare November 18, 2025 20:12
@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch from bc9b976 to 32394e7 Compare November 18, 2025 20:12
@adboio adboio force-pushed the 11-18-feat_surveys_add_fk_constraint branch from d2d3fa8 to d402eb6 Compare November 18, 2025 20:16
@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch from 32394e7 to 7ead735 Compare November 18, 2025 20:16
@adboio adboio changed the base branch from 11-18-feat_surveys_add_fk_constraint to graphite-base/41703 November 19, 2025 19:00
@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch from 7ead735 to 32e402b Compare November 20, 2025 04:58
@adboio adboio force-pushed the graphite-base/41703 branch from d402eb6 to be98be3 Compare November 20, 2025 04:58
@adboio adboio changed the base branch from graphite-base/41703 to master November 20, 2025 04:58
@adboio adboio changed the title feat(surveys): add index for linked_insight_id feat(surveys): add cross-sell button to funnel insights Nov 20, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Size Change: +93 B (0%)

Total Size: 3.4 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 3.4 MB +93 B (0%)

compressed-size-action

@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch 2 times, most recently from e28f35f to aacae82 Compare November 20, 2025 22:23
@adboio adboio marked this pull request as ready for review November 21, 2025 00:09
@posthog-bot posthog-bot requested a review from a team November 21, 2025 00:10
@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch from aacae82 to 465ab39 Compare November 21, 2025 00:13
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

13 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

const { nameSortedDashboards } = useValues(dashboardsModel)
const otherDashboards = nameSortedDashboards.filter((nsdb) => nsdb.id !== dashboard?.id)
const { featureFlags } = useValues(featureFlagLogic)
const { data: surveyLinkedInsights, loading: surveyLinkedInsightsLoading } = useSurveyLinkedInsights()
Copy link
Contributor

Choose a reason for hiding this comment

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

style: calling useSurveyLinkedInsights() unconditionally makes API request even when feature flag is disabled

Suggested change
const { data: surveyLinkedInsights, loading: surveyLinkedInsightsLoading } = useSurveyLinkedInsights()
const { data: surveyLinkedInsights, loading: surveyLinkedInsightsLoading } = featureFlags[FEATURE_FLAGS.SURVEYS_FUNNELS_CROSS_SELL] ? useSurveyLinkedInsights() : { data: new Set<number>(), loading: false }
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/scenes/dashboard/DashboardItems.tsx
Line: 59:59

Comment:
**style:** calling `useSurveyLinkedInsights()` unconditionally makes API request even when feature flag is disabled

```suggestion
    const { data: surveyLinkedInsights, loading: surveyLinkedInsightsLoading } = featureFlags[FEATURE_FLAGS.SURVEYS_FUNNELS_CROSS_SELL] ? useSurveyLinkedInsights() : { data: new Set<number>(), loading: false }
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

conditional hooks huh 🫨

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(ig this is valid tho i’ll fix it a different way)

Copy link
Contributor

@arthurdedeus arthurdedeus left a comment

Choose a reason for hiding this comment

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

feels like I've reviewed this before, looks good though

@adboio
Copy link
Contributor Author

adboio commented Nov 21, 2025

feels like I've reviewed this before, looks good though

you have haha, sorry about that - had to break it down into different PRs to pass migration checks

thank you!!

@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch 4 times, most recently from a848bcc to 0fee956 Compare November 21, 2025 19:29
@adboio adboio force-pushed the 11-18-feat_surveys_add_index branch from 0fee956 to c640776 Compare November 21, 2025 21:27
@adboio adboio merged commit cc9ccbe into master Nov 21, 2025
201 checks passed
Copy link
Contributor Author

adboio commented Nov 21, 2025

Merge activity

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.

3 participants