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

chore: also count force_upgrade events as personfull for usage reports #21869

Merged
merged 4 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading