@oconde/radar 0.0.0-stage → 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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/PROTOCOL.md +185 -0
- package/README.md +119 -2
- package/dist/bin/radar-sourcemaps.js +244 -0
- package/dist/browser/index.cjs +173 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +30 -0
- package/dist/browser/index.d.ts +30 -0
- package/dist/browser/index.js +152 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/client-CZHtsQAd.d.cts +130 -0
- package/dist/client-DbBsXgpj.d.ts +130 -0
- package/dist/index.cjs +1335 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1307 -0
- package/dist/index.js.map +1 -0
- package/dist/nest/index.cjs +1495 -0
- package/dist/nest/index.cjs.map +1 -0
- package/dist/nest/index.d.cts +41 -0
- package/dist/nest/index.d.ts +41 -0
- package/dist/nest/index.js +1470 -0
- package/dist/nest/index.js.map +1 -0
- package/dist/protocol/index.cjs +66 -0
- package/dist/protocol/index.cjs.map +1 -0
- package/dist/protocol/index.d.cts +136 -0
- package/dist/protocol/index.d.ts +136 -0
- package/dist/protocol/index.js +35 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/sveltekit/index.cjs +1840 -0
- package/dist/sveltekit/index.cjs.map +1 -0
- package/dist/sveltekit/index.d.cts +28 -0
- package/dist/sveltekit/index.d.ts +28 -0
- package/dist/sveltekit/index.js +1810 -0
- package/dist/sveltekit/index.js.map +1 -0
- package/package.json +142 -4
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { UserInfo, LogLevel, RequestInfo, RuntimeInfo, CheckInStatus, ExceptionInfo } from './protocol/index.js';
|
|
2
|
+
|
|
3
|
+
type HeaderValue = string | string[] | number | undefined;
|
|
4
|
+
type RequestLike = {
|
|
5
|
+
method?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
originalUrl?: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
route?: {
|
|
10
|
+
path?: unknown;
|
|
11
|
+
};
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
query?: unknown;
|
|
14
|
+
headers: Record<string, HeaderValue>;
|
|
15
|
+
body?: unknown;
|
|
16
|
+
ip?: string;
|
|
17
|
+
socket?: {
|
|
18
|
+
remoteAddress?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type ResponseLike = {
|
|
22
|
+
statusCode: number;
|
|
23
|
+
setHeader(name: string, value: string): unknown;
|
|
24
|
+
once(event: 'finish', listener: () => void): unknown;
|
|
25
|
+
};
|
|
26
|
+
type RadarContext = {
|
|
27
|
+
requestId: string;
|
|
28
|
+
startedAt: number;
|
|
29
|
+
req?: RequestLike;
|
|
30
|
+
route?: string;
|
|
31
|
+
user?: UserInfo;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type RadarMiddleware = (req: RequestLike, res: ResponseLike, next: (error?: unknown) => void) => void;
|
|
35
|
+
|
|
36
|
+
type RedactMode = 'mask' | 'none';
|
|
37
|
+
type RequestDetail = 'full' | 'route';
|
|
38
|
+
type RadarOptions = {
|
|
39
|
+
key?: string;
|
|
40
|
+
endpoint?: string;
|
|
41
|
+
environment?: string;
|
|
42
|
+
release?: string;
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
console?: boolean;
|
|
45
|
+
minLevel?: LogLevel;
|
|
46
|
+
redact?: RedactMode;
|
|
47
|
+
requestDetail?: RequestDetail;
|
|
48
|
+
logRequests?: boolean;
|
|
49
|
+
ignorePaths?: string[];
|
|
50
|
+
captureUnhandled?: boolean;
|
|
51
|
+
debug?: boolean;
|
|
52
|
+
};
|
|
53
|
+
type ResolvedOptions = {
|
|
54
|
+
key: string | undefined;
|
|
55
|
+
endpoint: string;
|
|
56
|
+
environment: string;
|
|
57
|
+
release: string | undefined;
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
console: boolean;
|
|
60
|
+
minLevel: LogLevel;
|
|
61
|
+
redact: RedactMode;
|
|
62
|
+
requestDetail: RequestDetail;
|
|
63
|
+
logRequests: boolean;
|
|
64
|
+
ignorePaths: string[];
|
|
65
|
+
captureUnhandled: boolean;
|
|
66
|
+
debug: boolean;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
type MapLocator = (file: string) => string | null;
|
|
70
|
+
type EnrichOptions = {
|
|
71
|
+
mapLocator?: MapLocator;
|
|
72
|
+
inferFunctionNames?: boolean;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type Attributes = Record<string, unknown>;
|
|
76
|
+
type LogRequestOptions = {
|
|
77
|
+
level?: LogLevel;
|
|
78
|
+
redact?: RedactMode;
|
|
79
|
+
};
|
|
80
|
+
type CheckInOptions = {
|
|
81
|
+
checkInId?: string;
|
|
82
|
+
durationMs?: number;
|
|
83
|
+
};
|
|
84
|
+
type CaptureExceptionOptions = {
|
|
85
|
+
handled?: boolean;
|
|
86
|
+
level?: 'error' | 'fatal';
|
|
87
|
+
request?: RequestInfo | null;
|
|
88
|
+
attrs?: Attributes;
|
|
89
|
+
runtime?: RuntimeInfo | null;
|
|
90
|
+
enrich?: EnrichOptions;
|
|
91
|
+
};
|
|
92
|
+
declare class RadarClient {
|
|
93
|
+
private options;
|
|
94
|
+
private transport;
|
|
95
|
+
private initialized;
|
|
96
|
+
private closed;
|
|
97
|
+
private readonly captured;
|
|
98
|
+
get isEnabled(): boolean;
|
|
99
|
+
get settings(): Readonly<ResolvedOptions>;
|
|
100
|
+
init(options?: RadarOptions): void;
|
|
101
|
+
debug(message: string, data?: Attributes): void;
|
|
102
|
+
info(message: string, data?: Attributes): void;
|
|
103
|
+
warn(message: string, data?: Attributes): void;
|
|
104
|
+
error(message: string, data?: Attributes): void;
|
|
105
|
+
logRequest(title: string, data?: Attributes, options?: LogRequestOptions): void;
|
|
106
|
+
captureError(error: unknown, data?: Attributes): void;
|
|
107
|
+
captureUnhandled(error: unknown, level: 'error' | 'fatal'): void;
|
|
108
|
+
setUser(user: UserInfo): void;
|
|
109
|
+
track<T>(name: string, fn: () => T | Promise<T>, data?: Attributes): Promise<T>;
|
|
110
|
+
withContext<T>(fn: () => T, options?: {
|
|
111
|
+
requestId?: string;
|
|
112
|
+
}): T;
|
|
113
|
+
checkIn(slug: string, status: CheckInStatus, options?: CheckInOptions): Promise<void>;
|
|
114
|
+
cron<T>(slug: string, fn: () => T | Promise<T>): Promise<T>;
|
|
115
|
+
middleware(): RadarMiddleware;
|
|
116
|
+
shouldLogRequest(req: RequestLike): boolean;
|
|
117
|
+
logHttpRequest(context: RadarContext, status: number): void;
|
|
118
|
+
flush(timeoutMs?: number): Promise<void>;
|
|
119
|
+
close(timeoutMs?: number): Promise<void>;
|
|
120
|
+
private emitLog;
|
|
121
|
+
captureException(exception: ExceptionInfo, options?: CaptureExceptionOptions): void;
|
|
122
|
+
private emitError;
|
|
123
|
+
private emitException;
|
|
124
|
+
private print;
|
|
125
|
+
private safely;
|
|
126
|
+
private debugWarn;
|
|
127
|
+
private writeWarning;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { type Attributes as A, type CaptureExceptionOptions as C, type EnrichOptions as E, type LogRequestOptions as L, type MapLocator as M, RadarClient as R, type CheckInOptions as a, type RadarMiddleware as b, type RadarOptions as c, type RedactMode as d, type RequestLike as e, type ResponseLike as f };
|