@naturalcycles/backend-lib 4.5.1 → 4.6.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.
@@ -32,7 +32,7 @@ async function createAndSaveDeployInfo(backendCfg, targetDir) {
32
32
  }
33
33
  exports.createAndSaveDeployInfo = createAndSaveDeployInfo;
34
34
  async function createDeployInfo(backendCfg) {
35
- const simpleGit = require('simple-git/promise'); // lazy load
35
+ const simpleGit = require('simple-git'); // lazy load
36
36
  const git = simpleGit('.');
37
37
  const now = (0, js_lib_1.localTime)();
38
38
  const gitBranch = (await git.status()).current;
@@ -43,6 +43,7 @@ const DEFAULT_FILES = [
43
43
  'secret/**/*.enc',
44
44
  'package.json',
45
45
  'yarn.lock',
46
+ '.yarnrc',
46
47
  'tsconfig.json',
47
48
  'tsconfig.dist.json',
48
49
  '.gcloudignore',
@@ -27,9 +27,9 @@ export declare class SentrySharedService {
27
27
  setUserId(id: string): void;
28
28
  /**
29
29
  * Does console.error(err)
30
- * Returns "eventId"
30
+ * Returns "eventId" or undefined (if error was not reported).
31
31
  */
32
- captureException(err: any, logError?: boolean): string;
32
+ captureException(err: any, logError?: boolean): string | undefined;
33
33
  /**
34
34
  * Returns "eventId"
35
35
  */
@@ -64,7 +64,7 @@ class SentrySharedService {
64
64
  }
65
65
  /**
66
66
  * Does console.error(err)
67
- * Returns "eventId"
67
+ * Returns "eventId" or undefined (if error was not reported).
68
68
  */
69
69
  captureException(err, logError = true) {
70
70
  // console.error(err)
@@ -72,7 +72,11 @@ class SentrySharedService {
72
72
  if (logError) {
73
73
  (0, index_1.getRequestLogger)().error('captureException:', err);
74
74
  }
75
- // This is to avoid Sentry cutting the err.message to 253 characters
75
+ if (err?.data?.report === false) {
76
+ // Skip reporting the error
77
+ return;
78
+ }
79
+ // This is to avoid Sentry cutting err.message to 253 characters
76
80
  // It will log additional "breadcrumb object" before the error
77
81
  // It's a Breadcrumb, not a console.log, because console.log are NOT automatically attached as Breadcrumbs in cron-job environments (outside of Express)
78
82
  this.sentry().addBreadcrumb({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install && patch-package",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -40,7 +40,7 @@ export async function createAndSaveDeployInfo(
40
40
  }
41
41
 
42
42
  export async function createDeployInfo(backendCfg: BackendCfg): Promise<DeployInfo> {
43
- const simpleGit = require('simple-git/promise') as typeof simpleGitLib // lazy load
43
+ const simpleGit = require('simple-git') as typeof simpleGitLib // lazy load
44
44
  const git = simpleGit('.')
45
45
 
46
46
  const now = localTime()
@@ -55,6 +55,7 @@ const DEFAULT_FILES = [
55
55
  'secret/**/*.enc', // encrypted secrets
56
56
  'package.json',
57
57
  'yarn.lock',
58
+ '.yarnrc',
58
59
  'tsconfig.json', // for path-mapping to work!
59
60
  'tsconfig.dist.json',
60
61
  '.gcloudignore',
@@ -74,16 +74,21 @@ export class SentrySharedService {
74
74
 
75
75
  /**
76
76
  * Does console.error(err)
77
- * Returns "eventId"
77
+ * Returns "eventId" or undefined (if error was not reported).
78
78
  */
79
- captureException(err: any, logError = true): string {
79
+ captureException(err: any, logError = true): string | undefined {
80
80
  // console.error(err)
81
81
  // Using request-aware logger here
82
82
  if (logError) {
83
83
  getRequestLogger().error('captureException:', err)
84
84
  }
85
85
 
86
- // This is to avoid Sentry cutting the err.message to 253 characters
86
+ if (err?.data?.report === false) {
87
+ // Skip reporting the error
88
+ return
89
+ }
90
+
91
+ // This is to avoid Sentry cutting err.message to 253 characters
87
92
  // It will log additional "breadcrumb object" before the error
88
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)
89
94
  this.sentry().addBreadcrumb({