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