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'; import { AzureFunctionsExtensionApi } from '../../../types/vscode-azurefunctions.api';
// https://github.com/microsoft/vscode-azuretools/blob/main/ui/api.d.ts // https://github.com/microsoft/vscode-azuretools/blob/main/ui/api.d.ts
import { AzureExtensionApiProvider } from '../../../types/vscode-azuretools.api'; 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 * 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> { export async function addSqlNugetReferenceToProjectFile(selectedProjectFile: string): Promise<void> {
await utils.executeCommand(`dotnet add "${selectedProjectFile}" package ${constants.sqlExtensionPackageName} --prerelease`); 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 { export enum TelemetryViews {
SqlBindingsQuickPick = 'SqlBindingsQuickPick', SqlBindingsQuickPick = 'SqlBindingsQuickPick',
CreateAzureFunctionWithSqlBinding = 'CreateAzureFunctionWithSqlBinding' CreateAzureFunctionWithSqlBinding = 'CreateAzureFunctionWithSqlBinding',
AzureFunctionsUtils = 'AzureFunctionsUtils',
} }
export enum TelemetryActions { export enum TelemetryActions {
@@ -28,9 +29,13 @@ export enum TelemetryActions {
updateConnectionString = 'updateConnectionString', updateConnectionString = 'updateConnectionString',
finishAddSqlBinding = 'finishAddSqlBinding', finishAddSqlBinding = 'finishAddSqlBinding',
exitSqlBindingsQuickpick = 'exitSqlBindingsQuickpick', exitSqlBindingsQuickpick = 'exitSqlBindingsQuickpick',
// Azure Functions Utils
addSQLNugetPackage = 'addSQLNugetPackage',
} }
export enum CreateAzureFunctionStep { export enum CreateAzureFunctionStep {
noAzureFunctionsExtension = 'noAzureFunctionsExtension',
getAzureFunctionProject = 'getAzureFunctionProject', getAzureFunctionProject = 'getAzureFunctionProject',
learnMore = 'learnMore', learnMore = 'learnMore',
helpCreateAzureFunctionProject = 'helpCreateAzureFunctionProject', helpCreateAzureFunctionProject = 'helpCreateAzureFunctionProject',

View File

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