@c15t/cli 2.0.0-rc.5 → 2.0.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
- import type { Logger } from '../../../logger/dist-types/index.d.ts';
2
- import { PostHog } from 'posthog-node';
1
+ import { type DrainContext } from 'evlog';
2
+ import { type DrainPipelineOptions } from 'evlog/pipeline';
3
+ import type { CliLogger } from './logger';
3
4
  export declare const TelemetryEventName: {
4
5
  readonly CLI_INVOKED: "cli.invoked";
5
6
  readonly CLI_COMPLETED: "cli.completed";
@@ -17,6 +18,7 @@ export declare const TelemetryEventName: {
17
18
  readonly HELP_DISPLAYED: "help.displayed";
18
19
  readonly VERSION_DISPLAYED: "version.displayed";
19
20
  readonly ONBOARDING_STARTED: "onboarding.started";
21
+ readonly ONBOARDING_STAGE: "onboarding.stage";
20
22
  readonly ONBOARDING_COMPLETED: "onboarding.completed";
21
23
  readonly ONBOARDING_EXITED: "onboarding.exited";
22
24
  readonly ONBOARDING_STORAGE_MODE_SELECTED: "onboarding.storage_mode_selected";
@@ -27,6 +29,13 @@ export declare const TelemetryEventName: {
27
29
  readonly ONBOARDING_DEPENDENCIES_CHOICE: "onboarding.dependencies_choice";
28
30
  readonly ONBOARDING_DEPENDENCIES_INSTALLED: "onboarding.dependencies_installed";
29
31
  readonly ONBOARDING_GITHUB_STAR: "onboarding.github_star";
32
+ readonly AUTH_LOGIN_STARTED: "auth.login.started";
33
+ readonly AUTH_LOGIN_SUCCEEDED: "auth.login.succeeded";
34
+ readonly AUTH_LOGIN_FAILED: "auth.login.failed";
35
+ readonly AUTH_LOGOUT: "auth.logout";
36
+ readonly PROJECTS_LISTED: "projects.listed";
37
+ readonly PROJECT_SELECTED: "project.selected";
38
+ readonly PROJECT_CREATED: "project.created";
30
39
  readonly ERROR_OCCURRED: "error.occurred";
31
40
  readonly MIGRATION_STARTED: "migration.started";
32
41
  readonly MIGRATION_PLANNED: "migration.planned";
@@ -45,133 +54,68 @@ export declare const TelemetryEventName: {
45
54
  readonly CLI_STATE_COMPLETE: "cli.state.complete";
46
55
  };
47
56
  export type TelemetryEventName = (typeof TelemetryEventName)[keyof typeof TelemetryEventName];
57
+ type EventLike = Record<string, unknown>;
48
58
  export interface TelemetryOptions {
49
- /**
50
- * Custom PostHog instance to use instead of the default
51
- */
52
- client?: PostHog;
53
- /**
54
- * Whether telemetry should be disabled
55
- */
56
59
  disabled?: boolean;
57
- /**
58
- * Whether telemetry debugging should be enabled
59
- */
60
60
  debug?: boolean;
61
- /**
62
- * Default properties to add to all telemetry events
63
- */
64
- defaultProperties?: Record<string, string | number | boolean>;
65
- /**
66
- * Logger instance to use for logging telemetry events
67
- */
68
- logger?: Logger;
61
+ defaultProperties?: EventLike;
62
+ logger?: CliLogger;
63
+ endpoint?: string;
64
+ headers?: Record<string, string>;
65
+ fetch?: typeof fetch;
66
+ storageDir?: string;
67
+ drainOptions?: DrainPipelineOptions<DrainContext>;
69
68
  }
70
- /**
71
- * Manages telemetry for the CLI
72
- *
73
- * The Telemetry class provides methods to track CLI usage and errors
74
- * in a privacy-preserving way.
75
- */
76
69
  export declare class Telemetry {
77
- private client;
70
+ private readonly endpoint;
71
+ private readonly fetchImpl;
72
+ private readonly queuePath;
73
+ private readonly statePath;
74
+ private readonly headers;
75
+ private readonly defaultProperties;
76
+ private readonly sessionId;
77
+ private readonly installId;
78
+ private readonly isFirstRun;
79
+ private readonly drain;
80
+ private readonly storageDir;
81
+ private logger;
78
82
  private disabled;
79
- private defaultProperties;
80
- private distinctId;
81
- private apiKey;
82
83
  private debug;
83
- private logger;
84
- /**
85
- * Creates a new telemetry instance
86
- *
87
- * @param options - Configuration options for telemetry
88
- */
84
+ private sequence;
85
+ private activeCommandName?;
86
+ private activeCommandRunId?;
87
+ private flushPromise;
88
+ private queueReplayPromise;
89
+ private queueWritePromise;
89
90
  constructor(options?: TelemetryOptions);
90
- /**
91
- * Track a telemetry event
92
- *
93
- * @param eventName - The event name to track
94
- * @param properties - Properties to include with the event
95
- */
96
- trackEvent(eventName: TelemetryEventName, properties?: Record<string, string | number | boolean | undefined>): void;
97
- /**
98
- * Track a telemetry event synchronously
99
- *
100
- * This method ensures the event is sent before returning
101
- *
102
- * @param eventName - The event name to track
103
- * @param properties - Properties to include with the event
104
- */
105
- trackEventSync(eventName: TelemetryEventName, properties?: Record<string, string | number | boolean | undefined>): void;
106
- /**
107
- * Track a command execution
108
- *
109
- * @param command - The command being executed
110
- * @param args - Command arguments
111
- * @param flags - Command flags
112
- */
91
+ trackEvent(eventName: TelemetryEventName | string, properties?: EventLike): void;
113
92
  trackCommand(command: string, args?: string[], flags?: Record<string, string | number | boolean | undefined>): void;
114
- /**
115
- * Track CLI errors
116
- *
117
- * @param error - The error that occurred
118
- * @param command - The command that was being executed when the error occurred
119
- */
120
93
  trackError(error: Error, command?: string): void;
121
- /**
122
- * Disable telemetry
123
- */
94
+ flushSync(): void;
95
+ shutdown(): Promise<void>;
96
+ isDisabled(): boolean;
124
97
  disable(): void;
125
- /**
126
- * Enable telemetry
127
- */
128
98
  enable(): void;
129
- /**
130
- * Check if telemetry is disabled
131
- *
132
- * @returns Whether telemetry is disabled
133
- */
134
- isDisabled(): boolean;
135
- /**
136
- * Shutdown telemetry client
137
- */
138
- shutdown(): Promise<void>;
139
- /**
140
- * Set the logger instance to use for logging
141
- *
142
- * @param logger - The logger instance to use
143
- */
144
- setLogger(logger: Logger): void;
145
- /**
146
- * Log a debug message using the configured logger or console.debug as fallback
147
- *
148
- * @param message - The message to log
149
- * @param args - Additional arguments to log
150
- */
99
+ setLogger(logger: CliLogger): void;
100
+ private applyLoggerConfig;
101
+ private buildBaseContext;
102
+ private buildHeaders;
103
+ private flushAll;
104
+ private sendBatch;
105
+ private persistDroppedEvents;
106
+ private flushQueuedEvents;
107
+ private readQueuedEvents;
108
+ private writeQueuedEvents;
109
+ private loadOrCreateInstallIdentity;
110
+ private buildErrorMetadata;
111
+ private sanitizeError;
112
+ private sanitizeProperties;
113
+ private sanitizeValue;
114
+ private sanitizePrimitive;
115
+ private getEnvironmentName;
116
+ private isCi;
117
+ private readString;
151
118
  private logDebug;
152
- /**
153
- * Initialize the PostHog client
154
- *
155
- * @param customClient - Optional custom PostHog client
156
- */
157
- private initClient;
158
- /**
159
- * Generate an anonymous ID based on machine info
160
- *
161
- * @returns A hash that uniquely identifies the machine without PII
162
- */
163
- private generateAnonymousId;
164
- /**
165
- * Force immediate flushing of any pending telemetry events
166
- *
167
- * This is useful when you need to ensure events are sent before process exit
168
- */
169
- flushSync(): void;
170
119
  }
171
- /**
172
- * Creates a telemetry instance with sensible defaults
173
- *
174
- * @param options - Configuration options for telemetry
175
- * @returns A configured telemetry instance
176
- */
177
120
  export declare function createTelemetry(options?: TelemetryOptions): Telemetry;
121
+ export {};
@@ -26,7 +26,7 @@ export declare function hasDynamicSegment(value: string): boolean;
26
26
  */
27
27
  export declare function extractDynamicSegment(value: string): string | null;
28
28
  /**
29
- * Validate an instance name
29
+ * Validate a hosted project slug
30
30
  */
31
31
  export declare function isValidInstanceName(value: string): boolean;
32
32
  /**
@@ -54,7 +54,7 @@ export declare const validateUrl: (value: string) => string | undefined;
54
54
  */
55
55
  export declare const validateC15tUrl: (value: string) => string | undefined;
56
56
  /**
57
- * Instance name validator for prompts
57
+ * Project slug validator for prompts
58
58
  */
59
59
  export declare const validateInstanceName: (value: string) => string | undefined;
60
60
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c15t/cli",
3
- "version": "2.0.0-rc.5",
3
+ "version": "2.0.0-rc.8",
4
4
  "description": "CLI for rapid c15t setup. Scaffold React and Next.js cookie banners and a preferences centre, generate types and config, and run migration tooling for self-hosted deployments.",
5
5
  "homepage": "https://v2.c15t.com",
6
6
  "repository": {
@@ -22,9 +22,9 @@
22
22
  "dist-types"
23
23
  ],
24
24
  "scripts": {
25
- "build": "rslib build",
25
+ "build": "rslib build && bun ../../scripts/normalize-dist-types.mjs",
26
26
  "check-types": "tsc --noEmit",
27
- "dev": "rslib build",
27
+ "dev": "rslib build && bun ../../scripts/normalize-dist-types.mjs",
28
28
  "fmt": "bun biome format --write . && bun biome check --formatter-enabled=false --linter-enabled=false --write",
29
29
  "knip": "knip",
30
30
  "lint": "bun biome lint ./src",
@@ -33,21 +33,21 @@
33
33
  "test:watch": "vitest"
34
34
  },
35
35
  "dependencies": {
36
- "@c15t/backend": "2.0.0-rc.5",
37
- "@c15t/logger": "1.0.2-rc.0",
38
- "@clack/prompts": "0.11.0",
39
- "@modelcontextprotocol/sdk": "^1.0.0",
40
- "c12": "3.3.2",
41
- "dotenv": "17.2.3",
42
- "figlet": "1.9.4",
43
- "fs-extra": "11.3.2",
36
+ "@c15t/backend": "2.0.0-rc.8",
37
+ "@c15t/logger": "1.0.2-rc.1",
38
+ "@clack/prompts": "1.1.0",
39
+ "@modelcontextprotocol/sdk": "^1.29.0",
40
+ "c12": "3.3.3",
41
+ "dotenv": "17.3.1",
42
+ "evlog": "^2.11.1",
43
+ "figlet": "1.11.0",
44
+ "fs-extra": "11.3.4",
44
45
  "open": "11.0.0",
45
46
  "package-manager-detector": "1.6.0",
46
47
  "picocolors": "1.1.1",
47
- "posthog-node": "5.17.0",
48
48
  "ts-morph": "27.0.2",
49
- "xstate": "^5.26.0",
50
- "zod": "4.1.13"
49
+ "xstate": "^5.30.0",
50
+ "zod": "4.3.6"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@c15t/typescript-config": "0.0.1-beta.1",