Skip to content

Commit 9f32eec

Browse files
committed
refactor: apply telemetry review conventions
Make telemetry dimensions explicit at every call site: suspendSession and clearDeployment now require a reason instead of defaulting (the suspendSession default was never used in production), and CliCredentialManager requires its TelemetryReporter rather than silently falling back to the noop reporter. Replace the scenario DSL in commands.telemetry.test.ts with plain it() blocks on a shared setup() that reuses createTelemetryHarness, and drop the unused clearDeploymentError option.
1 parent 23a5367 commit 9f32eec

4 files changed

Lines changed: 148 additions & 201 deletions

File tree

src/core/cliCredentialManager.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ import {
1414
} from "../instrumentation/credentials";
1515
import { isKeyringEnabled } from "../settings/cli";
1616
import { getHeaderArgs } from "../settings/headers";
17-
import {
18-
NOOP_TELEMETRY_REPORTER,
19-
type TelemetryReporter,
20-
} from "../telemetry/reporter";
17+
import { type TelemetryReporter } from "../telemetry/reporter";
2118
import { toSafeHost } from "../util";
2219
import { writeAtomically } from "../util/fs";
2320

@@ -62,7 +59,7 @@ export class CliCredentialManager {
6259
private readonly logger: Logger,
6360
private readonly resolveBinary: BinaryResolver,
6461
private readonly pathResolver: PathResolver,
65-
telemetry: TelemetryReporter = NOOP_TELEMETRY_REPORTER,
62+
telemetry: TelemetryReporter,
6663
) {
6764
this.credentialTelemetry = new CredentialTelemetry(telemetry);
6865
}

src/deployment/deploymentManager.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ export class DeploymentManager implements vscode.Disposable {
182182
/**
183183
* Clears the current deployment.
184184
*/
185-
public async clearDeployment(
186-
reason: DeploymentSuspendReason = "credentials_removed",
187-
): Promise<void> {
185+
public async clearDeployment(reason: DeploymentSuspendReason): Promise<void> {
188186
this.logger.debug("Clearing deployment", this.#deployment?.safeHostname);
189187
this.suspendSession(reason);
190188
this.#authListenerDisposable?.dispose();
@@ -199,9 +197,7 @@ export class DeploymentManager implements vscode.Disposable {
199197
* Suspend session: shows logged-out state but keeps deployment for easy re-login.
200198
* Auth listener remains active so recovery can happen automatically if tokens update.
201199
*/
202-
public suspendSession(
203-
reason: DeploymentSuspendReason = "auth_config_change",
204-
): void {
200+
public suspendSession(reason: DeploymentSuspendReason): void {
205201
const wasAuthenticated = this.isAuthenticated();
206202
this.oauthSessionManager.clearDeployment();
207203
this.client.setCredentials(undefined, undefined);
@@ -267,7 +263,7 @@ export class DeploymentManager implements vscode.Disposable {
267263
);
268264
}
269265
} else {
270-
await this.clearDeployment();
266+
await this.clearDeployment("credentials_removed");
271267
}
272268
},
273269
);

0 commit comments

Comments
 (0)