diff --git a/bin/bst-speak.ts b/bin/bst-speak.ts index 2a92be94..c154217a 100644 --- a/bin/bst-speak.ts +++ b/bin/bst-speak.ts @@ -66,7 +66,7 @@ Global.initializeCLI().then( if (Global.config() && Global.config().secretKey && Global.config().secretKey()) { nodeId = Global.config().secretKey(); } - BstStatistics.instance().record(BstCommand.speak, undefined, nodeId); + BstStatistics.instance().record(BstCommand.speak, undefined, nodeId, Global.version()); console.log(VirtualDeviceClient.renderResult(virtualDeviceResponse)); }); diff --git a/bin/bst-test.ts b/bin/bst-test.ts index e5bfabef..618e8cd0 100644 --- a/bin/bst-test.ts +++ b/bin/bst-test.ts @@ -62,7 +62,7 @@ Global.initializeCLI(false).then(() => { if (Global.config() && Global.config().secretKey && Global.config().secretKey()) { nodeId = Global.config().secretKey(); } - BstStatistics.instance().record(BstCommand.test, undefined, nodeId); + BstStatistics.instance().record(BstCommand.test, undefined, nodeId, Global.version()); process.exitCode = success ? 0 : 1; }); }); diff --git a/lib/client/bst-proxy.ts b/lib/client/bst-proxy.ts index 0b8db362..f0b79c2a 100644 --- a/lib/client/bst-proxy.ts +++ b/lib/client/bst-proxy.ts @@ -5,6 +5,8 @@ import {Global} from "../core/global"; import {BSTConfig} from "./bst-config"; import {FunctionServer} from "./function-server"; import {LoggingHelper} from "../core/logging-helper"; +import {BstStatistics, BstCommand} from "../statistics/bst-statistics"; + export enum ProxyType { GOOGLE_CLOUD_FUNCTION, @@ -163,6 +165,7 @@ export class BSTProxy { this.functionServer.start(callback); } + BstStatistics.instance().record(BstCommand.proxy, undefined, Global.config().secretKey(), Global.version()); return this; } diff --git a/lib/client/bst-virtual-alexa.ts b/lib/client/bst-virtual-alexa.ts index 12fa2e94..ef347f98 100644 --- a/lib/client/bst-virtual-alexa.ts +++ b/lib/client/bst-virtual-alexa.ts @@ -221,7 +221,7 @@ export class BSTVirtualAlexa { }).catch(error => { callback(error, null, request); }); - BstStatistics.instance().record(BstCommand.utter, undefined, this.nodeId); + BstStatistics.instance().record(BstCommand.utter, undefined, this.nodeId, Global.version()); return this; } @@ -244,7 +244,7 @@ export class BSTVirtualAlexa { }).catch(error => { callback(error, null, request); }); - BstStatistics.instance().record(BstCommand.intend, undefined, this.nodeId); + BstStatistics.instance().record(BstCommand.intend, undefined, this.nodeId, Global.version()); return this; } @@ -264,7 +264,7 @@ export class BSTVirtualAlexa { callback(error, null, request); }); - BstStatistics.instance().record(BstCommand.launch, undefined, this.nodeId); + BstStatistics.instance().record(BstCommand.launch, undefined, this.nodeId, Global.version()); return this; } } diff --git a/lib/statistics/bst-statistics.ts b/lib/statistics/bst-statistics.ts index 91360ade..9aa9e179 100644 --- a/lib/statistics/bst-statistics.ts +++ b/lib/statistics/bst-statistics.ts @@ -40,8 +40,8 @@ export class BstStatistics { clearInterval(this.timer); } - record(command: string, event?: string, nodeId?: string, flushed?: (error?: Error) => void) { - this.statisticsContext.record(command, event, nodeId); + record(command: string, event?: string, nodeId?: string, version?: string, flushed?: (error?: Error) => void) { + this.statisticsContext.record(command, event, nodeId, version); if (!this.timer) { this.statisticsContext.flush(flushed); } @@ -51,8 +51,8 @@ export class BstStatistics { export class StatisticsContext { private _queue: Array = []; - public record(command: string, event?: string, nodeId?: string) { - this._queue.push(new BstStat(command, event, nodeId)); + public record(command: string, event?: string, nodeId?: string, version?: string) { + this._queue.push(new BstStat(command, event, nodeId, version)); } public flush(flushed?: (error?: Error) => void) { @@ -123,7 +123,7 @@ export class StatisticsContext { export class BstStat { public _timestamp: Date; - public constructor(public command: string, public event?: string, public nodeId?: string) { + public constructor(public command: string, public event?: string, public nodeId?: string, public version?: string) { this._timestamp = new Date(); } diff --git a/package-lock.json b/package-lock.json index 2a071ac7..6d7cb852 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1046,9 +1046,9 @@ } }, "browser-process-hrtime": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz", - "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44=" + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", + "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" }, "browser-resolve": { "version": "1.11.3", diff --git a/test/statistics/bst-statistics-test.ts b/test/statistics/bst-statistics-test.ts index 588ccf1f..4488bfc8 100644 --- a/test/statistics/bst-statistics-test.ts +++ b/test/statistics/bst-statistics-test.ts @@ -28,7 +28,7 @@ describe("BstStatistics", function() { return {bstStats: requestBody.bstStats.length}; }); - BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, function(error) { + BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, "2.0.0", function(error) { assert(!error); done(); }); @@ -42,7 +42,7 @@ describe("BstStatistics", function() { }) .replyWithError("something bad happened"); - BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, function(error) { + BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, "2.0.0", function(error) { assert(error); done(); });