@driveflux/reporter 3.2.5 → 3.2.6

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
@@ -1,5 +1,16 @@
1
1
  # @flux/reporter
2
2
 
3
+ ## 3.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Minor upgrade for motorcycle
8
+ - Updated dependencies
9
+ - @driveflux/problem@2.2.12
10
+ - @driveflux/redact@1.1.10
11
+ - @driveflux/fetch@3.1.7
12
+ - @driveflux/utils@1.2.7
13
+
3
14
  ## 3.2.5
4
15
 
5
16
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/reporter",
3
- "version": "3.2.5",
3
+ "version": "3.2.6",
4
4
  "exports": {
5
5
  "./package.json": "./package.json",
6
6
  ".": {
@@ -21,10 +21,10 @@
21
21
  "@sentry/node": "^7.45.0",
22
22
  "flat": "^5.0.2",
23
23
  "rollbar": "^2.26.1",
24
- "@driveflux/fetch": "3.1.6",
25
- "@driveflux/problem": "2.2.11",
26
- "@driveflux/redact": "1.1.9",
27
- "@driveflux/utils": "1.2.6"
24
+ "@driveflux/fetch": "3.1.7",
25
+ "@driveflux/problem": "2.2.12",
26
+ "@driveflux/redact": "1.1.10",
27
+ "@driveflux/utils": "1.2.7"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/flat": "^5.0.2",
@@ -1,17 +0,0 @@
1
- export class ConsoleDriver {
2
- payload;
3
- async reportError(err, _) {
4
- console.error('An error happened');
5
- console.error('Error', err);
6
- console.error('Payload', this.payload);
7
- }
8
- async reportProblem(problem) {
9
- console.error('A problem happened');
10
- console.error('Problem', problem);
11
- console.error('Payload', this.payload);
12
- }
13
- setReporterPayload(payload) {
14
- this.payload = payload;
15
- }
16
- }
17
- //# sourceMappingURL=console.js.map
@@ -1,21 +0,0 @@
1
- import Rollbar from 'rollbar';
2
- export class RollbarDriver {
3
- rollbar;
4
- constructor(rollbarConfig) {
5
- this.rollbar = new Rollbar(rollbarConfig);
6
- }
7
- async reportError(err, metadata) {
8
- this.rollbar.error(err, metadata.request || {}, metadata.others);
9
- }
10
- async reportProblem(problem) {
11
- await new Promise((resolve) => {
12
- this.rollbar.error(problem.privateMetadata?.error || new Error(problem.message || problem.code), problem.privateMetadata?.request, problem.privateMetadata || {}, (error) => {
13
- resolve(error);
14
- });
15
- });
16
- }
17
- setReporterPayload(payload) {
18
- this.rollbar.configure({ payload });
19
- }
20
- }
21
- //# sourceMappingURL=rollbar.js.map
@@ -1,123 +0,0 @@
1
- import { enhancedFetch } from '@driveflux/fetch';
2
- import { isEmpty, omit } from '@driveflux/utils';
3
- import flat from 'flat';
4
- const lines = (object) => {
5
- return {
6
- type: 'section',
7
- fields: Object.keys(object).map((key) => ({
8
- type: 'mrkdwn',
9
- body: `*${key}:*\n${JSON.stringify(object[key])}`
10
- }))
11
- };
12
- };
13
- export class SlackDriver {
14
- accessToken;
15
- payload = {};
16
- channel;
17
- constructor(slackConfig) {
18
- this.accessToken = slackConfig.token;
19
- this.channel = slackConfig.errorChannelId;
20
- }
21
- async reportError(err, metadata) {
22
- const blocks = [
23
- {
24
- type: 'header',
25
- text: {
26
- type: 'plain_text',
27
- text: ':fire: Unexpected error happened',
28
- emoji: true
29
- }
30
- },
31
- {
32
- type: 'section',
33
- text: {
34
- type: 'mrkdwn',
35
- text: err.message
36
- }
37
- }
38
- ];
39
- this.standardBody(blocks, metadata);
40
- await this.slack(blocks);
41
- }
42
- async reportProblem(problem) {
43
- const blocks = [
44
- {
45
- type: 'header',
46
- text: {
47
- type: 'plain_text',
48
- text: 'Problem',
49
- emoji: true
50
- }
51
- },
52
- {
53
- type: 'section',
54
- text: {
55
- type: 'mrkdwn',
56
- text: `*Code:*: ${problem.code}\n*Message:* ${problem.message}`
57
- }
58
- }
59
- ];
60
- this.standardBody(blocks, problem.metadata);
61
- await this.slack(blocks);
62
- }
63
- setReporterPayload(payload) {
64
- this.payload = payload;
65
- }
66
- async slack(blocks) {
67
- return await enhancedFetch('https://slack.com/api/chat.postMessage', {
68
- method: 'POST',
69
- headers: {
70
- Authorization: `Bearer ${this.accessToken}`
71
- },
72
- body: JSON.stringify({
73
- channel: this.channel,
74
- blocks,
75
- })
76
- });
77
- }
78
- standardBody(blocks, metadata) {
79
- if (metadata?.request) {
80
- blocks.push({
81
- type: 'section',
82
- text: {
83
- type: "plain_text",
84
- text: "Request:",
85
- }
86
- });
87
- blocks.push({
88
- type: 'section',
89
- fields: [
90
- {
91
- type: 'mrkdwn',
92
- body: `*URL:*\n${metadata.request?.url}`
93
- },
94
- {
95
- type: 'mrkdwn',
96
- body: `*Method:*\n${metadata.request?.method}`
97
- }
98
- ]
99
- });
100
- }
101
- if (metadata) {
102
- blocks.push({
103
- type: 'section',
104
- text: {
105
- type: "plain_text",
106
- text: "Other Information:",
107
- }
108
- });
109
- blocks.push(lines(flat(omit(metadata, 'request'))));
110
- }
111
- if (!isEmpty(this.payload)) {
112
- blocks.push({
113
- type: 'section',
114
- text: {
115
- type: "plain_text",
116
- text: "Other Information:",
117
- }
118
- });
119
- blocks.push(lines(flat(this.payload)));
120
- }
121
- }
122
- }
123
- //# sourceMappingURL=slack.js.map