Merge pull request #2115 from github/robertbrignull/cleanup_new_telemetry

Cleanup config to enabling new telemetry
This commit is contained in:
Robert
2023-03-03 14:13:47 +00:00
committed by GitHub
3 changed files with 23 additions and 66 deletions

View File

@@ -83,10 +83,6 @@ export const GLOBAL_ENABLE_TELEMETRY = new Setting(
GLOBAL_TELEMETRY_SETTING,
);
export function newTelemetryEnabled(): boolean {
return true;
}
// Distribution configuration
const DISTRIBUTION_SETTING = new Setting("cli", ROOT_SETTING);
export const CUSTOM_CODEQL_PATH_SETTING = new Setting(

View File

@@ -13,7 +13,6 @@ import {
LOG_TELEMETRY,
isIntegrationTestMode,
isCanary,
newTelemetryEnabled,
} from "./config";
import * as appInsights from "applicationinsights";
import { extLogger } from "./common";
@@ -174,10 +173,6 @@ export class TelemetryListener extends ConfigListener {
return;
}
if (!newTelemetryEnabled()) {
return;
}
this.reporter.sendTelemetryEvent(
"ui-interaction",
{
@@ -196,10 +191,6 @@ export class TelemetryListener extends ConfigListener {
return;
}
if (!newTelemetryEnabled()) {
return;
}
const properties: { [key: string]: string } = {
isCanary: isCanary().toString(),
message: error.redactedMessage,

View File

@@ -11,7 +11,6 @@ import {
} from "../../../src/telemetry";
import { UserCancellationException } from "../../../src/commandRunner";
import { ENABLE_TELEMETRY } from "../../../src/config";
import * as Config from "../../../src/config";
import { createMockExtensionContext } from "./index";
import { vscodeGetConfigurationMock } from "../test-config";
import { redactableError } from "../../../src/pure/errors";
@@ -393,67 +392,38 @@ describe("telemetry reporting", () => {
expect(showInformationMessageSpy).toBeCalledTimes(1);
});
describe("when new telementry is not enabled", () => {
beforeEach(async () => {
jest.spyOn(Config, "newTelemetryEnabled").mockReturnValue(false);
});
it("should send a ui-interaction telementry event", async () => {
await telemetryListener.initialize();
it("should not send a ui-interaction telementry event", async () => {
await telemetryListener.initialize();
telemetryListener.sendUIInteraction("test");
telemetryListener.sendUIInteraction("test");
expect(sendTelemetryEventSpy).not.toBeCalled();
});
it("should not send an error telementry event", async () => {
await telemetryListener.initialize();
telemetryListener.sendError(redactableError`test`);
expect(sendTelemetryEventSpy).not.toBeCalled();
});
expect(sendTelemetryEventSpy).toHaveBeenCalledWith(
"ui-interaction",
{
name: "test",
isCanary,
},
{},
);
});
describe("when new telementry is enabled", () => {
beforeEach(async () => {
jest.spyOn(Config, "newTelemetryEnabled").mockReturnValue(true);
});
it("should send an error telementry event", async () => {
await telemetryListener.initialize();
it("should send a ui-interaction telementry event", async () => {
await telemetryListener.initialize();
telemetryListener.sendError(redactableError`test`);
telemetryListener.sendUIInteraction("test");
expect(sendTelemetryEventSpy).toHaveBeenCalledWith(
"ui-interaction",
{
name: "test",
isCanary,
},
{},
);
});
it("should send an error telementry event", async () => {
await telemetryListener.initialize();
telemetryListener.sendError(redactableError`test`);
expect(sendTelemetryEventSpy).toHaveBeenCalledWith(
"error",
{
message: "test",
isCanary,
stack: expect.any(String),
},
{},
);
});
expect(sendTelemetryEventSpy).toHaveBeenCalledWith(
"error",
{
message: "test",
isCanary,
stack: expect.any(String),
},
{},
);
});
it("should redact error message contents", async () => {
jest.spyOn(Config, "newTelemetryEnabled").mockReturnValue(true);
await telemetryListener.initialize();
telemetryListener.sendError(