Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a few telemetry points for preview features #18887

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/controllers/executionPlanWebviewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class ExecutionPlanWebviewController extends ReactWebviewPanelController<
state,
this.executionPlanService,
[this.executionPlanContents],
"SqlplanFile",
);
return {
...state,
Expand Down
7 changes: 7 additions & 0 deletions src/controllers/mainController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@ export default class MainController implements vscode.Disposable {
await this.sanitizeConnectionProfiles();
await this.loadTokenCache();
Utils.logDebug("activated.");

// capture basic metadata
sendActionEvent(TelemetryViews.General, TelemetryActions.Activated, {
isExperimental: this.isExperimentalEnabled.toString(),
isRichExperiences: this.isRichExperiencesEnabled.toString(),
});

this._initialized = true;
return true;
}
Expand Down
31 changes: 19 additions & 12 deletions src/controllers/sharedExecutionPlanUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function saveExecutionPlan(
const saveUri = await vscode.window.showSaveDialog({
defaultUri: await getUniqueFilePath(folder, `plan`, sqlPlanLanguageId),
filters: {
[executionPlanFileFilter]: [`.${sqlPlanLanguageId}`],
[executionPlanFileFilter]: [`${sqlPlanLanguageId}`],
},
});

Expand Down Expand Up @@ -86,10 +86,15 @@ export async function updateTotalCost(
};
}

/**
* Creates the execution plan graph state from XML, and loads them into `state`
* @param source the UI making the call, for telemetry purposes.
*/
export async function createExecutionPlanGraphs(
state: QueryResultWebviewState | ExecutionPlanWebviewState,
executionPlanService: ExecutionPlanService,
xmlPlans: string[],
source: "SqlplanFile" | "QueryResults",
) {
let newState = {
...state.executionPlanState,
Expand All @@ -105,23 +110,25 @@ export async function createExecutionPlanGraphs(
(await executionPlanService.getExecutionPlan(planFile)).graphs,
);
newState.loadState = ApiStatus.Loaded;

sendActionEvent(
TelemetryViews.ExecutionPlan,
TelemetryActions.OpenExecutionPlan,
{},
{
numberOfPlans:
state.executionPlanState.executionPlanGraphs.length,
loadTimeInMs: performance.now() - startTime,
},
);
} catch (e) {
// malformed xml
newState.loadState = ApiStatus.Error;
newState.errorMessage = getErrorMessage(e);
}
}

sendActionEvent(
TelemetryViews.ExecutionPlan,
TelemetryActions.OpenExecutionPlan,
{
source: source,
},
{
numberOfPlans: state.executionPlanState.executionPlanGraphs.length,
loadTimeInMs: performance.now() - startTime,
},
);

state.executionPlanState = newState;
state.executionPlanState.totalCost = calculateTotalCost(state);

Expand Down
1 change: 1 addition & 0 deletions src/queryResult/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export function registerCommonRequestHandlers(
Object.values(
currentResultState.executionPlanState.xmlPlans,
),
"QueryResults",
)) as qr.QueryResultWebviewState;
state.executionPlanState.loadState = ApiStatus.Loaded;
state.tabStates.resultPaneTab =
Expand Down
1 change: 1 addition & 0 deletions src/sharedInterfaces/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum TelemetryViews {
}

export enum TelemetryActions {
Activated = "Activated",
GenerateScript = "GenerateScript",
Refresh = "Refresh",
CreateProject = "CreateProject",
Expand Down
3 changes: 3 additions & 0 deletions test/unit/executionPlanWebviewController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ suite("ExecutionPlanWebviewController", () => {
mockInitialState,
controller.executionPlanService,
[controller.executionPlanContents],
"SqlplanFile",
],
"createExecutionPlanGraphs should be called with correct arguments",
);
Expand Down Expand Up @@ -402,6 +403,7 @@ suite("Execution Plan Utilities", () => {
mockInitialState,
mockExecutionPlanService,
[executionPlanContents],
"Tests" as never,
);

const planFile: ep.ExecutionPlanGraphInfo = {
Expand All @@ -428,6 +430,7 @@ suite("Execution Plan Utilities", () => {
mockInitialState,
mockExecutionPlanService,
[executionPlanContents],
"Tests" as never,
);

const planFile: ep.ExecutionPlanGraphInfo = {
Expand Down
Loading