@johnboxcodes/boxlogger 0.1.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 +23 -0
- package/LICENSE +21 -0
- package/README.md +248 -0
- package/dist/index.d.ts +607 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1147 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +180 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +389 -0
- package/dist/logger.js.map +1 -0
- package/dist/scope.d.ts +242 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +373 -0
- package/dist/scope.js.map +1 -0
- package/dist/stores/base.d.ts +127 -0
- package/dist/stores/base.d.ts.map +1 -0
- package/dist/stores/base.js +288 -0
- package/dist/stores/base.js.map +1 -0
- package/dist/stores/index.d.ts +12 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +12 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/stores/memory.d.ts +131 -0
- package/dist/stores/memory.d.ts.map +1 -0
- package/dist/stores/memory.js +284 -0
- package/dist/stores/memory.js.map +1 -0
- package/dist/stores/sqlite.d.ts +204 -0
- package/dist/stores/sqlite.d.ts.map +1 -0
- package/dist/stores/sqlite.js +608 -0
- package/dist/stores/sqlite.js.map +1 -0
- package/dist/types.d.ts +607 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/types.js.map +1 -0
- package/package.json +84 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NodeLogger - Backend Logger with Pluggable Storage
|
|
3
|
+
*
|
|
4
|
+
* A lightweight, Sentry-compatible logger with multiple storage backends.
|
|
5
|
+
* Implements the top 5 Sentry functions for Next.js production apps.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*
|
|
9
|
+
* @example Quick Start
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import * as Sentry from '@nodelogger/core';
|
|
12
|
+
*
|
|
13
|
+
* // Initialize with SQLite storage
|
|
14
|
+
* await Sentry.init('sqlite', { filename: './logs.db' });
|
|
15
|
+
*
|
|
16
|
+
* // 1. captureException - The Error Workhorse
|
|
17
|
+
* try {
|
|
18
|
+
* await riskyOperation();
|
|
19
|
+
* } catch (error) {
|
|
20
|
+
* Sentry.captureException(error, {
|
|
21
|
+
* tags: { section: 'payment', userId: '123' },
|
|
22
|
+
* extra: { endpoint: '/api/charge', amount: 99.99 },
|
|
23
|
+
* level: 'error',
|
|
24
|
+
* });
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* // 2. captureMessage - Custom Alerts
|
|
28
|
+
* Sentry.captureMessage('User reached payment limit', 'warning');
|
|
29
|
+
* Sentry.captureMessage('High-value transaction', {
|
|
30
|
+
* level: 'info',
|
|
31
|
+
* tags: { transactionType: 'purchase' },
|
|
32
|
+
* extra: { amount: 5000 },
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // 3. setUser - User Context
|
|
36
|
+
* Sentry.setUser({
|
|
37
|
+
* id: user.id,
|
|
38
|
+
* email: user.email,
|
|
39
|
+
* segment: user.subscriptionTier,
|
|
40
|
+
* ip_address: '{{auto}}',
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // 4. addBreadcrumb - Event Trail
|
|
44
|
+
* Sentry.addBreadcrumb({
|
|
45
|
+
* category: 'navigation',
|
|
46
|
+
* message: 'Navigated to checkout',
|
|
47
|
+
* level: 'info',
|
|
48
|
+
* data: { from: '/cart', to: '/checkout' },
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // 5. withScope - Isolated Context
|
|
52
|
+
* Sentry.withScope((scope) => {
|
|
53
|
+
* scope.setTag('transaction', 'payment');
|
|
54
|
+
* scope.setExtra('orderId', orderId);
|
|
55
|
+
* scope.setFingerprint(['payment', orderId]);
|
|
56
|
+
* Sentry.captureException(error);
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
import { Logger } from './logger.js';
|
|
61
|
+
import { Scope, getCurrentScope, getGlobalScope, getIsolationScope, configureScope, type SeverityLevel } from './scope.js';
|
|
62
|
+
import type { LogLevel, LogMetadata, LogEntry, Session, StoreStats, LogFilter, SessionFilter, UserInfo, Breadcrumb, CaptureContext, BeforeSendHook, BeforeSendMessageHook, SentryEvent, Transaction as TransactionInterface, TransactionContext, TransactionStatus, Measurement } from './types.js';
|
|
63
|
+
/**
|
|
64
|
+
* Provider type for quick initialization
|
|
65
|
+
*/
|
|
66
|
+
export type ProviderType = 'sqlite' | 'memory' | 'mongodb';
|
|
67
|
+
/**
|
|
68
|
+
* Initialization options
|
|
69
|
+
*/
|
|
70
|
+
export interface InitOptions {
|
|
71
|
+
/** SQLite database filename (for sqlite provider) */
|
|
72
|
+
filename?: string;
|
|
73
|
+
/** MongoDB connection URI (for mongodb provider) */
|
|
74
|
+
uri?: string;
|
|
75
|
+
/** Service/application name */
|
|
76
|
+
service?: string;
|
|
77
|
+
/** Environment (production, staging, development) */
|
|
78
|
+
environment?: string;
|
|
79
|
+
/** Release/version string */
|
|
80
|
+
release?: string;
|
|
81
|
+
/** Minimum log level */
|
|
82
|
+
minLevel?: LogLevel;
|
|
83
|
+
/** Enable session tracking */
|
|
84
|
+
enableSessions?: boolean;
|
|
85
|
+
/** Default metadata for all logs */
|
|
86
|
+
defaultMetadata?: LogMetadata;
|
|
87
|
+
/** Debug mode - logs SDK internals */
|
|
88
|
+
debug?: boolean;
|
|
89
|
+
/** Patterns to match error messages that should be ignored. Strings or RegExp. */
|
|
90
|
+
ignoreErrors?: (string | RegExp)[];
|
|
91
|
+
/** Sample rate for error events (0.0 to 1.0). Default 1.0 (100%). */
|
|
92
|
+
sampleRate?: number;
|
|
93
|
+
/** Sample rate for message events (0.0 to 1.0). Default 1.0 (100%). */
|
|
94
|
+
messagesSampleRate?: number;
|
|
95
|
+
/** Called before sending exception event. Return null to drop the event. */
|
|
96
|
+
beforeSend?: BeforeSendHook;
|
|
97
|
+
/** Called before sending message event. Return null to drop the event. */
|
|
98
|
+
beforeSendMessage?: BeforeSendMessageHook;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Initialize the global logger singleton
|
|
102
|
+
*
|
|
103
|
+
* @param provider - Storage provider type ('sqlite', 'memory', 'mongodb')
|
|
104
|
+
* @param options - Configuration options
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* // SQLite (persistent)
|
|
109
|
+
* await init('sqlite', { filename: './logs.db' });
|
|
110
|
+
*
|
|
111
|
+
* // Memory (development/testing)
|
|
112
|
+
* await init('memory');
|
|
113
|
+
*
|
|
114
|
+
* // MongoDB (future)
|
|
115
|
+
* await init('mongodb', { uri: 'mongodb://localhost/logs' });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function init(provider?: ProviderType, options?: InitOptions): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Create a new logger instance with its own store
|
|
121
|
+
*
|
|
122
|
+
* Factory function for creating isolated logger instances.
|
|
123
|
+
*
|
|
124
|
+
* @param provider - Storage provider type
|
|
125
|
+
* @param options - Configuration options
|
|
126
|
+
* @returns Logger instance
|
|
127
|
+
*/
|
|
128
|
+
export declare function create(provider?: ProviderType, options?: InitOptions): Promise<Logger>;
|
|
129
|
+
/**
|
|
130
|
+
* Close the global logger and release resources
|
|
131
|
+
*/
|
|
132
|
+
export declare function close(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Check if the global logger is initialized
|
|
135
|
+
*/
|
|
136
|
+
export declare function isInitialized(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Capture an exception (Sentry-compatible)
|
|
139
|
+
*
|
|
140
|
+
* This is the most used Sentry function. It captures errors with full stack
|
|
141
|
+
* traces and context information.
|
|
142
|
+
*
|
|
143
|
+
* @param error - Error object or error message string
|
|
144
|
+
* @param captureContext - Additional context (tags, extra, level, fingerprint)
|
|
145
|
+
* @returns Event ID (UUID)
|
|
146
|
+
*
|
|
147
|
+
* @example Basic usage
|
|
148
|
+
* ```typescript
|
|
149
|
+
* try {
|
|
150
|
+
* await riskyOperation();
|
|
151
|
+
* } catch (error) {
|
|
152
|
+
* Sentry.captureException(error);
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example With full context (production pattern)
|
|
157
|
+
* ```typescript
|
|
158
|
+
* try {
|
|
159
|
+
* await fetchUserProfile(userId);
|
|
160
|
+
* } catch (error) {
|
|
161
|
+
* Sentry.captureException(error, {
|
|
162
|
+
* tags: {
|
|
163
|
+
* section: 'user-profile',
|
|
164
|
+
* userId,
|
|
165
|
+
* },
|
|
166
|
+
* extra: {
|
|
167
|
+
* endpoint: '/api/users/profile',
|
|
168
|
+
* timestamp: Date.now(),
|
|
169
|
+
* },
|
|
170
|
+
* level: 'error',
|
|
171
|
+
* });
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare function captureException(error: Error | string | unknown, captureContext?: CaptureContext): string;
|
|
176
|
+
/**
|
|
177
|
+
* Capture a message (Sentry-compatible)
|
|
178
|
+
*
|
|
179
|
+
* Used for logging important events that aren't errors but need visibility,
|
|
180
|
+
* such as security events or business logic anomalies.
|
|
181
|
+
*
|
|
182
|
+
* @param message - Message to capture
|
|
183
|
+
* @param captureContextOrLevel - Severity level string OR full context object
|
|
184
|
+
* @returns Event ID (UUID)
|
|
185
|
+
*
|
|
186
|
+
* @example Simple message
|
|
187
|
+
* ```typescript
|
|
188
|
+
* Sentry.captureMessage('User reached payment limit');
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @example With severity level
|
|
192
|
+
* ```typescript
|
|
193
|
+
* Sentry.captureMessage('Suspicious login attempt detected', 'warning');
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @example With full context
|
|
197
|
+
* ```typescript
|
|
198
|
+
* Sentry.captureMessage('High-value transaction completed', {
|
|
199
|
+
* level: 'info',
|
|
200
|
+
* tags: {
|
|
201
|
+
* transactionType: 'purchase',
|
|
202
|
+
* amount: 'high',
|
|
203
|
+
* },
|
|
204
|
+
* extra: {
|
|
205
|
+
* orderId,
|
|
206
|
+
* amount: 5000,
|
|
207
|
+
* userTier: 'premium',
|
|
208
|
+
* },
|
|
209
|
+
* });
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export declare function captureMessage(message: string, captureContextOrLevel?: CaptureContext | SeverityLevel): string;
|
|
213
|
+
/**
|
|
214
|
+
* Set user context (Sentry-compatible)
|
|
215
|
+
*
|
|
216
|
+
* Essential for tracking which users are affected by errors.
|
|
217
|
+
* Critical for production debugging.
|
|
218
|
+
*
|
|
219
|
+
* @param user - User info or null to clear
|
|
220
|
+
*
|
|
221
|
+
* @example After user authentication
|
|
222
|
+
* ```typescript
|
|
223
|
+
* function setSentryUser(user: User) {
|
|
224
|
+
* Sentry.setUser({
|
|
225
|
+
* id: user.id,
|
|
226
|
+
* email: user.email,
|
|
227
|
+
* username: user.username,
|
|
228
|
+
* ip_address: '{{auto}}', // Auto-detect IP
|
|
229
|
+
* });
|
|
230
|
+
* }
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* @example On logout
|
|
234
|
+
* ```typescript
|
|
235
|
+
* function clearSentryUser() {
|
|
236
|
+
* Sentry.setUser(null);
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @example With segment data
|
|
241
|
+
* ```typescript
|
|
242
|
+
* Sentry.setUser({
|
|
243
|
+
* id: user.id,
|
|
244
|
+
* email: user.email,
|
|
245
|
+
* segment: user.subscriptionTier, // 'free' | 'pro' | 'enterprise'
|
|
246
|
+
* plan: user.planType,
|
|
247
|
+
* });
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
export declare function setUser(user: UserInfo | null): void;
|
|
251
|
+
/**
|
|
252
|
+
* Add a breadcrumb (Sentry-compatible)
|
|
253
|
+
*
|
|
254
|
+
* Creates a trail of events leading up to an error.
|
|
255
|
+
* Invaluable for understanding what happened before a crash.
|
|
256
|
+
*
|
|
257
|
+
* @param breadcrumb - Breadcrumb data
|
|
258
|
+
*
|
|
259
|
+
* @example Navigation breadcrumb
|
|
260
|
+
* ```typescript
|
|
261
|
+
* function trackNavigation(url: string) {
|
|
262
|
+
* Sentry.addBreadcrumb({
|
|
263
|
+
* category: 'navigation',
|
|
264
|
+
* message: `Navigated to ${url}`,
|
|
265
|
+
* level: 'info',
|
|
266
|
+
* data: {
|
|
267
|
+
* from: window.location.pathname,
|
|
268
|
+
* to: url,
|
|
269
|
+
* },
|
|
270
|
+
* });
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @example API call breadcrumb
|
|
275
|
+
* ```typescript
|
|
276
|
+
* Sentry.addBreadcrumb({
|
|
277
|
+
* category: 'api',
|
|
278
|
+
* message: 'API request started',
|
|
279
|
+
* level: 'info',
|
|
280
|
+
* data: { endpoint, method: 'GET' },
|
|
281
|
+
* });
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @example User action breadcrumb
|
|
285
|
+
* ```typescript
|
|
286
|
+
* Sentry.addBreadcrumb({
|
|
287
|
+
* category: 'ui.click',
|
|
288
|
+
* message: 'User clicked checkout button',
|
|
289
|
+
* level: 'info',
|
|
290
|
+
* data: {
|
|
291
|
+
* cartItems: 5,
|
|
292
|
+
* totalAmount: 129.99,
|
|
293
|
+
* },
|
|
294
|
+
* });
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
export declare function addBreadcrumb(breadcrumb: Breadcrumb): void;
|
|
298
|
+
/**
|
|
299
|
+
* Run code with an isolated scope (Sentry-compatible)
|
|
300
|
+
*
|
|
301
|
+
* Creates a temporary scope that doesn't pollute the global scope.
|
|
302
|
+
* This is the preferred way to add context to specific errors.
|
|
303
|
+
*
|
|
304
|
+
* @param callback - Function to run with isolated scope
|
|
305
|
+
* @returns Result of the callback
|
|
306
|
+
*
|
|
307
|
+
* @example Basic usage
|
|
308
|
+
* ```typescript
|
|
309
|
+
* function processPayment(orderId: string, amount: number) {
|
|
310
|
+
* return Sentry.withScope((scope) => {
|
|
311
|
+
* scope.setTag('transaction', 'payment');
|
|
312
|
+
* scope.setExtra('orderId', orderId);
|
|
313
|
+
* scope.setExtra('amount', amount);
|
|
314
|
+
* scope.setFingerprint(['payment', orderId]);
|
|
315
|
+
*
|
|
316
|
+
* try {
|
|
317
|
+
* return executePayment(orderId, amount);
|
|
318
|
+
* } catch (error) {
|
|
319
|
+
* Sentry.captureException(error);
|
|
320
|
+
* throw error;
|
|
321
|
+
* }
|
|
322
|
+
* });
|
|
323
|
+
* }
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* @example Async operations
|
|
327
|
+
* ```typescript
|
|
328
|
+
* async function handleUserAction(userId: string, action: string) {
|
|
329
|
+
* return Sentry.withScope(async (scope) => {
|
|
330
|
+
* scope.setUser({ id: userId });
|
|
331
|
+
* scope.setTag('action', action);
|
|
332
|
+
*
|
|
333
|
+
* const result = await performAction(userId, action);
|
|
334
|
+
* return result;
|
|
335
|
+
* });
|
|
336
|
+
* }
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
export declare function withScope<T>(callback: (scope: Scope) => T): T;
|
|
340
|
+
/**
|
|
341
|
+
* Configure the global scope (Sentry-compatible)
|
|
342
|
+
*
|
|
343
|
+
* Modifies the global scope that affects all future events.
|
|
344
|
+
* Use sparingly - prefer withScope for isolated context.
|
|
345
|
+
*
|
|
346
|
+
* @param callback - Function to configure the scope
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* Sentry.configureScope((scope) => {
|
|
351
|
+
* scope.setTag('environment', 'production');
|
|
352
|
+
* scope.setTag('release', process.env.APP_VERSION);
|
|
353
|
+
* });
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
export { configureScope };
|
|
357
|
+
/**
|
|
358
|
+
* Capture a raw event (Sentry-compatible)
|
|
359
|
+
*
|
|
360
|
+
* This is a low-level function that captures a raw event object.
|
|
361
|
+
* Use this for maximum control over event data, such as manually constructed
|
|
362
|
+
* exception events or custom event formats.
|
|
363
|
+
*
|
|
364
|
+
* @param event - The raw Sentry event object
|
|
365
|
+
* @returns Event ID (UUID)
|
|
366
|
+
*
|
|
367
|
+
* @example Basic message event
|
|
368
|
+
* ```typescript
|
|
369
|
+
* Sentry.captureEvent({
|
|
370
|
+
* message: 'Manual event',
|
|
371
|
+
* level: 'info',
|
|
372
|
+
* tags: { source: 'manual' },
|
|
373
|
+
* });
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @example Exception event
|
|
377
|
+
* ```typescript
|
|
378
|
+
* Sentry.captureEvent({
|
|
379
|
+
* message: 'Something went wrong',
|
|
380
|
+
* level: 'error',
|
|
381
|
+
* exception: {
|
|
382
|
+
* values: [{
|
|
383
|
+
* type: 'Error',
|
|
384
|
+
* value: 'Connection failed',
|
|
385
|
+
* stacktrace: { frames: [] },
|
|
386
|
+
* }],
|
|
387
|
+
* },
|
|
388
|
+
* });
|
|
389
|
+
* ```
|
|
390
|
+
*
|
|
391
|
+
* @example With full context
|
|
392
|
+
* ```typescript
|
|
393
|
+
* Sentry.captureEvent({
|
|
394
|
+
* message: 'Custom event',
|
|
395
|
+
* level: 'warning',
|
|
396
|
+
* tags: { module: 'payments' },
|
|
397
|
+
* extra: { orderId: '123', amount: 99.99 },
|
|
398
|
+
* user: { id: 'user-123', email: 'user@example.com' },
|
|
399
|
+
* contexts: {
|
|
400
|
+
* payment: { processor: 'stripe', status: 'failed' },
|
|
401
|
+
* },
|
|
402
|
+
* fingerprint: ['payment', 'stripe', 'failed'],
|
|
403
|
+
* });
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
406
|
+
export declare function captureEvent(event: SentryEvent): string;
|
|
407
|
+
/**
|
|
408
|
+
* Set a single tag on the global scope
|
|
409
|
+
*/
|
|
410
|
+
export declare function setTag(key: string, value: string): void;
|
|
411
|
+
/**
|
|
412
|
+
* Set multiple tags
|
|
413
|
+
*/
|
|
414
|
+
export declare function setTags(tags: Record<string, string>): void;
|
|
415
|
+
/**
|
|
416
|
+
* Set extra data on the global scope
|
|
417
|
+
*/
|
|
418
|
+
export declare function setExtra(key: string, value: unknown): void;
|
|
419
|
+
/**
|
|
420
|
+
* Set multiple extras
|
|
421
|
+
*/
|
|
422
|
+
export declare function setExtras(extras: Record<string, unknown>): void;
|
|
423
|
+
/**
|
|
424
|
+
* Set a named context (Sentry-compatible)
|
|
425
|
+
*
|
|
426
|
+
* @param name - Context name (e.g., 'browser', 'os', 'device', 'custom')
|
|
427
|
+
* @param context - Context data or null to clear
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* Sentry.setContext('payment', {
|
|
432
|
+
* processor: 'stripe',
|
|
433
|
+
* orderId: '12345',
|
|
434
|
+
* amount: 99.99,
|
|
435
|
+
* });
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
export declare function setContext(name: string, context: Record<string, unknown> | null): void;
|
|
439
|
+
/**
|
|
440
|
+
* Log a fatal error
|
|
441
|
+
*/
|
|
442
|
+
export declare function fatal(message: string, metadata?: LogMetadata): void;
|
|
443
|
+
/**
|
|
444
|
+
* Log an error
|
|
445
|
+
*/
|
|
446
|
+
export declare function error(message: string, metadata?: LogMetadata): void;
|
|
447
|
+
/**
|
|
448
|
+
* Log a warning
|
|
449
|
+
*/
|
|
450
|
+
export declare function warn(message: string, metadata?: LogMetadata): void;
|
|
451
|
+
/**
|
|
452
|
+
* Log an info message
|
|
453
|
+
*/
|
|
454
|
+
export declare function info(message: string, metadata?: LogMetadata): void;
|
|
455
|
+
/**
|
|
456
|
+
* Log a debug message
|
|
457
|
+
*/
|
|
458
|
+
export declare function debug(message: string, metadata?: LogMetadata): void;
|
|
459
|
+
/**
|
|
460
|
+
* Log a trace message
|
|
461
|
+
*/
|
|
462
|
+
export declare function trace(message: string, metadata?: LogMetadata): void;
|
|
463
|
+
/**
|
|
464
|
+
* Log an exception
|
|
465
|
+
*/
|
|
466
|
+
export declare function exception(err: Error, message?: string, metadata?: LogMetadata): void;
|
|
467
|
+
/**
|
|
468
|
+
* Generic log method
|
|
469
|
+
*/
|
|
470
|
+
export declare function log(level: LogLevel, message: string, metadata?: LogMetadata): void;
|
|
471
|
+
export declare function startSession(attributes?: Record<string, unknown>): Promise<string>;
|
|
472
|
+
export declare function endSession(status?: 'ended' | 'crashed'): Promise<void>;
|
|
473
|
+
export declare function getCurrentSession(): Session | null;
|
|
474
|
+
export declare function getLogs(filter?: LogFilter): Promise<LogEntry[]>;
|
|
475
|
+
export declare function getSessions(filter?: SessionFilter): Promise<Session[]>;
|
|
476
|
+
export declare function getStats(): Promise<StoreStats>;
|
|
477
|
+
export declare function setMinLevel(level: LogLevel): void;
|
|
478
|
+
export declare function getMinLevel(): LogLevel;
|
|
479
|
+
export declare function isLevelEnabled(level: LogLevel): boolean;
|
|
480
|
+
export declare function child(name: string, defaultMetadata?: LogMetadata): Logger;
|
|
481
|
+
/**
|
|
482
|
+
* Transaction implementation for performance monitoring (Sentry-compatible)
|
|
483
|
+
*
|
|
484
|
+
* @remarks
|
|
485
|
+
* Transactions represent a unit of work and can contain measurements
|
|
486
|
+
* and contextual data. Logs captured during an active transaction
|
|
487
|
+
* automatically get traceId and spanId attached.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```typescript
|
|
491
|
+
* const transaction = Sentry.startTransaction({ name: 'checkout', op: 'http.server' });
|
|
492
|
+
* transaction.setMeasurement('ttfb', 250, 'millisecond');
|
|
493
|
+
* // ... do work ...
|
|
494
|
+
* transaction.finish();
|
|
495
|
+
* ```
|
|
496
|
+
*/
|
|
497
|
+
export declare class Transaction implements TransactionInterface {
|
|
498
|
+
name: string;
|
|
499
|
+
op?: string;
|
|
500
|
+
description?: string;
|
|
501
|
+
traceId: string;
|
|
502
|
+
spanId: string;
|
|
503
|
+
startTimestamp: number;
|
|
504
|
+
endTimestamp?: number;
|
|
505
|
+
status?: TransactionStatus;
|
|
506
|
+
tags?: Record<string, string>;
|
|
507
|
+
data?: Record<string, unknown>;
|
|
508
|
+
measurements?: Record<string, Measurement>;
|
|
509
|
+
constructor(context: TransactionContext);
|
|
510
|
+
/**
|
|
511
|
+
* Set a tag on the transaction
|
|
512
|
+
*/
|
|
513
|
+
setTag(key: string, value: string): void;
|
|
514
|
+
/**
|
|
515
|
+
* Set arbitrary data on the transaction
|
|
516
|
+
*/
|
|
517
|
+
setData(key: string, value: unknown): void;
|
|
518
|
+
/**
|
|
519
|
+
* Set a performance measurement
|
|
520
|
+
*/
|
|
521
|
+
setMeasurement(name: string, value: number, unit?: string): void;
|
|
522
|
+
/**
|
|
523
|
+
* Set the transaction status
|
|
524
|
+
*/
|
|
525
|
+
setStatus(status: TransactionStatus): void;
|
|
526
|
+
/**
|
|
527
|
+
* Finish the transaction and calculate duration
|
|
528
|
+
*/
|
|
529
|
+
finish(): void;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Start a new transaction for performance monitoring (Sentry-compatible)
|
|
533
|
+
*
|
|
534
|
+
* @param context - Transaction context with name and optional operation type
|
|
535
|
+
* @returns Transaction object with methods to add measurements and finish
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```typescript
|
|
539
|
+
* const transaction = Sentry.startTransaction({
|
|
540
|
+
* name: 'checkout',
|
|
541
|
+
* op: 'http.server',
|
|
542
|
+
* });
|
|
543
|
+
* transaction.setMeasurement('ttfb', 250, 'millisecond');
|
|
544
|
+
* // ... do work ...
|
|
545
|
+
* transaction.finish();
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
export declare function startTransaction(context: TransactionContext): Transaction;
|
|
549
|
+
/**
|
|
550
|
+
* Get the currently active transaction (if any)
|
|
551
|
+
*
|
|
552
|
+
* @returns The active transaction or null
|
|
553
|
+
*/
|
|
554
|
+
export declare function getActiveTransaction(): Transaction | null;
|
|
555
|
+
export { Logger, createLogger } from './logger.js';
|
|
556
|
+
export { Scope } from './scope.js';
|
|
557
|
+
export { MemoryStoreProvider, type MemoryStoreConfig } from './stores/memory.js';
|
|
558
|
+
export { SQLiteStoreProvider, type SQLiteStoreConfig } from './stores/sqlite.js';
|
|
559
|
+
export { BaseStoreProvider } from './stores/base.js';
|
|
560
|
+
export { getCurrentScope, getGlobalScope, getIsolationScope, withScopeAsync, } from './scope.js';
|
|
561
|
+
export type { LogLevel, LogEntry, LogMetadata, Session, StoreProvider, StoreProviderConfig, StoreStats, LogFilter, SessionFilter, LoggerConfig, UserInfo, RequestInfo, ErrorInfo, Breadcrumb, CaptureContext, SeverityLevel, SentryEvent, ExceptionValue, TransactionContext, TransactionStatus, Measurement, BeforeSendHook, BeforeSendMessageHook, BeforeSendHint, BeforeSendMessageHint, } from './types.js';
|
|
562
|
+
export { LogLevelValue } from './types.js';
|
|
563
|
+
export type { Transaction as TransactionInterface } from './types.js';
|
|
564
|
+
declare const _default: {
|
|
565
|
+
init: typeof init;
|
|
566
|
+
create: typeof create;
|
|
567
|
+
close: typeof close;
|
|
568
|
+
isInitialized: typeof isInitialized;
|
|
569
|
+
captureException: typeof captureException;
|
|
570
|
+
captureMessage: typeof captureMessage;
|
|
571
|
+
setUser: typeof setUser;
|
|
572
|
+
addBreadcrumb: typeof addBreadcrumb;
|
|
573
|
+
withScope: typeof withScope;
|
|
574
|
+
configureScope: typeof configureScope;
|
|
575
|
+
captureEvent: typeof captureEvent;
|
|
576
|
+
setTag: typeof setTag;
|
|
577
|
+
setTags: typeof setTags;
|
|
578
|
+
setExtra: typeof setExtra;
|
|
579
|
+
setExtras: typeof setExtras;
|
|
580
|
+
setContext: typeof setContext;
|
|
581
|
+
fatal: typeof fatal;
|
|
582
|
+
error: typeof error;
|
|
583
|
+
warn: typeof warn;
|
|
584
|
+
info: typeof info;
|
|
585
|
+
debug: typeof debug;
|
|
586
|
+
trace: typeof trace;
|
|
587
|
+
exception: typeof exception;
|
|
588
|
+
log: typeof log;
|
|
589
|
+
startSession: typeof startSession;
|
|
590
|
+
endSession: typeof endSession;
|
|
591
|
+
getCurrentSession: typeof getCurrentSession;
|
|
592
|
+
getLogs: typeof getLogs;
|
|
593
|
+
getSessions: typeof getSessions;
|
|
594
|
+
getStats: typeof getStats;
|
|
595
|
+
setMinLevel: typeof setMinLevel;
|
|
596
|
+
getMinLevel: typeof getMinLevel;
|
|
597
|
+
isLevelEnabled: typeof isLevelEnabled;
|
|
598
|
+
child: typeof child;
|
|
599
|
+
getCurrentScope: typeof getCurrentScope;
|
|
600
|
+
getGlobalScope: typeof getGlobalScope;
|
|
601
|
+
getIsolationScope: typeof getIsolationScope;
|
|
602
|
+
startTransaction: typeof startTransaction;
|
|
603
|
+
getActiveTransaction: typeof getActiveTransaction;
|
|
604
|
+
Transaction: typeof Transaction;
|
|
605
|
+
};
|
|
606
|
+
export default _default;
|
|
607
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAGH,OAAO,EAAE,MAAM,EAAgB,MAAM,aAAa,CAAC;AAGnD,OAAO,EACL,KAAK,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,cAAc,EAMd,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,OAAO,EAEP,UAAU,EACV,SAAS,EACT,aAAa,EAEb,QAAQ,EAGR,UAAU,EACV,cAAc,EACd,cAAc,EACd,qB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