@byhealth/data-reporter
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
@@ -13,3 +13,3 @@ 'use strict'; | ||
const config = { | ||
SDK_VERSION: "1.0.0-beta.7", | ||
SDK_VERSION: "1.0.0-beta.8", | ||
DEBUG: false, | ||
@@ -69,2 +69,5 @@ API_URL: 'https://trk.by-health.com/trk-api/trk/data', | ||
this.emit('ready', this); | ||
if ((options === null || options === void 0 ? void 0 : options.keepalive) && options.keepalive > 0) { | ||
setInterval(() => this.keepalive(), options.keepalive); | ||
} | ||
} | ||
@@ -150,3 +153,3 @@ on(hook, listener) { | ||
if (this._captureQueue.length >= 5) { | ||
this.nextTick(() => this.flush(), 0); | ||
this.nextTick(() => this.flush()); | ||
} | ||
@@ -156,4 +159,8 @@ } | ||
} | ||
keepalive() { | ||
if (this._captureQueue.length === 0) { | ||
this.capture('keepalive', {}, { instant: true }); | ||
} | ||
} | ||
flush() { | ||
console.log('flush', this._captureQueue.length, this._sending); | ||
if (this._captureQueue.length === 0) | ||
@@ -160,0 +167,0 @@ return; |
@@ -24,2 +24,6 @@ interface ClientOptions { | ||
transport: Transport; | ||
/** | ||
* Keepalive timeout | ||
*/ | ||
keepalive?: number; | ||
} | ||
@@ -163,2 +167,3 @@ interface PersistStorage { | ||
protected send(data: CaptureData, options: SendOption): void; | ||
protected keepalive(): void; | ||
flush(): Promise<boolean> | undefined; | ||
@@ -165,0 +170,0 @@ protected nextTick(fn: Function, delay?: number): void; |
@@ -11,3 +11,3 @@ import { nanoid } from 'nanoid'; | ||
const config = { | ||
SDK_VERSION: "1.0.0-beta.7", | ||
SDK_VERSION: "1.0.0-beta.8", | ||
DEBUG: false, | ||
@@ -67,2 +67,5 @@ API_URL: 'https://trk.by-health.com/trk-api/trk/data', | ||
this.emit('ready', this); | ||
if ((options === null || options === void 0 ? void 0 : options.keepalive) && options.keepalive > 0) { | ||
setInterval(() => this.keepalive(), options.keepalive); | ||
} | ||
} | ||
@@ -148,3 +151,3 @@ on(hook, listener) { | ||
if (this._captureQueue.length >= 5) { | ||
this.nextTick(() => this.flush(), 0); | ||
this.nextTick(() => this.flush()); | ||
} | ||
@@ -154,4 +157,8 @@ } | ||
} | ||
keepalive() { | ||
if (this._captureQueue.length === 0) { | ||
this.capture('keepalive', {}, { instant: true }); | ||
} | ||
} | ||
flush() { | ||
console.log('flush', this._captureQueue.length, this._sending); | ||
if (this._captureQueue.length === 0) | ||
@@ -158,0 +165,0 @@ return; |
{ | ||
"name": "@byhealth/data-reporter", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55033
999