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

refactor(insights): remove filter based insights frontend side #24076

Merged
merged 112 commits into from
Aug 20, 2024

Conversation

thmsobrmlr
Copy link
Contributor

@thmsobrmlr thmsobrmlr commented Jul 30, 2024

Problem

We still have filters in the frontend.

Changes

  • removes legacyInsight usage, with exception of api handlers where we still get the legacy insights
  • removes InsightModel in the same way
  • renames queryBasedInsight to insight
  • changes the readAsQuery option from false to true everywhere -> the option will be removed in a follow up

Follow-up

How did you test this code?

  • Creating a notebook from a dashboard
  • Deleting a dashboard
  • Restoring a dashboard -> doesn't restore insight (neither does on master)
  • Pinning a dashboard
  • Unpinning a dashboard
  • Duplicating a dashboard -> Check that it is saved with filters!
  • Update a dashboard -> Check that it is saved with filters!
  • Test canceling changes
  • Test experiment results
  • Navigating away from an insight (regular, hogql, with test account filters, without test account filters)
  • Test account defaults
  • Changes to test account filters are persisted

@thmsobrmlr thmsobrmlr changed the title use query based insight in insight scene refactor(insights): remove filter based insights frontend side Jul 30, 2024
@thmsobrmlr thmsobrmlr force-pushed the remove-insight-model branch 2 times, most recently from c5c9543 to 5a40f2f Compare August 2, 2024 08:51
Base automatically changed from remove-filter-based-card-3 to master August 5, 2024 07:14
@thmsobrmlr thmsobrmlr force-pushed the remove-insight-model branch from 0c76cfa to c38d7d2 Compare August 5, 2024 07:22
@thmsobrmlr thmsobrmlr force-pushed the remove-insight-model branch from 830a48b to 27c601d Compare August 13, 2024 10:21
@thmsobrmlr thmsobrmlr removed the stale label Aug 13, 2024
@PostHog PostHog deleted a comment from posthog-bot Aug 13, 2024
@PostHog PostHog deleted a comment from github-actions bot Aug 13, 2024
Copy link
Contributor

github-actions bot commented Aug 13, 2024

Size Change: +3.44 kB (+0.32%)

Total Size: 1.08 MB

Filename Size Change
frontend/dist/toolbar.js 1.08 MB +3.44 kB (+0.32%)

compressed-size-action

@thmsobrmlr thmsobrmlr force-pushed the remove-insight-model branch from 8c60cb1 to a1dd6cd Compare August 13, 2024 13:31
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 3 modified, 0 deleted (diff for shard 1)
  • 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

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

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • 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

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

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

thmsobrmlr and others added 2 commits August 16, 2024 09:27
# Conflicts:
#	frontend/__snapshots__/exporter-exporter--user-paths-insight--light.png
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 3 modified, 0 deleted (diff for shard 1)
  • 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:

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@thmsobrmlr thmsobrmlr marked this pull request as ready for review August 16, 2024 08:13
@thmsobrmlr thmsobrmlr requested a review from a team August 16, 2024 08:14
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 3 modified, 0 deleted (diff for shard 1)
  • 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

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

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • 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:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • 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:

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@webjunkie webjunkie left a comment

Choose a reason for hiding this comment

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

A dizzying amount of changes 😵‍💫

I skimmed things and it looks alright. Just one question.

@@ -101,43 +102,51 @@ export const savedInsightsLogic = kea<savedInsightsLogicType>([
basic: true,
}

const response = await api.get(
const legacyResponse: CountedPaginatedResponse<InsightModel> = await api.get(
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering why this would be a legacy response... wouldn't this also respond with a query based insight if it's updated on the backend-side?

Copy link
Contributor Author

@thmsobrmlr thmsobrmlr Aug 19, 2024

Choose a reason for hiding this comment

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

Yep, you're right - this will be a query based insight if it is already stored with a query on the backend. legacyInsight in this context means an insight that is potentially a legacy one. The conversion function will give precedence to a query already present on an insight.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, good to know.

@thmsobrmlr
Copy link
Contributor Author

A dizzying amount of changes 😵‍💫

I skimmed things and it looks alright. Just one question.

Unfortunately I haven't been able to slice-and-dice this any further :/

Copy link
Contributor

@webjunkie webjunkie left a comment

Choose a reason for hiding this comment

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

Unfortunately I haven't been able to slice-and-dice this any further :/

No worries, this was more meant as appreciation of this ongoing diligent work.

return await api.update(`api/projects/${values.currentTeamId}/dashboards/${props.id}`, {
filters: values.filters,
})
const dashboard: DashboardType<InsightModel> = await api.update(
Copy link
Contributor

Choose a reason for hiding this comment

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

probably a dumb question, why do all API responses still return InsightModel and not QueryBasedInsightModel? Do we need to wait on that till we run the db migration script

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it's a good question. Basically QueryBasedInsightModel is everything in InsightModel, except filters. This helped me see where we were still accessing filters in a converted model.

The reason that the backend endpoint are still typed as InsightModel, is because they actually are. The backend side conversion is totally separate from the frontend side one. And you're right, we can change them once we ran the db migration script.

@@ -1034,7 +1049,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
'force_cache',
methodOptions
)
dashboardsModel.actions.updateDashboardInsight(polledInsight)
dashboardsModel.actions.updateDashboardInsight(polledInsight!)
Copy link
Contributor

Choose a reason for hiding this comment

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

not following why we suddenly need the non null assertion here 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the type of the getSingleInsight function (see line 134) above to be more in line with what it actually returns. The insight is only null if something went wrong and I didn't add error handling (we didn't have it before as well).

Copy link
Contributor

Choose a reason for hiding this comment

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

aah missed that, thought it was unchanged. Thanks for explaining!

@thmsobrmlr thmsobrmlr enabled auto-merge (squash) August 20, 2024 07:38
# Conflicts:
#	frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--dark.png
@thmsobrmlr thmsobrmlr merged commit c5dc3b7 into master Aug 20, 2024
93 checks passed
@thmsobrmlr thmsobrmlr deleted the remove-insight-model branch August 20, 2024 08:02
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