Skip to content

Commit

Permalink
ensure workspaceChangeEvent interval is triggered only once
Browse files Browse the repository at this point in the history
  • Loading branch information
Achal1607 committed Jan 13, 2025
1 parent c4bc7e6 commit 6644d24
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vscode/src/telemetry/events/workspaceChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export interface WorkspaceChangeData {
projInitTimeTaken: number;
}

let workspaceChangeEventTimeout: NodeJS.Timeout | null = null;

export class WorkspaceChangeEvent extends BaseEvent<WorkspaceChangeData> {
public static readonly NAME = "workspaceChange";
public static readonly ENDPOINT = "/workspaceChange";
Expand All @@ -42,6 +44,10 @@ export class WorkspaceChangeEvent extends BaseEvent<WorkspaceChangeData> {

public onSuccessPostEventCallback = async (): Promise<void> => {
LOGGER.debug(`WorkspaceChange event sent successfully`);
setTimeout(()=>Telemetry.sendTelemetry(this), 60*60*24*1000);
if (workspaceChangeEventTimeout != null) {
clearTimeout(workspaceChangeEventTimeout);
workspaceChangeEventTimeout = null;
}
workspaceChangeEventTimeout = setTimeout(() => Telemetry.sendTelemetry(this), 60 * 60 * 24 * 1000);
};
}

0 comments on commit 6644d24

Please sign in to comment.