@naturalcycles/backend-lib 4.14.2 → 4.16.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/cfg/tsconfig.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
{
|
|
7
7
|
"compilerOptions": {
|
|
8
8
|
// Target/module
|
|
9
|
-
"target": "
|
|
9
|
+
"target": "es2022",
|
|
10
10
|
"lib": ["esnext"], // add "dom" if needed
|
|
11
11
|
"module": "commonjs",
|
|
12
12
|
"moduleResolution": "node",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"noImplicitOverride": true,
|
|
25
25
|
"noUncheckedIndexedAccess": true,
|
|
26
26
|
"noPropertyAccessFromIndexSignature": true,
|
|
27
|
+
// Otherwise since es2022 it defaults to true
|
|
28
|
+
// and starts to produce different/unexpected behavior
|
|
29
|
+
// https://angular.schule/blog/2022-11-use-define-for-class-fields
|
|
30
|
+
"useDefineForClassFields": false,
|
|
27
31
|
|
|
28
32
|
// Enabled should be faster, but will catch less errors
|
|
29
33
|
// "skipLibCheck": true,
|
|
@@ -6,7 +6,7 @@ const js_lib_1 = require("@naturalcycles/js-lib");
|
|
|
6
6
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
7
7
|
const yaml = require("js-yaml");
|
|
8
8
|
const APP_YAML_DEFAULT = () => ({
|
|
9
|
-
runtime: '
|
|
9
|
+
runtime: 'nodejs18',
|
|
10
10
|
service: 'default',
|
|
11
11
|
inbound_services: ['warmup'],
|
|
12
12
|
instance_class: 'F1',
|
|
@@ -76,6 +76,12 @@ class SentrySharedService {
|
|
|
76
76
|
// Skip reporting the error
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
+
if (err?.data?.reportRate) {
|
|
80
|
+
const reportRate = err.data.reportRate;
|
|
81
|
+
// E.g rate of 0.1 means 10% of errors are reported
|
|
82
|
+
if (Math.random() > reportRate)
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
79
85
|
// This is to avoid Sentry cutting err.message to 253 characters
|
|
80
86
|
// It will log additional "breadcrumb object" before the error
|
|
81
87
|
// It's a Breadcrumb, not a console.log, because console.log are NOT automatically attached as Breadcrumbs in cron-job environments (outside of Express)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install && patch-package",
|
|
6
6
|
"serve": "APP_ENV=dev nodemon",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"url": "https://github.com/NaturalCycles/backend-lib"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
|
-
"node": ">=
|
|
81
|
+
"node": ">=18.12.0"
|
|
82
82
|
},
|
|
83
83
|
"type": "commonjs",
|
|
84
84
|
"description": "Standard library for making Express.js / AppEngine based backend services",
|
|
@@ -6,7 +6,7 @@ import { BackendCfg } from './backend.cfg.util'
|
|
|
6
6
|
import { AppYaml, DeployInfo } from './deploy.model'
|
|
7
7
|
|
|
8
8
|
const APP_YAML_DEFAULT = (): AppYaml => ({
|
|
9
|
-
runtime: '
|
|
9
|
+
runtime: 'nodejs18',
|
|
10
10
|
service: 'default',
|
|
11
11
|
inbound_services: ['warmup'],
|
|
12
12
|
instance_class: 'F1',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _anyToError, _Memo, CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib'
|
|
1
|
+
import { _anyToError, _Memo, AppError, CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib'
|
|
2
2
|
import { inspectAny } from '@naturalcycles/nodejs-lib'
|
|
3
3
|
import type { Breadcrumb, NodeOptions, SeverityLevel } from '@sentry/node'
|
|
4
4
|
import type * as SentryLib from '@sentry/node'
|
|
@@ -88,6 +88,12 @@ export class SentrySharedService {
|
|
|
88
88
|
return
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
if (err?.data?.reportRate) {
|
|
92
|
+
const reportRate = (err as AppError).data.reportRate!
|
|
93
|
+
// E.g rate of 0.1 means 10% of errors are reported
|
|
94
|
+
if (Math.random() > reportRate) return
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
// This is to avoid Sentry cutting err.message to 253 characters
|
|
92
98
|
// It will log additional "breadcrumb object" before the error
|
|
93
99
|
// It's a Breadcrumb, not a console.log, because console.log are NOT automatically attached as Breadcrumbs in cron-job environments (outside of Express)
|