UNPKG

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