mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 11:38:36 -05:00
Feature: Usage metrics (#2227)
* added user stats telemetry * finished daily, weekly and monthly events * code review comments * added wekly and monthly start dates * fixed the day condition using testing
This commit is contained in:
@@ -291,6 +291,35 @@ export class WorkbenchShell {
|
||||
});
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
private sendUsageEvents(): void {
|
||||
const dailyLastUseDate = Date.parse(this.storageService.get('telemetry.dailyLastUseDate'));
|
||||
const weeklyLastUseDate = Date.parse(this.storageService.get('telemetry.weeklyLastUseDate'));
|
||||
const monthlyLastUseDate = Date.parse(this.storageService.get('telemetry.monthlyLastUseDate'));
|
||||
|
||||
let today = new Date().toUTCString();
|
||||
|
||||
// daily user event
|
||||
if (this.diffInDays(Date.parse(today), dailyLastUseDate) >= 1) {
|
||||
// daily first use
|
||||
this.telemetryService.publicLog('telemetry.dailyFirstUse', { dailyFirstUse: true });
|
||||
this.storageService.store('telemetry.dailyLastUseDate', today);
|
||||
}
|
||||
|
||||
// weekly user event
|
||||
if (this.diffInDays(Date.parse(today), weeklyLastUseDate) >= 7) {
|
||||
// weekly first use
|
||||
this.telemetryService.publicLog('telemetry.weeklyFirstUse', { weeklyFirstUse: true });
|
||||
this.storageService.store('telemetry.weeklyLastUseDate', today);
|
||||
}
|
||||
|
||||
// monthly user events
|
||||
if (this.diffInDays(Date.parse(today), monthlyLastUseDate) >= 30) {
|
||||
this.telemetryService.publicLog('telemetry.monthlyUse', { monthlyFirstUse: true });
|
||||
this.storageService.store('telemetry.monthlyLastUseDate', today);
|
||||
}
|
||||
}
|
||||
|
||||
private logLocalStorageMetrics(): void {
|
||||
if (this.lifecycleService.startupKind === StartupKind.ReloadedWindow || this.lifecycleService.startupKind === StartupKind.ReopenedWindow) {
|
||||
return; // avoid logging localStorage metrics for reload/reopen, we prefer cold startup numbers
|
||||
@@ -400,6 +429,7 @@ export class WorkbenchShell {
|
||||
const errorTelemetry = new ErrorTelemetry(telemetryService);
|
||||
|
||||
this.toUnbind.push(telemetryService, errorTelemetry);
|
||||
this.sendUsageEvents();
|
||||
} else {
|
||||
this.telemetryService = NullTelemetryService;
|
||||
}
|
||||
@@ -504,6 +534,11 @@ export class WorkbenchShell {
|
||||
this.toUnbind.push(addDisposableListener(window, EventType.RESIZE, () => this.layout()));
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
private diffInDays(nowDate: number, lastUseDate: number): number {
|
||||
return (nowDate - lastUseDate)/(24*3600*1000);
|
||||
}
|
||||
|
||||
public onUnexpectedError(error: any): void {
|
||||
const errorMsg = toErrorMessage(error, true);
|
||||
if (!errorMsg) {
|
||||
|
||||
Reference in New Issue
Block a user