1 | Object.defineProperty(exports, "__esModule", { value: true });
|
2 | var tslib_1 = require("tslib");
|
3 | var core_1 = require("@sentry/core");
|
4 | var types_1 = require("@sentry/types");
|
5 | var utils_1 = require("@sentry/utils");
|
6 | var parsers_1 = require("./parsers");
|
7 | var transports_1 = require("./transports");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var NodeBackend = (function (_super) {
|
13 | tslib_1.__extends(NodeBackend, _super);
|
14 | function NodeBackend() {
|
15 | return _super !== null && _super.apply(this, arguments) || this;
|
16 | }
|
17 | |
18 |
|
19 |
|
20 |
|
21 | NodeBackend.prototype.eventFromException = function (exception, hint) {
|
22 | var _this = this;
|
23 |
|
24 | var ex = exception;
|
25 | var providedMechanism = hint && hint.data && hint.data.mechanism;
|
26 | var mechanism = providedMechanism || {
|
27 | handled: true,
|
28 | type: 'generic',
|
29 | };
|
30 | if (!utils_1.isError(exception)) {
|
31 | if (utils_1.isPlainObject(exception)) {
|
32 |
|
33 |
|
34 | var message = "Non-Error exception captured with keys: " + utils_1.extractExceptionKeysForMessage(exception);
|
35 | core_1.getCurrentHub().configureScope(function (scope) {
|
36 | scope.setExtra('__serialized__', utils_1.normalizeToSize(exception));
|
37 | });
|
38 | ex = (hint && hint.syntheticException) || new Error(message);
|
39 | ex.message = message;
|
40 | }
|
41 | else {
|
42 |
|
43 |
|
44 | ex = (hint && hint.syntheticException) || new Error(exception);
|
45 | ex.message = exception;
|
46 | }
|
47 | mechanism.synthetic = true;
|
48 | }
|
49 | return new utils_1.SyncPromise(function (resolve, reject) {
|
50 | return parsers_1.parseError(ex, _this._options)
|
51 | .then(function (event) {
|
52 | utils_1.addExceptionTypeValue(event, undefined, undefined);
|
53 | utils_1.addExceptionMechanism(event, mechanism);
|
54 | resolve(tslib_1.__assign(tslib_1.__assign({}, event), { event_id: hint && hint.event_id }));
|
55 | })
|
56 | .then(null, reject);
|
57 | });
|
58 | };
|
59 | |
60 |
|
61 |
|
62 | NodeBackend.prototype.eventFromMessage = function (message, level, hint) {
|
63 | var _this = this;
|
64 | if (level === void 0) { level = types_1.Severity.Info; }
|
65 | var event = {
|
66 | event_id: hint && hint.event_id,
|
67 | level: level,
|
68 | message: message,
|
69 | };
|
70 | return new utils_1.SyncPromise(function (resolve) {
|
71 | if (_this._options.attachStacktrace && hint && hint.syntheticException) {
|
72 | var stack = hint.syntheticException ? parsers_1.extractStackFromError(hint.syntheticException) : [];
|
73 | void parsers_1.parseStack(stack, _this._options)
|
74 | .then(function (frames) {
|
75 | event.stacktrace = {
|
76 | frames: parsers_1.prepareFramesForEvent(frames),
|
77 | };
|
78 | resolve(event);
|
79 | })
|
80 | .then(null, function () {
|
81 | resolve(event);
|
82 | });
|
83 | }
|
84 | else {
|
85 | resolve(event);
|
86 | }
|
87 | });
|
88 | };
|
89 | |
90 |
|
91 |
|
92 | NodeBackend.prototype._setupTransport = function () {
|
93 | if (!this._options.dsn) {
|
94 |
|
95 | return _super.prototype._setupTransport.call(this);
|
96 | }
|
97 | var dsn = new utils_1.Dsn(this._options.dsn);
|
98 | var transportOptions = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, this._options.transportOptions), (this._options.httpProxy && { httpProxy: this._options.httpProxy })), (this._options.httpsProxy && { httpsProxy: this._options.httpsProxy })), (this._options.caCerts && { caCerts: this._options.caCerts })), { dsn: this._options.dsn, tunnel: this._options.tunnel, _metadata: this._options._metadata });
|
99 | if (this._options.transport) {
|
100 | return new this._options.transport(transportOptions);
|
101 | }
|
102 | if (dsn.protocol === 'http') {
|
103 | return new transports_1.HTTPTransport(transportOptions);
|
104 | }
|
105 | return new transports_1.HTTPSTransport(transportOptions);
|
106 | };
|
107 | return NodeBackend;
|
108 | }(core_1.BaseBackend));
|
109 | exports.NodeBackend = NodeBackend;
|
110 |
|
\ | No newline at end of file |