nightingale-sentry 15.0.0 → 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 CHANGED
@@ -3,6 +3,21 @@
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
+
6
21
  ## [15.0.0](https://github.com/christophehurpeau/nightingale/compare/v14.2.1...v15.0.0) (2023-12-25)
7
22
 
8
23
 
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- <h3 align="center">
1
+ <h1 align="center">
2
2
  nightingale-sentry
3
- </h3>
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 '@sentry/node';
31
- import { configure, Level, listenUnhandledErrors } from 'nightingale';
32
- import { SentryHandler } from 'nightingale-sentry';
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 === 'production' ? '__DSN__' : undefined,
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 '@sentry/browser';
68
- import { addConfig, Level } from 'nightingale-app';
69
- import SentryHandler from 'nightingale-sentry';
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 === 'production' ? '__DSN__' : undefined,
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 '@sentry/browser';
98
- import { configure, Level } from 'nightingale';
99
- import { SentryHandler } from 'nightingale-sentry';
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 === 'production' ? '__DSN__' : undefined,
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 '@sentry/core';
2
- import type { User } from '@sentry/types';
3
- import { Level } from 'nightingale-levels';
4
- import type { LogRecord, Handle, Metadata, Handler } from 'nightingale-types';
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,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAgB9E,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,CAAC,CAAC,SAAS,iBAAiB,EACpC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,KACjB,IAAI,GAAG,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,CAAC,CAAC,SAAS,iBAAiB,EACpC,MAAM,EAAE,SAAS,CAAC,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 -1,27 +1,24 @@
1
1
  import { Level } from 'nightingale-levels';
2
2
 
3
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',
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]: 'error'
14
+ [Level.ALL]: "error"
15
15
  };
16
16
  const createHandler = (Sentry, {
17
17
  getUser = () => undefined,
18
18
  getTags = () => ({}),
19
19
  getBreadcrumbCategory = () => undefined,
20
20
  getBreadcrumbType = () => undefined,
21
- shouldSendAsException = record => {
22
- var _record$metadata;
23
- return ((_record$metadata = record.metadata) == null ? void 0 : _record$metadata.error) !== undefined && record.metadata.unhandled !== true;
24
- },
21
+ shouldSendAsException = record => record.metadata?.error !== undefined && record.metadata.unhandled !== true,
25
22
  shouldSendAsBreadcrumb = () => false
26
23
  } = {}) => {
27
24
  return record => {
@@ -33,7 +30,7 @@ const createHandler = (Sentry, {
33
30
  message
34
31
  } = record;
35
32
  if (shouldSendAsException(record)) {
36
- const error = (metadata == null ? void 0 : metadata.error) || record.message;
33
+ const error = metadata?.error || record.message;
37
34
  const extraData = {
38
35
  nightingaleErrorMessage: message,
39
36
  ...metadata,
@@ -41,7 +38,7 @@ const createHandler = (Sentry, {
41
38
  };
42
39
  delete extraData.error;
43
40
  Sentry.captureException(error, {
44
- level: mapToSentryLevel[level] || 'error',
41
+ level: mapToSentryLevel[level] || "error",
45
42
  user: getUser(record),
46
43
  tags: {
47
44
  loggerKey: key,
@@ -51,7 +48,7 @@ const createHandler = (Sentry, {
51
48
  });
52
49
  } else if (shouldSendAsBreadcrumb(record)) {
53
50
  Sentry.addBreadcrumb({
54
- level: mapToSentryLevel[level] || 'error',
51
+ level: mapToSentryLevel[level] || "error",
55
52
  category: getBreadcrumbCategory(record),
56
53
  type: getBreadcrumbType(record),
57
54
  message: record.message,
@@ -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 '@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","_record$metadata","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,CAAC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,IAAI,CAACE,MAAM,GAAGnC,aAAa,CAAIC,MAAM,EAAEiC,OAAO,CAAC,CAAA;AACjD,GAAA;AACF;;;;"}
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,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,GAA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I,OAAO;AACzCM,QAAAA,IAAI,EAAElB,OAAO,CAACM,MAAM,CAAC;AACrBa,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;;;;"}
@@ -1,17 +1,17 @@
1
1
  import { Level } from 'nightingale-levels';
2
2
 
3
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',
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]: 'error'
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] || 'error',
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] || 'error',
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-node18.mjs.map
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;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;AACf,CAAC;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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,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": "15.0.0",
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": ">=18.12.0"
19
+ "node": ">=20.9.0"
20
20
  },
21
- "browserslist": {
22
- "production": [
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,14 +28,13 @@
36
28
  ".": {
37
29
  "types": "./dist/definitions/index.d.ts",
38
30
  "node": {
39
- "import": "./dist/index-node18.mjs"
31
+ "import": "./dist/index-node20.mjs"
40
32
  },
41
33
  "browser": {
42
34
  "import": "./dist/index-browser.es.js"
43
35
  }
44
36
  }
45
37
  },
46
- "sideEffects": false,
47
38
  "files": [
48
39
  "src",
49
40
  "dist"
@@ -54,34 +45,44 @@
54
45
  "clean": "yarn clean:build",
55
46
  "clean:build": "pob-babel-clean-out dist",
56
47
  "lint": "yarn run lint:eslint",
57
- "lint:eslint": "yarn ../.. run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/nightingale-sentry",
48
+ "lint:eslint": "yarn ../.. run eslint --quiet packages/nightingale-sentry",
58
49
  "watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
59
50
  },
60
- "prettier": "@pob/root/prettier-config",
51
+ "browserslist": {
52
+ "production": [
53
+ "defaults",
54
+ "> 0.2%",
55
+ "not ie < 12",
56
+ "not safari < 10",
57
+ "not ios_saf < 10"
58
+ ]
59
+ },
61
60
  "pob": {
62
- "babelEnvs": [
61
+ "bundler": "rollup-babel",
62
+ "entries": [
63
+ "index"
64
+ ],
65
+ "envs": [
63
66
  {
64
67
  "target": "node",
65
- "version": "18"
68
+ "version": "20"
66
69
  },
67
70
  {
68
71
  "target": "browser"
69
72
  }
70
- ],
71
- "entries": [
72
- "index"
73
73
  ]
74
74
  },
75
+ "prettier": "@pob/root/prettier-config",
75
76
  "dependencies": {
76
- "@sentry/core": "^7.19.0",
77
- "@sentry/types": "^7.19.0",
78
- "nightingale-levels": "15.0.0",
79
- "nightingale-types": "15.0.0"
77
+ "@sentry/core": "^7.120.3",
78
+ "@sentry/types": "^7.120.3",
79
+ "nightingale-levels": "16.0.0",
80
+ "nightingale-types": "16.0.0"
80
81
  },
81
82
  "devDependencies": {
82
- "@babel/core": "7.23.6",
83
- "@babel/preset-env": "7.23.6",
84
- "pob-babel": "38.0.0",
85
- "typescript": "5.3.3"
83
+ "@babel/core": "7.26.10",
84
+ "@babel/preset-env": "7.26.9",
85
+ "pob-babel": "43.4.0",
86
+ "typescript": "5.8.2"
86
87
  }
87
88
  }
package/src/index.ts CHANGED
@@ -2,23 +2,23 @@ import type {
2
2
  addBreadcrumb,
3
3
  captureException,
4
4
  captureMessage,
5
- } from '@sentry/core';
6
- import type { User, SeverityLevel } from '@sentry/types';
7
- import { Level } from 'nightingale-levels';
8
- import type { LogRecord, Handle, Metadata, Handler } from 'nightingale-types';
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]: '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',
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]: 'error',
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] || 'error',
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] || 'error',
93
+ level: mapToSentryLevel[level] || "error",
94
94
  category: getBreadcrumbCategory(record),
95
95
  type: getBreadcrumbType(record),
96
96
  message: record.message,
@@ -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","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,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AClB;AACDO,QAAAA,KAAK,EAAEE,SAAAA;AACT,OAAC,CAAC,CAAA;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,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,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
- }