nightingale-sentry 14.2.1 → 16.0.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 +35 -0
- package/README.md +18 -18
- package/dist/definitions/index.d.ts +4 -4
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/index-browser.es.js +47 -51
- package/dist/index-browser.es.js.map +1 -1
- package/dist/{index-node18.mjs → index-node20.mjs} +13 -13
- package/dist/index-node20.mjs.map +1 -0
- package/package.json +30 -37
- package/src/index.ts +16 -16
- package/dist/index-browsermodern.es.js +0 -69
- package/dist/index-browsermodern.es.js.map +0 -1
- package/dist/index-node18.mjs.map +0 -1
- package/src/.eslintrc.json +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [16.0.0](https://github.com/christophehurpeau/nightingale/compare/v15.0.0...v16.0.0) (2025-03-30)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* drop node 18
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **deps:** update sentry ([dbbf42f](https://github.com/christophehurpeau/nightingale/commit/dbbf42fe7d52b4cb8de378bf284924cee33e68d6))
|
|
15
|
+
* drop node 18 ([1b11a55](https://github.com/christophehurpeau/nightingale/commit/1b11a55dd24c9435be50519a748316079f554414))
|
|
16
|
+
|
|
17
|
+
Version bump for dependency: nightingale-levels
|
|
18
|
+
Version bump for dependency: nightingale-types
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [15.0.0](https://github.com/christophehurpeau/nightingale/compare/v14.2.1...v15.0.0) (2023-12-25)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### ⚠ BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
* update babel and drop browser modern version
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* update babel and drop browser modern version ([5c76abc](https://github.com/christophehurpeau/nightingale/commit/5c76abc8bfb595a617fc4c8b795dae7e674ea664))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* remove unused dependency @sentry/node ([82b190b](https://github.com/christophehurpeau/nightingale/commit/82b190ba3659308874f24ca759961dc9a84b8964))
|
|
36
|
+
|
|
37
|
+
Version bump for dependency: nightingale-levels
|
|
38
|
+
Version bump for dependency: nightingale-types
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
## [14.2.1](https://github.com/christophehurpeau/nightingale/compare/v14.2.0...v14.2.1) (2023-11-05)
|
|
7
42
|
|
|
8
43
|
Note: no notable changes
|
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
<
|
|
1
|
+
<h1 align="center">
|
|
2
2
|
nightingale-sentry
|
|
3
|
-
</
|
|
3
|
+
</h1>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
Sentry handler for nightingale
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/npm/v/nightingale-sentry.svg?style=flat-square"></a>
|
|
11
|
-
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/npm/dw/nightingale-sentry.svg?style=flat-square"></a>
|
|
12
|
-
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/node/v/nightingale-sentry.svg?style=flat-square"></a>
|
|
13
|
-
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/npm/types/nightingale-sentry.svg?style=flat-square"></a>
|
|
10
|
+
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/npm/v/nightingale-sentry.svg?style=flat-square" alt="npm version"></a>
|
|
11
|
+
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/npm/dw/nightingale-sentry.svg?style=flat-square" alt="npm downloads"></a>
|
|
12
|
+
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/node/v/nightingale-sentry.svg?style=flat-square" alt="node version"></a>
|
|
13
|
+
<a href="https://npmjs.org/package/nightingale-sentry"><img src="https://img.shields.io/npm/types/nightingale-sentry.svg?style=flat-square" alt="types"></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
## Install
|
|
@@ -27,14 +27,14 @@ import {
|
|
|
27
27
|
addBreadcrumb,
|
|
28
28
|
captureException,
|
|
29
29
|
captureMessage,
|
|
30
|
-
} from
|
|
31
|
-
import { configure, Level, listenUnhandledErrors } from
|
|
32
|
-
import { SentryHandler } from
|
|
30
|
+
} from "@sentry/node";
|
|
31
|
+
import { configure, Level, listenUnhandledErrors } from "nightingale";
|
|
32
|
+
import { SentryHandler } from "nightingale-sentry";
|
|
33
33
|
|
|
34
34
|
listenUnhandledErrors();
|
|
35
35
|
|
|
36
36
|
sentryInit({
|
|
37
|
-
dsn: process.env.NODE_ENV ===
|
|
37
|
+
dsn: process.env.NODE_ENV === "production" ? "__DSN__" : undefined,
|
|
38
38
|
// ...
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -64,12 +64,12 @@ import {
|
|
|
64
64
|
addBreadcrumb,
|
|
65
65
|
captureException,
|
|
66
66
|
captureMessage,
|
|
67
|
-
} from
|
|
68
|
-
import { addConfig, Level } from
|
|
69
|
-
import SentryHandler from
|
|
67
|
+
} from "@sentry/browser";
|
|
68
|
+
import { addConfig, Level } from "nightingale-app";
|
|
69
|
+
import SentryHandler from "nightingale-sentry";
|
|
70
70
|
|
|
71
71
|
sentryInit({
|
|
72
|
-
dsn: process.env.NODE_ENV ===
|
|
72
|
+
dsn: process.env.NODE_ENV === "production" ? "__DSN__" : undefined,
|
|
73
73
|
// ...
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -94,12 +94,12 @@ import {
|
|
|
94
94
|
addBreadcrumb,
|
|
95
95
|
captureException,
|
|
96
96
|
captureMessage,
|
|
97
|
-
} from
|
|
98
|
-
import { configure, Level } from
|
|
99
|
-
import { SentryHandler } from
|
|
97
|
+
} from "@sentry/browser";
|
|
98
|
+
import { configure, Level } from "nightingale";
|
|
99
|
+
import { SentryHandler } from "nightingale-sentry";
|
|
100
100
|
|
|
101
101
|
sentryInit({
|
|
102
|
-
dsn: process.env.NODE_ENV ===
|
|
102
|
+
dsn: process.env.NODE_ENV === "production" ? "__DSN__" : undefined,
|
|
103
103
|
// ...
|
|
104
104
|
});
|
|
105
105
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { addBreadcrumb, captureException, captureMessage } from
|
|
2
|
-
import type { User } from
|
|
3
|
-
import { Level } from
|
|
4
|
-
import type {
|
|
1
|
+
import type { addBreadcrumb, captureException, captureMessage } from "@sentry/core";
|
|
2
|
+
import type { User } from "@sentry/types";
|
|
3
|
+
import { Level } from "nightingale-levels";
|
|
4
|
+
import type { Handle, Handler, LogRecord, Metadata } from "nightingale-types";
|
|
5
5
|
export interface MetadataWithError extends Metadata {
|
|
6
6
|
error?: Error;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAiB,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,M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AAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO;CAI1D"}
|
package/dist/index-browser.es.js
CHANGED
|
@@ -1,60 +1,54 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
1
|
import { Level } from 'nightingale-levels';
|
|
3
2
|
|
|
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
|
-
return function (record) {
|
|
34
|
-
var key = record.key,
|
|
35
|
-
level = record.level,
|
|
36
|
-
metadata = record.metadata,
|
|
37
|
-
extra = record.extra,
|
|
38
|
-
message = record.message,
|
|
39
|
-
error,
|
|
40
|
-
extraData;
|
|
3
|
+
const mapToSentryLevel = {
|
|
4
|
+
[Level.TRACE]: "debug",
|
|
5
|
+
[Level.DEBUG]: "debug",
|
|
6
|
+
[Level.INFO]: "info",
|
|
7
|
+
[Level.NOTICE]: "log",
|
|
8
|
+
[Level.WARNING]: "warning",
|
|
9
|
+
[Level.ERROR]: "error",
|
|
10
|
+
[Level.CRITICAL]: "fatal",
|
|
11
|
+
[Level.FATAL]: "fatal",
|
|
12
|
+
[Level.EMERGENCY]: "fatal",
|
|
13
|
+
// not a level
|
|
14
|
+
[Level.ALL]: "error"
|
|
15
|
+
};
|
|
16
|
+
const createHandler = (Sentry, {
|
|
17
|
+
getUser = () => undefined,
|
|
18
|
+
getTags = () => ({}),
|
|
19
|
+
getBreadcrumbCategory = () => undefined,
|
|
20
|
+
getBreadcrumbType = () => undefined,
|
|
21
|
+
shouldSendAsException = record => record.metadata?.error !== undefined && record.metadata.unhandled !== true,
|
|
22
|
+
shouldSendAsBreadcrumb = () => false
|
|
23
|
+
} = {}) => {
|
|
24
|
+
return record => {
|
|
25
|
+
const {
|
|
26
|
+
key,
|
|
27
|
+
level,
|
|
28
|
+
metadata,
|
|
29
|
+
extra,
|
|
30
|
+
message
|
|
31
|
+
} = record;
|
|
41
32
|
if (shouldSendAsException(record)) {
|
|
42
|
-
error =
|
|
43
|
-
extraData =
|
|
44
|
-
nightingaleErrorMessage: message
|
|
45
|
-
|
|
33
|
+
const error = metadata?.error || record.message;
|
|
34
|
+
const extraData = {
|
|
35
|
+
nightingaleErrorMessage: message,
|
|
36
|
+
...metadata,
|
|
37
|
+
...extra
|
|
38
|
+
};
|
|
46
39
|
delete extraData.error;
|
|
47
40
|
Sentry.captureException(error, {
|
|
48
|
-
level: mapToSentryLevel[level] ||
|
|
41
|
+
level: mapToSentryLevel[level] || "error",
|
|
49
42
|
user: getUser(record),
|
|
50
|
-
tags:
|
|
51
|
-
loggerKey: key
|
|
52
|
-
|
|
43
|
+
tags: {
|
|
44
|
+
loggerKey: key,
|
|
45
|
+
...getTags(record)
|
|
46
|
+
},
|
|
53
47
|
extra: extraData
|
|
54
48
|
});
|
|
55
49
|
} else if (shouldSendAsBreadcrumb(record)) {
|
|
56
50
|
Sentry.addBreadcrumb({
|
|
57
|
-
level: mapToSentryLevel[level] ||
|
|
51
|
+
level: mapToSentryLevel[level] || "error",
|
|
58
52
|
category: getBreadcrumbCategory(record),
|
|
59
53
|
type: getBreadcrumbType(record),
|
|
60
54
|
message: record.message,
|
|
@@ -64,10 +58,12 @@ var createHandler = function createHandler(Sentry, _temp) {
|
|
|
64
58
|
}
|
|
65
59
|
};
|
|
66
60
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
class SentryHandler {
|
|
62
|
+
constructor(Sentry, minLevel, options) {
|
|
63
|
+
this.minLevel = minLevel;
|
|
64
|
+
this.handle = createHandler(Sentry, options);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
71
67
|
|
|
72
68
|
export { SentryHandler };
|
|
73
69
|
//# sourceMappingURL=index-browser.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.es.js","sources":["../src/index.ts"],"sourcesContent":["import type {\n addBreadcrumb,\n captureException,\n captureMessage,\n} from
|
|
1
|
+
{"version":3,"file":"index-browser.es.js","sources":["../src/index.ts"],"sourcesContent":["import type {\n addBreadcrumb,\n captureException,\n captureMessage,\n} from \"@sentry/core\";\nimport type { SeverityLevel, User } from \"@sentry/types\";\nimport { Level } from \"nightingale-levels\";\nimport type { Handle, Handler, LogRecord, Metadata } from \"nightingale-types\";\n\nconst mapToSentryLevel: Record<Level, SeverityLevel> = {\n [Level.TRACE]: \"debug\",\n [Level.DEBUG]: \"debug\",\n [Level.INFO]: \"info\",\n [Level.NOTICE]: \"log\",\n [Level.WARNING]: \"warning\",\n [Level.ERROR]: \"error\",\n [Level.CRITICAL]: \"fatal\",\n [Level.FATAL]: \"fatal\",\n [Level.EMERGENCY]: \"fatal\",\n // not a level\n [Level.ALL]: \"error\",\n};\n\nexport interface MetadataWithError extends Metadata {\n error?: Error;\n}\n\nexport interface Options {\n getUser?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => User | undefined;\n getTags?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => Record<string, string>;\n getBreadcrumbCategory?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n getBreadcrumbType?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n shouldSendAsException?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => boolean;\n shouldSendAsBreadcrumb?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => boolean;\n}\n\nexport interface SentryRequiredMethods {\n addBreadcrumb: typeof addBreadcrumb;\n captureException: typeof captureException;\n captureMessage: typeof captureMessage;\n}\n\nconst createHandler = <S extends SentryRequiredMethods>(\n Sentry: S,\n {\n getUser = () => undefined,\n getTags = () => ({}),\n getBreadcrumbCategory = () => undefined,\n getBreadcrumbType = () => undefined,\n shouldSendAsException = <T extends Metadata>(record: LogRecord<T>) =>\n record.metadata?.error !== undefined &&\n record.metadata.unhandled !== true,\n shouldSendAsBreadcrumb = <T extends Metadata>(record: LogRecord<T>) =>\n false,\n }: Options = {},\n): Handle => {\n return <T extends MetadataWithError>(record: LogRecord<T>) => {\n const { key, level, metadata, extra, message } = record;\n\n if (shouldSendAsException(record)) {\n const error = metadata?.error || record.message;\n\n const extraData: Record<string, unknown> = {\n nightingaleErrorMessage: message,\n ...metadata,\n ...extra,\n };\n delete extraData.error;\n\n Sentry.captureException(error, {\n level: mapToSentryLevel[level] || \"error\",\n user: getUser(record),\n tags: {\n loggerKey: key,\n ...getTags(record),\n },\n extra: extraData,\n });\n } else if (shouldSendAsBreadcrumb(record)) {\n Sentry.addBreadcrumb({\n level: mapToSentryLevel[level] || \"error\",\n category: getBreadcrumbCategory(record),\n type: getBreadcrumbType(record),\n message: record.message,\n data: record.metadata,\n timestamp: record.datetime.getTime(),\n });\n }\n };\n};\n\nexport class SentryHandler<S extends SentryRequiredMethods> implements Handler {\n minLevel: Level;\n\n handle: Handle;\n\n constructor(Sentry: S, minLevel: Level, options?: Options) {\n this.minLevel = minLevel;\n this.handle = createHandler<S>(Sentry, options);\n }\n}\n"],"names":["mapToSentryLevel","Level","TRACE","DEBUG","INFO","NOTICE","WARNING","ERROR","CRITICAL","FATAL","EMERGENCY","ALL","createHandler","Sentry","getUser","undefined","getTags","getBreadcrumbCategory","getBreadcrumbType","shouldSendAsException","record","metadata","error","unhandled","shouldSendAsBreadcrumb","key","level","extra","message","extraData","nightingaleErrorMessage","captureException","user","tags","loggerKey","addBreadcrumb","category","type","data","timestamp","datetime","getTime","SentryHandler","constructor","minLevel","options","handle"],"mappings":";;AASA,MAAMA,gBAA8C,GAAG;AACrD,EAAA,CAACC,KAA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[Level.NOTICE]:
|
|
8
|
-
[Level.WARNING]:
|
|
9
|
-
[Level.ERROR]:
|
|
10
|
-
[Level.CRITICAL]:
|
|
11
|
-
[Level.FATAL]:
|
|
12
|
-
[Level.EMERGENCY]:
|
|
4
|
+
[Level.TRACE]: "debug",
|
|
5
|
+
[Level.DEBUG]: "debug",
|
|
6
|
+
[Level.INFO]: "info",
|
|
7
|
+
[Level.NOTICE]: "log",
|
|
8
|
+
[Level.WARNING]: "warning",
|
|
9
|
+
[Level.ERROR]: "error",
|
|
10
|
+
[Level.CRITICAL]: "fatal",
|
|
11
|
+
[Level.FATAL]: "fatal",
|
|
12
|
+
[Level.EMERGENCY]: "fatal",
|
|
13
13
|
// not a level
|
|
14
|
-
[Level.ALL]:
|
|
14
|
+
[Level.ALL]: "error"
|
|
15
15
|
};
|
|
16
16
|
const createHandler = (Sentry, {
|
|
17
17
|
getUser = () => undefined,
|
|
@@ -38,7 +38,7 @@ const createHandler = (Sentry, {
|
|
|
38
38
|
};
|
|
39
39
|
delete extraData.error;
|
|
40
40
|
Sentry.captureException(error, {
|
|
41
|
-
level: mapToSentryLevel[level] ||
|
|
41
|
+
level: mapToSentryLevel[level] || "error",
|
|
42
42
|
user: getUser(record),
|
|
43
43
|
tags: {
|
|
44
44
|
loggerKey: key,
|
|
@@ -48,7 +48,7 @@ const createHandler = (Sentry, {
|
|
|
48
48
|
});
|
|
49
49
|
} else if (shouldSendAsBreadcrumb(record)) {
|
|
50
50
|
Sentry.addBreadcrumb({
|
|
51
|
-
level: mapToSentryLevel[level] ||
|
|
51
|
+
level: mapToSentryLevel[level] || "error",
|
|
52
52
|
category: getBreadcrumbCategory(record),
|
|
53
53
|
type: getBreadcrumbType(record),
|
|
54
54
|
message: record.message,
|
|
@@ -66,4 +66,4 @@ class SentryHandler {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export { SentryHandler };
|
|
69
|
-
//# sourceMappingURL=index-
|
|
69
|
+
//# sourceMappingURL=index-node20.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node20.mjs","sources":["../src/index.ts"],"sourcesContent":["import type {\n addBreadcrumb,\n captureException,\n captureMessage,\n} from \"@sentry/core\";\nimport type { SeverityLevel, User } from \"@sentry/types\";\nimport { Level } from \"nightingale-levels\";\nimport type { Handle, Handler, LogRecord, Metadata } from \"nightingale-types\";\n\nconst mapToSentryLevel: Record<Level, SeverityLevel> = {\n [Level.TRACE]: \"debug\",\n [Level.DEBUG]: \"debug\",\n [Level.INFO]: \"info\",\n [Level.NOTICE]: \"log\",\n [Level.WARNING]: \"warning\",\n [Level.ERROR]: \"error\",\n [Level.CRITICAL]: \"fatal\",\n [Level.FATAL]: \"fatal\",\n [Level.EMERGENCY]: \"fatal\",\n // not a level\n [Level.ALL]: \"error\",\n};\n\nexport interface MetadataWithError extends Metadata {\n error?: Error;\n}\n\nexport interface Options {\n getUser?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => User | undefined;\n getTags?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => Record<string, string>;\n getBreadcrumbCategory?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n getBreadcrumbType?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n shouldSendAsException?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => boolean;\n shouldSendAsBreadcrumb?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => boolean;\n}\n\nexport interface SentryRequiredMethods {\n addBreadcrumb: typeof addBreadcrumb;\n captureException: typeof captureException;\n captureMessage: typeof captureMessage;\n}\n\nconst createHandler = <S extends SentryRequiredMethods>(\n Sentry: S,\n {\n getUser = () => undefined,\n getTags = () => ({}),\n getBreadcrumbCategory = () => undefined,\n getBreadcrumbType = () => undefined,\n shouldSendAsException = <T extends Metadata>(record: LogRecord<T>) =>\n record.metadata?.error !== undefined &&\n record.metadata.unhandled !== true,\n shouldSendAsBreadcrumb = <T extends Metadata>(record: LogRecord<T>) =>\n false,\n }: Options = {},\n): Handle => {\n return <T extends MetadataWithError>(record: LogRecord<T>) => {\n const { key, level, metadata, extra, message } = record;\n\n if (shouldSendAsException(record)) {\n const error = metadata?.error || record.message;\n\n const extraData: Record<string, unknown> = {\n nightingaleErrorMessage: message,\n ...metadata,\n ...extra,\n };\n delete extraData.error;\n\n Sentry.captureException(error, {\n level: mapToSentryLevel[level] || \"error\",\n user: getUser(record),\n tags: {\n loggerKey: key,\n ...getTags(record),\n },\n extra: extraData,\n });\n } else if (shouldSendAsBreadcrumb(record)) {\n Sentry.addBreadcrumb({\n level: mapToSentryLevel[level] || \"error\",\n category: getBreadcrumbCategory(record),\n type: getBreadcrumbType(record),\n message: record.message,\n data: record.metadata,\n timestamp: record.datetime.getTime(),\n });\n }\n };\n};\n\nexport class SentryHandler<S extends SentryRequiredMethods> implements Handler {\n minLevel: Level;\n\n handle: Handle;\n\n constructor(Sentry: S, minLevel: Level, options?: Options) {\n this.minLevel = minLevel;\n this.handle = createHandler<S>(Sentry, options);\n }\n}\n"],"names":["mapToSentryLevel","Level","TRACE","DEBUG","INFO","NOTICE","WARNING","ERROR","CRITICAL","FATAL","EMERGENCY","ALL","createHandler","Sentry","getUser","undefined","getTags","getBreadcrumbCategory","getBreadcrumbType","shouldSendAsException","record","metadata","error","unhandled","shouldSendAsBreadcrumb","key","level","extra","message","extraData","nightingaleErrorMessage","captureException","user","tags","loggerKey","addBreadcrumb","category","type","data","timestamp","datetime","getTime","SentryHandler","constructor","minLevel","options","handle"],"mappings":";;AASA,MAAMA,gBAA8C,GAAG;AACrD,EAAA,CAACC,KAAK,CAACC,KAAK,GAAG,OAAO;AACtB,EAAA,CAACD,KAAK,CAACE,KAAK,GAAG,OAAO;AACtB,EAAA,CAACF,KAAK,CAACG,IAAI,GAAG,MAAM;AACpB,EAAA,CAACH,KAAK,CAACI,MAAM,GAAG,KAAK;AACrB,EAAA,CAACJ,KAAK,CAACK,OAAO,GAAG,SAAS;AAC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ACrBa,QAAAA,IAAI,EAAE;AACJC,UAAAA,SAAS,EAAET,GAAG;UACd,GAAGT,OAAO,CAACI,MAAM;SAClB;AACDO,QAAAA,KAAK,EAAEE;AACT,OAAC,CAAC;AACJ,KAAC,MAAM,IAAIL,sBAAsB,CAACJ,MAAM,CAAC,EAAE;MACzCP,MAAM,CAACsB,aAAa,CAAC;AACnBT,QAAAA,KAAK,EAAE1B,gBAAgB,CAAC0B,KAAK,CAAC,IAAI,OAAO;AACzCU,QAAAA,QAAQ,EAAEnB,qBAAqB,CAACG,MAAM,CAAC;AACvCiB,QAAAA,IAAI,EAAEnB,iBAAiB,CAACE,MAAM,CAAC;QAC/BQ,OAAO,EAAER,MAAM,CAACQ,OAAO;QACvBU,IAAI,EAAElB,MAAM,CAACC,QAAQ;AACrBkB,QAAAA,SAAS,EAAEnB,MAAM,CAACoB,QAAQ,CAACC,OAAO;AACpC,OAAC,CAAC;AACJ;GACD;AACH,CAAC;AAEM,MAAMC,aAAa,CAAqD;AAK7EC,EAAAA,WAAWA,CAAC9B,MAAS,EAAE+B,QAAe,EAAEC,OAAiB,EAAE;IACzD,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACE,MAAM,GAAGlC,aAAa,CAAIC,MAAM,EAAEgC,OAAO,CAAC;AACjD;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nightingale-sentry",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "Sentry handler for nightingale",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nightingale",
|
|
@@ -16,18 +16,10 @@
|
|
|
16
16
|
"homepage": "https://github.com/christophehurpeau/nightingale",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">=20.9.0"
|
|
20
20
|
},
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"defaults",
|
|
24
|
-
"> 0.2%",
|
|
25
|
-
"not ie < 12",
|
|
26
|
-
"not safari < 10",
|
|
27
|
-
"not ios_saf < 10"
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
"main": "./dist/index-node18.mjs",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index-node20.mjs",
|
|
31
23
|
"types": "./dist/definitions/index.d.ts",
|
|
32
24
|
"module": "./dist/index-browser.es.js",
|
|
33
25
|
"browser": "./dist/index-browser.es.js",
|
|
@@ -36,17 +28,13 @@
|
|
|
36
28
|
".": {
|
|
37
29
|
"types": "./dist/definitions/index.d.ts",
|
|
38
30
|
"node": {
|
|
39
|
-
"import": "./dist/index-
|
|
31
|
+
"import": "./dist/index-node20.mjs"
|
|
40
32
|
},
|
|
41
33
|
"browser": {
|
|
42
|
-
"browser:modern": {
|
|
43
|
-
"import": "./dist/index-browsermodern.es.js"
|
|
44
|
-
},
|
|
45
34
|
"import": "./dist/index-browser.es.js"
|
|
46
35
|
}
|
|
47
36
|
}
|
|
48
37
|
},
|
|
49
|
-
"sideEffects": false,
|
|
50
38
|
"files": [
|
|
51
39
|
"src",
|
|
52
40
|
"dist"
|
|
@@ -57,39 +45,44 @@
|
|
|
57
45
|
"clean": "yarn clean:build",
|
|
58
46
|
"clean:build": "pob-babel-clean-out dist",
|
|
59
47
|
"lint": "yarn run lint:eslint",
|
|
60
|
-
"lint:eslint": "yarn ../.. run eslint --
|
|
48
|
+
"lint:eslint": "yarn ../.. run eslint --quiet packages/nightingale-sentry",
|
|
61
49
|
"watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
|
|
62
50
|
},
|
|
63
|
-
"
|
|
51
|
+
"browserslist": {
|
|
52
|
+
"production": [
|
|
53
|
+
"defaults",
|
|
54
|
+
"> 0.2%",
|
|
55
|
+
"not ie < 12",
|
|
56
|
+
"not safari < 10",
|
|
57
|
+
"not ios_saf < 10"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
64
60
|
"pob": {
|
|
65
|
-
"
|
|
61
|
+
"bundler": "rollup-babel",
|
|
62
|
+
"entries": [
|
|
63
|
+
"index"
|
|
64
|
+
],
|
|
65
|
+
"envs": [
|
|
66
66
|
{
|
|
67
67
|
"target": "node",
|
|
68
|
-
"version": "
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"target": "browser",
|
|
72
|
-
"version": "modern"
|
|
68
|
+
"version": "20"
|
|
73
69
|
},
|
|
74
70
|
{
|
|
75
71
|
"target": "browser"
|
|
76
72
|
}
|
|
77
|
-
],
|
|
78
|
-
"entries": [
|
|
79
|
-
"index"
|
|
80
73
|
]
|
|
81
74
|
},
|
|
75
|
+
"prettier": "@pob/root/prettier-config",
|
|
82
76
|
"dependencies": {
|
|
83
|
-
"@sentry/core": "^7.
|
|
84
|
-
"@sentry/
|
|
85
|
-
"
|
|
86
|
-
"nightingale-
|
|
87
|
-
"nightingale-types": "14.2.1"
|
|
77
|
+
"@sentry/core": "^7.120.3",
|
|
78
|
+
"@sentry/types": "^7.120.3",
|
|
79
|
+
"nightingale-levels": "16.0.0",
|
|
80
|
+
"nightingale-types": "16.0.0"
|
|
88
81
|
},
|
|
89
82
|
"devDependencies": {
|
|
90
|
-
"@babel/core": "7.
|
|
91
|
-
"@babel/preset-env": "7.
|
|
92
|
-
"pob-babel": "
|
|
93
|
-
"typescript": "5.
|
|
83
|
+
"@babel/core": "7.26.10",
|
|
84
|
+
"@babel/preset-env": "7.26.9",
|
|
85
|
+
"pob-babel": "43.4.0",
|
|
86
|
+
"typescript": "5.8.2"
|
|
94
87
|
}
|
|
95
88
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,23 +2,23 @@ import type {
|
|
|
2
2
|
addBreadcrumb,
|
|
3
3
|
captureException,
|
|
4
4
|
captureMessage,
|
|
5
|
-
} from
|
|
6
|
-
import type {
|
|
7
|
-
import { Level } from
|
|
8
|
-
import type {
|
|
5
|
+
} from "@sentry/core";
|
|
6
|
+
import type { SeverityLevel, User } from "@sentry/types";
|
|
7
|
+
import { Level } from "nightingale-levels";
|
|
8
|
+
import type { Handle, Handler, LogRecord, Metadata } from "nightingale-types";
|
|
9
9
|
|
|
10
10
|
const mapToSentryLevel: Record<Level, SeverityLevel> = {
|
|
11
|
-
[Level.TRACE]:
|
|
12
|
-
[Level.DEBUG]:
|
|
13
|
-
[Level.INFO]:
|
|
14
|
-
[Level.NOTICE]:
|
|
15
|
-
[Level.WARNING]:
|
|
16
|
-
[Level.ERROR]:
|
|
17
|
-
[Level.CRITICAL]:
|
|
18
|
-
[Level.FATAL]:
|
|
19
|
-
[Level.EMERGENCY]:
|
|
11
|
+
[Level.TRACE]: "debug",
|
|
12
|
+
[Level.DEBUG]: "debug",
|
|
13
|
+
[Level.INFO]: "info",
|
|
14
|
+
[Level.NOTICE]: "log",
|
|
15
|
+
[Level.WARNING]: "warning",
|
|
16
|
+
[Level.ERROR]: "error",
|
|
17
|
+
[Level.CRITICAL]: "fatal",
|
|
18
|
+
[Level.FATAL]: "fatal",
|
|
19
|
+
[Level.EMERGENCY]: "fatal",
|
|
20
20
|
// not a level
|
|
21
|
-
[Level.ALL]:
|
|
21
|
+
[Level.ALL]: "error",
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export interface MetadataWithError extends Metadata {
|
|
@@ -80,7 +80,7 @@ const createHandler = <S extends SentryRequiredMethods>(
|
|
|
80
80
|
delete extraData.error;
|
|
81
81
|
|
|
82
82
|
Sentry.captureException(error, {
|
|
83
|
-
level: mapToSentryLevel[level] ||
|
|
83
|
+
level: mapToSentryLevel[level] || "error",
|
|
84
84
|
user: getUser(record),
|
|
85
85
|
tags: {
|
|
86
86
|
loggerKey: key,
|
|
@@ -90,7 +90,7 @@ const createHandler = <S extends SentryRequiredMethods>(
|
|
|
90
90
|
});
|
|
91
91
|
} else if (shouldSendAsBreadcrumb(record)) {
|
|
92
92
|
Sentry.addBreadcrumb({
|
|
93
|
-
level: mapToSentryLevel[level] ||
|
|
93
|
+
level: mapToSentryLevel[level] || "error",
|
|
94
94
|
category: getBreadcrumbCategory(record),
|
|
95
95
|
type: getBreadcrumbType(record),
|
|
96
96
|
message: record.message,
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Level } from 'nightingale-levels';
|
|
2
|
-
|
|
3
|
-
const mapToSentryLevel = {
|
|
4
|
-
[Level.TRACE]: 'debug',
|
|
5
|
-
[Level.DEBUG]: 'debug',
|
|
6
|
-
[Level.INFO]: 'info',
|
|
7
|
-
[Level.NOTICE]: 'log',
|
|
8
|
-
[Level.WARNING]: 'warning',
|
|
9
|
-
[Level.ERROR]: 'error',
|
|
10
|
-
[Level.CRITICAL]: 'fatal',
|
|
11
|
-
[Level.FATAL]: 'fatal',
|
|
12
|
-
[Level.EMERGENCY]: 'fatal',
|
|
13
|
-
// not a level
|
|
14
|
-
[Level.ALL]: 'error'
|
|
15
|
-
};
|
|
16
|
-
const createHandler = (Sentry, {
|
|
17
|
-
getUser = () => undefined,
|
|
18
|
-
getTags = () => ({}),
|
|
19
|
-
getBreadcrumbCategory = () => undefined,
|
|
20
|
-
getBreadcrumbType = () => undefined,
|
|
21
|
-
shouldSendAsException = record => record.metadata?.error !== undefined && record.metadata.unhandled !== true,
|
|
22
|
-
shouldSendAsBreadcrumb = () => false
|
|
23
|
-
} = {}) => {
|
|
24
|
-
return record => {
|
|
25
|
-
const {
|
|
26
|
-
key,
|
|
27
|
-
level,
|
|
28
|
-
metadata,
|
|
29
|
-
extra,
|
|
30
|
-
message
|
|
31
|
-
} = record;
|
|
32
|
-
if (shouldSendAsException(record)) {
|
|
33
|
-
const error = metadata?.error || record.message;
|
|
34
|
-
const extraData = {
|
|
35
|
-
nightingaleErrorMessage: message,
|
|
36
|
-
...metadata,
|
|
37
|
-
...extra
|
|
38
|
-
};
|
|
39
|
-
delete extraData.error;
|
|
40
|
-
Sentry.captureException(error, {
|
|
41
|
-
level: mapToSentryLevel[level] || 'error',
|
|
42
|
-
user: getUser(record),
|
|
43
|
-
tags: {
|
|
44
|
-
loggerKey: key,
|
|
45
|
-
...getTags(record)
|
|
46
|
-
},
|
|
47
|
-
extra: extraData
|
|
48
|
-
});
|
|
49
|
-
} else if (shouldSendAsBreadcrumb(record)) {
|
|
50
|
-
Sentry.addBreadcrumb({
|
|
51
|
-
level: mapToSentryLevel[level] || 'error',
|
|
52
|
-
category: getBreadcrumbCategory(record),
|
|
53
|
-
type: getBreadcrumbType(record),
|
|
54
|
-
message: record.message,
|
|
55
|
-
data: record.metadata,
|
|
56
|
-
timestamp: record.datetime.getTime()
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
class SentryHandler {
|
|
62
|
-
constructor(Sentry, minLevel, options) {
|
|
63
|
-
this.minLevel = minLevel;
|
|
64
|
-
this.handle = createHandler(Sentry, options);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { SentryHandler };
|
|
69
|
-
//# sourceMappingURL=index-browsermodern.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-browsermodern.es.js","sources":["../src/index.ts"],"sourcesContent":["import type {\n addBreadcrumb,\n captureException,\n captureMessage,\n} from '@sentry/core';\nimport type { User, SeverityLevel } from '@sentry/types';\nimport { Level } from 'nightingale-levels';\nimport type { LogRecord, Handle, Metadata, Handler } from 'nightingale-types';\n\nconst mapToSentryLevel: Record<Level, SeverityLevel> = {\n [Level.TRACE]: 'debug',\n [Level.DEBUG]: 'debug',\n [Level.INFO]: 'info',\n [Level.NOTICE]: 'log',\n [Level.WARNING]: 'warning',\n [Level.ERROR]: 'error',\n [Level.CRITICAL]: 'fatal',\n [Level.FATAL]: 'fatal',\n [Level.EMERGENCY]: 'fatal',\n // not a level\n [Level.ALL]: 'error',\n};\n\nexport interface MetadataWithError extends Metadata {\n error?: Error;\n}\n\nexport interface Options {\n getUser?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => User | undefined;\n getTags?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => Record<string, string>;\n getBreadcrumbCategory?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n getBreadcrumbType?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n shouldSendAsException?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => boolean;\n shouldSendAsBreadcrumb?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => boolean;\n}\n\nexport interface SentryRequiredMethods {\n addBreadcrumb: typeof addBreadcrumb;\n captureException: typeof captureException;\n captureMessage: typeof captureMessage;\n}\n\nconst createHandler = <S extends SentryRequiredMethods>(\n Sentry: S,\n {\n getUser = () => undefined,\n getTags = () => ({}),\n getBreadcrumbCategory = () => undefined,\n getBreadcrumbType = () => undefined,\n shouldSendAsException = <T extends Metadata>(record: LogRecord<T>) =>\n record.metadata?.error !== undefined &&\n record.metadata.unhandled !== true,\n shouldSendAsBreadcrumb = <T extends Metadata>(record: LogRecord<T>) =>\n false,\n }: Options = {},\n): Handle => {\n return <T extends MetadataWithError>(record: LogRecord<T>) => {\n const { key, level, metadata, extra, message } = record;\n\n if (shouldSendAsException(record)) {\n const error = metadata?.error || record.message;\n\n const extraData: Record<string, unknown> = {\n nightingaleErrorMessage: message,\n ...metadata,\n ...extra,\n };\n delete extraData.error;\n\n Sentry.captureException(error, {\n level: mapToSentryLevel[level] || 'error',\n user: getUser(record),\n tags: {\n loggerKey: key,\n ...getTags(record),\n },\n extra: extraData,\n });\n } else if (shouldSendAsBreadcrumb(record)) {\n Sentry.addBreadcrumb({\n level: mapToSentryLevel[level] || 'error',\n category: getBreadcrumbCategory(record),\n type: getBreadcrumbType(record),\n message: record.message,\n data: record.metadata,\n timestamp: record.datetime.getTime(),\n });\n }\n };\n};\n\nexport class SentryHandler<S extends SentryRequiredMethods> implements Handler {\n minLevel: Level;\n\n handle: Handle;\n\n constructor(Sentry: S, minLevel: Level, options?: Options) {\n this.minLevel = minLevel;\n this.handle = createHandler<S>(Sentry, options);\n }\n}\n"],"names":["mapToSentryLevel","Level","TRACE","DEBUG","INFO","NOTICE","WARNING","ERROR","CRITICAL","FATAL","EMERGENCY","ALL","createHandler","Sentry","getUser","undefined","getTags","getBreadcrumbCategory","getBreadcrumbType","shouldSendAsException","record","metadata","error","unhandled","shouldSendAsBreadcrumb","key","level","extra","message","extraData","nightingaleErrorMessage","captureException","user","tags","loggerKey","addBreadcrumb","category","type","data","timestamp","datetime","getTime","SentryHandler","constructor","minLevel","options","handle"],"mappings":";;AASA,MAAMA,gBAA8C,GAAG;AACrD,EAAA,CAACC,KAAK,CAACC,KAAK,GAAG,OAAO;AACtB,EAAA,CAACD,KAAK,CAACE,KAAK,GAAG,OAAO;AACtB,EAAA,CAACF,KAAK,CAACG,IAAI,GAAG,MAAM;AACpB,EAAA,CAACH,KAAK,CAACI,MAAM,GAAG,KAAK;AACrB,EAAA,CAACJ,KAAK,CAACK,OAAO,GAAG,SAAS;AAC1B,EAAA,CAACL,KAAK,CAACM,KAAK,GAAG,OAAO;AACtB,EAAA,CAACN,KAAK,CAACO,QAAQ,GAAG,OAAO;AACzB,EAAA,CAACP,KAAK,CAACQ,KAAK,GAAG,OAAO;AACtB,EAAA,CAACR,KAAK,CAACS,SAAS,GAAG,OAAO;AAC1B;EACA,CAACT,KAAK,CAACU,GAAG,GAAG,OAAA;AACf,CAAC,CAAA;AAiCD,MAAMC,aAAa,GAAGA,CACpBC,MAAS,EACT;EACEC,OAAO,GAAGA,MAAMC,SAAS;AACzBC,EAAAA,OAAO,GAAGA,OAAO,EAAE,CAAC;EACpBC,qBAAqB,GAAGA,MAAMF,SAAS;EACvCG,iBAAiB,GAAGA,MAAMH,SAAS;AACnCI,EAAAA,qBAAqB,GAAwBC,MAAoB,IAC/DA,MAAM,CAACC,QAAQ,EAAEC,KAAK,KAAKP,SAAS,IACpCK,MAAM,CAACC,QAAQ,CAACE,SAAS,KAAK,IAAI;EACpCC,sBAAsB,GAAGA,MAC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,OAAO,EAAC;AACrC,OAAC,CAAC,CAAA;AACJ,KAAA;GACD,CAAA;AACH,CAAC,CAAA;AAEM,MAAMC,aAAa,CAAqD;AAK7EC,EAAAA,WAAWA,CAAC9B,MAAS,EAAE+B,QAAe,EAAEC,OAAiB,EAAE;IACzD,IAAI,CAACD,QAAQ,GAAGA,QAAQ,CAAA;IACxB,IAAI,CAACE,MAAM,GAAGlC,aAAa,CAAIC,MAAM,EAAEgC,OAAO,CAAC,CAAA;AACjD,GAAA;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-node18.mjs","sources":["../src/index.ts"],"sourcesContent":["import type {\n addBreadcrumb,\n captureException,\n captureMessage,\n} from '@sentry/core';\nimport type { User, SeverityLevel } from '@sentry/types';\nimport { Level } from 'nightingale-levels';\nimport type { LogRecord, Handle, Metadata, Handler } from 'nightingale-types';\n\nconst mapToSentryLevel: Record<Level, SeverityLevel> = {\n [Level.TRACE]: 'debug',\n [Level.DEBUG]: 'debug',\n [Level.INFO]: 'info',\n [Level.NOTICE]: 'log',\n [Level.WARNING]: 'warning',\n [Level.ERROR]: 'error',\n [Level.CRITICAL]: 'fatal',\n [Level.FATAL]: 'fatal',\n [Level.EMERGENCY]: 'fatal',\n // not a level\n [Level.ALL]: 'error',\n};\n\nexport interface MetadataWithError extends Metadata {\n error?: Error;\n}\n\nexport interface Options {\n getUser?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => User | undefined;\n getTags?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => Record<string, string>;\n getBreadcrumbCategory?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n getBreadcrumbType?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => string | undefined;\n shouldSendAsException?: <T extends MetadataWithError>(\n record: LogRecord<T>,\n ) => boolean;\n shouldSendAsBreadcrumb?: <T extends Metadata>(\n record: LogRecord<T>,\n ) => boolean;\n}\n\nexport interface SentryRequiredMethods {\n addBreadcrumb: typeof addBreadcrumb;\n captureException: typeof captureException;\n captureMessage: typeof captureMessage;\n}\n\nconst createHandler = <S extends SentryRequiredMethods>(\n Sentry: S,\n {\n getUser = () => undefined,\n getTags = () => ({}),\n getBreadcrumbCategory = () => undefined,\n getBreadcrumbType = () => undefined,\n shouldSendAsException = <T extends Metadata>(record: LogRecord<T>) =>\n record.metadata?.error !== undefined &&\n record.metadata.unhandled !== true,\n shouldSendAsBreadcrumb = <T extends Metadata>(record: LogRecord<T>) =>\n false,\n }: Options = {},\n): Handle => {\n return <T extends MetadataWithError>(record: LogRecord<T>) => {\n const { key, level, metadata, extra, message } = record;\n\n if (shouldSendAsException(record)) {\n const error = metadata?.error || record.message;\n\n const extraData: Record<string, unknown> = {\n nightingaleErrorMessage: message,\n ...metadata,\n ...extra,\n };\n delete extraData.error;\n\n Sentry.captureException(error, {\n level: mapToSentryLevel[level] || 'error',\n user: getUser(record),\n tags: {\n loggerKey: key,\n ...getTags(record),\n },\n extra: extraData,\n });\n } else if (shouldSendAsBreadcrumb(record)) {\n Sentry.addBreadcrumb({\n level: mapToSentryLevel[level] || 'error',\n category: getBreadcrumbCategory(record),\n type: getBreadcrumbType(record),\n message: record.message,\n data: record.metadata,\n timestamp: record.datetime.getTime(),\n });\n }\n };\n};\n\nexport class SentryHandler<S extends SentryRequiredMethods> implements Handler {\n minLevel: Level;\n\n handle: Handle;\n\n constructor(Sentry: S, minLevel: Level, options?: Options) {\n this.minLevel = minLevel;\n this.handle = createHandler<S>(Sentry, options);\n }\n}\n"],"names":["mapToSentryLevel","Level","TRACE","DEBUG","INFO","NOTICE","WARNING","ERROR","CRITICAL","FATAL","EMERGENCY","ALL","createHandler","Sentry","getUser","undefined","getTags","getBreadcrumbCategory","getBreadcrumbType","shouldSendAsException","record","metadata","error","unhandled","shouldSendAsBreadcrumb","key","level","extra","message","extraData","nightingaleErrorMessage","captureException","user","tags","loggerKey","addBreadcrumb","category","type","data","timestamp","datetime","getTime","SentryHandler","const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ACF;;;;"}
|
package/src/.eslintrc.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"parserOptions": {
|
|
5
|
-
"project": "packages/nightingale-sentry/tsconfig.json"
|
|
6
|
-
},
|
|
7
|
-
"plugins": ["@typescript-eslint"],
|
|
8
|
-
"extends": ["@pob/eslint-config-typescript"],
|
|
9
|
-
"ignorePatterns": ["*.d.ts"],
|
|
10
|
-
"overrides": [
|
|
11
|
-
{
|
|
12
|
-
"files": ["**/*.test.ts", "__tests__/**/*.ts"],
|
|
13
|
-
"extends": ["@pob/eslint-config-typescript/test"],
|
|
14
|
-
"env": {
|
|
15
|
-
"jest": true
|
|
16
|
-
},
|
|
17
|
-
"rules": {
|
|
18
|
-
"import/no-extraneous-dependencies": [
|
|
19
|
-
"error",
|
|
20
|
-
{
|
|
21
|
-
"devDependencies": true
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|