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

feat: Add dotnet_events to the usage report #29206

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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/tasks/test/__snapshots__/test_usage_report.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''

SELECT team_id,
multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'web', 'web_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'js', 'web_lite_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-node', 'node_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-android', 'android_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-flutter', 'flutter_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-ios', 'ios_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-go', 'go_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-java', 'java_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-react-native', 'react_native_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-ruby', 'ruby_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-python', 'python_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-php', 'php_events', 'other') AS metric,
multiIf(event LIKE 'helicone%', 'helicone_events', event LIKE 'langfuse%', 'langfuse_events', event LIKE 'keywords_ai%', 'keywords_ai_events', event LIKE 'traceloop%', 'traceloop_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'web', 'web_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'js', 'web_lite_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-node', 'node_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-android', 'android_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-flutter', 'flutter_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-ios', 'ios_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-go', 'go_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-java', 'java_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-react-native', 'react_native_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-ruby', 'ruby_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-python', 'python_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-php', 'php_events', replaceRegexpAll(JSONExtractRaw(properties, '$lib'), '^"|"$', '') = 'posthog-dotnet', 'dotnet_events', 'other') AS metric,
count(1) as count
FROM events
WHERE timestamp BETWEEN '2022-01-10 00:00:00' AND '2022-01-10 23:59:59'
Expand Down
5 changes: 5 additions & 0 deletions posthog/tasks/test/test_usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ def _test_usage_report(self) -> list[dict]:
"ruby_events_count_in_period": 1,
"python_events_count_in_period": 1,
"php_events_count_in_period": 1,
"dotnet_events_count_in_period": 0,
"recording_count_in_period": 5,
"mobile_recording_count_in_period": 0,
"mobile_billable_recording_count_in_period": 0,
Expand Down Expand Up @@ -601,6 +602,7 @@ def _test_usage_report(self) -> list[dict]:
"ruby_events_count_in_period": 1,
"python_events_count_in_period": 1,
"php_events_count_in_period": 1,
"dotnet_events_count_in_period": 0,
"recording_count_in_period": 0,
"mobile_recording_count_in_period": 0,
"mobile_billable_recording_count_in_period": 0,
Expand Down Expand Up @@ -656,6 +658,7 @@ def _test_usage_report(self) -> list[dict]:
"ruby_events_count_in_period": 0,
"python_events_count_in_period": 0,
"php_events_count_in_period": 0,
"dotnet_events_count_in_period": 0,
"recording_count_in_period": 5,
"mobile_recording_count_in_period": 0,
"mobile_billable_recording_count_in_period": 0,
Expand Down Expand Up @@ -734,6 +737,7 @@ def _test_usage_report(self) -> list[dict]:
"ruby_events_count_in_period": 0,
"python_events_count_in_period": 0,
"php_events_count_in_period": 0,
"dotnet_events_count_in_period": 0,
"recording_count_in_period": 0,
"mobile_recording_count_in_period": 0,
"mobile_billable_recording_count_in_period": 0,
Expand Down Expand Up @@ -795,6 +799,7 @@ def _test_usage_report(self) -> list[dict]:
"ruby_events_count_in_period": 0,
"python_events_count_in_period": 0,
"php_events_count_in_period": 0,
"dotnet_events_count_in_period": 0,
"recording_count_in_period": 0,
"mobile_recording_count_in_period": 0,
"mobile_billable_recording_count_in_period": 0,
Expand Down
5 changes: 5 additions & 0 deletions posthog/tasks/usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class UsageReportCounters:
ruby_events_count_in_period: int
python_events_count_in_period: int
php_events_count_in_period: int
dotnet_events_count_in_period: int


# Instance metadata to be included in overall report
Expand Down Expand Up @@ -439,6 +440,7 @@ def get_all_event_metrics_in_period(begin: datetime, end: datetime) -> dict[str,
{lib_expression} = 'posthog-ruby', 'ruby_events',
{lib_expression} = 'posthog-python', 'python_events',
{lib_expression} = 'posthog-php', 'php_events',
{lib_expression} = 'posthog-dotnet', 'dotnet_events',
'other'
) AS metric,
count(1) as count
Expand Down Expand Up @@ -469,6 +471,7 @@ def get_all_event_metrics_in_period(begin: datetime, end: datetime) -> dict[str,
"ruby_events": [],
"python_events": [],
"php_events": [],
"dotnet_events": [],
}

for team_id, metric, count in results:
Expand Down Expand Up @@ -841,6 +844,7 @@ def _get_all_usage_data(period_start: datetime, period_end: datetime) -> dict[st
"teams_with_ruby_events_count_in_period": all_metrics["ruby_events"],
"teams_with_python_events_count_in_period": all_metrics["python_events"],
"teams_with_php_events_count_in_period": all_metrics["php_events"],
"teams_with_dotnet_events_count_in_period": all_metrics["dotnet_events"],
"teams_with_recording_count_in_period": get_teams_with_recording_count_in_period(
period_start, period_end, snapshot_source="web"
),
Expand Down Expand Up @@ -1079,6 +1083,7 @@ def _get_team_report(all_data: dict[str, Any], team: Team) -> UsageReportCounter
ruby_events_count_in_period=all_data["teams_with_ruby_events_count_in_period"].get(team.id, 0),
python_events_count_in_period=all_data["teams_with_python_events_count_in_period"].get(team.id, 0),
php_events_count_in_period=all_data["teams_with_php_events_count_in_period"].get(team.id, 0),
dotnet_events_count_in_period=all_data["teams_with_dotnet_events_count_in_period"].get(team.id, 0),
exceptions_captured_in_period=all_data["teams_with_exceptions_captured_in_period"].get(team.id, 0),
ai_event_count_in_period=all_data["teams_with_ai_event_count_in_period"].get(team.id, 0),
)
Expand Down
Loading