-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbasebackend.js
64 lines (64 loc) · 2.08 KB
/
basebackend.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { logger, SentryError } from '@sentry/utils';
import { NoopTransport } from './transports/noop';
/**
* This is the base implemention of a Backend.
* @hidden
*/
var BaseBackend = /** @class */ (function () {
/** Creates a new backend instance. */
function BaseBackend(options) {
this._options = options;
if (!this._options.dsn) {
logger.warn('No DSN provided, backend will not do anything.');
}
this._transport = this._setupTransport();
}
/**
* @inheritDoc
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
BaseBackend.prototype.eventFromException = function (_exception, _hint) {
throw new SentryError('Backend has to implement `eventFromException` method');
};
/**
* @inheritDoc
*/
BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
throw new SentryError('Backend has to implement `eventFromMessage` method');
};
/**
* @inheritDoc
*/
BaseBackend.prototype.sendEvent = function (event) {
this._transport.sendEvent(event).then(null, function (reason) {
logger.error("Error while sending event: " + reason);
});
};
/**
* @inheritDoc
*/
BaseBackend.prototype.sendSession = function (session) {
if (!this._transport.sendSession) {
logger.warn("Dropping session because custom transport doesn't implement sendSession");
return;
}
this._transport.sendSession(session).then(null, function (reason) {
logger.error("Error while sending session: " + reason);
});
};
/**
* @inheritDoc
*/
BaseBackend.prototype.getTransport = function () {
return this._transport;
};
/**
* Sets up the transport so it can be used later to send requests.
*/
BaseBackend.prototype._setupTransport = function () {
return new NoopTransport();
};
return BaseBackend;
}());
export { BaseBackend };
//# sourceMappingURL=basebackend.js.map