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

Setup Funnel Option Type, and proper Funnel[Persons] API routes #4946

Merged
merged 16 commits into from
Jul 1, 2021

Conversation

neilkakkar
Copy link
Collaborator

@neilkakkar neilkakkar commented Jun 30, 2021

Changes

WIP, need to heavily test test test for API breakages All good.

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests
  • Jest frontend tests
  • Cypress end-to-end tests
  • Migrations are safe to run at scale (e.g. PostHog Cloud) – present proof if not obvious
  • Frontend/CSS is usable at 320px (iPhone SE) and decent at 360px (most phones)
  • Breaking changes are backwards-compatible. Ensure old/new frontend requests work with new/old backends, and vice versa.

@timgl timgl temporarily deployed to posthog-pr-4946 June 30, 2021 12:57 Inactive
@timgl timgl temporarily deployed to posthog-pr-4946 June 30, 2021 15:16 Inactive
@timgl timgl temporarily deployed to posthog-pr-4946 June 30, 2021 15:20 Inactive
@timgl timgl temporarily deployed to posthog-pr-4946 June 30, 2021 15:23 Inactive
Comment on lines 97 to 98
UNORDERED = "unordered"
TRENDS = "trends"
Copy link
Collaborator

@Twixes Twixes Jun 30, 2021

Choose a reason for hiding this comment

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

Ordering vs. viz type are kind of orthogonal actually – you can have steps, trends, or time to convert graphs, and each of them can work with regular ordering OR with any ordering. I'm pretty sure we will allow mixing and matching this in the course of nailing funnels, as do other analytics tools, so I suggest to split this into two enums: FunnelOrdering and FunnelVizType.

BTW, is "strict" the best notion for what we have now? For instance Amplitude has a concept of "exact" order, meaning events must happen exactly one after another to count (none in between). This doesn't seem ideal for us (especially considering we do autocapture), but also seems like our way, while "ordered", is not particularly "strict". Feel free to disregard me rambling about this detail though. :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This makes A lot of sense! Didn't realise Trends was just a visualisation type.

@timgl timgl temporarily deployed to posthog-pr-4946 June 30, 2021 16:36 Inactive
@timgl timgl temporarily deployed to posthog-pr-4946 July 1, 2021 09:17 Inactive
@@ -53,6 +54,7 @@ def test_basic_format(self):
self.assertTrue("id" in j["results"][0] and "name" in j["results"][0] and "distinct_ids" in j["results"][0])

def test_basic_pagination(self):
cache.clear()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't set this in setUp, because I want things to be cached around so we know it's working fine generally. (it wasn't, so I fixed it a bit xD )

ORDERED = "ordered"


class FunnelVizType(str, Enum):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Better names very welcome.

I'm still not quite sure how we settled on ActionsLineGraph display type for Funnel Trends, but I think making it cleaner like this makes sense^ (thanks Twixes!)

@neilkakkar neilkakkar changed the title WIP: Setup funnel option type, and proper Funnel[Persons] API routes Setup Funnel Option Type, and proper Funnel[Persons] API routes Jul 1, 2021
@Twixes Twixes self-requested a review July 1, 2021 09:21
@timgl timgl temporarily deployed to posthog-pr-4946 July 1, 2021 09:31 Inactive
@timgl timgl temporarily deployed to posthog-pr-4946 July 1, 2021 09:36 Inactive
@neilkakkar neilkakkar requested a review from EDsCODE July 1, 2021 09:38
@neilkakkar neilkakkar marked this pull request as ready for review July 1, 2021 09:38
if not filter.funnel_viz_type and filter.display == TRENDS_LINEAR:
filter.funnel_viz_type = FunnelVizType.TRENDS

if filter.funnel_viz_type == FunnelVizType.TRENDS:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this checking will probably become more general later on, but fine (i think) as is for now.

@timgl timgl temporarily deployed to posthog-pr-4946 July 1, 2021 09:40 Inactive
@timgl timgl temporarily deployed to posthog-pr-4946 July 1, 2021 10:02 Inactive
class ClickhousePersonViewSet(PersonViewSet):

lifecycle_class = ClickhouseLifecycle
retention_class = ClickhouseRetention
stickiness_class = ClickhouseStickiness

@action(methods=["GET"], detail=False)
def funnel(self, request: request.Request, **kwargs) -> response.Response:
@action(methods=["GET", "POST"], detail=False)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

POST is important, because GET has issues with the URL being too long (on /insight/funnel/) and persons take all the same parameters!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm tempted to remove GET all together, since this is a new API endpoint.

@EDsCODE EDsCODE temporarily deployed to posthog-pr-4946 July 1, 2021 17:42 Inactive
Copy link
Member

@EDsCODE EDsCODE left a comment

Choose a reason for hiding this comment

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

Will need to add all the other types of funnels but getting this merged now so core experience can work with new api

@EDsCODE EDsCODE temporarily deployed to posthog-pr-4946 July 1, 2021 18:06 Inactive
@EDsCODE EDsCODE temporarily deployed to posthog-pr-4946 July 1, 2021 18:31 Inactive
@EDsCODE EDsCODE enabled auto-merge (squash) July 1, 2021 18:43
@EDsCODE EDsCODE disabled auto-merge July 1, 2021 18:43
@EDsCODE EDsCODE merged commit 22e0253 into master Jul 1, 2021
@EDsCODE EDsCODE deleted the funnel-api branch July 1, 2021 18:43
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