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: Allow creating a basic survey from a flag #17358

Merged
merged 23 commits into from
Sep 13, 2023
Merged

Conversation

neilkakkar
Copy link
Collaborator

Problem

Clean up the survey model & interface a bit - will create the migration separately to update the fields.

And allows creating a default survey from a flag, automatically linking it together.

2023-09-08 14 33 56

I need to think about how to order these options - but will do that at a later stage, since not everything can allow all these options, and some are more important than others.

Changes

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

Base automatically changed from notebook-survey to master September 11, 2023 10:18
@@ -162,8 +162,7 @@ export const dataTableLogic = kea<dataTableLogicType>([
showReload: query.showReload ?? showIfFull,
showTimings: query.showTimings ?? flagQueryTimingsEnabled,
showElapsedTime:
query.showTimings ||
flagQueryTimingsEnabled ||
(query.showTimings ?? flagQueryTimingsEnabled) ||
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mariusandra I'm assuming this was your intention here, as otherwise I can't override things

source: {
kind: NodeKind.HogQLQuery,
query: surveysShownHogqlQuery,
filters: { dateRange: { date_from: dayjs(createdAt).format('YYYY-MM-DD') } },
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@liyiy I've added date ranges to all queries which should make them faster + more accurate

@neilkakkar neilkakkar requested review from liyiy and daibhin September 12, 2023 12:49
@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.

@neilkakkar neilkakkar marked this pull request as ready for review September 12, 2023 13:14
frontend/src/scenes/feature-flags/featureFlagLogic.ts Outdated Show resolved Hide resolved
hasSurveys: [
(s) => [s.featureFlag],
(featureFlag) => {
return (featureFlag?.surveys?.length || 0) > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This selector will not update unless the feature flag changes. So if surveys are added / removed this selector will not update. Is that intended?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh good point, the flag is loaded only on mount right now, or when you revisit the feature flag, I'll add the appropriate listeners to update surveys on flag on survey creation, unless you think there's a better way to go about this?

Just noticed that if I delete something, the notebook logic stays mounted so it still shows the survey, need a refresh for it to say not found. Don't know if we want to do anything here as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm, this gets much messier, too many places for updates, need a better way around it 🤔

Copy link
Collaborator Author

@neilkakkar neilkakkar Sep 13, 2023

Choose a reason for hiding this comment

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

(to be clear, this is a problem when the survey is created/deleted outside the notebook flow, as within the notebook this is handled appropriately) - need to refresh in this case for now

frontend/src/scenes/feature-flags/featureFlagLogic.ts Outdated Show resolved Hide resolved
return (
(nextNode?.type.name === NotebookNodeType.Survey &&
hasSurveys &&
featureFlag.surveys &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this check given we're already guaranteeing surveys exist as part of the hasSurveys selector

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just satisfying typing 🙈 , because it can't parse that hasSurveys implies surveys exist

@neilkakkar neilkakkar enabled auto-merge (squash) September 13, 2023 10:28
@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.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

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

@neilkakkar neilkakkar merged commit 7c9d67e into master Sep 13, 2023
@neilkakkar neilkakkar deleted the notebook-survey-action branch September 13, 2023 13:32
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