@socketsecurity/cli-with-sentry 1.1.47 → 1.1.49

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 +1 @@
1
- {"version":3,"file":"cmd-npm.d.mts","sourceRoot":"","sources":["../../../../src/commands/npm/cmd-npm.mts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAI9C,eAAO,MAAM,QAAQ,OAAM,CAAA;AAM3B,eAAO,MAAM,MAAM;;;;CAIlB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAoEf"}
1
+ {"version":3,"file":"cmd-npm.d.mts","sourceRoot":"","sources":["../../../../src/commands/npm/cmd-npm.mts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAI9C,eAAO,MAAM,QAAQ,OAAM,CAAA;AAM3B,eAAO,MAAM,MAAM;;;;CAIlB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA6Ef"}
@@ -1 +1 @@
1
- {"version":3,"file":"cmd-npx.d.mts","sourceRoot":"","sources":["../../../../src/commands/npx/cmd-npx.mts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAU9C,eAAO,MAAM,MAAM;;;;CAIlB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAChC,OAAO,CAAC,IAAI,CAAC,CA4Df"}
1
+ {"version":3,"file":"cmd-npx.d.mts","sourceRoot":"","sources":["../../../../src/commands/npx/cmd-npx.mts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAU9C,eAAO,MAAM,MAAM;;;;CAIlB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAChC,OAAO,CAAC,IAAI,CAAC,CAoEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"cmd-pnpm.d.mts","sourceRoot":"","sources":["../../../../src/commands/pnpm/cmd-pnpm.mts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAI9C,eAAO,MAAM,QAAQ,QAAO,CAAA;AAM5B,eAAO,MAAM,OAAO;;;;CAInB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAwDf"}
1
+ {"version":3,"file":"cmd-pnpm.d.mts","sourceRoot":"","sources":["../../../../src/commands/pnpm/cmd-pnpm.mts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAI9C,eAAO,MAAM,QAAQ,QAAO,CAAA;AAM5B,eAAO,MAAM,OAAO;;;;CAInB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA4Ef"}
@@ -1 +1 @@
1
- {"version":3,"file":"cmd-yarn.d.mts","sourceRoot":"","sources":["../../../../src/commands/yarn/cmd-yarn.mts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAI9C,eAAO,MAAM,QAAQ,QAAO,CAAA;AAM5B,eAAO,MAAM,OAAO;;;;CAInB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAwDf"}
1
+ {"version":3,"file":"cmd-yarn.d.mts","sourceRoot":"","sources":["../../../../src/commands/yarn/cmd-yarn.mts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uCAAuC,CAAA;AAI9C,eAAO,MAAM,QAAQ,QAAO,CAAA;AAM5B,eAAO,MAAM,OAAO;;;;CAInB,CAAA;AAED,iBAAe,GAAG,CAChB,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,EAClC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA8Ef"}
@@ -2,11 +2,14 @@ import type { EcosystemString } from '@socketsecurity/registry';
2
2
  import type { components } from '@socketsecurity/sdk/types/api';
3
3
  export type PURL_Type = components['schemas']['SocketPURL_Type'];
4
4
  type ExpectNever<T extends never> = T;
5
- type MissingInEcosystemString = Exclude<PURL_Type, EcosystemString>;
5
+ // Temporarily commented out due to dependency version mismatch.
6
+ // SDK has "alpm" but registry's EcosystemString doesn't yet.
7
+ // type MissingInEcosystemString = Exclude<PURL_Type, EcosystemString>
6
8
  type ExtraInEcosystemString = Exclude<EcosystemString, PURL_Type>;
7
- export type _Check_EcosystemString_has_all_purl_types = ExpectNever<MissingInEcosystemString>;
9
+ // export type _Check_EcosystemString_has_all_purl_types =
10
+ // ExpectNever<MissingInEcosystemString>
8
11
  export type _Check_EcosystemString_has_no_extras = ExpectNever<ExtraInEcosystemString>;
9
- export declare const ALL_ECOSYSTEMS: readonly ["apk", "bitbucket", "cargo", "chrome", "cocoapods", "composer", "conan", "conda", "cran", "deb", "docker", "gem", "generic", "github", "golang", "hackage", "hex", "huggingface", "maven", "mlflow", "npm", "nuget", "oci", "pub", "pypi", "qpkg", "rpm", "swift", "swid", "unknown"];
12
+ export declare const ALL_ECOSYSTEMS: readonly ["alpm", "apk", "bitbucket", "cargo", "chrome", "cocoapods", "composer", "conan", "conda", "cran", "deb", "docker", "gem", "generic", "github", "golang", "hackage", "hex", "huggingface", "maven", "mlflow", "npm", "nuget", "oci", "pub", "pypi", "qpkg", "rpm", "swift", "swid", "unknown", "vscode"];
10
13
  type AllEcosystemsUnion = (typeof ALL_ECOSYSTEMS)[number];
11
14
  type MissingInAllEcosystems = Exclude<PURL_Type, AllEcosystemsUnion>;
12
15
  type ExtraInAllEcosystems = Exclude<AllEcosystemsUnion, PURL_Type>;
@@ -1 +1 @@
1
- {"version":3,"file":"ecosystem.d.mts","sourceRoot":"","sources":["../../../src/utils/ecosystem.mts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAE/D,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,iBAAiB,CAAC,CAAA;AAEhE,KAAK,WAAW,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,CAAA;AAErC,KAAK,wBAAwB,GAAG,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;AACnE,KAAK,sBAAsB,GAAG,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;AAEjE,MAAM,MAAM,yCAAyC,GACnD,WAAW,CAAC,wBAAwB,CAAC,CAAA;AACvC,MAAM,MAAM,o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C,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA;AAED,wBAAsB,QAAQ,CAC5B,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,GACpC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CA4E7B"}
1
+ {"version":3,"file":"sdk.d.mts","sourceRoot":"","sources":["../../../src/utils/sdk.mts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,SAAS,EAA8B,MAAM,qBAAqB,CAAA;AAW3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAO3C,4DAA4D;AAC5D,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAKzD;AAED,4DAA4D;AAC5D,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAKvD;AAKD,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAavD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAQ9C;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA;AAED,wBAAsB,QAAQ,CAC5B,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,GACpC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAmH7B"}
@@ -0,0 +1,146 @@
1
+ import type { TelemetryContext } from './types.mts';
2
+ /**
3
+ * Finalize telemetry and clean up resources (async version).
4
+ * This should be called before process.exit to ensure telemetry is sent and resources are cleaned up.
5
+ * Use this in async contexts like beforeExit handlers.
6
+ *
7
+ * @returns Promise that resolves when finalization completes.
8
+ */
9
+ export declare function finalizeTelemetry(): Promise<void>;
10
+ /**
11
+ * Finalize telemetry synchronously (best-effort).
12
+ * This triggers a flush without awaiting it.
13
+ * Use this in synchronous contexts like signal handlers where async operations are not possible.
14
+ *
15
+ * Note: This is best-effort only. Events may be lost if the process exits before flush completes.
16
+ * Prefer finalizeTelemetry() (async version) when possible.
17
+ */
18
+ export declare function finalizeTelemetrySync(): void;
19
+ /**
20
+ * Set up exit handlers for telemetry finalization.
21
+ * This registers handlers for both normal exits (beforeExit) and common fatal signals.
22
+ *
23
+ * Flushing strategy:
24
+ * - Batch-based: Auto-flush when queue reaches 10 events.
25
+ * - beforeExit: Async handler for clean shutdowns (when event loop empties).
26
+ * - Fatal signals (SIGINT, SIGTERM, SIGHUP): Best-effort sync flush.
27
+ * - Accepts that forced exits (SIGKILL, process.exit()) may lose final events.
28
+ *
29
+ * Call this once during CLI initialization to ensure telemetry is flushed on exit.
30
+ * Safe to call multiple times - only registers handlers once.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // In src/cli.mts
35
+ * setupTelemetryExitHandlers()
36
+ * ```
37
+ */
38
+ export declare function setupTelemetryExitHandlers(): void;
39
+ /**
40
+ * Track subprocess exit and finalize telemetry.
41
+ * This is a convenience function that tracks completion/error based on exit code
42
+ * and ensures telemetry is flushed before returning.
43
+ *
44
+ * Note: Only tracks subprocess-level events. CLI-level events (cli_complete, cli_error)
45
+ * are tracked by the main CLI entry point in src/cli.mts.
46
+ *
47
+ * @param command - Command name (e.g., 'npm', 'pip').
48
+ * @param startTime - Start timestamp from trackSubprocessStart.
49
+ * @param exitCode - Process exit code (null treated as error).
50
+ * @returns Promise that resolves when tracking and flush complete.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * await trackSubprocessExit(NPM, subprocessStartTime, code)
55
+ * ```
56
+ */
57
+ export declare function trackSubprocessExit(command: string, startTime: number, exitCode: number | null): Promise<void>;
58
+ /**
59
+ * Generic event tracking function.
60
+ * Tracks any telemetry event with optional error details and explicit flush.
61
+ *
62
+ * Events are automatically flushed via batch size or exit handlers.
63
+ * Use the flush option only when immediate submission is required.
64
+ *
65
+ * @param eventType Type of event to track.
66
+ * @param context Event context.
67
+ * @param metadata Event metadata.
68
+ * @param options Optional configuration.
69
+ * @returns Promise that resolves when tracking completes.
70
+ */
71
+ export declare function trackEvent(eventType: string, context: TelemetryContext, metadata?: Record<string, unknown>, options?: {
72
+ error?: Error | undefined;
73
+ flush?: boolean | undefined;
74
+ }): Promise<void>;
75
+ /**
76
+ * Track CLI initialization event.
77
+ * Should be called at the start of CLI execution.
78
+ *
79
+ * @param argv Command line arguments (process.argv).
80
+ * @returns Start timestamp for duration calculation.
81
+ */
82
+ export declare function trackCliStart(argv: string[]): Promise<number>;
83
+ /**
84
+ * Track a generic CLI event with optional metadata.
85
+ * Use this for tracking custom events during CLI execution.
86
+ *
87
+ * @param eventType Type of event to track.
88
+ * @param argv Command line arguments (process.argv).
89
+ * @param metadata Optional additional metadata to include with the event.
90
+ */
91
+ export declare function trackCliEvent(eventType: string, argv: string[], metadata?: Record<string, unknown> | undefined): Promise<void>;
92
+ /**
93
+ * Track CLI completion event.
94
+ * Should be called on successful CLI exit.
95
+ * Flushes immediately since this is typically the last event before process exit.
96
+ *
97
+ * @param argv
98
+ * @param startTime Start timestamp from trackCliStart.
99
+ * @param exitCode Process exit code (default: 0).
100
+ */
101
+ export declare function trackCliComplete(argv: string[], startTime: number, exitCode?: string | number | undefined | null): Promise<void>;
102
+ /**
103
+ * Track CLI error event.
104
+ * Should be called when CLI exits with an error.
105
+ * Flushes immediately since this is typically the last event before process exit.
106
+ *
107
+ * @param argv
108
+ * @param startTime Start timestamp from trackCliStart.
109
+ * @param error Error that occurred.
110
+ * @param exitCode Process exit code (default: 1).
111
+ */
112
+ export declare function trackCliError(argv: string[], startTime: number, error: unknown, exitCode?: number | string | undefined | null): Promise<void>;
113
+ /**
114
+ * Track subprocess/command start event.
115
+ *
116
+ * Use this when spawning external commands like npm, npx, coana, cdxgen, etc.
117
+ *
118
+ * @param command Command being executed (e.g., 'npm', 'npx', 'coana').
119
+ * @param metadata Optional additional metadata (e.g., cwd, purpose).
120
+ * @returns Start timestamp for duration calculation.
121
+ */
122
+ export declare function trackSubprocessStart(command: string, metadata?: Record<string, unknown> | undefined): Promise<number>;
123
+ /**
124
+ * Track subprocess/command completion event.
125
+ *
126
+ * Should be called when spawned command completes successfully.
127
+ *
128
+ * @param command Command that was executed.
129
+ * @param startTime Start timestamp from trackSubprocessStart.
130
+ * @param exitCode Process exit code.
131
+ * @param metadata Optional additional metadata (e.g., stdout length, stderr length).
132
+ */
133
+ export declare function trackSubprocessComplete(command: string, startTime: number, exitCode: number | null, metadata?: Record<string, unknown> | undefined): Promise<void>;
134
+ /**
135
+ * Track subprocess/command error event.
136
+ *
137
+ * Should be called when spawned command fails or throws error.
138
+ *
139
+ * @param command Command that was executed.
140
+ * @param startTime Start timestamp from trackSubprocessStart.
141
+ * @param error Error that occurred.
142
+ * @param exitCode Process exit code.
143
+ * @param metadata Optional additional metadata.
144
+ */
145
+ export declare function trackSubprocessError(command: string, startTime: number, error: unknown, exitCode?: number | null | undefined, metadata?: Record<string, unknown> | undefined): Promise<void>;
146
+ //# sourceMappingURL=integration.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.d.mts","sourceRoot":"","sources":["../../../../src/utils/telemetry/integration.mts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AASnD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMvD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAM5C;AAKD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAiCjD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAs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Q,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,IAAI,CAAC,CAgBf"}
@@ -0,0 +1,65 @@
1
+ import type { TelemetryEvent } from './types.mts';
2
+ /**
3
+ * Centralized telemetry service for Socket CLI.
4
+ * Telemetry is always scoped to an organization.
5
+ * Singleton pattern ensures only one instance exists per process.
6
+ *
7
+ * NOTE: Only one telemetry instance exists per process.
8
+ * If getTelemetryClient() is called with a different organization slug,
9
+ * it returns the existing instance for the original organization.
10
+ * Switching organizations mid-execution is not supported - the first
11
+ * organization to initialize telemetry will be used for the entire process.
12
+ *
13
+ * This is intended, since we can't switch an org during command execution.
14
+ */
15
+ export declare class TelemetryService {
16
+ private readonly orgSlug;
17
+ private config;
18
+ private eventQueue;
19
+ private isDestroyed;
20
+ /**
21
+ * Private constructor.
22
+ * Requires organization slug.
23
+ *
24
+ * @param orgSlug - Organization identifier.
25
+ */
26
+ private constructor();
27
+ /**
28
+ * Get the current telemetry instance if one exists.
29
+ * Does not create a new instance.
30
+ *
31
+ * @returns Current telemetry instance or null if none exists.
32
+ */
33
+ static getCurrentInstance(): TelemetryService | null;
34
+ /**
35
+ * Get telemetry client for an organization.
36
+ * Creates and initializes client if it doesn't exist.
37
+ * Returns existing instance if already initialized.
38
+ *
39
+ * @param orgSlug - Organization identifier (required).
40
+ * @returns Initialized telemetry service instance.
41
+ */
42
+ static getTelemetryClient(orgSlug: string): Promise<TelemetryService>;
43
+ /**
44
+ * Track a telemetry event.
45
+ * Adds event to queue for batching and eventual submission.
46
+ * Auto-flushes when batch size is reached.
47
+ *
48
+ * @param event - Telemetry event to track (session_id is optional and will be auto-set).
49
+ */
50
+ track(event: Omit<TelemetryEvent, 'session_id'>): void;
51
+ /**
52
+ * Flush all queued events to the API.
53
+ * Returns immediately if no events queued or telemetry disabled.
54
+ * Times out after configured flush_timeout to prevent blocking CLI exit.
55
+ */
56
+ flush(): Promise<void>;
57
+ private sendEvents;
58
+ /**
59
+ * Destroy the telemetry service for this organization.
60
+ * Flushes remaining events and clears all state.
61
+ * Idempotent - safe to call multiple times.
62
+ */
63
+ destroy(): Promise<void>;
64
+ }
65
+ //# sourceMappingURL=service.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.mts","sourceRoot":"","sources":["../../../../src/utils/telemetry/service.mts"],"names":[],"mappings":"AAiDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAmFjD;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,WAAW,CAAQ;IAE3B;;;;;OAKG;IACH,OAAO,eAKN;IAED;;;;;OAKG;IACH,MAAM,CAAC,kBAAkB,IAAI,gBAAgB,GAAG,IAAI,CAEnD;IAED;;;;;;;OAOG;IACH,OAAa,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2C1E;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,IAAI,CA8BrD;IAED;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAqD3B;YAQa,UAAU;IAiDxB;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAyD7B;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Telemetry types for Socket CLI.
3
+ * Defines the structure of telemetry events and related data.
4
+ */
5
+ /**
6
+ * Error details for telemetry events.
7
+ */
8
+ export interface TelemetryEventError {
9
+ /** Error class/type name. */
10
+ type: string;
11
+ /** Error message. */
12
+ message: string | undefined;
13
+ /** Stack trace (sanitized). */
14
+ stack?: string | undefined;
15
+ }
16
+ /**
17
+ * Telemetry Context.
18
+ *
19
+ * This represent how the cli was invoked and met.
20
+ */
21
+ export interface TelemetryContext {
22
+ version: string;
23
+ platform: string;
24
+ node_version: string;
25
+ arch: string;
26
+ argv: string[];
27
+ }
28
+ /**
29
+ * Telemetry event structure.
30
+ * All telemetry events must follow this schema.
31
+ */
32
+ export interface TelemetryEvent {
33
+ event_sender_created_at: string;
34
+ event_type: string;
35
+ context: TelemetryContext;
36
+ session_id?: string;
37
+ metadata?: Record<string, unknown>;
38
+ error?: TelemetryEventError | undefined;
39
+ }
40
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/utils/telemetry/types.mts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,qBAAqB;IACrB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB,EAAE,MAAM,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,gBAAgB,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,KAAK,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAA;CACxC"}