@statly/observe 1.0.0 → 1.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 +142 -1
- package/dist/chunk-7AITSJLP.mjs +1422 -0
- package/dist/chunk-J5AHUFP2.mjs +135 -0
- package/dist/{chunk-UNDSALI5.mjs → chunk-SJ7C46AP.mjs} +190 -122
- package/dist/index.d.mts +80 -43
- package/dist/index.d.ts +80 -43
- package/dist/index.js +1883 -207
- package/dist/index.mjs +62 -1
- package/dist/integrations/express.js +259 -35
- package/dist/integrations/express.mjs +3 -1
- package/dist/integrations/fastify.js +271 -47
- package/dist/integrations/fastify.mjs +3 -1
- package/dist/integrations/nextjs.js +347 -104
- package/dist/integrations/nextjs.mjs +3 -1
- package/dist/logger/index.d.mts +671 -0
- package/dist/logger/index.d.ts +671 -0
- package/dist/logger/index.js +1483 -0
- package/dist/logger/index.mjs +56 -0
- package/dist/telemetry-CXHOTW3Y.mjs +8 -0
- package/package.json +7 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
export { expressErrorHandler, requestHandler } from './integrations/express.mjs';
|
|
2
2
|
export { captureNextJsError, withStatly, withStatlyGetServerSideProps, withStatlyGetStaticProps, withStatlyPagesApi, withStatlyServerAction } from './integrations/nextjs.mjs';
|
|
3
3
|
export { createRequestCapture, statlyFastifyPlugin, statlyPlugin } from './integrations/fastify.mjs';
|
|
4
|
+
export { AIFeatures, ConsoleDestination, ConsoleDestinationConfig, DEFAULT_LEVELS, Destination, EXTENDED_LEVELS, ErrorExplanation, FileDestination, FileDestinationConfig, FileRotationConfig, FixSuggestion, LOG_LEVELS, LevelSet, LogEntry, LogLevel, Logger, LoggerConfig, ObserveDestination, ObserveDestinationConfig, REDACTED, SCRUB_PATTERNS, SENSITIVE_KEYS, ScrubPattern, Scrubber, ScrubbingConfig, formatJson, formatJsonPretty, formatPretty, getConsoleMethod, getDefaultLogger, isSensitiveKey, audit as logAudit, debug as logDebug, error as logError, fatal as logFatal, info as logInfo, trace as logTrace, warn as logWarn, setDefaultLogger } from './logger/index.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Span module for Statly Observe SDK
|
|
8
|
+
* Handles distributed tracing spans
|
|
9
|
+
*/
|
|
10
|
+
declare enum SpanStatus {
|
|
11
|
+
OK = "ok",
|
|
12
|
+
ERROR = "error"
|
|
13
|
+
}
|
|
14
|
+
interface SpanContext {
|
|
15
|
+
traceId: string;
|
|
16
|
+
spanId: string;
|
|
17
|
+
parentId?: string | null;
|
|
18
|
+
}
|
|
19
|
+
interface SpanData {
|
|
20
|
+
name: string;
|
|
21
|
+
traceId: string;
|
|
22
|
+
spanId: string;
|
|
23
|
+
parentId?: string | null;
|
|
24
|
+
startTime: number;
|
|
25
|
+
endTime?: number;
|
|
26
|
+
durationMs?: number;
|
|
27
|
+
status: SpanStatus;
|
|
28
|
+
tags: Record<string, string>;
|
|
29
|
+
metadata: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
declare class Span {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly context: SpanContext;
|
|
34
|
+
readonly startTime: number;
|
|
35
|
+
private _endTime?;
|
|
36
|
+
private _durationMs?;
|
|
37
|
+
private _status;
|
|
38
|
+
private _tags;
|
|
39
|
+
private _metadata;
|
|
40
|
+
private _finished;
|
|
41
|
+
constructor(name: string, context: SpanContext, tags?: Record<string, string>);
|
|
42
|
+
/**
|
|
43
|
+
* Finish the span and calculate duration
|
|
44
|
+
*/
|
|
45
|
+
finish(endTime?: number): void;
|
|
46
|
+
setTag(key: string, value: string): this;
|
|
47
|
+
setMetadata(key: string, value: unknown): this;
|
|
48
|
+
setStatus(status: SpanStatus): this;
|
|
49
|
+
get status(): SpanStatus;
|
|
50
|
+
get tags(): Record<string, string>;
|
|
51
|
+
get durationMs(): number | undefined;
|
|
52
|
+
toDict(): SpanData;
|
|
53
|
+
}
|
|
4
54
|
|
|
5
55
|
/**
|
|
6
56
|
* Statly Observe SDK Types
|
|
@@ -79,9 +129,10 @@ interface DeviceInfo {
|
|
|
79
129
|
interface StatlyEvent {
|
|
80
130
|
message: string;
|
|
81
131
|
timestamp?: number;
|
|
82
|
-
level?: 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
|
132
|
+
level?: 'debug' | 'info' | 'warning' | 'error' | 'fatal' | 'span';
|
|
83
133
|
stack?: string;
|
|
84
134
|
exception?: Exception;
|
|
135
|
+
span?: SpanData;
|
|
85
136
|
environment?: string;
|
|
86
137
|
release?: string;
|
|
87
138
|
url?: string;
|
|
@@ -130,6 +181,18 @@ declare class StatlyClient {
|
|
|
130
181
|
* Capture a message
|
|
131
182
|
*/
|
|
132
183
|
captureMessage(message: string, level?: EventLevel): string;
|
|
184
|
+
/**
|
|
185
|
+
* Capture a completed span
|
|
186
|
+
*/
|
|
187
|
+
captureSpan(span: Span): string;
|
|
188
|
+
/**
|
|
189
|
+
* Start a new tracing span
|
|
190
|
+
*/
|
|
191
|
+
startSpan(name: string, tags?: Record<string, string>): Span;
|
|
192
|
+
/**
|
|
193
|
+
* Execute a function within a trace span
|
|
194
|
+
*/
|
|
195
|
+
trace<T>(name: string, operation: (span: Span) => Promise<T> | T, tags?: Record<string, string>): Promise<T>;
|
|
133
196
|
/**
|
|
134
197
|
* Internal method to capture an error
|
|
135
198
|
*/
|
|
@@ -181,47 +244,6 @@ declare class StatlyClient {
|
|
|
181
244
|
flush(): Promise<void>;
|
|
182
245
|
}
|
|
183
246
|
|
|
184
|
-
/**
|
|
185
|
-
* Statly Observe SDK
|
|
186
|
-
*
|
|
187
|
-
* Error tracking and monitoring for JavaScript applications.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* import { Statly } from '@statly/observe-sdk';
|
|
192
|
-
*
|
|
193
|
-
* Statly.init({
|
|
194
|
-
* dsn: 'https://sk_live_xxx@statly.live/your-org',
|
|
195
|
-
* release: '1.0.0',
|
|
196
|
-
* environment: 'production',
|
|
197
|
-
* });
|
|
198
|
-
*
|
|
199
|
-
* // Errors are captured automatically
|
|
200
|
-
*
|
|
201
|
-
* // Manual capture
|
|
202
|
-
* try {
|
|
203
|
-
* riskyOperation();
|
|
204
|
-
* } catch (error) {
|
|
205
|
-
* Statly.captureException(error);
|
|
206
|
-
* }
|
|
207
|
-
*
|
|
208
|
-
* // Capture a message
|
|
209
|
-
* Statly.captureMessage('Something happened', 'warning');
|
|
210
|
-
*
|
|
211
|
-
* // Set user context
|
|
212
|
-
* Statly.setUser({
|
|
213
|
-
* id: 'user-123',
|
|
214
|
-
* email: 'user@example.com',
|
|
215
|
-
* });
|
|
216
|
-
*
|
|
217
|
-
* // Add breadcrumb
|
|
218
|
-
* Statly.addBreadcrumb({
|
|
219
|
-
* category: 'auth',
|
|
220
|
-
* message: 'User logged in',
|
|
221
|
-
* });
|
|
222
|
-
* ```
|
|
223
|
-
*/
|
|
224
|
-
|
|
225
247
|
/**
|
|
226
248
|
* Initialize the Statly SDK
|
|
227
249
|
*
|
|
@@ -274,6 +296,18 @@ declare function close(): Promise<void>;
|
|
|
274
296
|
* Get the current client instance
|
|
275
297
|
*/
|
|
276
298
|
declare function getClient(): StatlyClient | null;
|
|
299
|
+
/**
|
|
300
|
+
* Execute a function within a trace span
|
|
301
|
+
*/
|
|
302
|
+
declare function trace<T>(name: string, operation: (span: Span) => Promise<T> | T, tags?: Record<string, string>): Promise<T>;
|
|
303
|
+
/**
|
|
304
|
+
* Start a new tracing span
|
|
305
|
+
*/
|
|
306
|
+
declare function startSpan(name: string, tags?: Record<string, string>): Span | null;
|
|
307
|
+
/**
|
|
308
|
+
* Capture a completed span
|
|
309
|
+
*/
|
|
310
|
+
declare function captureSpan(span: Span): string;
|
|
277
311
|
declare const Statly: {
|
|
278
312
|
readonly init: typeof init;
|
|
279
313
|
readonly captureException: typeof captureException;
|
|
@@ -285,6 +319,9 @@ declare const Statly: {
|
|
|
285
319
|
readonly flush: typeof flush;
|
|
286
320
|
readonly close: typeof close;
|
|
287
321
|
readonly getClient: typeof getClient;
|
|
322
|
+
readonly trace: typeof trace;
|
|
323
|
+
readonly startSpan: typeof startSpan;
|
|
324
|
+
readonly captureSpan: typeof captureSpan;
|
|
288
325
|
};
|
|
289
326
|
|
|
290
|
-
export { type Breadcrumb, type BrowserInfo, type DeviceInfo, type EventLevel, type Exception, type OSInfo, type StackFrame, Statly, StatlyClient, type StatlyEvent, type StatlyOptions, type User, addBreadcrumb, captureException, captureMessage, close, flush, getClient, init, setTag, setTags, setUser };
|
|
327
|
+
export { type Breadcrumb, type BrowserInfo, type DeviceInfo, type EventLevel, type Exception, type OSInfo, type StackFrame, Statly, StatlyClient, type StatlyEvent, type StatlyOptions, type User, addBreadcrumb, captureException, captureMessage, captureSpan, close, flush, getClient, init, setTag, setTags, setUser, startSpan, trace };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
export { expressErrorHandler, requestHandler } from './integrations/express.js';
|
|
2
2
|
export { captureNextJsError, withStatly, withStatlyGetServerSideProps, withStatlyGetStaticProps, withStatlyPagesApi, withStatlyServerAction } from './integrations/nextjs.js';
|
|
3
3
|
export { createRequestCapture, statlyFastifyPlugin, statlyPlugin } from './integrations/fastify.js';
|
|
4
|
+
export { AIFeatures, ConsoleDestination, ConsoleDestinationConfig, DEFAULT_LEVELS, Destination, EXTENDED_LEVELS, ErrorExplanation, FileDestination, FileDestinationConfig, FileRotationConfig, FixSuggestion, LOG_LEVELS, LevelSet, LogEntry, LogLevel, Logger, LoggerConfig, ObserveDestination, ObserveDestinationConfig, REDACTED, SCRUB_PATTERNS, SENSITIVE_KEYS, ScrubPattern, Scrubber, ScrubbingConfig, formatJson, formatJsonPretty, formatPretty, getConsoleMethod, getDefaultLogger, isSensitiveKey, audit as logAudit, debug as logDebug, error as logError, fatal as logFatal, info as logInfo, trace as logTrace, warn as logWarn, setDefaultLogger } from './logger/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Span module for Statly Observe SDK
|
|
8
|
+
* Handles distributed tracing spans
|
|
9
|
+
*/
|
|
10
|
+
declare enum SpanStatus {
|
|
11
|
+
OK = "ok",
|
|
12
|
+
ERROR = "error"
|
|
13
|
+
}
|
|
14
|
+
interface SpanContext {
|
|
15
|
+
traceId: string;
|
|
16
|
+
spanId: string;
|
|
17
|
+
parentId?: string | null;
|
|
18
|
+
}
|
|
19
|
+
interface SpanData {
|
|
20
|
+
name: string;
|
|
21
|
+
traceId: string;
|
|
22
|
+
spanId: string;
|
|
23
|
+
parentId?: string | null;
|
|
24
|
+
startTime: number;
|
|
25
|
+
endTime?: number;
|
|
26
|
+
durationMs?: number;
|
|
27
|
+
status: SpanStatus;
|
|
28
|
+
tags: Record<string, string>;
|
|
29
|
+
metadata: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
declare class Span {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly context: SpanContext;
|
|
34
|
+
readonly startTime: number;
|
|
35
|
+
private _endTime?;
|
|
36
|
+
private _durationMs?;
|
|
37
|
+
private _status;
|
|
38
|
+
private _tags;
|
|
39
|
+
private _metadata;
|
|
40
|
+
private _finished;
|
|
41
|
+
constructor(name: string, context: SpanContext, tags?: Record<string, string>);
|
|
42
|
+
/**
|
|
43
|
+
* Finish the span and calculate duration
|
|
44
|
+
*/
|
|
45
|
+
finish(endTime?: number): void;
|
|
46
|
+
setTag(key: string, value: string): this;
|
|
47
|
+
setMetadata(key: string, value: unknown): this;
|
|
48
|
+
setStatus(status: SpanStatus): this;
|
|
49
|
+
get status(): SpanStatus;
|
|
50
|
+
get tags(): Record<string, string>;
|
|
51
|
+
get durationMs(): number | undefined;
|
|
52
|
+
toDict(): SpanData;
|
|
53
|
+
}
|
|
4
54
|
|
|
5
55
|
/**
|
|
6
56
|
* Statly Observe SDK Types
|
|
@@ -79,9 +129,10 @@ interface DeviceInfo {
|
|
|
79
129
|
interface StatlyEvent {
|
|
80
130
|
message: string;
|
|
81
131
|
timestamp?: number;
|
|
82
|
-
level?: 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
|
132
|
+
level?: 'debug' | 'info' | 'warning' | 'error' | 'fatal' | 'span';
|
|
83
133
|
stack?: string;
|
|
84
134
|
exception?: Exception;
|
|
135
|
+
span?: SpanData;
|
|
85
136
|
environment?: string;
|
|
86
137
|
release?: string;
|
|
87
138
|
url?: string;
|
|
@@ -130,6 +181,18 @@ declare class StatlyClient {
|
|
|
130
181
|
* Capture a message
|
|
131
182
|
*/
|
|
132
183
|
captureMessage(message: string, level?: EventLevel): string;
|
|
184
|
+
/**
|
|
185
|
+
* Capture a completed span
|
|
186
|
+
*/
|
|
187
|
+
captureSpan(span: Span): string;
|
|
188
|
+
/**
|
|
189
|
+
* Start a new tracing span
|
|
190
|
+
*/
|
|
191
|
+
startSpan(name: string, tags?: Record<string, string>): Span;
|
|
192
|
+
/**
|
|
193
|
+
* Execute a function within a trace span
|
|
194
|
+
*/
|
|
195
|
+
trace<T>(name: string, operation: (span: Span) => Promise<T> | T, tags?: Record<string, string>): Promise<T>;
|
|
133
196
|
/**
|
|
134
197
|
* Internal method to capture an error
|
|
135
198
|
*/
|
|
@@ -181,47 +244,6 @@ declare class StatlyClient {
|
|
|
181
244
|
flush(): Promise<void>;
|
|
182
245
|
}
|
|
183
246
|
|
|
184
|
-
/**
|
|
185
|
-
* Statly Observe SDK
|
|
186
|
-
*
|
|
187
|
-
* Error tracking and monitoring for JavaScript applications.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* import { Statly } from '@statly/observe-sdk';
|
|
192
|
-
*
|
|
193
|
-
* Statly.init({
|
|
194
|
-
* dsn: 'https://sk_live_xxx@statly.live/your-org',
|
|
195
|
-
* release: '1.0.0',
|
|
196
|
-
* environment: 'production',
|
|
197
|
-
* });
|
|
198
|
-
*
|
|
199
|
-
* // Errors are captured automatically
|
|
200
|
-
*
|
|
201
|
-
* // Manual capture
|
|
202
|
-
* try {
|
|
203
|
-
* riskyOperation();
|
|
204
|
-
* } catch (error) {
|
|
205
|
-
* Statly.captureException(error);
|
|
206
|
-
* }
|
|
207
|
-
*
|
|
208
|
-
* // Capture a message
|
|
209
|
-
* Statly.captureMessage('Something happened', 'warning');
|
|
210
|
-
*
|
|
211
|
-
* // Set user context
|
|
212
|
-
* Statly.setUser({
|
|
213
|
-
* id: 'user-123',
|
|
214
|
-
* email: 'user@example.com',
|
|
215
|
-
* });
|
|
216
|
-
*
|
|
217
|
-
* // Add breadcrumb
|
|
218
|
-
* Statly.addBreadcrumb({
|
|
219
|
-
* category: 'auth',
|
|
220
|
-
* message: 'User logged in',
|
|
221
|
-
* });
|
|
222
|
-
* ```
|
|
223
|
-
*/
|
|
224
|
-
|
|
225
247
|
/**
|
|
226
248
|
* Initialize the Statly SDK
|
|
227
249
|
*
|
|
@@ -274,6 +296,18 @@ declare function close(): Promise<void>;
|
|
|
274
296
|
* Get the current client instance
|
|
275
297
|
*/
|
|
276
298
|
declare function getClient(): StatlyClient | null;
|
|
299
|
+
/**
|
|
300
|
+
* Execute a function within a trace span
|
|
301
|
+
*/
|
|
302
|
+
declare function trace<T>(name: string, operation: (span: Span) => Promise<T> | T, tags?: Record<string, string>): Promise<T>;
|
|
303
|
+
/**
|
|
304
|
+
* Start a new tracing span
|
|
305
|
+
*/
|
|
306
|
+
declare function startSpan(name: string, tags?: Record<string, string>): Span | null;
|
|
307
|
+
/**
|
|
308
|
+
* Capture a completed span
|
|
309
|
+
*/
|
|
310
|
+
declare function captureSpan(span: Span): string;
|
|
277
311
|
declare const Statly: {
|
|
278
312
|
readonly init: typeof init;
|
|
279
313
|
readonly captureException: typeof captureException;
|
|
@@ -285,6 +319,9 @@ declare const Statly: {
|
|
|
285
319
|
readonly flush: typeof flush;
|
|
286
320
|
readonly close: typeof close;
|
|
287
321
|
readonly getClient: typeof getClient;
|
|
322
|
+
readonly trace: typeof trace;
|
|
323
|
+
readonly startSpan: typeof startSpan;
|
|
324
|
+
readonly captureSpan: typeof captureSpan;
|
|
288
325
|
};
|
|
289
326
|
|
|
290
|
-
export { type Breadcrumb, type BrowserInfo, type DeviceInfo, type EventLevel, type Exception, type OSInfo, type StackFrame, Statly, StatlyClient, type StatlyEvent, type StatlyOptions, type User, addBreadcrumb, captureException, captureMessage, close, flush, getClient, init, setTag, setTags, setUser };
|
|
327
|
+
export { type Breadcrumb, type BrowserInfo, type DeviceInfo, type EventLevel, type Exception, type OSInfo, type StackFrame, Statly, StatlyClient, type StatlyEvent, type StatlyOptions, type User, addBreadcrumb, captureException, captureMessage, captureSpan, close, flush, getClient, init, setTag, setTags, setUser, startSpan, trace };
|