-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: funnel first_time_for_user logic change (#25448)
- Loading branch information
Showing
9 changed files
with
250 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
InsightDateRange, | ||
PersonsOnEventsMode, | ||
PropertyOperator, | ||
FunnelMathType, | ||
) | ||
from posthog.test.base import ( | ||
APIBaseTest, | ||
|
@@ -4189,6 +4190,66 @@ def test_first_time_for_user_funnel_multiple_ids(self): | |
self.assertEqual(results[0]["count"], 3) | ||
self.assertEqual(results[1]["count"], 1) | ||
|
||
def test_first_time_for_user_funnel_person_properties(self): | ||
_create_person(distinct_ids=["user_1"], team=self.team, properties={"email": "[email protected]"}) | ||
_create_person( | ||
distinct_ids=["user_2"], | ||
properties={"email": "[email protected]"}, | ||
team=self.team, | ||
) | ||
|
||
_create_event( | ||
team=self.team, | ||
event="event1", | ||
distinct_id="user_1", | ||
timestamp="2024-03-20T13:00:00Z", | ||
) | ||
_create_event( | ||
team=self.team, | ||
event="event1", | ||
distinct_id="user_1", | ||
properties={"property": "woah"}, | ||
timestamp="2024-03-21T13:00:00Z", | ||
) | ||
_create_event( | ||
team=self.team, | ||
event="event1", | ||
distinct_id="user_2", | ||
timestamp="2024-03-22T14:00:00Z", | ||
) | ||
_create_event( | ||
team=self.team, | ||
event="event2", | ||
distinct_id="user_1", | ||
timestamp="2024-03-23T13:00:00Z", | ||
) | ||
|
||
query = FunnelsQuery( | ||
series=[ | ||
EventsNode( | ||
event="event1", | ||
math=FunnelMathType.FIRST_TIME_FOR_USER_WITH_FILTERS, | ||
properties=[ | ||
EventPropertyFilter(key="property", value="woah", operator=PropertyOperator.EXACT), | ||
], | ||
), | ||
EventsNode(event="event2"), | ||
], | ||
dateRange=InsightDateRange( | ||
date_from="2024-03-20", | ||
date_to="2024-03-24", | ||
), | ||
) | ||
results = FunnelsQueryRunner(query=query, team=self.team).calculate().results | ||
|
||
self.assertEqual(results[0]["count"], 1) | ||
self.assertEqual(results[1]["count"], 1) | ||
|
||
query.series[0].math = FunnelMathType.FIRST_TIME_FOR_USER | ||
results = FunnelsQueryRunner(query=query, team=self.team).calculate().results | ||
# classic and udf funnels handle no events differently | ||
assert len(results) == 0 or results[0]["count"] == 0 | ||
|
||
def test_funnel_personless_events_are_supported(self): | ||
user_id = uuid.uuid4() | ||
_create_event( | ||
|
Oops, something went wrong.