@naturalcycles/backend-lib 5.0.1 → 5.1.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.
@@ -22,7 +22,6 @@ async function deployGae(opt = {}) {
22
22
  gaeService,
23
23
  gaeVersion,
24
24
  });
25
- (0, nodejs_lib_1.appendToGithubSummary)(`[versionUrl](${versionUrl})`);
26
25
  await (0, js_lib_1.pRetry)(async () => {
27
26
  try {
28
27
  (0, nodejs_lib_1.execVoidCommandSync)(`gcloud app deploy ${appYamlPath} --project ${gaeProject} --version ${gaeVersion} --quiet --no-promote`, [], { shell: true });
@@ -53,6 +52,7 @@ async function deployGae(opt = {}) {
53
52
  // yarn deploy-health-check --url $deployInfo_serviceUrl --repeat 3 --timeoutSec 60 --intervalSec 2
54
53
  await (0, deployHealthCheck_1.deployHealthCheck)(serviceUrl, opt);
55
54
  }
55
+ (0, nodejs_lib_1.appendToGithubSummary)(`Deployed ${serviceUrl}`);
56
56
  // Logs
57
57
  if (logOnSuccess) {
58
58
  logs(gaeProject, gaeService, gaeVersion);
@@ -73,6 +73,7 @@ async function undeployGae(branch) {
73
73
  // }
74
74
  console.log(`undeployGae (branch: ${branch}): going to remove ${gaeProject}/${gaeService}/${gaeVersion}`);
75
75
  (0, nodejs_lib_1.execVoidCommandSync)(`gcloud app versions delete --project ${gaeProject} --service ${gaeService} ${gaeVersion} --quiet`, [], { shell: true });
76
+ (0, nodejs_lib_1.appendToGithubSummary)(`removed ${gaeProject}/${gaeService}/${gaeVersion}`);
76
77
  }
77
78
  exports.undeployGae = undeployGae;
78
79
  function logs(gaeProject, gaeService, gaeVersion) {
@@ -1,4 +1,4 @@
1
- import { CommonLogger } from '@naturalcycles/js-lib';
1
+ import { CommonLogger, Primitive, StringMap } from '@naturalcycles/js-lib';
2
2
  import type { Breadcrumb, NodeOptions, SeverityLevel } from '@sentry/node';
3
3
  import type * as SentryLib from '@sentry/node';
4
4
  import { BackendErrorRequestHandler, BackendRequestHandler } from '../index';
@@ -24,7 +24,17 @@ export declare class SentrySharedService {
24
24
  /**
25
25
  * For GDPR reasons we never send more information than just User ID.
26
26
  */
27
- setUserId(id: string): void;
27
+ setUserId(id: string | null): void;
28
+ /**
29
+ * Tag keys have a maximum length of 32 characters and can contain only
30
+ * letters (a-zA-Z), numbers (0-9), underscores (_), periods (.), colons (:), and dashes (-).
31
+ *
32
+ * Tag values have a maximum length of 200 characters and they
33
+ * cannot contain the newline (\n) character.
34
+ *
35
+ * https://docs.sentry.io/platforms/node/enriching-events/scopes/
36
+ */
37
+ setTags(tags: StringMap<Primitive>): void;
28
38
  /**
29
39
  * Does console.log(err)
30
40
  * Returns "eventId" or undefined (if error was not reported).
@@ -60,12 +60,26 @@ class SentrySharedService {
60
60
  * For GDPR reasons we never send more information than just User ID.
61
61
  */
62
62
  setUserId(id) {
63
- this.sentry().configureScope(scope => {
64
- scope.setUser({
65
- id,
66
- });
63
+ if (id === null) {
64
+ this.sentry().setUser(null);
65
+ return;
66
+ }
67
+ this.sentry().setUser({
68
+ id,
67
69
  });
68
70
  }
71
+ /**
72
+ * Tag keys have a maximum length of 32 characters and can contain only
73
+ * letters (a-zA-Z), numbers (0-9), underscores (_), periods (.), colons (:), and dashes (-).
74
+ *
75
+ * Tag values have a maximum length of 200 characters and they
76
+ * cannot contain the newline (\n) character.
77
+ *
78
+ * https://docs.sentry.io/platforms/node/enriching-events/scopes/
79
+ */
80
+ setTags(tags) {
81
+ this.sentry().setTags(tags);
82
+ }
69
83
  /**
70
84
  * Does console.log(err)
71
85
  * Returns "eventId" or undefined (if error was not reported).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "dev": "APP_ENV=dev nodemon",
@@ -29,8 +29,6 @@ export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
29
29
  gaeVersion,
30
30
  })
31
31
 
32
- appendToGithubSummary(`[versionUrl](${versionUrl})`)
33
-
34
32
  await pRetry(
35
33
  async () => {
36
34
  try {
@@ -75,6 +73,8 @@ export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
75
73
  await deployHealthCheck(serviceUrl, opt)
76
74
  }
77
75
 
76
+ appendToGithubSummary(`Deployed ${serviceUrl}`)
77
+
78
78
  // Logs
79
79
  if (logOnSuccess) {
80
80
  logs(gaeProject, gaeService, gaeVersion)
@@ -105,6 +105,8 @@ export async function undeployGae(branch: string): Promise<void> {
105
105
  [],
106
106
  { shell: true },
107
107
  )
108
+
109
+ appendToGithubSummary(`removed ${gaeProject}/${gaeService}/${gaeVersion}`)
108
110
  }
109
111
 
110
112
  function logs(gaeProject: string, gaeService: string, gaeVersion: string): void {
@@ -4,6 +4,8 @@ import {
4
4
  _Memo,
5
5
  CommonLogger,
6
6
  CommonLogLevel,
7
+ Primitive,
8
+ StringMap,
7
9
  } from '@naturalcycles/js-lib'
8
10
  import { _inspect, InspectAnyOptions } from '@naturalcycles/nodejs-lib'
9
11
  // eslint-disable-next-line import/no-duplicates
@@ -77,14 +79,30 @@ export class SentrySharedService {
77
79
  /**
78
80
  * For GDPR reasons we never send more information than just User ID.
79
81
  */
80
- setUserId(id: string): void {
81
- this.sentry().configureScope(scope => {
82
- scope.setUser({
83
- id,
84
- })
82
+ setUserId(id: string | null): void {
83
+ if (id === null) {
84
+ this.sentry().setUser(null)
85
+ return
86
+ }
87
+
88
+ this.sentry().setUser({
89
+ id,
85
90
  })
86
91
  }
87
92
 
93
+ /**
94
+ * Tag keys have a maximum length of 32 characters and can contain only
95
+ * letters (a-zA-Z), numbers (0-9), underscores (_), periods (.), colons (:), and dashes (-).
96
+ *
97
+ * Tag values have a maximum length of 200 characters and they
98
+ * cannot contain the newline (\n) character.
99
+ *
100
+ * https://docs.sentry.io/platforms/node/enriching-events/scopes/
101
+ */
102
+ setTags(tags: StringMap<Primitive>): void {
103
+ this.sentry().setTags(tags)
104
+ }
105
+
88
106
  /**
89
107
  * Does console.log(err)
90
108
  * Returns "eventId" or undefined (if error was not reported).