mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Add sqlproj property to trace the origin of the project. (#18670)
* Add sqlproj property to trace the origin of the project. As part of the database migration process (schema conversion, in particular) we want to be able to tell when converted schemas are being built/deployed to the actual database server. Given that we rely on the SQL Database Projects ADS extension for the compilation/deployment, we don't have too many options other than updating the said extension. The suggested approach is to make the following changes: 1) Add new property to the sqlproj file (called `DatabaseSource`), which will maintain the origin(s) of the project. The property can contain multiple values (separated by semicolon), in case same project contains objects produced by multiple sources (extract schema, convert from another database, etc.). 2) During build and deploy actions, send the well-known values from the newly added property to the telemetry. We don't want to send any random value of the property, as it may raise some privacy concerns. Instead we define a list of the well-known values that we know do not carry any personal information and send those, if they are specified. This change adds all necessary APIs to the SQl Database projects extension which will be consumed by our migration extensions to populate new `DatabaseSource` property. * Use `undefined` instead of `null` Co-authored-by: Kim Santiago <kisantia@microsoft.com>
This commit is contained in:
@@ -599,3 +599,33 @@ export function getFoldersAlongPath(startFolder: string, endFolder: string): str
|
||||
|
||||
return folders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether provided value is a well-known database source and therefore is allowed to be sent in telemetry.
|
||||
*
|
||||
* @param value Value to check if it is a well-known database source
|
||||
* @returns Normalized database source value if it is well-known, otherwise returns undefined
|
||||
*/
|
||||
export function getWellKnownDatabaseSource(value: string): string | undefined {
|
||||
const upperCaseValue = value.toUpperCase();
|
||||
return constants.WellKnownDatabaseSources
|
||||
.find(wellKnownSource => wellKnownSource.toUpperCase() === upperCaseValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters an array of specified database project sources to only those that are well-known.
|
||||
*
|
||||
* @param databaseSourceValues Array of database source values to filter
|
||||
* @returns Array of well-known database sources
|
||||
*/
|
||||
export function getWellKnownDatabaseSources(databaseSourceValues: string[]): string[] {
|
||||
const databaseSourceSet = new Set<string>();
|
||||
for (let databaseSourceValue of databaseSourceValues) {
|
||||
const wellKnownDatabaseSourceValue = getWellKnownDatabaseSource(databaseSourceValue);
|
||||
if (wellKnownDatabaseSourceValue) {
|
||||
databaseSourceSet.add(wellKnownDatabaseSourceValue);
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(databaseSourceSet);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user