identity
identity
¶
Anonymous identity for external analytics.
One UUID v4 per install, persisted to disk on first use. The same file
is referenced by scripts/install/install.sh so install-time beacon
events tie back to the same person across the install→first-run funnel.
No email, no name, no hardware fingerprint — just an opaque UUID.
Classes¶
Functions¶
get_or_create_anon_id
¶
Return the persisted anon ID, generating one on first call.
Idempotent across processes — if the file already exists with a non-empty value, return it; otherwise generate a fresh UUID v4 and write atomically (rename-after-write so a crashed write leaves no half-file).
Source code in src/openjarvis/analytics/identity.py
reset_anon_id
¶
Delete the persisted ID and generate a fresh one (privacy reset).
is_analytics_enabled
¶
is_analytics_enabled(cfg: AnalyticsConfig) -> bool
Return True if analytics is enabled.
Disabled in three cases (any one is sufficient):
- Running under pytest. The PostHog SDK registers an
atexithook that synchronously joins its consumer thread; if the host is unreachable (CI runners can't reach the analytics endpoint), each queued batch retries fortimeout * max_retriesseconds and the interpreter never exits. Detect pytest viaPYTEST_CURRENT_TEST(set per test) and"pytest" in sys.modules(covers the collection phase before the first test runs). - An opt-out env var is set:
DO_NOT_TRACK=1(W3C convention) orOPENJARVIS_NO_ANALYTICS=1(project-specific). Both take precedence over the config so users can opt out without editing~/.openjarvis/config.toml. - The
[analytics] enabled = falseconfig-file setting.