telemetry for tde user actions (#22474)

* telemetry for user actions

* remove unused action

* try catch around admin function
This commit is contained in:
junierch
2023-03-27 17:48:47 -04:00
committed by GitHub
parent e80c6f2dcb
commit e741fa0bbd
7 changed files with 71 additions and 20 deletions

View File

@@ -13,6 +13,7 @@ import * as constants from '../constants/strings';
import { logError, TelemetryViews } from '../telemetry';
import { AdsMigrationStatus } from '../dashboard/tabBase';
import { getMigrationMode, getMigrationStatus, getMigrationTargetType, hasRestoreBlockingReason, PipelineStatusCodes } from '../constants/helper';
import * as os from 'os';
export type TargetServerType = azure.SqlVMServer | azureResource.AzureSqlManagedInstance | azure.AzureSqlDatabaseServer;
@@ -923,3 +924,20 @@ export async function promptUserForFolder(): Promise<string> {
return '';
}
export function isWindows(): boolean { return (os.platform() === 'win32') }
export async function isAdmin(): Promise<boolean> {
let isAdmin: boolean = false;
try {
if (isWindows()) {
isAdmin = (await import('native-is-elevated'))();
} else {
isAdmin = process.getuid() === 0;
}
} catch (e) {
//Ignore error and return false;
}
return isAdmin;
}