SQL Bindings add telemetry points (#20125)

* add telemetry points

* address comments
This commit is contained in:
Vasu Bhog
2022-07-27 16:38:37 -07:00
committed by GitHub
parent 4411a1f319
commit 514b0315cc
3 changed files with 23 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ import { ConnectionDetails, IConnectionInfo } from 'vscode-mssql';
import { AzureFunctionsExtensionApi } from '../../../types/vscode-azurefunctions.api';
// https://github.com/microsoft/vscode-azuretools/blob/main/ui/api.d.ts
import { AzureExtensionApiProvider } from '../../../types/vscode-azuretools.api';
import { TelemetryActions, TelemetryReporter, TelemetryViews } from './telemetry';
/**
* Represents the settings in an Azure function project's locawl.settings.json file
*/
@@ -239,6 +240,7 @@ export function waitForNewHostFile(): IFileFunctionObject {
*/
export async function addSqlNugetReferenceToProjectFile(selectedProjectFile: string): Promise<void> {
await utils.executeCommand(`dotnet add "${selectedProjectFile}" package ${constants.sqlExtensionPackageName} --prerelease`);
TelemetryReporter.sendActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.addSQLNugetPackage);
}
/**

View File

@@ -11,7 +11,8 @@ export const TelemetryReporter = new AdsTelemetryReporter(packageInfo.name, pack
export enum TelemetryViews {
SqlBindingsQuickPick = 'SqlBindingsQuickPick',
CreateAzureFunctionWithSqlBinding = 'CreateAzureFunctionWithSqlBinding'
CreateAzureFunctionWithSqlBinding = 'CreateAzureFunctionWithSqlBinding',
AzureFunctionsUtils = 'AzureFunctionsUtils',
}
export enum TelemetryActions {
@@ -28,9 +29,13 @@ export enum TelemetryActions {
updateConnectionString = 'updateConnectionString',
finishAddSqlBinding = 'finishAddSqlBinding',
exitSqlBindingsQuickpick = 'exitSqlBindingsQuickpick',
// Azure Functions Utils
addSQLNugetPackage = 'addSQLNugetPackage',
}
export enum CreateAzureFunctionStep {
noAzureFunctionsExtension = 'noAzureFunctionsExtension',
getAzureFunctionProject = 'getAzureFunctionProject',
learnMore = 'learnMore',
helpCreateAzureFunctionProject = 'helpCreateAzureFunctionProject',

View File

@@ -29,11 +29,13 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
let newFunctionFileObject: azureFunctionsUtils.IFileFunctionObject | undefined;
try {
// check to see if Azure Functions Extension is installed
const azureFunctionApi = await azureFunctionsUtils.getAzureFunctionsExtensionApi();
if (!azureFunctionApi) {
exitReason = ExitReason.error;
propertyBag.exitReason = exitReason;
TelemetryReporter.createErrorEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.exitCreateAzureFunctionQuickpick)
telemetryStep = CreateAzureFunctionStep.noAzureFunctionsExtension;
TelemetryReporter.createErrorEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, telemetryStep)
.withAdditionalProperties(propertyBag).send();
return;
}
@@ -70,6 +72,7 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
{ title: constants.selectAzureFunctionProjFolder, ignoreFocusOut: true });
if (!browseProjectLocation) {
// User cancelled
exitReason = ExitReason.cancelled;
return;
}
const projectFolders = (await vscode.window.showOpenDialog({
@@ -80,6 +83,7 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
}));
if (!projectFolders) {
// User cancelled
exitReason = ExitReason.cancelled;
return;
}
projectFolder = projectFolders[0].fsPath;
@@ -89,6 +93,7 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
break;
} else {
// user cancelled
exitReason = ExitReason.cancelled;
return;
}
}
@@ -109,6 +114,7 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
let chosenObjectType = await azureFunctionsUtils.promptForObjectType();
if (!chosenObjectType) {
// User cancelled
exitReason = ExitReason.cancelled;
return;
}
@@ -116,6 +122,8 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
telemetryStep = CreateAzureFunctionStep.getBindingType;
selectedBindingType = await azureFunctionsUtils.promptForBindingType(chosenObjectType);
if (!selectedBindingType) {
// User cancelled
exitReason = ExitReason.cancelled;
return;
}
@@ -137,6 +145,7 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
}
if (!connectionInfo) {
// User cancelled
exitReason = ExitReason.cancelled;
return;
}
TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, telemetryStep)
@@ -174,6 +183,8 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
let nodeType = ObjectType.Table === node.nodeType ? ObjectType.Table : ObjectType.View;
selectedBindingType = await azureFunctionsUtils.promptForBindingType(nodeType);
if (!selectedBindingType) {
// User cancelled
exitReason = ExitReason.cancelled;
return;
}
@@ -201,6 +212,8 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
validateInput: input => utils.validateFunctionName(input)
}) as string;
if (!functionName) {
// User cancelled
exitReason = ExitReason.cancelled;
return;
}
TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, telemetryStep)
@@ -219,6 +232,7 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
connectionStringInfo = await azureFunctionsUtils.promptAndUpdateConnectionStringSetting(vscode.Uri.parse(projectFile), connectionInfo);
if (!connectionStringInfo) {
// User cancelled connection string setting name prompt or connection string method prompt
exitReason = ExitReason.cancelled;
return;
}
TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, telemetryStep)