fix(agent): hotfix vscode extension 0.6.1. Filter out no data AgentStats event. (#489)
parent
5d9ca6928c
commit
4ebad71805
|
|
@ -10,6 +10,6 @@
|
|||
"devDependencies": {
|
||||
"cpy-cli": "^4.2.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"tabby-agent": "0.3.0"
|
||||
"tabby-agent": "0.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tabby-agent",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "Generic client agent for Tabby AI coding assistant IDE extensions.",
|
||||
"repository": "https://github.com/TabbyML/tabby",
|
||||
"main": "./dist/index.js",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ export class AnonymousUsageLogger {
|
|||
: `${process.version} ${process.platform} ${require("os").arch()} ${require("os").release()}`,
|
||||
};
|
||||
private sessionProperties: Record<string, any> = {};
|
||||
private pendingUserProperties: Record<string, any> = {};
|
||||
private userProperties: Record<string, any> = {};
|
||||
private userPropertiesUpdated = false;
|
||||
private emittedUniqueEvent: string[] = [];
|
||||
private dataStore: DataStore | null = null;
|
||||
private anonymousId: string;
|
||||
|
|
@ -68,7 +69,8 @@ export class AnonymousUsageLogger {
|
|||
* Set properties which will be bind to the user.
|
||||
*/
|
||||
setUserProperties(key: string, value: any) {
|
||||
setProperty(this.pendingUserProperties, key, value);
|
||||
setProperty(this.userProperties, key, value);
|
||||
this.userPropertiesUpdated = true;
|
||||
}
|
||||
|
||||
async uniqueEvent(event: string, data: { [key: string]: any } = {}) {
|
||||
|
|
@ -90,9 +92,9 @@ export class AnonymousUsageLogger {
|
|||
...this.sessionProperties,
|
||||
...data,
|
||||
};
|
||||
if (Object.keys(this.pendingUserProperties).length > 0) {
|
||||
properties["$set"] = this.pendingUserProperties;
|
||||
this.pendingUserProperties = {};
|
||||
if (this.userPropertiesUpdated) {
|
||||
properties["$set"] = this.userProperties;
|
||||
this.userPropertiesUpdated = false;
|
||||
}
|
||||
try {
|
||||
await this.anonymousUsageTrackingApi.POST("/usage", {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ class Average {
|
|||
this.quantity += 1;
|
||||
}
|
||||
|
||||
mean(): number {
|
||||
mean(): number | undefined {
|
||||
if (this.quantity === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return this.sum / this.quantity;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ export class TabbyAgent extends EventEmitter implements Agent {
|
|||
|
||||
this.submitStatsTimer = setInterval(async () => {
|
||||
await this.submitStats();
|
||||
this.logger.debug("Stats submitted");
|
||||
}, TabbyAgent.submitStatsInterval);
|
||||
}
|
||||
|
||||
|
|
@ -185,8 +184,11 @@ export class TabbyAgent extends EventEmitter implements Agent {
|
|||
|
||||
private async submitStats() {
|
||||
const stats = this.completionProviderStats.stats();
|
||||
await this.anonymousUsageLogger.event("AgentStats", { stats, config: this.config.completion });
|
||||
this.completionProviderStats.reset();
|
||||
if (stats.completion_request.count > 0) {
|
||||
await this.anonymousUsageLogger.event("AgentStats", { stats });
|
||||
this.completionProviderStats.reset();
|
||||
this.logger.debug({ stats }, "Stats submitted");
|
||||
}
|
||||
}
|
||||
|
||||
private async post<T extends Parameters<typeof this.api.POST>[0]>(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
"devDependencies": {
|
||||
"cpy-cli": "^4.2.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"tabby-agent": "0.3.0"
|
||||
"tabby-agent": "0.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
## 0.6.1
|
||||
|
||||
### Fixes:
|
||||
|
||||
- Reduced the frequency of event submissions for anonymous usage tracking.
|
||||
|
||||
## 0.6.0
|
||||
|
||||
### Features:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"repository": "https://github.com/TabbyML/tabby",
|
||||
"bugs": "https://github.com/TabbyML/tabby/issues",
|
||||
"license": "Apache-2.0",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"keywords": [
|
||||
"ai",
|
||||
"autocomplete",
|
||||
|
|
@ -217,6 +217,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@xstate/fsm": "^2.0.1",
|
||||
"tabby-agent": "0.3.0"
|
||||
"tabby-agent": "0.3.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue