Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(surveys): allow to stop surveys once reached enough responses #21528

Merged
merged 25 commits into from
Apr 26, 2024

Conversation

nikitaevg
Copy link
Contributor

@nikitaevg nikitaevg commented Apr 14, 2024

Problem

Fixes #21179

Changes

  1. It allows a user to set responses limits for surveys on frontend
  2. It creates a periodic task, which stops surveys which reached their limits

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Manually:

  1. The survey wait period field improvement
    1. The number field is cleared on unchecking the checkbox
    2. One can clear the field manually now
  2. The responses limit field can be set and is saved (screencast)
  3. The responses limit is used (screencast, I'm waiting for the job invocation on it for 1 minute)

@@ -516,13 +516,18 @@ export default function SurveyEdit(): JSX.Element {
type="number"
size="small"
min={0}
value={value?.seenSurveyWaitPeriodInDays}
value={value?.seenSurveyWaitPeriodInDays || NaN}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This cleans the input field when the value is null

onChange={(val) => {
if (val !== undefined && val > 0) {
onChange({
...value,
seenSurveyWaitPeriodInDays: val,
})
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows one to actually clean the input field

Copy link
Contributor

@neilkakkar neilkakkar left a comment

Choose a reason for hiding this comment

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

Hey @nikitaevg - excellent work so far! Great job improving the survey wait period component. Some comments on things to fix.

Also, we want some indication on the UI when the survey is running: A dismissible info banner saying the survey will be stopped when X responses are reached.

@nikitaevg
Copy link
Contributor Author

nikitaevg commented Apr 21, 2024

Thanks for the comments @neilkakkar

Also, we want some indication on the UI when the survey is running: A dismissible info banner saying the survey will be stopped when X responses are reached.

Yeah, it makes sense. I'm not sure if it should be dismissible though. WDYT about this place at the bottom, in the Overview? IMO it's pretty suitable there.

I see the storybook tests fail here. I tried updating the screenshots, but storybook fails for chromium on my laptop with an error page.waitForLoadState: Timeout 10000ms exceeded. for all tests, you can see the command with the full error here. If you know why this might happen (assuming Posthog is up and running locally), please let me know. But I looked into it for only 10m or so, I'll give it another try soon. Upd: hmm, it fails on waiting for the "networkidle" state.

@neilkakkar
Copy link
Contributor

nice, agree not dismissible like you have is much better 👍 . I think I was thinking of dismissible banner after the celery task runs and ends the survey. But we don't have a good way to detect this currently. Hmm.

@neilkakkar
Copy link
Contributor

Haven't seen that storybook error before, so unsure, but for the CI failure, it seems like updating snapshots from a fork PR isn't possible, hmm, let me try pushing to see if that makes a difference.

@neilkakkar
Copy link
Contributor

You can copy the snapshot updates from my PR above if you prefer, or I can merge your changes into that PR and merge that. Upto you :)

nikitaevg and others added 2 commits April 23, 2024 20:38
@nikitaevg
Copy link
Contributor Author

nice, agree not dismissible like you have is much better 👍 . I think I was thinking of dismissible banner after the celery task runs and ends the survey. But we don't have a good way to detect this currently. Hmm.

I agree it would be nice. Let's see if users get confused about this and if so I could add a banner. My current idea is that we would need to persist the responses_limit until the survey is relaunched, so that when a user sees a finished survey we could determine if it was finished due to the responses_limit and show such a banner. That would complicate the solution in a sense that responses_limit should now be updated in the survey launch.

You can copy the snapshot updates from my PR above if you prefer, or I can merge your changes into that PR and merge that. Upto you :)

Thank you! Will transfer the screenshots to my PR once it's ready to be submitted

@neilkakkar
Copy link
Contributor

Seriously great work here, I'm impressed how you managed to sort this really big chunk of work mostly autonomously, and had great suggestions on how to do things 🚀 🙌

@nikitaevg
Copy link
Contributor Author

Seriously great work here, I'm impressed how you managed to sort this really big chunk of work mostly autonomously, and had great suggestions on how to do things 🚀 🙌

Thank you:) I'm pleased to hear that!

@nikitaevg
Copy link
Contributor Author

@neilkakkar I added a cypress test and transferred the screenshots, could you please have another look?

@nikitaevg nikitaevg requested a review from neilkakkar April 25, 2024 18:37
Copy link
Contributor

@neilkakkar neilkakkar left a comment

Choose a reason for hiding this comment

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

looks good thanks!

@neilkakkar neilkakkar enabled auto-merge (squash) April 26, 2024 13:24
@neilkakkar neilkakkar merged commit 50360e7 into PostHog:master Apr 26, 2024
100 of 101 checks passed
fuziontech added a commit that referenced this pull request Apr 26, 2024
* master: (28 commits)
  fix: refactor update animation to do less (#21901)
  fix(plugin-server): add time component to person.force_upgrade (#21899)
  fix(dashboards): Indicate 404/400/500 properly (#21853)
  fix: recording exports (#21900)
  feat: Update SLAs, remove GitHub buttons (#21818)
  chore: Removed feature flag for heatmaps (#21886)
  fix(data-warehouse): Added an error message for empty data source files (#21843)
  feat(surveys): allow to stop surveys once reached enough responses (#21528)
  fix: patch missing pause method in rrweb (#21898)
  fix(hogql): make funnels fast again (#21890)
  fix: Explicitly call out readonly user fields (#21889)
  chore(dev): Allow mypy to run in VS Code extension (#21891)
  feat: Small heatmap UI fixes (#21849)
  feat: Improve Heatmaps UI and notices (#21887)
  fix: Redirection to keep query params (#21881)
  fix: hot path is cooler now (#21888)
  feat(data-warehouse): Moved the table model creation to the data pipeline activity (#21817)
  fix: snapshot response timings (#21885)
  chore(deps): Update posthog-js to 1.130.0 (#21884)
  feat(debug): tabs + better view for non-hogql-query nodes (#21867)
  ...
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.

Stop a survey once enough responses received
2 participants