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

Conversation

haacked
Copy link
Contributor

@haacked haacked commented Feb 25, 2025

This adds the tracking of events from the posthog-dotnet library to the usage report.

Changes

Added dotnet_events, teams_with_dotnet_events_count_in_period, dotnet_events_count_in_period to usage_report.py

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Tried to run the usage report locally. No errors. Wasn't able to confirm results.

@haacked haacked requested a review from a team February 25, 2025 18:21
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added support for tracking events from the posthog-dotnet library in the usage report, enabling visibility into .NET SDK usage alongside other client libraries.

  • Added dotnet_events_count_in_period field to the UsageReportCounters dataclass in /posthog/tasks/usage_report.py
  • Added condition to identify events from the posthog-dotnet library in the SQL query that categorizes events by source
  • Added dotnet_events to the metrics dictionary that collects SDK usage statistics
  • Included the new metric in team report generation to ensure it's properly tracked and reported

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@haacked haacked requested a review from a team February 25, 2025 19:46
Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

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

seems reasonable to me, but I'd get an opinion from @zlwaterfield or someone else in growth before merging.

@zlwaterfield
Copy link
Contributor

Looks good

@haacked haacked enabled auto-merge (squash) February 25, 2025 22:34
@haacked
Copy link
Contributor Author

haacked commented Feb 25, 2025

Thanks @zlwaterfield. It looks like the same unit test is consistently failing and I'm not sure why. I tried running it locally, but I get unrelated exceptions such as failure to drop tables in use, etc.

I tried recreating the clickhouse container (917f02afdaa9 is the clickhouse docker container):

# Stop the container
docker stop 917f02afdaa9

# Remove the container
docker rm 917f02afdaa9

# Remove the volume
docker volume rm 0782200f2267f1bf332366ebc20593ff989e84b068175673318d51072a9fe4a3

# Start services again
docker compose -f docker-compose.dev.yml up -d

# 1. Create test database
docker exec -it $(docker ps | grep clickhouse | awk '{print $1}') clickhouse-client --query "CREATE DATABASE IF NOT EXISTS posthog_test"

# 2. Run Django migrations first
DEBUG=1 python manage.py migrate

# 3. Run ClickHouse migrations with test database
DEBUG=1 CLICKHOUSE_DATABASE=posthog_test python manage.py migrate_clickhouse --no-input

# 4. Run the test
DEBUG=1 python manage.py test posthog.tasks.test.test_usage_report.UsageReport.test_unlicensed_usage_report -v 3

And when I run the test, I get:

DB::Exception: There was an error on [clickhouse:9000]: Code: 630. DB::Exception: Cannot drop or rename posthog_test.channel_definition (40ffeaa9-0df7-4360-bfec-15a09b5c5b9c), because some tables depend on it: posthog_test.channel_definition_dict. (HAVE_DEPENDENT_OBJECTS) (version 24.8.7.41 (official build)). Stack trace:

So I'm at a loss trying to figure out why this test is failing.

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.

3 participants