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 LLM integration usage to organization reports #24757

Merged
merged 13 commits into from
Sep 17, 2024

Conversation

Lior539
Copy link
Contributor

@Lior539 Lior539 commented Sep 3, 2024

Problem

We want to know which companies are using our LLM integrations in PostHog. Currently, there's no way to do this

Changes

Add the following fields to the organization_usage_report

  • event_count_from_helicone_in_period
  • event_count_from_langfuse_in_period
  • event_count_from_keywords_ai_in_period
  • event_count_from_traceloop_in_period

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

No impact

How did you test this code?

Added tests + ran pytest posthog/tasks/test/test_usage_report.py

@Lior539 Lior539 requested a review from raquelmsmith September 6, 2024 09:39
@raquelmsmith
Copy link
Member

I'm really sorry but I'm nervous about this being 4 extra big queries across the events table. I will look tomorrow to see if I can do a rollup. If not I will merge this and hope it's okay.

@Lior539
Copy link
Contributor Author

Lior539 commented Sep 10, 2024

@raquelmsmith with the help of ChatGPT I managed to combine it into a single query. Let me know if this looks better!

Copy link
Member

@raquelmsmith raquelmsmith left a comment

Choose a reason for hiding this comment

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

Nice work with this! Thank you for taking it on 🙏 One suggestion for clarity, one question, and the type annotation should be fixed. but otherwise looks great 🙌

posthog/tasks/usage_report.py Outdated Show resolved Hide resolved
posthog/tasks/usage_report.py Outdated Show resolved Hide resolved
@raquelmsmith
Copy link
Member

@Lior539 can you fix the code quality check failures?

@Lior539
Copy link
Contributor Author

Lior539 commented Sep 12, 2024

@raquelmsmith fixed the code quality checks :)

@raquelmsmith raquelmsmith enabled auto-merge (squash) September 17, 2024 18:46
@raquelmsmith raquelmsmith merged commit a3ee2ea into master Sep 17, 2024
86 checks passed
@raquelmsmith raquelmsmith deleted the add-ai-logging branch September 17, 2024 19:00
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.

2 participants