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

fix(insights): Remove insight reuse on dashboard and insights #21471

Merged
merged 19 commits into from
Apr 29, 2024

Conversation

webjunkie
Copy link
Contributor

@webjunkie webjunkie commented Apr 10, 2024

Problem

Another try for #20371 and #20508

How to reproduce:

  • create two dashboards with separate filters
    • e.g. dashboard A filters for "browser = Firefox" an dashboard B for "browser = Hogbrowser"
  • add an insight, e.g. pageviews per day and add it to both dashboards
  • when switching between dashboards it will first show correct data depending on where you go first, but then start to show wrong data, for example no data when you previously already saw the Firefox filtered data
  • on top of that, when going to view or edit the insight, you will also still see wrong data and when editing, you will also the filters from the dashboard that are not really stored on the insight

Changes

  • remove any reuse of logics and cached insights accross dashboards and/or insight scene.
  • cleaned up when insightLogic and dataNodeLogic should load stuff
    • it's important they don't load onMount as we already have insights from the main dashboard call
      • which is nice since we get all data in one call from cache

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

it doesn't have an impact

How did you test this code?

  • tested creating insights, filters, dashboards
  • see extended Crypress tests... got them to pass 🤞🏻

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

Copy link
Contributor

github-actions bot commented Apr 10, 2024

Size Change: -259 B (0%)

Total Size: 1.04 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.04 MB -259 B (0%)

compressed-size-action

@webjunkie webjunkie marked this pull request as ready for review April 11, 2024 10:50
@webjunkie webjunkie requested a review from thmsobrmlr April 11, 2024 10:50
@webjunkie
Copy link
Contributor Author

@thmsobrmlr Asking you since @Twixes is ooo.

I started to think about dashboard insight loading from scratch. But when accepting that we might just load things fresh from the backend, I found that I can quick fix these issues after all, by removing specific logic that reuses insights.

Do you think this works as a short term solution (while I still check if we might cache some insights)? If you don't want to dig into it, it can also wait for Michael.

@thmsobrmlr
Copy link
Contributor

I started to think about dashboard insight loading from scratch. But when accepting that we might just load things fresh from the backend, I found that I can quick fix these issues after all, by removing specific logic that reuses insights.

I don't have a definitive answer here, but imagine that cached results are quite important for performance. I think something causes insights to load more often then they should when visiting a dashboard, but there are other instance where we still take the cached result.

@Twixes Twixes self-requested a review April 17, 2024 09:12
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

I fixed one more edge case that's been reported and added a test for that. Looking good, just pending a couple extra questions!

@@ -629,7 +629,7 @@ describe('insightLogic', () => {
}),
})

it('loads from the dashboardLogic when in dashboard context', async () => {
it.skip('loads from the dashboardLogic when in dashboard context', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

If these tests are no longer relevant, we should just remove them. It's improbable that we're ever going to re-enable them

@@ -885,7 +861,9 @@ export const dashboardLogic = kea<dashboardLogicType>([
let refreshesFinished = 0
let totalResponseBytes = 0

const hardRefreshWithoutCache = ['refresh', 'load_missing'].includes(action)
const hardRefreshWithoutCache = ['refresh', 'load_missing', 'refresh_insights_on_filters_updated'].includes(
Copy link
Member

Choose a reason for hiding this comment

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

Can we walk me through why refresh_insights_on_filters_updated is added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was because upon changing filters, a request to /insight is made with refresh=false which might return null as results. Maybe that's different with your other changes now? But yeah let's check tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

Are all the changes in results here expected?

  1. "Pageview count" table is no longer time series
  2. The retention tile no longer shows the date range
  3. The stickiness tile now shows "No matching events"

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

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

  • chromium: 0 added, 2 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.

@webjunkie
Copy link
Contributor Author

Any idea why one Cypress test now fails?

@Twixes Twixes force-pushed the fix/dashboard-logic-insights branch from 31526a6 to 16e9855 Compare April 26, 2024 13:06
@Twixes
Copy link
Member

Twixes commented Apr 26, 2024

Found why the UI snapshots were different: mocks reused the same shortId, so resulted in accidental reuse of the same insightLogic instances. Fixed.
As for the failing error, not sure, but should be pretty evident when you run bin/e2e-test-runner. Have you tried that?

@webjunkie
Copy link
Contributor Author

It was all green earlier.. and locally it fails on a different thing for me, which is not helpful 🤔

@Twixes
Copy link
Member

Twixes commented Apr 26, 2024

614068b should fix it.

@webjunkie webjunkie merged commit ebd336f into master Apr 29, 2024
103 checks passed
@webjunkie webjunkie deleted the fix/dashboard-logic-insights branch April 29, 2024 06:25
@webjunkie
Copy link
Contributor Author

This PR fixes (or tries to) #19788 by the way.

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