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

@ -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;