@backtrace/sdk-core
Advanced tools
Comparing version
import { BacktraceReportSubmission } from '../model/http/BacktraceReportSubmission'; | ||
import { BacktraceRequestHandler } from '../model/http/BacktraceRequestHandler'; | ||
import { BacktraceModule } from '../modules/BacktraceModule'; | ||
import { BacktraceAttributeProvider } from '../modules/attribute/BacktraceAttributeProvider'; | ||
@@ -28,3 +29,4 @@ import { BreadcrumbsEventSubscriber, BreadcrumbsStorage } from '../modules/breadcrumbs'; | ||
useUniqueMetricsQueue(queue: MetricsQueue<UniqueEvent>): this; | ||
useModule(module: BacktraceModule): this; | ||
} | ||
export {}; |
@@ -64,4 +64,13 @@ "use strict"; | ||
} | ||
useModule(module) { | ||
if (!this.clientSetup.modules) { | ||
this.clientSetup.modules = [module]; | ||
} | ||
else { | ||
this.clientSetup.modules.push(module); | ||
} | ||
return this; | ||
} | ||
} | ||
exports.BacktraceCoreClientBuilder = BacktraceCoreClientBuilder; | ||
//# sourceMappingURL=BacktraceCoreClientBuilder.js.map |
@@ -9,2 +9,3 @@ export * from './BacktraceCoreClient'; | ||
export * from './common/jsonEscaper'; | ||
export * from './dataStructures'; | ||
export * from './model/attachment'; | ||
@@ -11,0 +12,0 @@ export * from './model/configuration/BacktraceConfiguration'; |
@@ -27,2 +27,3 @@ "use strict"; | ||
__exportStar(require("./common/jsonEscaper"), exports); | ||
__exportStar(require("./dataStructures"), exports); | ||
__exportStar(require("./model/attachment"), exports); | ||
@@ -29,0 +30,0 @@ __exportStar(require("./model/configuration/BacktraceConfiguration"), exports); |
@@ -18,2 +18,7 @@ import { BacktraceAttachment } from '../../model/attachment'; | ||
get enabled(): boolean; | ||
/** | ||
* Abort controller to cancel asynchronous database operations when | ||
* the database is being disabled by the user. | ||
*/ | ||
private readonly _abortController; | ||
private readonly _databaseRecordContext; | ||
@@ -62,8 +67,10 @@ private readonly _storageProviders; | ||
* no matter if the submission process was successful or not. | ||
* @param abortSignal optional abort signal to cancel sending requests | ||
*/ | ||
flush(): Promise<void>; | ||
flush(abortSignal?: AbortSignal): Promise<void>; | ||
/** | ||
* Sends all records available in the database to Backtrace. | ||
* @param abortSignal optional abort signal to cancel sending requests | ||
*/ | ||
send(): Promise<void>; | ||
send(abortSignal?: AbortSignal): Promise<void>; | ||
/** | ||
@@ -70,0 +77,0 @@ * Prepare database to insert records |
@@ -13,2 +13,3 @@ "use strict"; | ||
exports.BacktraceDatabase = void 0; | ||
const AbortController_1 = require("../../common/AbortController"); | ||
const IdGenerator_1 = require("../../common/IdGenerator"); | ||
@@ -30,2 +31,7 @@ const TimeHelper_1 = require("../../common/TimeHelper"); | ||
this._sessionFiles = _sessionFiles; | ||
/** | ||
* Abort controller to cancel asynchronous database operations when | ||
* the database is being disabled by the user. | ||
*/ | ||
this._abortController = (0, AbortController_1.createAbortController)(); | ||
this._storageProviders = []; | ||
@@ -138,2 +144,3 @@ this._enabled = false; | ||
clearInterval(this._intervalId); | ||
this._abortController.abort(); | ||
} | ||
@@ -165,9 +172,13 @@ /** | ||
* no matter if the submission process was successful or not. | ||
* @param abortSignal optional abort signal to cancel sending requests | ||
*/ | ||
flush() { | ||
flush(abortSignal) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const start = TimeHelper_1.TimeHelper.now(); | ||
yield this.send(); | ||
yield this.send(abortSignal); | ||
const records = this.get().filter((n) => n.timestamp <= start); | ||
for (const record of records) { | ||
if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) { | ||
return; | ||
} | ||
this.remove(record); | ||
@@ -179,4 +190,5 @@ } | ||
* Sends all records available in the database to Backtrace. | ||
* @param abortSignal optional abort signal to cancel sending requests | ||
*/ | ||
send() { | ||
send(abortSignal) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -186,3 +198,7 @@ for (let bucketIndex = 0; bucketIndex < this._databaseRecordContext.bucketCount; bucketIndex++) { | ||
const records = [...this._databaseRecordContext.getBucket(bucketIndex)]; | ||
const signal = (0, AbortController_1.anySignal)(abortSignal, this._abortController.signal); | ||
for (const record of records) { | ||
if (!this.enabled) { | ||
return; | ||
} | ||
if (record.locked) { | ||
@@ -193,3 +209,3 @@ continue; | ||
record.locked = true; | ||
const result = yield this._requestHandler.send(record.data, record.attachments); | ||
const result = yield this._requestHandler.send(record.data, record.attachments, signal); | ||
if (result.status === 'Ok') { | ||
@@ -196,0 +212,0 @@ this.remove(record); |
{ | ||
"name": "@backtrace/sdk-core", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Backtrace-JavaScript SDK core library", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
298672
1.18%282
1.08%4814
1.18%