posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(insights): Compare to arbitrary prior periods of time

Open aspicer opened this issue 1 year ago â€ĸ 12 comments

Problem

The "compare to previous period" function currently only allows you to compare to the period immediately preceding what is shown on the graph.

Changes

Change the compare selector to let the user select an arbitrary time in the past to compare with

Works with trends and stickiness

image image image image

The old functionality is still available as "period": image

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

Yes

How did you test this code?

Tested in dev. Wrote tests for the python date class that handles the logic.

aspicer avatar May 21 '24 19:05 aspicer

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 21 '24 19:05 posthog-bot

Size Change: +355 B (+0.03%)

Total Size: 1.06 MB

â„šī¸ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.06 MB +355 B (+0.03%)

compressed-size-action

github-actions[bot] avatar May 21 '24 19:05 github-actions[bot]

📸 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 avatar May 21 '24 20:05 posthog-bot

📸 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 avatar May 21 '24 20:05 posthog-bot

📸 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 avatar May 22 '24 03:05 posthog-bot

@thmsobrmlr Thanks for the heads up! I made those changes and wrote more thorough tests for the trends query, actors query, and stickiness query.

I saw your PR here with notes about future fixes for actors: https://github.com/PostHog/posthog/pull/22132 I'm happy to help chip away at any outstanding issues - let's sync up tomorrow at the standup or afterwards on what issues I could help resolve.

As for this PR, here's an example of the actors query working. The insight below has a 2 day compare set up. You can then see that the actors query for current May 15th returns the same data as previous May 17th image image image

aspicer avatar May 22 '24 05:05 aspicer

It looks like there's another PR out there implementing some of the same stuff: https://github.com/PostHog/posthog/pull/22267

mariusandra avatar May 22 '24 08:05 mariusandra

📸 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 avatar May 22 '24 16:05 posthog-bot

📸 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 avatar May 22 '24 16:05 posthog-bot

📸 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 avatar May 22 '24 16:05 posthog-bot

📸 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 avatar May 22 '24 16:05 posthog-bot

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 24 '24 22:05 posthog-bot

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 06:05 posthog-bot

📸 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 avatar May 29 '24 07:05 posthog-bot

📸 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 avatar May 29 '24 21:05 posthog-bot

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 21:05 posthog-bot

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 22:05 posthog-bot

📸 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 avatar May 29 '24 22:05 posthog-bot

📸 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 avatar May 29 '24 23:05 posthog-bot

📸 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 avatar May 29 '24 23:05 posthog-bot

📸 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 avatar May 30 '24 00:05 posthog-bot

📸 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 avatar May 30 '24 04:05 posthog-bot

📸 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 avatar May 30 '24 05:05 posthog-bot

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 30 '24 05:05 posthog-bot

Is this up for re-review? @aspicer Lemme know with a review request

Twixes avatar May 30 '24 18:05 Twixes

📸 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 avatar May 30 '24 18:05 posthog-bot

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 30 '24 18:05 posthog-bot

📸 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 avatar May 30 '24 19:05 posthog-bot

📸 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 avatar May 30 '24 19:05 posthog-bot

@thmsobrmlr @Twixes can i get a new look at this PR? it should be good to go with design and backend changes.

I have

  • Replaced the UI with @Twixes's dropdown selection.
  • Moved compare and compare_to onto a compareFilter and refactored accordingly
  • Updated web analytics to use the new format
  • Changed the front-end "all time" selector to remove compare, which the backend already does when you save
  • Updated tests to include the new format

I have tested this in dev and also tested to ensure that current saved insights keep their "compare" flag when you switch from master to this branch.

Thanks, let me know if you have questions

https://github.com/PostHog/posthog/assets/1855120/fb890186-8a6d-4fb7-b893-7e4628c3795b

aspicer avatar May 30 '24 19:05 aspicer