Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Merge 27ae690 into 9ae02dc
Browse files Browse the repository at this point in the history
  • Loading branch information
jperata committed Sep 26, 2018
2 parents 9ae02dc + 27ae690 commit 2dc5adf
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bin/bst-speak.ts
Expand Up @@ -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));
});

Expand Down
2 changes: 1 addition & 1 deletion bin/bst-test.ts
Expand Up @@ -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;
});
});
3 changes: 3 additions & 0 deletions lib/client/bst-proxy.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -163,6 +165,7 @@ export class BSTProxy {
this.functionServer.start(callback);
}

BstStatistics.instance().record(BstCommand.proxy, undefined, Global.config().secretKey(), Global.version());
return this;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/client/bst-virtual-alexa.ts
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
}
10 changes: 5 additions & 5 deletions lib/statistics/bst-statistics.ts
Expand Up @@ -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);
}
Expand All @@ -51,8 +51,8 @@ export class BstStatistics {
export class StatisticsContext {
private _queue: Array<BstStat> = [];

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) {
Expand Down Expand Up @@ -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();
}

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/statistics/bst-statistics-test.ts
Expand Up @@ -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();
});
Expand All @@ -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();
});
Expand Down

0 comments on commit 2dc5adf

Please sign in to comment.