@naturalcycles/backend-lib 4.18.2 → 4.18.4

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.
@@ -13,6 +13,9 @@ const sentrySeverityMap = {
13
13
  error: 'error',
14
14
  fatal: 'error',
15
15
  };
16
+ const INSPECT_OPT = {
17
+ colors: false,
18
+ };
16
19
  class SentrySharedService {
17
20
  constructor(sentryServiceCfg) {
18
21
  this.sentryServiceCfg = sentryServiceCfg;
@@ -89,9 +92,10 @@ class SentrySharedService {
89
92
  // It will log additional "breadcrumb object" before the error
90
93
  // It's a Breadcrumb, not a console.log, because console.log are NOT automatically attached as Breadcrumbs in cron-job environments (outside of Express)
91
94
  this.sentry().addBreadcrumb({
92
- message: (0, nodejs_lib_1.inspectAny)(err, {
93
- colors: false,
94
- }),
95
+ message: [err, data]
96
+ .filter(Boolean)
97
+ .map(a => (0, nodejs_lib_1.inspectAny)(a, INSPECT_OPT))
98
+ .join('\n'),
95
99
  });
96
100
  return this.sentry().captureException(err);
97
101
  }
@@ -117,11 +121,7 @@ class SentrySharedService {
117
121
  log: () => { },
118
122
  warn: () => { },
119
123
  error: (...args) => {
120
- const message = args
121
- .map(arg => (0, nodejs_lib_1.inspectAny)(arg, {
122
- colors: false,
123
- }))
124
- .join(' ');
124
+ const message = args.map(arg => (0, nodejs_lib_1.inspectAny)(arg, INSPECT_OPT)).join(' ');
125
125
  this.sentry().addBreadcrumb({
126
126
  message,
127
127
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.18.2",
3
+ "version": "4.18.4",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -6,7 +6,7 @@ import {
6
6
  CommonLogLevel,
7
7
  ErrorData,
8
8
  } from '@naturalcycles/js-lib'
9
- import { inspectAny } from '@naturalcycles/nodejs-lib'
9
+ import { inspectAny, InspectAnyOptions } from '@naturalcycles/nodejs-lib'
10
10
  import type { Breadcrumb, NodeOptions, SeverityLevel } from '@sentry/node'
11
11
  import type * as SentryLib from '@sentry/node'
12
12
  import { BackendErrorRequestHandler, BackendRequestHandler, getRequestLogger } from '../index'
@@ -22,6 +22,10 @@ const sentrySeverityMap: Record<SeverityLevel, CommonLogLevel> = {
22
22
  fatal: 'error',
23
23
  }
24
24
 
25
+ const INSPECT_OPT: InspectAnyOptions = {
26
+ colors: false,
27
+ }
28
+
25
29
  export class SentrySharedService {
26
30
  constructor(private sentryServiceCfg: SentrySharedServiceCfg) {}
27
31
 
@@ -109,9 +113,10 @@ export class SentrySharedService {
109
113
  // It will log additional "breadcrumb object" before the error
110
114
  // It's a Breadcrumb, not a console.log, because console.log are NOT automatically attached as Breadcrumbs in cron-job environments (outside of Express)
111
115
  this.sentry().addBreadcrumb({
112
- message: inspectAny(err, {
113
- colors: false,
114
- }),
116
+ message: [err, data]
117
+ .filter(Boolean)
118
+ .map(a => inspectAny(a, INSPECT_OPT))
119
+ .join('\n'),
115
120
  })
116
121
 
117
122
  return this.sentry().captureException(err)
@@ -141,13 +146,7 @@ export class SentrySharedService {
141
146
  log: () => {}, // noop
142
147
  warn: () => {}, // noop
143
148
  error: (...args) => {
144
- const message = args
145
- .map(arg =>
146
- inspectAny(arg, {
147
- colors: false,
148
- }),
149
- )
150
- .join(' ')
149
+ const message = args.map(arg => inspectAny(arg, INSPECT_OPT)).join(' ')
151
150
 
152
151
  this.sentry().addBreadcrumb({
153
152
  message,