Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 51 lines 1.91 KB
Raw
1 import { describe, it } from '@effect/vitest';
2 import { deepStrictEqual } from '@effect/vitest/utils';
3 import { Config, ConfigProvider, Effect } from 'effect';
4 import { TELEMETRY_CONFIG } from 'src/config';
5 import * as constants from 'src/constants';
6
7 const read = (env: Record<string, string>) =>
8 Config.all(TELEMETRY_CONFIG).parse(ConfigProvider.fromEnvRecord(env));
9
10 describe('TELEMETRY_CONFIG', () => {
11 it.effect('[Given] an empty environment [Then] telemetry is on and targets PostHog', () =>
12 Effect.gen(function* () {
13 deepStrictEqual(yield* read({}), {
14 DISABLED: false,
15 POSTHOG_INGEST_URL: constants.COMPOSIO_POSTHOG_INGEST_URL,
16 POSTHOG_PROJECT_API_KEY: constants.COMPOSIO_POSTHOG_PROJECT_API_KEY,
17 });
18 })
19 );
20
21 it.effect.each([
22 { name: 'COMPOSIO_CLI_TELEMETRY_DISABLED', value: 'yes' },
23 { name: 'COMPOSIO_DISABLE_TELEMETRY', value: 'true' },
24 { name: 'TELEMETRY_DISABLED', value: '1' },
25 { name: 'CI', value: 'true' },
26 { name: 'NODE_ENV', value: 'test' },
27 ])(
28 '[Given] an opt-out, CI, or a test run ($name=$value) [Then] telemetry is disabled',
29 ({ name, value }) =>
30 Effect.gen(function* () {
31 deepStrictEqual((yield* read({ [name]: value })).DISABLED, true);
32 })
33 );
34
35 it.effect('[Given] CI off outside a test run [Then] telemetry stays on', () =>
36 Effect.gen(function* () {
37 deepStrictEqual((yield* read({ CI: 'false', NODE_ENV: 'development' })).DISABLED, false);
38 })
39 );
40
41 it.effect('[Given] a PostHog override [Then] it replaces the baked target', () =>
42 Effect.gen(function* () {
43 const actual = yield* read({
44 COMPOSIO_POSTHOG_INGEST_URL: 'https://posthog.example.test/i/v0/e/',
45 COMPOSIO_POSTHOG_PROJECT_API_KEY: ' phc_test ',
46 });
47 deepStrictEqual(actual.POSTHOG_INGEST_URL, 'https://posthog.example.test/i/v0/e/');
48 deepStrictEqual(actual.POSTHOG_PROJECT_API_KEY, 'phc_test');
49 })
50 );
51 });