56
vi.stubEnv('COMPOSIO_CLI_TELEMETRY_DISABLED', 'false');
57
vi.stubEnv('TELEMETRY_DISABLED', 'false');
58
vi.stubEnv('COMPOSIO_DISABLE_TELEMETRY', 'false');
59
+ // A configured project key is what gates delivery/worker spawning; enabled
60
+ // telemetry implies a target. The no-key path is covered explicitly below.
61
+ vi.stubEnv('COMPOSIO_POSTHOG_KEY', 'phc_test_key');
62
};
63
64
const decodeWorkerPayload = <A>(encodedPayload: string): A => {
228
.replace(/\//gu, '_')
229
.replace(/=+$/u, '');
230
enableTelemetry();
228
- // No COMPOSIO_POSTHOG_KEY override -> falls back to the empty embedded
229
- // placeholder, so delivery is a safe no-op until the real key is filled in.
231
+ // No project key -> the empty embedded placeholder, so the worker's delivery
232
+ // is a safe no-op until the real key is baked in.
233
+ vi.stubEnv('COMPOSIO_POSTHOG_KEY', '');
234
const fetchSpy = vi
235
.spyOn(globalThis, 'fetch')
236
.mockResolvedValue(new Response(null, { status: 200 }));
247
});
248
});
249
250
+ it.effect('does not spawn a worker when no project key is configured', () => {
251
+ const home = tempy.temporaryDirectory();
252
+ const scriptPath = `${home}/composio.ts`;
253
+ enableTelemetry();
254
+ // Empty key: forks / local builds without a baked key must not spawn a
255
+ // detached worker on every command just to have it no-op.
256
+ vi.stubEnv('COMPOSIO_POSTHOG_KEY', '');
257
+ process.argv[1] = scriptPath;
258
+
259
+ return Effect.gen(function* () {
260
+ const fs = yield* FileSystem.FileSystem;
261
+ yield* fs.writeFileString(scriptPath, '');
262
+ yield* trackCliEventEffect({ name: 'producer_event', properties: { sample: 'value' } });
263
+
264
+ expect(childProcessMocks.spawn).not.toHaveBeenCalled();
265
+ }).pipe(Effect.provide(makePlatformLayer(home)));
266
+ });
267
+
268
it.effect('spawns a detached analytics worker with a decodable envelope', () => {
269
const home = tempy.temporaryDirectory();
270
const scriptPath = `${home}/composio.ts`;