@driveflux/reporter 7.0.1 → 7.0.3
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/dist/config.js +44 -52
- package/dist/drivers/console.js +202 -13
- package/dist/drivers/rollbar.d.ts +1 -1
- package/dist/drivers/rollbar.d.ts.map +1 -1
- package/dist/drivers/rollbar.js +215 -16
- package/dist/drivers/rollbar.js.map +1 -1
- package/dist/drivers/slack.js +348 -117
- package/dist/index.js +380 -67
- package/dist/types.js +1 -2
- package/package.json +12 -12
package/dist/config.js
CHANGED
|
@@ -1,80 +1,69 @@
|
|
|
1
1
|
import { ProblemSeverity } from '@driveflux/problem';
|
|
2
2
|
import { initSingleton } from '@driveflux/singleton';
|
|
3
3
|
import z from 'zod';
|
|
4
|
-
export
|
|
5
|
-
.object({
|
|
4
|
+
export var ConfigValidation = z.object({
|
|
6
5
|
isProd: z.boolean(),
|
|
7
6
|
deferReporting: z.boolean(),
|
|
8
|
-
slack: z
|
|
9
|
-
.object({
|
|
7
|
+
slack: z.object({
|
|
10
8
|
errorChannelId: z.string(),
|
|
11
9
|
token: z.string(),
|
|
12
|
-
minimumSeverity: z.enum(ProblemSeverity)
|
|
13
|
-
})
|
|
14
|
-
.optional(),
|
|
10
|
+
minimumSeverity: z.enum(ProblemSeverity)
|
|
11
|
+
}).optional(),
|
|
15
12
|
drivers: z.object({
|
|
16
13
|
slack: z.boolean(),
|
|
17
14
|
rollbar: z.boolean(),
|
|
18
|
-
console: z.boolean()
|
|
15
|
+
console: z.boolean()
|
|
19
16
|
}),
|
|
20
|
-
rollbar: z
|
|
21
|
-
.object({
|
|
17
|
+
rollbar: z.object({
|
|
22
18
|
accessToken: z.string(),
|
|
23
19
|
enabled: z.boolean(),
|
|
24
20
|
captureUncaught: z.boolean(),
|
|
25
21
|
captureUnhandledRejections: z.boolean(),
|
|
26
|
-
environment: z.string().optional()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
})
|
|
30
|
-
.superRefine((data, ctx) => {
|
|
22
|
+
environment: z.string().optional()
|
|
23
|
+
}).optional()
|
|
24
|
+
}).superRefine(function(data, ctx) {
|
|
31
25
|
if (data.drivers.rollbar && !data.rollbar) {
|
|
32
26
|
ctx.addIssue({
|
|
33
27
|
code: z.ZodIssueCode.custom,
|
|
34
|
-
message: 'Rollbar is required when using the Rollbar driver'
|
|
28
|
+
message: 'Rollbar is required when using the Rollbar driver'
|
|
35
29
|
});
|
|
36
30
|
}
|
|
37
31
|
if (data.drivers.rollbar && !data.rollbar) {
|
|
38
32
|
ctx.addIssue({
|
|
39
33
|
code: z.ZodIssueCode.custom,
|
|
40
|
-
message: 'Rollbar is required when using the Rollbar driver'
|
|
34
|
+
message: 'Rollbar is required when using the Rollbar driver'
|
|
41
35
|
});
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
process.env.REPORTER_DEFER !== ''
|
|
48
|
-
|
|
49
|
-
: true,
|
|
50
|
-
slack: process.env.REPORTER_USE_SLACK === 'true'
|
|
51
|
-
? {
|
|
38
|
+
var getConfig = function getConfig() {
|
|
39
|
+
return ConfigValidation.parse({
|
|
40
|
+
isProd: process.env.APP_ENV === 'production',
|
|
41
|
+
deferReporting: typeof process.env.REPORTER_DEFER === 'string' && process.env.REPORTER_DEFER !== '' ? process.env.REPORTER_DEFER === 'true' : true,
|
|
42
|
+
slack: process.env.REPORTER_USE_SLACK === 'true' ? {
|
|
52
43
|
errorChannelId: process.env.SLACK_ERROR_CHANNEL_ID || '',
|
|
53
44
|
token: process.env.SLACK_BOT_TOKEN || '',
|
|
54
|
-
minimumSeverity: ProblemSeverity.HIGH
|
|
55
|
-
}
|
|
56
|
-
:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
rollbar: process.env.REPORTER_USE_ROLLBAR === 'true'
|
|
63
|
-
? {
|
|
45
|
+
minimumSeverity: ProblemSeverity.HIGH
|
|
46
|
+
} : undefined,
|
|
47
|
+
drivers: {
|
|
48
|
+
slack: process.env.REPORTER_USE_SLACK === 'true',
|
|
49
|
+
rollbar: process.env.REPORTER_USE_ROLLBAR === 'true',
|
|
50
|
+
console: process.env.REPORTER_USE_CONSOLE !== 'false'
|
|
51
|
+
},
|
|
52
|
+
rollbar: process.env.REPORTER_USE_ROLLBAR === 'true' ? {
|
|
64
53
|
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
|
|
65
54
|
enabled: true,
|
|
66
55
|
captureUncaught: true,
|
|
67
56
|
captureUnhandledRejections: true,
|
|
68
|
-
environment: process.env.APP_ENV || process.env.NODE_ENV
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
57
|
+
environment: process.env.APP_ENV || process.env.NODE_ENV
|
|
58
|
+
} : undefined
|
|
59
|
+
});
|
|
60
|
+
};
|
|
72
61
|
// Cache for validated configuration
|
|
73
|
-
|
|
62
|
+
var validatedConfig = null;
|
|
74
63
|
// Create a proxy that validates only on first property access
|
|
75
|
-
|
|
64
|
+
var createConfigProxy = function createConfigProxy() {
|
|
76
65
|
return new Proxy({}, {
|
|
77
|
-
get(_target, prop) {
|
|
66
|
+
get: function get(_target, prop) {
|
|
78
67
|
// If config hasn't been validated yet, validate it now
|
|
79
68
|
if (validatedConfig === null) {
|
|
80
69
|
validatedConfig = getConfig();
|
|
@@ -82,7 +71,7 @@ const createConfigProxy = () => {
|
|
|
82
71
|
// Return the property from the validated config
|
|
83
72
|
return validatedConfig[prop];
|
|
84
73
|
},
|
|
85
|
-
set(_target, prop, value) {
|
|
74
|
+
set: function set(_target, prop, value) {
|
|
86
75
|
// If config hasn't been validated yet, validate it now
|
|
87
76
|
if (validatedConfig === null) {
|
|
88
77
|
validatedConfig = getConfig();
|
|
@@ -91,38 +80,41 @@ const createConfigProxy = () => {
|
|
|
91
80
|
validatedConfig[prop] = value;
|
|
92
81
|
return true;
|
|
93
82
|
},
|
|
94
|
-
has(_target, prop) {
|
|
83
|
+
has: function has(_target, prop) {
|
|
95
84
|
// If config hasn't been validated yet, validate it now
|
|
96
85
|
if (validatedConfig === null) {
|
|
97
86
|
validatedConfig = getConfig();
|
|
98
87
|
}
|
|
99
88
|
return prop in validatedConfig;
|
|
100
89
|
},
|
|
101
|
-
ownKeys(_target) {
|
|
90
|
+
ownKeys: function ownKeys(_target) {
|
|
102
91
|
// If config hasn't been validated yet, validate it now
|
|
103
92
|
if (validatedConfig === null) {
|
|
104
93
|
validatedConfig = getConfig();
|
|
105
94
|
}
|
|
106
95
|
return Object.keys(validatedConfig);
|
|
107
96
|
},
|
|
108
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
97
|
+
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(_target, prop) {
|
|
109
98
|
// If config hasn't been validated yet, validate it now
|
|
110
99
|
if (validatedConfig === null) {
|
|
111
100
|
validatedConfig = getConfig();
|
|
112
101
|
}
|
|
113
102
|
return Object.getOwnPropertyDescriptor(validatedConfig, prop);
|
|
114
|
-
}
|
|
103
|
+
}
|
|
115
104
|
});
|
|
116
105
|
};
|
|
117
|
-
export
|
|
118
|
-
|
|
106
|
+
export var config = initSingleton('reporterConfig', function() {
|
|
107
|
+
return createConfigProxy();
|
|
108
|
+
});
|
|
109
|
+
export var resetConfig = function resetConfig() {
|
|
119
110
|
// Clear the validation cache to force re-validation on next property access
|
|
120
111
|
validatedConfig = null;
|
|
121
112
|
// Reset the singleton
|
|
122
|
-
config = initSingleton('reporterConfig', ()
|
|
113
|
+
config = initSingleton('reporterConfig', function() {
|
|
114
|
+
return createConfigProxy();
|
|
115
|
+
}, true);
|
|
123
116
|
return config;
|
|
124
117
|
};
|
|
125
|
-
export
|
|
118
|
+
export var setConfig = function setConfig(key, value) {
|
|
126
119
|
config[key] = value;
|
|
127
120
|
};
|
|
128
|
-
//# sourceMappingURL=config.js.map
|
package/dist/drivers/console.js
CHANGED
|
@@ -1,17 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _class_call_check(instance, Constructor) {
|
|
31
|
+
if (!(instance instanceof Constructor)) {
|
|
32
|
+
throw new TypeError("Cannot call a class as a function");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _defineProperties(target, props) {
|
|
36
|
+
for(var i = 0; i < props.length; i++){
|
|
37
|
+
var descriptor = props[i];
|
|
38
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
+
descriptor.configurable = true;
|
|
40
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
15
42
|
}
|
|
16
43
|
}
|
|
17
|
-
|
|
44
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
45
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
|
+
return Constructor;
|
|
48
|
+
}
|
|
49
|
+
function _define_property(obj, key, value) {
|
|
50
|
+
if (key in obj) {
|
|
51
|
+
Object.defineProperty(obj, key, {
|
|
52
|
+
value: value,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
function _ts_generator(thisArg, body) {
|
|
63
|
+
var f, y, t, _ = {
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
71
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
72
|
+
return d(g, "next", {
|
|
73
|
+
value: verb(0)
|
|
74
|
+
}), d(g, "throw", {
|
|
75
|
+
value: verb(1)
|
|
76
|
+
}), d(g, "return", {
|
|
77
|
+
value: verb(2)
|
|
78
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
79
|
+
value: function() {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
}), g;
|
|
83
|
+
function verb(n) {
|
|
84
|
+
return function(v) {
|
|
85
|
+
return step([
|
|
86
|
+
n,
|
|
87
|
+
v
|
|
88
|
+
]);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function step(op) {
|
|
92
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
93
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
94
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
95
|
+
if (y = 0, t) op = [
|
|
96
|
+
op[0] & 2,
|
|
97
|
+
t.value
|
|
98
|
+
];
|
|
99
|
+
switch(op[0]){
|
|
100
|
+
case 0:
|
|
101
|
+
case 1:
|
|
102
|
+
t = op;
|
|
103
|
+
break;
|
|
104
|
+
case 4:
|
|
105
|
+
_.label++;
|
|
106
|
+
return {
|
|
107
|
+
value: op[1],
|
|
108
|
+
done: false
|
|
109
|
+
};
|
|
110
|
+
case 5:
|
|
111
|
+
_.label++;
|
|
112
|
+
y = op[1];
|
|
113
|
+
op = [
|
|
114
|
+
0
|
|
115
|
+
];
|
|
116
|
+
continue;
|
|
117
|
+
case 7:
|
|
118
|
+
op = _.ops.pop();
|
|
119
|
+
_.trys.pop();
|
|
120
|
+
continue;
|
|
121
|
+
default:
|
|
122
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
123
|
+
_ = 0;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
127
|
+
_.label = op[1];
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
131
|
+
_.label = t[1];
|
|
132
|
+
t = op;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
if (t && _.label < t[2]) {
|
|
136
|
+
_.label = t[2];
|
|
137
|
+
_.ops.push(op);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (t[2]) _.ops.pop();
|
|
141
|
+
_.trys.pop();
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
op = body.call(thisArg, _);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
op = [
|
|
147
|
+
6,
|
|
148
|
+
e
|
|
149
|
+
];
|
|
150
|
+
y = 0;
|
|
151
|
+
} finally{
|
|
152
|
+
f = t = 0;
|
|
153
|
+
}
|
|
154
|
+
if (op[0] & 5) throw op[1];
|
|
155
|
+
return {
|
|
156
|
+
value: op[0] ? op[1] : void 0,
|
|
157
|
+
done: true
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export var ConsoleDriver = /*#__PURE__*/ function() {
|
|
162
|
+
"use strict";
|
|
163
|
+
function ConsoleDriver() {
|
|
164
|
+
_class_call_check(this, ConsoleDriver);
|
|
165
|
+
_define_property(this, "payload", void 0);
|
|
166
|
+
}
|
|
167
|
+
_create_class(ConsoleDriver, [
|
|
168
|
+
{
|
|
169
|
+
key: "reportError",
|
|
170
|
+
value: function reportError(err, _) {
|
|
171
|
+
return _async_to_generator(function() {
|
|
172
|
+
return _ts_generator(this, function(_state) {
|
|
173
|
+
console.error('An error happened');
|
|
174
|
+
console.error('Error', err);
|
|
175
|
+
console.error('Payload', this.payload);
|
|
176
|
+
return [
|
|
177
|
+
2
|
|
178
|
+
];
|
|
179
|
+
});
|
|
180
|
+
}).call(this);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
key: "reportProblem",
|
|
185
|
+
value: function reportProblem(problem) {
|
|
186
|
+
return _async_to_generator(function() {
|
|
187
|
+
return _ts_generator(this, function(_state) {
|
|
188
|
+
console.error('A problem happened');
|
|
189
|
+
console.error('Problem', problem);
|
|
190
|
+
console.error('Payload', this.payload);
|
|
191
|
+
return [
|
|
192
|
+
2
|
|
193
|
+
];
|
|
194
|
+
});
|
|
195
|
+
}).call(this);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
key: "setReporterPayload",
|
|
200
|
+
value: function setReporterPayload(payload) {
|
|
201
|
+
this.payload = payload;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
]);
|
|
205
|
+
return ConsoleDriver;
|
|
206
|
+
}();
|
|
@@ -2,7 +2,7 @@ import type { Problem } from '@driveflux/problem';
|
|
|
2
2
|
import type { Metadata, Reporter } from '../types.js';
|
|
3
3
|
export declare class RollbarDriver implements Reporter {
|
|
4
4
|
private rollbar;
|
|
5
|
-
constructor(rollbarConfig?: import('rollbar').Configuration);
|
|
5
|
+
constructor(rollbarConfig?: import('rollbar').default.Configuration);
|
|
6
6
|
reportError(err: Error, metadata: Metadata): Promise<void>;
|
|
7
7
|
reportProblem(problem: Problem): Promise<void>;
|
|
8
8
|
setReporterPayload(payload: Record<string, any>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollbar.d.ts","sourceRoot":"","sources":["../../src/drivers/rollbar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,qBAAa,aAAc,YAAW,QAAQ;IAC7C,OAAO,CAAC,OAAO,CAAA;gBAEH,aAAa,CAAC,EAAE,OAAO,SAAS,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"rollbar.d.ts","sourceRoot":"","sources":["../../src/drivers/rollbar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,qBAAa,aAAc,YAAW,QAAQ;IAC7C,OAAO,CAAC,OAAO,CAAA;gBAEH,aAAa,CAAC,EAAE,OAAO,SAAS,EAAE,OAAO,CAAC,aAAa;IAI7D,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ;IAI1C,aAAa,CAAC,OAAO,EAAE,OAAO;IAcpC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAG/C"}
|
package/dist/drivers/rollbar.js
CHANGED
|
@@ -1,22 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
16
27
|
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _class_call_check(instance, Constructor) {
|
|
31
|
+
if (!(instance instanceof Constructor)) {
|
|
32
|
+
throw new TypeError("Cannot call a class as a function");
|
|
17
33
|
}
|
|
18
|
-
|
|
19
|
-
|
|
34
|
+
}
|
|
35
|
+
function _defineProperties(target, props) {
|
|
36
|
+
for(var i = 0; i < props.length; i++){
|
|
37
|
+
var descriptor = props[i];
|
|
38
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
+
descriptor.configurable = true;
|
|
40
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
20
42
|
}
|
|
21
43
|
}
|
|
22
|
-
|
|
44
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
45
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
|
+
return Constructor;
|
|
48
|
+
}
|
|
49
|
+
function _define_property(obj, key, value) {
|
|
50
|
+
if (key in obj) {
|
|
51
|
+
Object.defineProperty(obj, key, {
|
|
52
|
+
value: value,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
function _ts_generator(thisArg, body) {
|
|
63
|
+
var f, y, t, _ = {
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
71
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
72
|
+
return d(g, "next", {
|
|
73
|
+
value: verb(0)
|
|
74
|
+
}), d(g, "throw", {
|
|
75
|
+
value: verb(1)
|
|
76
|
+
}), d(g, "return", {
|
|
77
|
+
value: verb(2)
|
|
78
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
79
|
+
value: function() {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
}), g;
|
|
83
|
+
function verb(n) {
|
|
84
|
+
return function(v) {
|
|
85
|
+
return step([
|
|
86
|
+
n,
|
|
87
|
+
v
|
|
88
|
+
]);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function step(op) {
|
|
92
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
93
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
94
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
95
|
+
if (y = 0, t) op = [
|
|
96
|
+
op[0] & 2,
|
|
97
|
+
t.value
|
|
98
|
+
];
|
|
99
|
+
switch(op[0]){
|
|
100
|
+
case 0:
|
|
101
|
+
case 1:
|
|
102
|
+
t = op;
|
|
103
|
+
break;
|
|
104
|
+
case 4:
|
|
105
|
+
_.label++;
|
|
106
|
+
return {
|
|
107
|
+
value: op[1],
|
|
108
|
+
done: false
|
|
109
|
+
};
|
|
110
|
+
case 5:
|
|
111
|
+
_.label++;
|
|
112
|
+
y = op[1];
|
|
113
|
+
op = [
|
|
114
|
+
0
|
|
115
|
+
];
|
|
116
|
+
continue;
|
|
117
|
+
case 7:
|
|
118
|
+
op = _.ops.pop();
|
|
119
|
+
_.trys.pop();
|
|
120
|
+
continue;
|
|
121
|
+
default:
|
|
122
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
123
|
+
_ = 0;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
127
|
+
_.label = op[1];
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
131
|
+
_.label = t[1];
|
|
132
|
+
t = op;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
if (t && _.label < t[2]) {
|
|
136
|
+
_.label = t[2];
|
|
137
|
+
_.ops.push(op);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (t[2]) _.ops.pop();
|
|
141
|
+
_.trys.pop();
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
op = body.call(thisArg, _);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
op = [
|
|
147
|
+
6,
|
|
148
|
+
e
|
|
149
|
+
];
|
|
150
|
+
y = 0;
|
|
151
|
+
} finally{
|
|
152
|
+
f = t = 0;
|
|
153
|
+
}
|
|
154
|
+
if (op[0] & 5) throw op[1];
|
|
155
|
+
return {
|
|
156
|
+
value: op[0] ? op[1] : void 0,
|
|
157
|
+
done: true
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
import Rollbar from 'rollbar';
|
|
162
|
+
export var RollbarDriver = /*#__PURE__*/ function() {
|
|
163
|
+
"use strict";
|
|
164
|
+
function RollbarDriver(rollbarConfig) {
|
|
165
|
+
_class_call_check(this, RollbarDriver);
|
|
166
|
+
_define_property(this, "rollbar", void 0);
|
|
167
|
+
this.rollbar = new Rollbar(rollbarConfig);
|
|
168
|
+
}
|
|
169
|
+
_create_class(RollbarDriver, [
|
|
170
|
+
{
|
|
171
|
+
key: "reportError",
|
|
172
|
+
value: function reportError(err, metadata) {
|
|
173
|
+
return _async_to_generator(function() {
|
|
174
|
+
return _ts_generator(this, function(_state) {
|
|
175
|
+
this.rollbar.error(err, metadata.request || {}, metadata.others);
|
|
176
|
+
return [
|
|
177
|
+
2
|
|
178
|
+
];
|
|
179
|
+
});
|
|
180
|
+
}).call(this);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
key: "reportProblem",
|
|
185
|
+
value: function reportProblem(problem) {
|
|
186
|
+
return _async_to_generator(function() {
|
|
187
|
+
var _this;
|
|
188
|
+
return _ts_generator(this, function(_state) {
|
|
189
|
+
switch(_state.label){
|
|
190
|
+
case 0:
|
|
191
|
+
_this = this;
|
|
192
|
+
return [
|
|
193
|
+
4,
|
|
194
|
+
new Promise(function(resolve) {
|
|
195
|
+
var _problem_privateMetadata, _problem_privateMetadata1;
|
|
196
|
+
_this.rollbar.error(((_problem_privateMetadata = problem.privateMetadata) === null || _problem_privateMetadata === void 0 ? void 0 : _problem_privateMetadata.error) || new Error(problem.message || problem.code), (_problem_privateMetadata1 = problem.privateMetadata) === null || _problem_privateMetadata1 === void 0 ? void 0 : _problem_privateMetadata1.request, problem.privateMetadata || {}, function(error) {
|
|
197
|
+
resolve(error);
|
|
198
|
+
});
|
|
199
|
+
})
|
|
200
|
+
];
|
|
201
|
+
case 1:
|
|
202
|
+
_state.sent();
|
|
203
|
+
return [
|
|
204
|
+
2
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}).call(this);
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
key: "setReporterPayload",
|
|
213
|
+
value: function setReporterPayload(payload) {
|
|
214
|
+
this.rollbar.configure({
|
|
215
|
+
payload: payload
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
]);
|
|
220
|
+
return RollbarDriver;
|
|
221
|
+
}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollbar.js","sourceRoot":"","sources":["../../src/drivers/rollbar.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B,MAAM,OAAO,aAAa;IACjB,OAAO,CAAA;IAEf,YAAY,
|
|
1
|
+
{"version":3,"file":"rollbar.js","sourceRoot":"","sources":["../../src/drivers/rollbar.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B,MAAM,OAAO,aAAa;IACjB,OAAO,CAAA;IAEf,YAAY,aAAuD;QAClE,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAA;IAC1C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,GAAU,EAAE,QAAkB;QAC/C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,IAAI,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACjE,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAgB;QACnC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,OAAO,CAAC,KAAK,CACjB,OAAO,CAAC,eAAe,EAAE,KAAK;gBAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,EAC3C,OAAO,CAAC,eAAe,EAAE,OAAO,EAChC,OAAO,CAAC,eAAe,IAAI,EAAE,EAC7B,CAAC,KAAK,EAAE,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,CAAA;YACf,CAAC,CACD,CAAA;QACF,CAAC,CAAC,CAAA;IACH,CAAC;IAED,kBAAkB,CAAC,OAA4B;QAC9C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IACpC,CAAC;CACD"}
|