Add telemetry to App
This commit is contained in:
@@ -4,11 +4,13 @@ import { AppEventEmitter } from "./events";
|
||||
import { NotificationLogger } from "./logging";
|
||||
import { Memento } from "./memento";
|
||||
import { AppCommandManager } from "./commands";
|
||||
import { AppTelemetry } from "./telemetry";
|
||||
|
||||
export interface App {
|
||||
createEventEmitter<T>(): AppEventEmitter<T>;
|
||||
readonly mode: AppMode;
|
||||
readonly logger: NotificationLogger;
|
||||
readonly telemetry?: AppTelemetry;
|
||||
readonly subscriptions: Disposable[];
|
||||
readonly extensionPath: string;
|
||||
readonly globalStoragePath: string;
|
||||
|
||||
@@ -9,6 +9,8 @@ import { VSCodeAppEventEmitter } from "./events";
|
||||
import { AppCommandManager, QueryServerCommandManager } from "../commands";
|
||||
import { createVSCodeCommandManager } from "./commands";
|
||||
import { AppEnvironmentContext } from "./environment-context";
|
||||
import { AppTelemetry } from "../telemetry";
|
||||
import { telemetryListener } from "./telemetry";
|
||||
|
||||
export class ExtensionApp implements App {
|
||||
public readonly credentials: VSCodeCredentials;
|
||||
@@ -59,6 +61,10 @@ export class ExtensionApp implements App {
|
||||
return extLogger;
|
||||
}
|
||||
|
||||
public get telemetry(): AppTelemetry | undefined {
|
||||
return telemetryListener;
|
||||
}
|
||||
|
||||
public createEventEmitter<T>(): AppEventEmitter<T> {
|
||||
return new VSCodeAppEventEmitter<T>();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import { Credentials } from "../../src/common/authentication";
|
||||
import { AppCommandManager } from "../../src/common/commands";
|
||||
import { createMockCommandManager } from "./commandsMock";
|
||||
import { NotificationLogger } from "../../src/common";
|
||||
import { AppTelemetry } from "../../src/common/telemetry";
|
||||
import { createMockTelemetryReporter } from "./telemetryMock";
|
||||
|
||||
export function createMockApp({
|
||||
extensionPath = "/mock/extension/path",
|
||||
@@ -20,6 +22,7 @@ export function createMockApp({
|
||||
commands = createMockCommandManager(),
|
||||
environment = createMockEnvironmentContext(),
|
||||
logger = createMockLogger(),
|
||||
telemetry = createMockTelemetryReporter(),
|
||||
}: {
|
||||
extensionPath?: string;
|
||||
workspaceStoragePath?: string;
|
||||
@@ -30,10 +33,12 @@ export function createMockApp({
|
||||
commands?: AppCommandManager;
|
||||
environment?: EnvironmentContext;
|
||||
logger?: NotificationLogger;
|
||||
telemetry?: AppTelemetry;
|
||||
}): App {
|
||||
return {
|
||||
mode: AppMode.Test,
|
||||
logger,
|
||||
telemetry,
|
||||
subscriptions: [],
|
||||
extensionPath,
|
||||
workspaceStoragePath,
|
||||
|
||||
9
extensions/ql-vscode/test/__mocks__/telemetryMock.ts
Normal file
9
extensions/ql-vscode/test/__mocks__/telemetryMock.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { AppTelemetry } from "../../src/common/telemetry";
|
||||
|
||||
export function createMockTelemetryReporter(): AppTelemetry {
|
||||
return {
|
||||
sendCommandUsage: jest.fn(),
|
||||
sendUIInteraction: jest.fn(),
|
||||
sendError: jest.fn(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user