-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsubject-special-objects.ts
More file actions
44 lines (34 loc) · 1.24 KB
/
subject-special-objects.ts
File metadata and controls
44 lines (34 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import { consola } from 'consola';
Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0.0',
environment: 'test',
enableLogs: true,
transport: loggingTransport,
});
async function run(): Promise<void> {
consola.level = 5;
const sentryReporter = Sentry.createConsolaReporter();
consola.addReporter(sentryReporter);
// Test Date objects are preserved
consola.info('Current time:', new Date('2023-01-01T00:00:00.000Z'));
// Test Error objects are preserved
consola.error('Error occurred:', new Error('Test error'));
// Test RegExp objects are preserved
consola.info('Pattern:', /test/gi);
// Test Map and Set objects are preserved
consola.info('Collections:', new Map([['key', 'value']]), new Set([1, 2, 3]));
// Test mixed: nested object, primitives, Date, and Map
consola.info(
'Mixed data',
{ userId: 123, nestedMetadata: { id: 789, name: 'Jane', source: 'api' } },
new Date('2023-06-15T12:00:00.000Z'),
'a-simple-string',
new Map([['key', 'value']]),
);
await Sentry.flush();
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
void run();