feat(telemetry): wire ktx PostHog project for live ingestion

This commit is contained in:
Andrey Avtomonov 2026-05-22 17:00:26 +02:00
parent 91772e5bce
commit 31bc96cc77
4 changed files with 18 additions and 8 deletions

View file

@ -84,5 +84,6 @@ emits the event; if it is sampled out, none do.
## Storage and retention
Telemetry is sent to the GTX PostHog project. Raw event data is retained for
90 days in PostHog. Aggregated counts may be retained indefinitely.
Telemetry is sent to the **ktx** PostHog project at
`https://us.i.posthog.com`. Raw event data is retained for 90 days in PostHog.
Aggregated counts may be retained indefinitely.

View file

@ -71,7 +71,7 @@ describe('telemetry emitter', () => {
expect(captures).toEqual([]);
});
it('does not send when config constants are blank', async () => {
it('sends to PostHog by default once config constants are populated', async () => {
await trackTelemetryEvent({
event: commandEvent(),
distinctId: 'install-1',
@ -80,7 +80,12 @@ describe('telemetry emitter', () => {
stderr: { write: () => {} },
});
expect(captures).toEqual([]);
expect(captures).toHaveLength(1);
expect(captures[0]).toMatchObject({
distinctId: 'install-1',
event: 'command',
groups: { project: 'project-1' },
});
});
it('group-identifies once per project when live config is supplied', async () => {

View file

@ -21,8 +21,9 @@ type PostHogClient = {
shutdown(): Promise<void> | void;
};
const POSTHOG_PROJECT_API_KEY = '';
const POSTHOG_HOST = '';
// PostHog public project ingestion key — safe to embed; capture-only, no read access.
const POSTHOG_PROJECT_API_KEY = 'phc_xbvZpbu8ZNLnogTbY7MEMWhCF2rzzApYsDndjKaRBXXx'; // pragma: allowlist secret
const POSTHOG_HOST = 'https://us.i.posthog.com';
const SHUTDOWN_TIMEOUT_MS = 1500;
let clientPromise: Promise<PostHogClient | null> | undefined;

View file

@ -10,8 +10,11 @@ from collections.abc import Mapping
from ktx_daemon.telemetry.events import build_telemetry_event
from ktx_daemon.telemetry.identity import load_telemetry_identity
POSTHOG_PROJECT_API_KEY = ""
POSTHOG_HOST = ""
# PostHog public project ingestion key - safe to embed; capture-only, no read access.
POSTHOG_PROJECT_API_KEY = (
"phc_xbvZpbu8ZNLnogTbY7MEMWhCF2rzzApYsDndjKaRBXXx" # pragma: allowlist secret
)
POSTHOG_HOST = "https://us.i.posthog.com"
def _host(env: Mapping[str, str]) -> str: