@glasstrace/sdk 0.2.0 → 0.2.3
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.
- package/dist/adapters/drizzle.cjs +729 -3
- package/dist/adapters/drizzle.cjs.map +1 -1
- package/dist/adapters/drizzle.js +6 -1
- package/dist/adapters/drizzle.js.map +1 -1
- package/dist/chunk-CUFIV225.js +14083 -0
- package/dist/chunk-CUFIV225.js.map +1 -0
- package/dist/chunk-DQ25VOKK.js +1250 -0
- package/dist/chunk-DQ25VOKK.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-WZXVS2EO.js +9 -0
- package/dist/chunk-WZXVS2EO.js.map +1 -0
- package/dist/cli/init.cjs +13863 -12
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +10 -9
- package/dist/cli/init.js.map +1 -1
- package/dist/esm-POMEQPKL.js +62 -0
- package/dist/esm-POMEQPKL.js.map +1 -0
- package/dist/getMachineId-bsd-TC3JSTY5.js +29 -0
- package/dist/getMachineId-bsd-TC3JSTY5.js.map +1 -0
- package/dist/getMachineId-darwin-2SUKQCE6.js +29 -0
- package/dist/getMachineId-darwin-2SUKQCE6.js.map +1 -0
- package/dist/getMachineId-linux-PNAFHLXH.js +23 -0
- package/dist/getMachineId-linux-PNAFHLXH.js.map +1 -0
- package/dist/getMachineId-unsupported-L2MNYW3W.js +14 -0
- package/dist/getMachineId-unsupported-L2MNYW3W.js.map +1 -0
- package/dist/getMachineId-win-D6D42WOQ.js +31 -0
- package/dist/getMachineId-win-D6D42WOQ.js.map +1 -0
- package/dist/index.cjs +18836 -815
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +131 -5
- package/dist/index.d.ts +131 -5
- package/dist/index.js +2758 -238
- package/dist/index.js.map +1 -1
- package/package.json +4 -10
- package/dist/chunk-BKMITIEZ.js +0 -169
- package/dist/chunk-BKMITIEZ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,127 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import * as z from './v4/classic/external.cjs';
|
|
2
|
+
import { ReadableSpan } from './export/ReadableSpan';
|
|
3
|
+
import { Span } from './Span';
|
|
4
|
+
import { SpanProcessor } from './SpanProcessor';
|
|
5
|
+
import { SpanExporter } from './export/SpanExporter';
|
|
6
|
+
import { ExportResult } from './ExportResult';
|
|
7
|
+
|
|
8
|
+
/** Anonymous API key: `gt_anon_` + 48 hex chars. */
|
|
9
|
+
declare const AnonApiKeySchema: z.core.$ZodBranded<z.ZodString, "AnonApiKey", "out">;
|
|
10
|
+
type AnonApiKey = z.infer<typeof AnonApiKeySchema>;
|
|
11
|
+
/** Session ID: 16 hex chars (deterministic, derived from API key + time window). */
|
|
12
|
+
declare const SessionIdSchema: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
|
|
13
|
+
type SessionId = z.infer<typeof SessionIdSchema>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* SDK-specific enums.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Diagnostic codes the SDK can report during health checks. */
|
|
20
|
+
declare const SdkDiagnosticCodeSchema: z.ZodEnum<{
|
|
21
|
+
ingestion_unreachable: "ingestion_unreachable";
|
|
22
|
+
ingestion_auth_failed: "ingestion_auth_failed";
|
|
23
|
+
ingestion_rate_limited: "ingestion_rate_limited";
|
|
24
|
+
config_sync_failed: "config_sync_failed";
|
|
25
|
+
source_map_upload_failed: "source_map_upload_failed";
|
|
26
|
+
}>;
|
|
27
|
+
type SdkDiagnosticCode = z.infer<typeof SdkDiagnosticCodeSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* SDK configuration types.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** SDK capture configuration: which events to capture. */
|
|
34
|
+
declare const CaptureConfigSchema: z.ZodObject<{
|
|
35
|
+
requestBodies: z.ZodBoolean;
|
|
36
|
+
queryParamValues: z.ZodBoolean;
|
|
37
|
+
envVarValues: z.ZodBoolean;
|
|
38
|
+
fullConsoleOutput: z.ZodBoolean;
|
|
39
|
+
importGraph: z.ZodBoolean;
|
|
40
|
+
consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
type CaptureConfig = z.infer<typeof CaptureConfigSchema>;
|
|
43
|
+
/** Developer-facing config for registerGlasstrace(). */
|
|
44
|
+
declare const GlasstraceOptionsSchema: z.ZodObject<{
|
|
45
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
46
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
47
|
+
forceEnable: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
verbose: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
type GlasstraceOptions = z.infer<typeof GlasstraceOptionsSchema>;
|
|
51
|
+
/** All recognized SDK environment variables. */
|
|
52
|
+
declare const GlasstraceEnvVarsSchema: z.ZodObject<{
|
|
53
|
+
GLASSTRACE_API_KEY: z.ZodOptional<z.ZodString>;
|
|
54
|
+
GLASSTRACE_FORCE_ENABLE: z.ZodOptional<z.ZodString>;
|
|
55
|
+
GLASSTRACE_ENV: z.ZodOptional<z.ZodString>;
|
|
56
|
+
GLASSTRACE_COVERAGE_MAP: z.ZodOptional<z.ZodString>;
|
|
57
|
+
NODE_ENV: z.ZodOptional<z.ZodString>;
|
|
58
|
+
VERCEL_ENV: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
type GlasstraceEnvVars = z.infer<typeof GlasstraceEnvVarsSchema>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Wire format types for SDK ↔ backend communication.
|
|
64
|
+
*
|
|
65
|
+
* These schemas define the request/response shapes for:
|
|
66
|
+
* - SDK initialization (POST /v1/sdk/init)
|
|
67
|
+
* - SDK health diagnostics (embedded in init requests)
|
|
68
|
+
* - Discovery endpoint (GET /__glasstrace/config)
|
|
69
|
+
* - Source map upload (POST /v1/source-maps)
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/** Test file import relationships, embedded in SDK init request. */
|
|
73
|
+
declare const ImportGraphPayloadSchema: z.ZodObject<{
|
|
74
|
+
buildHash: z.core.$ZodBranded<z.ZodString, "BuildHash", "out">;
|
|
75
|
+
graph: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
type ImportGraphPayload = z.infer<typeof ImportGraphPayloadSchema>;
|
|
78
|
+
/** SDK health diagnostics included in init requests. */
|
|
79
|
+
declare const SdkHealthReportSchema: z.ZodObject<{
|
|
80
|
+
tracesExportedSinceLastInit: z.ZodNumber;
|
|
81
|
+
tracesDropped: z.ZodNumber;
|
|
82
|
+
initFailures: z.ZodNumber;
|
|
83
|
+
configAge: z.ZodNumber;
|
|
84
|
+
sdkVersion: z.ZodString;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
type SdkHealthReport = z.infer<typeof SdkHealthReportSchema>;
|
|
87
|
+
/**
|
|
88
|
+
* Response from POST /v1/sdk/init.
|
|
89
|
+
*
|
|
90
|
+
* Note: SdkInitRequest is intentionally NOT in the protocol package.
|
|
91
|
+
* The request schema includes backend-specific types (TierLimits,
|
|
92
|
+
* SubscriptionStatus) that are not part of the public contract.
|
|
93
|
+
* The backend owns the request validation; the SDK only needs to
|
|
94
|
+
* understand the response.
|
|
95
|
+
*/
|
|
96
|
+
declare const SdkInitResponseSchema: z.ZodObject<{
|
|
97
|
+
config: z.ZodObject<{
|
|
98
|
+
requestBodies: z.ZodBoolean;
|
|
99
|
+
queryParamValues: z.ZodBoolean;
|
|
100
|
+
envVarValues: z.ZodBoolean;
|
|
101
|
+
fullConsoleOutput: z.ZodBoolean;
|
|
102
|
+
importGraph: z.ZodBoolean;
|
|
103
|
+
consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
subscriptionStatus: z.ZodString;
|
|
106
|
+
linkedAccountId: z.ZodOptional<z.ZodString>;
|
|
107
|
+
minimumSdkVersion: z.ZodString;
|
|
108
|
+
apiVersion: z.ZodString;
|
|
109
|
+
tierLimits: z.ZodObject<{
|
|
110
|
+
tracesPerMinute: z.ZodNumber;
|
|
111
|
+
storageTtlHours: z.ZodNumber;
|
|
112
|
+
maxTraceSizeBytes: z.ZodNumber;
|
|
113
|
+
maxConcurrentSessions: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
type SdkInitResponse = z.infer<typeof SdkInitResponseSchema>;
|
|
117
|
+
/** Response from POST /v1/source-maps. */
|
|
118
|
+
declare const SourceMapUploadResponseSchema: z.ZodObject<{
|
|
119
|
+
success: z.ZodLiteral<true>;
|
|
120
|
+
buildHash: z.core.$ZodBranded<z.ZodString, "BuildHash", "out">;
|
|
121
|
+
fileCount: z.ZodNumber;
|
|
122
|
+
totalSizeBytes: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
type SourceMapUploadResponse = z.infer<typeof SourceMapUploadResponseSchema>;
|
|
5
125
|
|
|
6
126
|
/**
|
|
7
127
|
* Internal SDK error class with a typed diagnostic code.
|
|
@@ -180,7 +300,7 @@ declare function getActiveConfig(): CaptureConfig;
|
|
|
180
300
|
declare class GlasstraceSpanProcessor implements SpanProcessor {
|
|
181
301
|
private readonly wrappedProcessor;
|
|
182
302
|
constructor(wrappedProcessor: SpanProcessor, _sessionManager?: SessionManager, _apiKey?: string | (() => string), _getConfig?: () => CaptureConfig, _environment?: string);
|
|
183
|
-
onStart(span: Span, parentContext:
|
|
303
|
+
onStart(span: Span, parentContext: Parameters<SpanProcessor["onStart"]>[1]): void;
|
|
184
304
|
onEnd(readableSpan: ReadableSpan): void;
|
|
185
305
|
shutdown(): Promise<void>;
|
|
186
306
|
forceFlush(): Promise<void>;
|
|
@@ -334,6 +454,12 @@ declare function computeBuildHash(maps?: SourceMapEntry[]): Promise<string>;
|
|
|
334
454
|
*/
|
|
335
455
|
declare function uploadSourceMaps(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[]): Promise<SourceMapUploadResponse>;
|
|
336
456
|
|
|
457
|
+
/**
|
|
458
|
+
* Manual error capture API.
|
|
459
|
+
*
|
|
460
|
+
* Provides a simple function for developers to manually record errors
|
|
461
|
+
* as span events, independent of the `consoleErrors` config flag.
|
|
462
|
+
*/
|
|
337
463
|
/**
|
|
338
464
|
* Records an error as a span event on the currently active OTel span.
|
|
339
465
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,127 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import * as z from './v4/classic/external.cjs';
|
|
2
|
+
import { ReadableSpan } from './export/ReadableSpan';
|
|
3
|
+
import { Span } from './Span';
|
|
4
|
+
import { SpanProcessor } from './SpanProcessor';
|
|
5
|
+
import { SpanExporter } from './export/SpanExporter';
|
|
6
|
+
import { ExportResult } from './ExportResult';
|
|
7
|
+
|
|
8
|
+
/** Anonymous API key: `gt_anon_` + 48 hex chars. */
|
|
9
|
+
declare const AnonApiKeySchema: z.core.$ZodBranded<z.ZodString, "AnonApiKey", "out">;
|
|
10
|
+
type AnonApiKey = z.infer<typeof AnonApiKeySchema>;
|
|
11
|
+
/** Session ID: 16 hex chars (deterministic, derived from API key + time window). */
|
|
12
|
+
declare const SessionIdSchema: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
|
|
13
|
+
type SessionId = z.infer<typeof SessionIdSchema>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* SDK-specific enums.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Diagnostic codes the SDK can report during health checks. */
|
|
20
|
+
declare const SdkDiagnosticCodeSchema: z.ZodEnum<{
|
|
21
|
+
ingestion_unreachable: "ingestion_unreachable";
|
|
22
|
+
ingestion_auth_failed: "ingestion_auth_failed";
|
|
23
|
+
ingestion_rate_limited: "ingestion_rate_limited";
|
|
24
|
+
config_sync_failed: "config_sync_failed";
|
|
25
|
+
source_map_upload_failed: "source_map_upload_failed";
|
|
26
|
+
}>;
|
|
27
|
+
type SdkDiagnosticCode = z.infer<typeof SdkDiagnosticCodeSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* SDK configuration types.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** SDK capture configuration: which events to capture. */
|
|
34
|
+
declare const CaptureConfigSchema: z.ZodObject<{
|
|
35
|
+
requestBodies: z.ZodBoolean;
|
|
36
|
+
queryParamValues: z.ZodBoolean;
|
|
37
|
+
envVarValues: z.ZodBoolean;
|
|
38
|
+
fullConsoleOutput: z.ZodBoolean;
|
|
39
|
+
importGraph: z.ZodBoolean;
|
|
40
|
+
consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
type CaptureConfig = z.infer<typeof CaptureConfigSchema>;
|
|
43
|
+
/** Developer-facing config for registerGlasstrace(). */
|
|
44
|
+
declare const GlasstraceOptionsSchema: z.ZodObject<{
|
|
45
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
46
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
47
|
+
forceEnable: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
verbose: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
type GlasstraceOptions = z.infer<typeof GlasstraceOptionsSchema>;
|
|
51
|
+
/** All recognized SDK environment variables. */
|
|
52
|
+
declare const GlasstraceEnvVarsSchema: z.ZodObject<{
|
|
53
|
+
GLASSTRACE_API_KEY: z.ZodOptional<z.ZodString>;
|
|
54
|
+
GLASSTRACE_FORCE_ENABLE: z.ZodOptional<z.ZodString>;
|
|
55
|
+
GLASSTRACE_ENV: z.ZodOptional<z.ZodString>;
|
|
56
|
+
GLASSTRACE_COVERAGE_MAP: z.ZodOptional<z.ZodString>;
|
|
57
|
+
NODE_ENV: z.ZodOptional<z.ZodString>;
|
|
58
|
+
VERCEL_ENV: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
type GlasstraceEnvVars = z.infer<typeof GlasstraceEnvVarsSchema>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Wire format types for SDK ↔ backend communication.
|
|
64
|
+
*
|
|
65
|
+
* These schemas define the request/response shapes for:
|
|
66
|
+
* - SDK initialization (POST /v1/sdk/init)
|
|
67
|
+
* - SDK health diagnostics (embedded in init requests)
|
|
68
|
+
* - Discovery endpoint (GET /__glasstrace/config)
|
|
69
|
+
* - Source map upload (POST /v1/source-maps)
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/** Test file import relationships, embedded in SDK init request. */
|
|
73
|
+
declare const ImportGraphPayloadSchema: z.ZodObject<{
|
|
74
|
+
buildHash: z.core.$ZodBranded<z.ZodString, "BuildHash", "out">;
|
|
75
|
+
graph: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
type ImportGraphPayload = z.infer<typeof ImportGraphPayloadSchema>;
|
|
78
|
+
/** SDK health diagnostics included in init requests. */
|
|
79
|
+
declare const SdkHealthReportSchema: z.ZodObject<{
|
|
80
|
+
tracesExportedSinceLastInit: z.ZodNumber;
|
|
81
|
+
tracesDropped: z.ZodNumber;
|
|
82
|
+
initFailures: z.ZodNumber;
|
|
83
|
+
configAge: z.ZodNumber;
|
|
84
|
+
sdkVersion: z.ZodString;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
type SdkHealthReport = z.infer<typeof SdkHealthReportSchema>;
|
|
87
|
+
/**
|
|
88
|
+
* Response from POST /v1/sdk/init.
|
|
89
|
+
*
|
|
90
|
+
* Note: SdkInitRequest is intentionally NOT in the protocol package.
|
|
91
|
+
* The request schema includes backend-specific types (TierLimits,
|
|
92
|
+
* SubscriptionStatus) that are not part of the public contract.
|
|
93
|
+
* The backend owns the request validation; the SDK only needs to
|
|
94
|
+
* understand the response.
|
|
95
|
+
*/
|
|
96
|
+
declare const SdkInitResponseSchema: z.ZodObject<{
|
|
97
|
+
config: z.ZodObject<{
|
|
98
|
+
requestBodies: z.ZodBoolean;
|
|
99
|
+
queryParamValues: z.ZodBoolean;
|
|
100
|
+
envVarValues: z.ZodBoolean;
|
|
101
|
+
fullConsoleOutput: z.ZodBoolean;
|
|
102
|
+
importGraph: z.ZodBoolean;
|
|
103
|
+
consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
subscriptionStatus: z.ZodString;
|
|
106
|
+
linkedAccountId: z.ZodOptional<z.ZodString>;
|
|
107
|
+
minimumSdkVersion: z.ZodString;
|
|
108
|
+
apiVersion: z.ZodString;
|
|
109
|
+
tierLimits: z.ZodObject<{
|
|
110
|
+
tracesPerMinute: z.ZodNumber;
|
|
111
|
+
storageTtlHours: z.ZodNumber;
|
|
112
|
+
maxTraceSizeBytes: z.ZodNumber;
|
|
113
|
+
maxConcurrentSessions: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
type SdkInitResponse = z.infer<typeof SdkInitResponseSchema>;
|
|
117
|
+
/** Response from POST /v1/source-maps. */
|
|
118
|
+
declare const SourceMapUploadResponseSchema: z.ZodObject<{
|
|
119
|
+
success: z.ZodLiteral<true>;
|
|
120
|
+
buildHash: z.core.$ZodBranded<z.ZodString, "BuildHash", "out">;
|
|
121
|
+
fileCount: z.ZodNumber;
|
|
122
|
+
totalSizeBytes: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
type SourceMapUploadResponse = z.infer<typeof SourceMapUploadResponseSchema>;
|
|
5
125
|
|
|
6
126
|
/**
|
|
7
127
|
* Internal SDK error class with a typed diagnostic code.
|
|
@@ -180,7 +300,7 @@ declare function getActiveConfig(): CaptureConfig;
|
|
|
180
300
|
declare class GlasstraceSpanProcessor implements SpanProcessor {
|
|
181
301
|
private readonly wrappedProcessor;
|
|
182
302
|
constructor(wrappedProcessor: SpanProcessor, _sessionManager?: SessionManager, _apiKey?: string | (() => string), _getConfig?: () => CaptureConfig, _environment?: string);
|
|
183
|
-
onStart(span: Span, parentContext:
|
|
303
|
+
onStart(span: Span, parentContext: Parameters<SpanProcessor["onStart"]>[1]): void;
|
|
184
304
|
onEnd(readableSpan: ReadableSpan): void;
|
|
185
305
|
shutdown(): Promise<void>;
|
|
186
306
|
forceFlush(): Promise<void>;
|
|
@@ -334,6 +454,12 @@ declare function computeBuildHash(maps?: SourceMapEntry[]): Promise<string>;
|
|
|
334
454
|
*/
|
|
335
455
|
declare function uploadSourceMaps(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[]): Promise<SourceMapUploadResponse>;
|
|
336
456
|
|
|
457
|
+
/**
|
|
458
|
+
* Manual error capture API.
|
|
459
|
+
*
|
|
460
|
+
* Provides a simple function for developers to manually record errors
|
|
461
|
+
* as span events, independent of the `consoleErrors` config flag.
|
|
462
|
+
*/
|
|
337
463
|
/**
|
|
338
464
|
* Records an error as a span event on the currently active OTel span.
|
|
339
465
|
*
|