@driveflux/reporter 5.0.2 → 5.0.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.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +13 -0
- package/package.json +3 -3
- package/dist/drivers/console.js +0 -17
- package/dist/drivers/rollbar.js +0 -21
- package/dist/drivers/slack.js +0 -129
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
> @driveflux/reporter@5.0.
|
|
2
|
+
> @driveflux/reporter@5.0.4 build /Users/flux/Projects/flux/packages/reporter
|
|
3
3
|
> npm run clean && npm run build:types && npm run build:js
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @driveflux/reporter@5.0.
|
|
6
|
+
> @driveflux/reporter@5.0.4 clean
|
|
7
7
|
> del dist/**/*.js
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @driveflux/reporter@5.0.
|
|
10
|
+
> @driveflux/reporter@5.0.4 build:types
|
|
11
11
|
> tsc --build
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
> @driveflux/reporter@5.0.
|
|
14
|
+
> @driveflux/reporter@5.0.4 build:js
|
|
15
15
|
> node -r esbuild-register build.js
|
|
16
16
|
|
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/reporter",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"module": "dist/index.js",
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@driveflux/fetch": "6.0.
|
|
22
|
+
"@driveflux/fetch": "6.0.3",
|
|
23
23
|
"@driveflux/problem": "4.0.2",
|
|
24
24
|
"@driveflux/redact": "4.0.2",
|
|
25
|
-
"@driveflux/utils": "3.0.
|
|
25
|
+
"@driveflux/utils": "3.0.3",
|
|
26
26
|
"@sentry/node": "^7.110.0",
|
|
27
27
|
"flat": "6.0.1",
|
|
28
28
|
"rollbar": "^2.26.4"
|
package/dist/drivers/console.js
DELETED
|
@@ -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
|
package/dist/drivers/rollbar.js
DELETED
|
@@ -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
|
package/dist/drivers/slack.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { enhancedFetch } from '@driveflux/fetch';
|
|
2
|
-
import { ProblemSeverity, hasSeverityGte } from '@driveflux/problem';
|
|
3
|
-
import { isEmpty, omit } from '@driveflux/utils';
|
|
4
|
-
import { flatten } from 'flat';
|
|
5
|
-
import { config } from '../config.js';
|
|
6
|
-
const lines = (object) => {
|
|
7
|
-
return {
|
|
8
|
-
type: 'section',
|
|
9
|
-
fields: Object.keys(object).map((key) => ({
|
|
10
|
-
type: 'mrkdwn',
|
|
11
|
-
body: `*${key}:*\n${JSON.stringify(object[key])}`
|
|
12
|
-
}))
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export class SlackDriver {
|
|
16
|
-
accessToken;
|
|
17
|
-
payload = {};
|
|
18
|
-
channel;
|
|
19
|
-
constructor(slackConfig) {
|
|
20
|
-
this.accessToken = slackConfig.token;
|
|
21
|
-
this.channel = slackConfig.errorChannelId;
|
|
22
|
-
}
|
|
23
|
-
async reportError(err, metadata) {
|
|
24
|
-
// We won't check for severity for Error objects as they are most likely always critical
|
|
25
|
-
const blocks = [
|
|
26
|
-
{
|
|
27
|
-
type: 'header',
|
|
28
|
-
text: {
|
|
29
|
-
type: 'mrkdwn',
|
|
30
|
-
text: ':fire: Unexpected error happened',
|
|
31
|
-
emoji: true
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: 'section',
|
|
36
|
-
text: {
|
|
37
|
-
type: 'mrkdwn',
|
|
38
|
-
text: err.message
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
];
|
|
42
|
-
this.standardBody(blocks, metadata);
|
|
43
|
-
await this.slack(blocks);
|
|
44
|
-
}
|
|
45
|
-
async reportProblem(problem) {
|
|
46
|
-
if (!hasSeverityGte(problem, config.slack?.minimumSeverity || ProblemSeverity.CRITICAL)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const blocks = [
|
|
50
|
-
{
|
|
51
|
-
type: 'header',
|
|
52
|
-
text: {
|
|
53
|
-
type: 'plain_text',
|
|
54
|
-
text: 'Problem',
|
|
55
|
-
emoji: true
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: 'section',
|
|
60
|
-
text: {
|
|
61
|
-
type: 'mrkdwn',
|
|
62
|
-
text: `*Code:*: ${problem.code}\n*Message:* ${problem.message}`
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
];
|
|
66
|
-
this.standardBody(blocks, problem.metadata);
|
|
67
|
-
await this.slack(blocks);
|
|
68
|
-
}
|
|
69
|
-
setReporterPayload(payload) {
|
|
70
|
-
this.payload = payload;
|
|
71
|
-
}
|
|
72
|
-
async slack(blocks) {
|
|
73
|
-
return await enhancedFetch('https://slack.com/api/chat.postMessage', {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
headers: {
|
|
76
|
-
Authorization: `Bearer ${this.accessToken}`
|
|
77
|
-
},
|
|
78
|
-
body: JSON.stringify({
|
|
79
|
-
channel: this.channel,
|
|
80
|
-
blocks
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
standardBody(blocks, metadata) {
|
|
85
|
-
if (metadata?.request) {
|
|
86
|
-
blocks.push({
|
|
87
|
-
type: 'section',
|
|
88
|
-
text: {
|
|
89
|
-
type: 'plain_text',
|
|
90
|
-
text: 'Request:'
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
blocks.push({
|
|
94
|
-
type: 'section',
|
|
95
|
-
fields: [
|
|
96
|
-
{
|
|
97
|
-
type: 'mrkdwn',
|
|
98
|
-
body: `*URL:*\n${metadata.request?.url}`
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
type: 'mrkdwn',
|
|
102
|
-
body: `*Method:*\n${metadata.request?.method}`
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
if (metadata) {
|
|
108
|
-
blocks.push({
|
|
109
|
-
type: 'section',
|
|
110
|
-
text: {
|
|
111
|
-
type: 'plain_text',
|
|
112
|
-
text: 'Other Information:'
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
blocks.push(lines(flatten(omit(metadata, 'request'))));
|
|
116
|
-
}
|
|
117
|
-
if (!isEmpty(this.payload)) {
|
|
118
|
-
blocks.push({
|
|
119
|
-
type: 'section',
|
|
120
|
-
text: {
|
|
121
|
-
type: 'plain_text',
|
|
122
|
-
text: 'Other Information:'
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
blocks.push(lines(flatten(this.payload)));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=slack.js.map
|