feat(telemetry): add anonymous opt-out PostHog telemetry#115
Merged
Conversation
0ac5c44 to
64f2736
Compare
Add lightweight, privacy-preserving usage telemetry to understand which engines, functions, and features are actually used. Zero new dependencies (stdlib urllib.request only). Fire-and-forget daemon threads ensure zero latency impact. - Create datafog/telemetry.py with PostHog /capture/ integration - Instrument detect, process, detect_pii, anonymize_text, scan_text, get_supported_entities, DataFog class, TextService, and CLI commands - Wire track_error() into exception handlers for error visibility - Opt-out via DATAFOG_NO_TELEMETRY=1 or DO_NOT_TRACK=1 - Anonymous ID via SHA-256 of machine info (no PII) - Text lengths bucketed, error messages never sent - Thread-local dedup prevents double-counting nested calls - Fix services/__init__.py to lazy-import ImageService and SparkService, so TextService works on minimal installs without aiohttp/PIL/pyspark - Fix pre-existing NameError in __init__.py detect() for RegexAnnotator - 44 tests covering opt-out, privacy, non-blocking, payloads, integration, error tracking, and edge cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
64f2736 to
68bc2e1
Compare
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
datafog/telemetry.py: Anonymous, opt-out usage telemetry via PostHog's/capture/API using only stdlib (urllib.request) — zero new dependenciesdetect(),process(),DataFogclass,TextService, core functions, and all 5 CLI commandstrack_error()into exception handlers acrosscore.py,main.py, andclient.pyservices/__init__.py: Bare imports of heavy deps now wrapped intry/exceptdetect()in__init__.pyreferencedRegexAnnotatorwithout calling lazy importTest plan
DATAFOG_NO_TELEMETRY=1disables all telemetry