feat: add PostHog event tracking for SDK installs (ENG-2277)#141
Open
devin-ai-integration[bot] wants to merge 3 commits into
Open
feat: add PostHog event tracking for SDK installs (ENG-2277)#141devin-ai-integration[bot] wants to merge 3 commits into
devin-ai-integration[bot] wants to merge 3 commits into
Conversation
- Create lightweight PostHog client using httpx (no external dependencies) - Track 'Installed SDK' event once per new version via ~/.blaxel/telemetry.json - Inject __posthog_key__ at build time via sed in CI workflows - Fire-and-forget async capture, respects DO_NOT_TRACK and config.yaml - Anonymous UUID as distinct_id (generated via uuid.uuid4) Co-Authored-By: tcrochet <tcrochet@blaxel.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…ding Co-Authored-By: tcrochet <tcrochet@blaxel.ai>
Co-Authored-By: tcrochet <tcrochet@blaxel.ai>
Contributor
There was a problem hiding this comment.
LGTM
All three commits are clean. The TOCTOU fix and unknown-field preservation are both correctly implemented. No new issues.
Tag @mendral-app with feedback or questions. View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds lightweight PostHog event tracking to the Python SDK to fire an "Installed SDK" event once per new SDK version. Mirrors the existing Sentry pattern — no external PostHog library, uses
httpx(already a dependency) for a raw HTTP POST tohttps://us.i.posthog.com/capture/.How it works:
track_sdk_installed()is called duringautoload()(gated behindsettings.tracking)~/.blaxel/telemetry.json— only fires once per SDK version__posthog_key__placeholder in__init__.pyis injected at build time viasedin CI (same pattern as__sentry_dsn__)distinct_id, persisted intelemetry.jsonReview & Testing Checklist for Human
POSTHOG_KEYsecret in the repo'sreleaseenvironment before the next release — without it, tracking is silently disabled (no build failure)posthog.pydoesimport blaxelinside_get_posthog_key()which is called fromtrack_sdk_installed()duringautoload(), itself called fromblaxel.__init__. The lazy call timing should be safe (same pattern assettings.sentry_dsn), but worth a manualpython -c "import blaxel.core"checktelemetry.jsonconcurrent access is acceptable: no file lock is used when reading/writing the shared state file — concurrent CLI + SDK runs could race, but worst case is a duplicate event (matches existing CLI pattern)__posthog_key__in the built package is replaced with the actual key valueNotes
httpxis already a core dependency — no new packages addedtelemetry.jsonis shared between CLI and all SDKs (Python, TypeScript) — thesdks.pythonkey tracks the last reported Python SDK versionsettings.trackingdefaults toFalse), consistent with the existing Sentry behaviorLink to Devin session: https://app.devin.ai/sessions/43a6073c1fe54dbfb87b42e3dc01db56
Requested by: @Grotoma
Note
Adds lightweight PostHog "Installed SDK" event tracking to the Python SDK. Uses httpx for a raw HTTP POST (no new dependencies), deduplicates via
~/.blaxel/telemetry.json, fires on a daemon thread, and injects the API key at build time via sed — mirroring the existing Sentry pattern.Written by Mendral for commit 2cf9882.