vedatrace 0.1.9 → 0.2.0
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/README.md +25 -5
- package/dist/index.cjs +282 -81
- package/dist/index.d.cts +116 -52
- package/dist/index.d.mts +116 -52
- package/dist/index.mjs +279 -83
- package/dist/integrations/express.d.cts +1 -1
- package/dist/integrations/express.d.mts +1 -1
- package/dist/integrations/nextjs.d.cts +1 -1
- package/dist/integrations/nextjs.d.mts +1 -1
- package/dist/integrations/react.cjs +1 -2
- package/dist/integrations/react.d.cts +1 -1
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +1 -2
- package/dist/transports/index.cjs +26 -1
- package/dist/transports/index.d.cts +23 -6
- package/dist/transports/index.d.mts +23 -6
- package/dist/transports/index.mjs +26 -2
- package/dist/{types-DUNRMOTv.d.cts → types-BU0UESs9.d.cts} +20 -44
- package/dist/{types-DUNRMOTv.d.mts → types-BU0UESs9.d.mts} +20 -44
- package/package.json +2 -2
|
@@ -82,11 +82,13 @@ class VedaTraceHttpTransport {
|
|
|
82
82
|
apiKey;
|
|
83
83
|
timeout;
|
|
84
84
|
headers;
|
|
85
|
+
keepalive;
|
|
85
86
|
constructor(config) {
|
|
86
87
|
this.apiKey = config.apiKey;
|
|
87
88
|
this.endpoint = config.endpoint ?? "https://ingest.vedatrace.dev/v1/logs";
|
|
88
89
|
this.timeout = config.timeout ?? 3e4;
|
|
89
90
|
this.headers = config.headers ?? {};
|
|
91
|
+
this.keepalive = config.keepalive ?? false;
|
|
90
92
|
}
|
|
91
93
|
/** Send logs via HTTP POST */
|
|
92
94
|
async send(logs) {
|
|
@@ -108,7 +110,8 @@ class VedaTraceHttpTransport {
|
|
|
108
110
|
...this.headers
|
|
109
111
|
},
|
|
110
112
|
body: JSON.stringify(payload),
|
|
111
|
-
signal: controller.signal
|
|
113
|
+
signal: controller.signal,
|
|
114
|
+
keepalive: this.keepalive
|
|
112
115
|
});
|
|
113
116
|
clearTimeout(timeoutId);
|
|
114
117
|
if (!response.ok) {
|
|
@@ -126,7 +129,29 @@ class VedaTraceHttpTransport {
|
|
|
126
129
|
throw new Error(String(error));
|
|
127
130
|
}
|
|
128
131
|
}
|
|
132
|
+
/** Flush pending logs - called on page unload */
|
|
133
|
+
async flush() {
|
|
134
|
+
return Promise.resolve();
|
|
135
|
+
}
|
|
136
|
+
/** Check if keepalive is enabled */
|
|
137
|
+
isKeepaliveEnabled() {
|
|
138
|
+
return this.keepalive;
|
|
139
|
+
}
|
|
140
|
+
/** Enable/disable keepalive */
|
|
141
|
+
setKeepalive(enabled) {
|
|
142
|
+
this.keepalive = enabled;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
class VedaTraceHttpTransportBrowser extends VedaTraceHttpTransport {
|
|
146
|
+
constructor(config) {
|
|
147
|
+
super({ ...config, keepalive: true });
|
|
148
|
+
}
|
|
149
|
+
async flush() {
|
|
150
|
+
this.setKeepalive(true);
|
|
151
|
+
return super.flush();
|
|
152
|
+
}
|
|
129
153
|
}
|
|
130
154
|
|
|
131
155
|
exports.VedaTraceConsoleTransport = VedaTraceConsoleTransport;
|
|
132
156
|
exports.VedaTraceHttpTransport = VedaTraceHttpTransport;
|
|
157
|
+
exports.VedaTraceHttpTransportBrowser = VedaTraceHttpTransportBrowser;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as VedaTraceLevel, b as VedaTraceTransport, I as InternalLogEntry } from '../types-BU0UESs9.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Console transport for development/debugging
|
|
@@ -31,17 +31,20 @@ declare class VedaTraceConsoleTransport implements VedaTraceTransport {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* HTTP transport for sending logs to VedaTrace ingestion endpoint
|
|
34
|
+
*
|
|
35
|
+
* Features:
|
|
36
|
+
* - Timeout support with AbortController
|
|
37
|
+
* - Retry on network failure
|
|
38
|
+
* - Keepalive support for browser final flush
|
|
34
39
|
*/
|
|
35
40
|
|
|
36
41
|
interface HttpTransportConfig {
|
|
37
|
-
/** API key for authentication */
|
|
38
42
|
apiKey: string;
|
|
39
|
-
/** Ingestion endpoint URL */
|
|
40
43
|
endpoint?: string;
|
|
41
|
-
/** Request timeout in milliseconds */
|
|
42
44
|
timeout?: number;
|
|
43
|
-
/** Additional headers */
|
|
44
45
|
headers?: Record<string, string>;
|
|
46
|
+
/** Enable keepalive for browser final flush */
|
|
47
|
+
keepalive?: boolean;
|
|
45
48
|
}
|
|
46
49
|
declare class VedaTraceHttpTransport implements VedaTraceTransport {
|
|
47
50
|
readonly name = "http";
|
|
@@ -49,10 +52,24 @@ declare class VedaTraceHttpTransport implements VedaTraceTransport {
|
|
|
49
52
|
private apiKey;
|
|
50
53
|
private timeout;
|
|
51
54
|
private headers;
|
|
55
|
+
private keepalive;
|
|
52
56
|
constructor(config: HttpTransportConfig);
|
|
53
57
|
/** Send logs via HTTP POST */
|
|
54
58
|
send(logs: InternalLogEntry[]): Promise<void>;
|
|
59
|
+
/** Flush pending logs - called on page unload */
|
|
60
|
+
flush(): Promise<void>;
|
|
61
|
+
/** Check if keepalive is enabled */
|
|
62
|
+
isKeepaliveEnabled(): boolean;
|
|
63
|
+
/** Enable/disable keepalive */
|
|
64
|
+
setKeepalive(enabled: boolean): void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Browser-safe HTTP transport that uses keepalive for final flush
|
|
68
|
+
*/
|
|
69
|
+
declare class VedaTraceHttpTransportBrowser extends VedaTraceHttpTransport {
|
|
70
|
+
constructor(config: HttpTransportConfig);
|
|
71
|
+
flush(): Promise<void>;
|
|
55
72
|
}
|
|
56
73
|
|
|
57
|
-
export { VedaTraceConsoleTransport, VedaTraceHttpTransport };
|
|
74
|
+
export { VedaTraceConsoleTransport, VedaTraceHttpTransport, VedaTraceHttpTransportBrowser };
|
|
58
75
|
export type { ConsoleFormat, ConsoleTransportConfig, HttpTransportConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as VedaTraceLevel, b as VedaTraceTransport, I as InternalLogEntry } from '../types-BU0UESs9.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Console transport for development/debugging
|
|
@@ -31,17 +31,20 @@ declare class VedaTraceConsoleTransport implements VedaTraceTransport {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* HTTP transport for sending logs to VedaTrace ingestion endpoint
|
|
34
|
+
*
|
|
35
|
+
* Features:
|
|
36
|
+
* - Timeout support with AbortController
|
|
37
|
+
* - Retry on network failure
|
|
38
|
+
* - Keepalive support for browser final flush
|
|
34
39
|
*/
|
|
35
40
|
|
|
36
41
|
interface HttpTransportConfig {
|
|
37
|
-
/** API key for authentication */
|
|
38
42
|
apiKey: string;
|
|
39
|
-
/** Ingestion endpoint URL */
|
|
40
43
|
endpoint?: string;
|
|
41
|
-
/** Request timeout in milliseconds */
|
|
42
44
|
timeout?: number;
|
|
43
|
-
/** Additional headers */
|
|
44
45
|
headers?: Record<string, string>;
|
|
46
|
+
/** Enable keepalive for browser final flush */
|
|
47
|
+
keepalive?: boolean;
|
|
45
48
|
}
|
|
46
49
|
declare class VedaTraceHttpTransport implements VedaTraceTransport {
|
|
47
50
|
readonly name = "http";
|
|
@@ -49,10 +52,24 @@ declare class VedaTraceHttpTransport implements VedaTraceTransport {
|
|
|
49
52
|
private apiKey;
|
|
50
53
|
private timeout;
|
|
51
54
|
private headers;
|
|
55
|
+
private keepalive;
|
|
52
56
|
constructor(config: HttpTransportConfig);
|
|
53
57
|
/** Send logs via HTTP POST */
|
|
54
58
|
send(logs: InternalLogEntry[]): Promise<void>;
|
|
59
|
+
/** Flush pending logs - called on page unload */
|
|
60
|
+
flush(): Promise<void>;
|
|
61
|
+
/** Check if keepalive is enabled */
|
|
62
|
+
isKeepaliveEnabled(): boolean;
|
|
63
|
+
/** Enable/disable keepalive */
|
|
64
|
+
setKeepalive(enabled: boolean): void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Browser-safe HTTP transport that uses keepalive for final flush
|
|
68
|
+
*/
|
|
69
|
+
declare class VedaTraceHttpTransportBrowser extends VedaTraceHttpTransport {
|
|
70
|
+
constructor(config: HttpTransportConfig);
|
|
71
|
+
flush(): Promise<void>;
|
|
55
72
|
}
|
|
56
73
|
|
|
57
|
-
export { VedaTraceConsoleTransport, VedaTraceHttpTransport };
|
|
74
|
+
export { VedaTraceConsoleTransport, VedaTraceHttpTransport, VedaTraceHttpTransportBrowser };
|
|
58
75
|
export type { ConsoleFormat, ConsoleTransportConfig, HttpTransportConfig };
|
|
@@ -80,11 +80,13 @@ class VedaTraceHttpTransport {
|
|
|
80
80
|
apiKey;
|
|
81
81
|
timeout;
|
|
82
82
|
headers;
|
|
83
|
+
keepalive;
|
|
83
84
|
constructor(config) {
|
|
84
85
|
this.apiKey = config.apiKey;
|
|
85
86
|
this.endpoint = config.endpoint ?? "https://ingest.vedatrace.dev/v1/logs";
|
|
86
87
|
this.timeout = config.timeout ?? 3e4;
|
|
87
88
|
this.headers = config.headers ?? {};
|
|
89
|
+
this.keepalive = config.keepalive ?? false;
|
|
88
90
|
}
|
|
89
91
|
/** Send logs via HTTP POST */
|
|
90
92
|
async send(logs) {
|
|
@@ -106,7 +108,8 @@ class VedaTraceHttpTransport {
|
|
|
106
108
|
...this.headers
|
|
107
109
|
},
|
|
108
110
|
body: JSON.stringify(payload),
|
|
109
|
-
signal: controller.signal
|
|
111
|
+
signal: controller.signal,
|
|
112
|
+
keepalive: this.keepalive
|
|
110
113
|
});
|
|
111
114
|
clearTimeout(timeoutId);
|
|
112
115
|
if (!response.ok) {
|
|
@@ -124,6 +127,27 @@ class VedaTraceHttpTransport {
|
|
|
124
127
|
throw new Error(String(error));
|
|
125
128
|
}
|
|
126
129
|
}
|
|
130
|
+
/** Flush pending logs - called on page unload */
|
|
131
|
+
async flush() {
|
|
132
|
+
return Promise.resolve();
|
|
133
|
+
}
|
|
134
|
+
/** Check if keepalive is enabled */
|
|
135
|
+
isKeepaliveEnabled() {
|
|
136
|
+
return this.keepalive;
|
|
137
|
+
}
|
|
138
|
+
/** Enable/disable keepalive */
|
|
139
|
+
setKeepalive(enabled) {
|
|
140
|
+
this.keepalive = enabled;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
class VedaTraceHttpTransportBrowser extends VedaTraceHttpTransport {
|
|
144
|
+
constructor(config) {
|
|
145
|
+
super({ ...config, keepalive: true });
|
|
146
|
+
}
|
|
147
|
+
async flush() {
|
|
148
|
+
this.setKeepalive(true);
|
|
149
|
+
return super.flush();
|
|
150
|
+
}
|
|
127
151
|
}
|
|
128
152
|
|
|
129
|
-
export { VedaTraceConsoleTransport, VedaTraceHttpTransport };
|
|
153
|
+
export { VedaTraceConsoleTransport, VedaTraceHttpTransport, VedaTraceHttpTransportBrowser };
|
|
@@ -6,109 +6,79 @@
|
|
|
6
6
|
type VedaTraceLevel = "debug" | "info" | "warn" | "error" | "fatal";
|
|
7
7
|
/** Log entry structure matching ingestion API */
|
|
8
8
|
interface VedaTraceLog {
|
|
9
|
-
/** Log severity level */
|
|
10
9
|
level: VedaTraceLevel;
|
|
11
|
-
/** Log message */
|
|
12
10
|
message: string;
|
|
13
|
-
/** Service name (optional, can override default) */
|
|
14
11
|
service?: string;
|
|
15
|
-
/** Unix timestamp in milliseconds (optional, auto-generated if not provided) */
|
|
16
12
|
timestamp?: number;
|
|
17
|
-
/** Arbitrary metadata object */
|
|
18
13
|
metadata?: Record<string, unknown>;
|
|
19
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Generic Edge Context interface for Cloudflare Workers / Pages / etc.
|
|
17
|
+
* This avoids importing heavy framework-specific types and works with any
|
|
18
|
+
* environment that provides a waitUntil() method.
|
|
19
|
+
*/
|
|
20
|
+
interface VedaTraceEdgeContext {
|
|
21
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
22
|
+
}
|
|
20
23
|
/** Configuration options for VedaTrace SDK */
|
|
21
24
|
interface VedaTraceConfig {
|
|
22
|
-
/** API key for authentication */
|
|
23
25
|
apiKey?: string;
|
|
24
|
-
/** Default service name for all logs */
|
|
25
26
|
service?: string;
|
|
26
|
-
/** Ingestion endpoint URL */
|
|
27
27
|
endpoint?: string;
|
|
28
|
-
/** Environment identifier */
|
|
29
28
|
environment?: "production" | "staging" | "development" | string;
|
|
30
|
-
/** Batch size before flushing (default: 100) */
|
|
31
29
|
batchSize?: number;
|
|
32
|
-
/** Flush interval in milliseconds (default: 5000) */
|
|
33
30
|
flushInterval?: number;
|
|
34
|
-
/** Maximum retry attempts for failed requests (default: 3) */
|
|
35
31
|
maxRetries?: number;
|
|
36
|
-
/** Delay between retries in milliseconds (default: 1000) */
|
|
37
32
|
retryDelay?: number;
|
|
38
|
-
/** Redaction configuration for PII */
|
|
39
33
|
redaction?: RedactionConfig;
|
|
40
|
-
/** Custom transports (defaults to HTTP if apiKey provided) */
|
|
41
34
|
transports?: VedaTraceTransport[];
|
|
42
|
-
/** Callback for transport errors */
|
|
43
35
|
onError?: (error: Error) => void;
|
|
44
|
-
/** Callback for successful sends */
|
|
45
36
|
onSuccess?: () => void;
|
|
46
|
-
/** Disable logging entirely */
|
|
47
37
|
disabled?: boolean;
|
|
48
|
-
/** Enable debug mode (verbose console output) */
|
|
49
38
|
debug?: boolean;
|
|
50
|
-
/** Flush immediately after each log (for console/dev mode) */
|
|
51
39
|
immediateFlush?: boolean;
|
|
52
|
-
/** Unref the flush timer (Node.js only, default: false) */
|
|
53
40
|
unrefTimer?: boolean;
|
|
54
|
-
/** Auto-start the flush timer (default: true, auto-disabled for edge runtimes) */
|
|
55
41
|
autoStart?: boolean;
|
|
56
|
-
/** Force a specific runtime (auto-detected by default) */
|
|
57
42
|
runtime?: RuntimeType;
|
|
43
|
+
/** Cloudflare Workers ExecutionContext - enables waitUntil support */
|
|
44
|
+
executionContext?: VedaTraceEdgeContext;
|
|
58
45
|
}
|
|
59
|
-
/** Redaction configuration */
|
|
60
46
|
interface RedactionConfig {
|
|
61
|
-
/** Field paths to redact (e.g., ['password', 'user.token']) */
|
|
62
47
|
paths?: string[];
|
|
63
|
-
/** Custom redaction mask (default: '[REDACTED]') */
|
|
64
48
|
mask?: string;
|
|
65
|
-
/** Enable automatic PII detection */
|
|
66
49
|
autoDetectPii?: boolean;
|
|
67
50
|
}
|
|
68
|
-
/** Runtime environment type */
|
|
69
51
|
type RuntimeType = "node" | "browser" | "cloudflare" | "deno" | "bun" | "edge";
|
|
70
|
-
/** Transport interface for sending logs */
|
|
71
52
|
interface VedaTraceTransport {
|
|
72
|
-
/** Transport name */
|
|
73
53
|
name: string;
|
|
74
|
-
/** Send logs to destination */
|
|
75
54
|
send(logs: InternalLogEntry[]): Promise<void> | void;
|
|
76
|
-
/** Flush any pending logs */
|
|
77
55
|
flush?(): Promise<void>;
|
|
78
56
|
}
|
|
79
|
-
/** Metadata that can be passed to log methods */
|
|
80
57
|
interface LogMetadata {
|
|
81
|
-
/** Override default service name */
|
|
82
58
|
service?: string;
|
|
83
|
-
/** Any other metadata fields */
|
|
84
59
|
[key: string]: unknown;
|
|
85
60
|
}
|
|
86
|
-
/** Internal log entry with SDK metadata */
|
|
87
61
|
interface InternalLogEntry extends VedaTraceLog {
|
|
88
|
-
/** SDK-generated fields */
|
|
89
62
|
_sdk?: {
|
|
90
|
-
/** Source of the log (node, browser, edge) */
|
|
91
63
|
source?: string;
|
|
92
|
-
/** SDK version */
|
|
93
64
|
version?: string;
|
|
94
|
-
/** Error stack trace if log is an error */
|
|
95
65
|
stackTrace?: string;
|
|
96
|
-
/** Browser info */
|
|
97
66
|
browser?: {
|
|
98
67
|
userAgent?: string;
|
|
99
68
|
url?: string;
|
|
100
69
|
};
|
|
101
70
|
};
|
|
102
71
|
}
|
|
103
|
-
/** Batcher configuration */
|
|
104
72
|
interface BatcherConfig {
|
|
105
73
|
batchSize: number;
|
|
106
74
|
flushInterval: number;
|
|
107
75
|
maxRetries: number;
|
|
108
76
|
retryDelay: number;
|
|
109
77
|
unrefTimer?: boolean;
|
|
78
|
+
executionContext?: VedaTraceEdgeContext;
|
|
79
|
+
onError?: (error: Error) => void;
|
|
80
|
+
onSuccess?: () => void;
|
|
110
81
|
}
|
|
111
|
-
/** Logger interface */
|
|
112
82
|
interface VedaTraceLoggerInterface {
|
|
113
83
|
debug(message: string, metadata?: LogMetadata): void;
|
|
114
84
|
info(message: string, metadata?: LogMetadata): void;
|
|
@@ -120,6 +90,12 @@ interface VedaTraceLoggerInterface {
|
|
|
120
90
|
stop(): void;
|
|
121
91
|
start(): void;
|
|
122
92
|
runtime: RuntimeType;
|
|
93
|
+
/** Attach execution context for waitUntil support (Cloudflare Workers) */
|
|
94
|
+
withContext(ctx: VedaTraceEdgeContext): this;
|
|
95
|
+
/** Check if context is attached */
|
|
96
|
+
hasContext(): boolean;
|
|
97
|
+
/** Get current execution context */
|
|
98
|
+
getContext(): VedaTraceEdgeContext | undefined;
|
|
123
99
|
}
|
|
124
100
|
|
|
125
|
-
export type { BatcherConfig as B, InternalLogEntry as I, LogMetadata as L, RuntimeType as R, VedaTraceLoggerInterface as V, VedaTraceConfig as a, VedaTraceTransport as b,
|
|
101
|
+
export type { BatcherConfig as B, InternalLogEntry as I, LogMetadata as L, RuntimeType as R, VedaTraceLoggerInterface as V, VedaTraceConfig as a, VedaTraceTransport as b, VedaTraceEdgeContext as c, RedactionConfig as d, VedaTraceLevel as e, VedaTraceLog as f };
|
|
@@ -6,109 +6,79 @@
|
|
|
6
6
|
type VedaTraceLevel = "debug" | "info" | "warn" | "error" | "fatal";
|
|
7
7
|
/** Log entry structure matching ingestion API */
|
|
8
8
|
interface VedaTraceLog {
|
|
9
|
-
/** Log severity level */
|
|
10
9
|
level: VedaTraceLevel;
|
|
11
|
-
/** Log message */
|
|
12
10
|
message: string;
|
|
13
|
-
/** Service name (optional, can override default) */
|
|
14
11
|
service?: string;
|
|
15
|
-
/** Unix timestamp in milliseconds (optional, auto-generated if not provided) */
|
|
16
12
|
timestamp?: number;
|
|
17
|
-
/** Arbitrary metadata object */
|
|
18
13
|
metadata?: Record<string, unknown>;
|
|
19
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Generic Edge Context interface for Cloudflare Workers / Pages / etc.
|
|
17
|
+
* This avoids importing heavy framework-specific types and works with any
|
|
18
|
+
* environment that provides a waitUntil() method.
|
|
19
|
+
*/
|
|
20
|
+
interface VedaTraceEdgeContext {
|
|
21
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
22
|
+
}
|
|
20
23
|
/** Configuration options for VedaTrace SDK */
|
|
21
24
|
interface VedaTraceConfig {
|
|
22
|
-
/** API key for authentication */
|
|
23
25
|
apiKey?: string;
|
|
24
|
-
/** Default service name for all logs */
|
|
25
26
|
service?: string;
|
|
26
|
-
/** Ingestion endpoint URL */
|
|
27
27
|
endpoint?: string;
|
|
28
|
-
/** Environment identifier */
|
|
29
28
|
environment?: "production" | "staging" | "development" | string;
|
|
30
|
-
/** Batch size before flushing (default: 100) */
|
|
31
29
|
batchSize?: number;
|
|
32
|
-
/** Flush interval in milliseconds (default: 5000) */
|
|
33
30
|
flushInterval?: number;
|
|
34
|
-
/** Maximum retry attempts for failed requests (default: 3) */
|
|
35
31
|
maxRetries?: number;
|
|
36
|
-
/** Delay between retries in milliseconds (default: 1000) */
|
|
37
32
|
retryDelay?: number;
|
|
38
|
-
/** Redaction configuration for PII */
|
|
39
33
|
redaction?: RedactionConfig;
|
|
40
|
-
/** Custom transports (defaults to HTTP if apiKey provided) */
|
|
41
34
|
transports?: VedaTraceTransport[];
|
|
42
|
-
/** Callback for transport errors */
|
|
43
35
|
onError?: (error: Error) => void;
|
|
44
|
-
/** Callback for successful sends */
|
|
45
36
|
onSuccess?: () => void;
|
|
46
|
-
/** Disable logging entirely */
|
|
47
37
|
disabled?: boolean;
|
|
48
|
-
/** Enable debug mode (verbose console output) */
|
|
49
38
|
debug?: boolean;
|
|
50
|
-
/** Flush immediately after each log (for console/dev mode) */
|
|
51
39
|
immediateFlush?: boolean;
|
|
52
|
-
/** Unref the flush timer (Node.js only, default: false) */
|
|
53
40
|
unrefTimer?: boolean;
|
|
54
|
-
/** Auto-start the flush timer (default: true, auto-disabled for edge runtimes) */
|
|
55
41
|
autoStart?: boolean;
|
|
56
|
-
/** Force a specific runtime (auto-detected by default) */
|
|
57
42
|
runtime?: RuntimeType;
|
|
43
|
+
/** Cloudflare Workers ExecutionContext - enables waitUntil support */
|
|
44
|
+
executionContext?: VedaTraceEdgeContext;
|
|
58
45
|
}
|
|
59
|
-
/** Redaction configuration */
|
|
60
46
|
interface RedactionConfig {
|
|
61
|
-
/** Field paths to redact (e.g., ['password', 'user.token']) */
|
|
62
47
|
paths?: string[];
|
|
63
|
-
/** Custom redaction mask (default: '[REDACTED]') */
|
|
64
48
|
mask?: string;
|
|
65
|
-
/** Enable automatic PII detection */
|
|
66
49
|
autoDetectPii?: boolean;
|
|
67
50
|
}
|
|
68
|
-
/** Runtime environment type */
|
|
69
51
|
type RuntimeType = "node" | "browser" | "cloudflare" | "deno" | "bun" | "edge";
|
|
70
|
-
/** Transport interface for sending logs */
|
|
71
52
|
interface VedaTraceTransport {
|
|
72
|
-
/** Transport name */
|
|
73
53
|
name: string;
|
|
74
|
-
/** Send logs to destination */
|
|
75
54
|
send(logs: InternalLogEntry[]): Promise<void> | void;
|
|
76
|
-
/** Flush any pending logs */
|
|
77
55
|
flush?(): Promise<void>;
|
|
78
56
|
}
|
|
79
|
-
/** Metadata that can be passed to log methods */
|
|
80
57
|
interface LogMetadata {
|
|
81
|
-
/** Override default service name */
|
|
82
58
|
service?: string;
|
|
83
|
-
/** Any other metadata fields */
|
|
84
59
|
[key: string]: unknown;
|
|
85
60
|
}
|
|
86
|
-
/** Internal log entry with SDK metadata */
|
|
87
61
|
interface InternalLogEntry extends VedaTraceLog {
|
|
88
|
-
/** SDK-generated fields */
|
|
89
62
|
_sdk?: {
|
|
90
|
-
/** Source of the log (node, browser, edge) */
|
|
91
63
|
source?: string;
|
|
92
|
-
/** SDK version */
|
|
93
64
|
version?: string;
|
|
94
|
-
/** Error stack trace if log is an error */
|
|
95
65
|
stackTrace?: string;
|
|
96
|
-
/** Browser info */
|
|
97
66
|
browser?: {
|
|
98
67
|
userAgent?: string;
|
|
99
68
|
url?: string;
|
|
100
69
|
};
|
|
101
70
|
};
|
|
102
71
|
}
|
|
103
|
-
/** Batcher configuration */
|
|
104
72
|
interface BatcherConfig {
|
|
105
73
|
batchSize: number;
|
|
106
74
|
flushInterval: number;
|
|
107
75
|
maxRetries: number;
|
|
108
76
|
retryDelay: number;
|
|
109
77
|
unrefTimer?: boolean;
|
|
78
|
+
executionContext?: VedaTraceEdgeContext;
|
|
79
|
+
onError?: (error: Error) => void;
|
|
80
|
+
onSuccess?: () => void;
|
|
110
81
|
}
|
|
111
|
-
/** Logger interface */
|
|
112
82
|
interface VedaTraceLoggerInterface {
|
|
113
83
|
debug(message: string, metadata?: LogMetadata): void;
|
|
114
84
|
info(message: string, metadata?: LogMetadata): void;
|
|
@@ -120,6 +90,12 @@ interface VedaTraceLoggerInterface {
|
|
|
120
90
|
stop(): void;
|
|
121
91
|
start(): void;
|
|
122
92
|
runtime: RuntimeType;
|
|
93
|
+
/** Attach execution context for waitUntil support (Cloudflare Workers) */
|
|
94
|
+
withContext(ctx: VedaTraceEdgeContext): this;
|
|
95
|
+
/** Check if context is attached */
|
|
96
|
+
hasContext(): boolean;
|
|
97
|
+
/** Get current execution context */
|
|
98
|
+
getContext(): VedaTraceEdgeContext | undefined;
|
|
123
99
|
}
|
|
124
100
|
|
|
125
|
-
export type { BatcherConfig as B, InternalLogEntry as I, LogMetadata as L, RuntimeType as R, VedaTraceLoggerInterface as V, VedaTraceConfig as a, VedaTraceTransport as b,
|
|
101
|
+
export type { BatcherConfig as B, InternalLogEntry as I, LogMetadata as L, RuntimeType as R, VedaTraceLoggerInterface as V, VedaTraceConfig as a, VedaTraceTransport as b, VedaTraceEdgeContext as c, RedactionConfig as d, VedaTraceLevel as e, VedaTraceLog as f };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vedatrace",
|
|
3
3
|
"description": "Universal JavaScript logging SDK for VedaTrace - type-safe, lightweight, and developer-friendly",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"setup": "rm -rf node_modules && npm i && git init && husky",
|
|
7
7
|
"prepublishOnly": "npm run build",
|
|
8
8
|
"build": "pkgroll --clean-dist",
|
|
9
9
|
"test": "vitest --run",
|
|
10
|
-
"lint": "
|
|
10
|
+
"lint": "bunx @biomejs/biome check --write",
|
|
11
11
|
"changeset": "changeset",
|
|
12
12
|
"version": "changeset version",
|
|
13
13
|
"release": "bun run build && changeset publish",
|