Skip to content

Commit

Permalink
chore: also count force_upgrade events as personfull for usage reports (
Browse files Browse the repository at this point in the history
#21869)

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
raquelmsmith and github-actions[bot] authored Apr 26, 2024
1 parent a6f03de commit e24d18e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion posthog/models/event/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create_event(
group2_created_at: Optional[Union[timezone.datetime, str]] = None,
group3_created_at: Optional[Union[timezone.datetime, str]] = None,
group4_created_at: Optional[Union[timezone.datetime, str]] = None,
person_mode: Literal["full", "propertyless"] = "full",
person_mode: Literal["full", "propertyless", "force_upgrade"] = "full",
) -> str:
if properties is None:
properties = {}
Expand Down
3 changes: 2 additions & 1 deletion posthog/tasks/test/__snapshots__/test_usage_report.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@
AND event NOT IN ('survey sent',
'survey shown',
'survey dismissed')
AND person_mode = 'full'
AND person_mode IN ('full',
'force_upgrade')
GROUP BY team_id
'''
# ---
Expand Down
25 changes: 17 additions & 8 deletions posthog/tasks/test/test_usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ def _create_sample_usage_data(self) -> None:
team=self.org_1_team_1,
person_mode="propertyless",
)
_create_event(
event_uuid=uuid4(),
distinct_id=distinct_id,
event="$propertyless_event",
properties={"$lib": "$web"},
timestamp=now() - relativedelta(hours=12),
team=self.org_1_team_1,
person_mode="force_upgrade",
)

flush_persons_and_events()

Expand Down Expand Up @@ -400,10 +409,10 @@ def _test_usage_report(self) -> list[dict]:
},
"plugins_enabled": {"Installed and enabled": 1},
"instance_tag": "none",
"event_count_lifetime": 56,
"event_count_in_period": 23,
"enhanced_persons_event_count_in_period": 22,
"event_count_in_month": 43,
"event_count_lifetime": 57,
"event_count_in_period": 24,
"enhanced_persons_event_count_in_period": 23,
"event_count_in_month": 44,
"event_count_with_groups_in_period": 2,
"recording_count_in_period": 5,
"recording_count_total": 16,
Expand Down Expand Up @@ -444,10 +453,10 @@ def _test_usage_report(self) -> list[dict]:
"team_count": 2,
"teams": {
str(self.org_1_team_1.id): {
"event_count_lifetime": 45,
"event_count_in_period": 13,
"enhanced_persons_event_count_in_period": 12,
"event_count_in_month": 33,
"event_count_lifetime": 46,
"event_count_in_period": 14,
"enhanced_persons_event_count_in_period": 13,
"event_count_in_month": 34,
"event_count_with_groups_in_period": 2,
"recording_count_in_period": 0,
"recording_count_total": 0,
Expand Down
2 changes: 1 addition & 1 deletion posthog/tasks/usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def get_teams_with_billable_enhanced_persons_event_count_in_period(
f"""
SELECT team_id, count({distinct_expression}) as count
FROM events
WHERE timestamp between %(begin)s AND %(end)s AND event != '$feature_flag_called' AND event NOT IN ('survey sent', 'survey shown', 'survey dismissed') AND person_mode = 'full'
WHERE timestamp between %(begin)s AND %(end)s AND event != '$feature_flag_called' AND event NOT IN ('survey sent', 'survey shown', 'survey dismissed') AND person_mode IN ('full', 'force_upgrade')
GROUP BY team_id
""",
{"begin": begin, "end": end},
Expand Down

0 comments on commit e24d18e

Please sign in to comment.