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): auto opt in and out surveys for users #18080

Merged
merged 17 commits into from
Oct 20, 2023
Merged

Conversation

liyiy
Copy link
Contributor

@liyiy liyiy commented Oct 19, 2023

Problem

There's pretty much no reason a user needs to manually toggle surveys functionality themselves if they want to use surveys, so we should just make it work out of the box.

Changes

Whenever a user launches a survey, we toggle the surveys script automatically for them. If they stop a survey and there are no other active surveys, we toggle the script off automatically for them.

There is still a manual option for updating the surveys toggle in Project Settings if the user needs to for whatever reason.

A banner will also display if the user has active surveys but their toggle is turned off

Screen.Recording.2023-10-18.at.10.07.41.PM.mov
  • TODO: @neilkakkar to update the version banner so it's more accurate in diagnosing that a user's JS library version is out of date for surveys? 🙏

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

How did you test this code?

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

frontend/src/scenes/surveys/Surveys.tsx Outdated Show resolved Hide resolved
frontend/src/scenes/surveys/Surveys.tsx Outdated Show resolved Hide resolved
frontend/src/scenes/surveys/Surveys.tsx Show resolved Hide resolved
frontend/src/scenes/surveys/surveyLogic.tsx Outdated Show resolved Hide resolved
frontend/src/scenes/surveys/Surveys.tsx Outdated Show resolved Hide resolved
frontend/src/scenes/surveys/Surveys.tsx Outdated Show resolved Hide resolved
frontend/src/scenes/surveys/surveyLogic.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@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.

This toggle updating should be in the backend, which will make sure we cover all paths much more easily. Only where the user themselves can change things should we use updateCurrentTeam in the frontend.

frontend/src/scenes/surveys/Surveys.tsx Outdated Show resolved Hide resolved
@liyiy
Copy link
Contributor Author

liyiy commented Oct 19, 2023

Fixed the flicker

Screen.Recording.2023-10-19.at.4.20.21.PM.mov

@@ -33,7 +34,8 @@ interface SurveysCreators {
export const surveysLogic = kea<surveysLogicType>([
path(['scenes', 'surveys', 'surveysLogic']),
connect(() => ({
values: [userLogic, ['user']],
values: [userLogic, ['user'], teamLogic, ['currentTeam', 'currentTeamLoading']],
actions: [teamLogic, ['loadCurrentTeam']],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're reloading current team to get the most up to date surveys_opt_in value since it's being triggered in the backend now.

},
setSurveysFilters: () => {
actions.loadSurveys()
actions.loadResponsesCount()
},
loadSurveysSuccess: () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

surveyLogic calls loadSurveys when surveys are launched/updated/resumed, so this should cover team reloading for all those cases

Copy link
Collaborator

@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.

🚀

posthog/models/feedback/survey.py Outdated Show resolved Hide resolved
frontend/src/scenes/surveys/Surveys.tsx Show resolved Hide resolved
@liyiy liyiy enabled auto-merge (squash) October 20, 2023 16:20
@liyiy liyiy merged commit fb6e408 into master Oct 20, 2023
73 checks passed
@liyiy liyiy deleted the remove-surveys-toggle branch October 20, 2023 18:01
daibhin pushed a commit that referenced this pull request Oct 23, 2023
* opt in surveys when creating survey and opt out when no active surveys

* update survey banner warning

* add auto opt ins for surveys list launch and stop surveys

* remove from onboarding step

* Update UI snapshots for `chromium` (2)

* update opt in from backend instead

* add filter for api surveys and post delete to receiver

* Update query snapshots

* fix popup flicker

* ambr snapshots

* disabled popup banner rename

* exclude api surveys in query instead

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Justicea83 pushed a commit to Justicea83/posthog that referenced this pull request Oct 24, 2023
* opt in surveys when creating survey and opt out when no active surveys

* update survey banner warning

* add auto opt ins for surveys list launch and stop surveys

* remove from onboarding step

* Update UI snapshots for `chromium` (2)

* update opt in from backend instead

* add filter for api surveys and post delete to receiver

* Update query snapshots

* fix popup flicker

* ambr snapshots

* disabled popup banner rename

* exclude api surveys in query instead

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants