diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89efde5b..72f5f3ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,3 +36,5 @@ jobs: - name: Test run: npx turbo test + env: + DO_NOT_TRACK: '1' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 62d38e5f..0ffd271b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,6 +34,8 @@ jobs: - name: Test run: npx turbo test + env: + DO_NOT_TRACK: '1' deploy: name: Deploy to Fly.io diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a9371997..133f5f31 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -149,6 +149,8 @@ jobs: - name: Run tests run: npx turbo test + env: + DO_NOT_TRACK: '1' - name: Upload build artifacts uses: actions/upload-artifact@v4 diff --git a/packages/mcp/src/__tests__/telemetry.test.ts b/packages/mcp/src/__tests__/telemetry.test.ts index 19ef2375..4032ad84 100644 --- a/packages/mcp/src/__tests__/telemetry.test.ts +++ b/packages/mcp/src/__tests__/telemetry.test.ts @@ -3,6 +3,36 @@ import fs from 'node:fs'; import path from 'node:path'; const mockHomedir = vi.hoisted(() => '/mock/home'); +const posthogRequestMock = vi.hoisted(() => + vi.fn( + ( + _options: unknown, + callback?: (res: { resume: () => void; on: (event: string, listener: () => void) => void }) => void, + ) => { + const endListeners: Array<() => void> = []; + callback?.({ + resume: () => undefined, + on: (event: string, listener: () => void) => { + if (event === 'end') { + endListeners.push(listener); + } + }, + }); + + return { + on: vi.fn(), + setTimeout: vi.fn(), + destroy: vi.fn(), + write: vi.fn(), + end: vi.fn(() => { + for (const listener of endListeners) { + listener(); + } + }), + }; + }, + ), +); vi.mock('node:os', () => ({ default: { @@ -11,6 +41,16 @@ vi.mock('node:os', () => ({ })); vi.mock('node:fs'); +vi.mock('node:http', () => ({ + default: { + request: posthogRequestMock, + }, +})); +vi.mock('node:https', () => ({ + default: { + request: posthogRequestMock, + }, +})); import { createMcpTelemetry } from '../telemetry.js';