mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 17:23:02 -05:00
Add telemetry for opening dacpac wizard (#14884)
* add telemetry for opening dacpac wizard * add wizard open telemetry to core * fix tests * remove WizardOpen
This commit is contained in:
6
src/sql/azdata.proposed.d.ts
vendored
6
src/sql/azdata.proposed.d.ts
vendored
@@ -584,6 +584,12 @@ declare module 'azdata' {
|
||||
* Width of the wizard
|
||||
*/
|
||||
width?: DialogWidth;
|
||||
|
||||
/**
|
||||
* Open the wizard. Does nothing if the wizard is already open.
|
||||
* @param source Where the wizard was opened from for telemetry (ex: command palette, context menu)
|
||||
*/
|
||||
open(source?: string): Thenable<void>;
|
||||
}
|
||||
|
||||
export interface WizardPage extends ModelViewPanel {
|
||||
|
||||
@@ -256,11 +256,11 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
|
||||
return modal.showPage(pageIndex);
|
||||
}
|
||||
|
||||
public $openWizard(handle: number): Thenable<void> {
|
||||
public $openWizard(handle: number, source?: string): Thenable<void> {
|
||||
let wizard = this.getWizard(handle);
|
||||
const options = assign({}, DefaultWizardOptions);
|
||||
options.width = wizard.width;
|
||||
this._dialogService.showWizard(wizard, options);
|
||||
this._dialogService.showWizard(wizard, options, source);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
@@ -502,8 +502,8 @@ class WizardImpl implements azdata.window.Wizard {
|
||||
return this._extHostModelViewDialog.setWizardPage(this, index);
|
||||
}
|
||||
|
||||
public open(): Thenable<void> {
|
||||
return this._extHostModelViewDialog.openWizard(this);
|
||||
public open(source?: string): Thenable<void> {
|
||||
return this._extHostModelViewDialog.openWizard(this, source);
|
||||
}
|
||||
|
||||
public close(): Thenable<void> {
|
||||
@@ -943,10 +943,10 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
|
||||
return this._proxy.$setWizardPage(this.getHandle(wizard), pageIndex);
|
||||
}
|
||||
|
||||
public openWizard(wizard: azdata.window.Wizard): Thenable<void> {
|
||||
public openWizard(wizard: azdata.window.Wizard, source?: string): Thenable<void> {
|
||||
let handle = this.getHandle(wizard);
|
||||
this.updateWizard(wizard);
|
||||
return this._proxy.$openWizard(handle);
|
||||
return this._proxy.$openWizard(handle, source);
|
||||
}
|
||||
|
||||
public closeWizard(wizard: azdata.window.Wizard): Thenable<void> {
|
||||
|
||||
@@ -826,7 +826,7 @@ export interface MainThreadModelViewDialogShape extends IDisposable {
|
||||
$setDialogDetails(handle: number, details: IModelViewDialogDetails): Thenable<void>;
|
||||
$setTabDetails(handle: number, details: IModelViewTabDetails): Thenable<void>;
|
||||
$setButtonDetails(handle: number, details: IModelViewButtonDetails): Thenable<void>;
|
||||
$openWizard(handle: number): Thenable<void>;
|
||||
$openWizard(handle: number, source?: string): Thenable<void>;
|
||||
$closeWizard(handle: number): Thenable<void>;
|
||||
$setWizardPageDetails(handle: number, details: IModelViewWizardPageDetails): Thenable<void>;
|
||||
$setWizardDetails(handle: number, details: IModelViewWizardDetails): Thenable<void>;
|
||||
|
||||
@@ -465,8 +465,9 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
|
||||
/**
|
||||
* Shows the modal and attaches key listeners
|
||||
* @param source Where the modal was opened from for telemetry (ex: command palette, context menu)
|
||||
*/
|
||||
protected show() {
|
||||
protected show(source?: string) {
|
||||
if (this._modalOptions.dialogStyle === 'callout') {
|
||||
this.positionCalloutDialog();
|
||||
}
|
||||
@@ -496,7 +497,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
}));
|
||||
|
||||
this.layout(DOM.getTotalHeight(this._modalBodySection!));
|
||||
this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.ModalDialogOpened)
|
||||
this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.TelemetryAction.ModalDialogOpened, undefined, source)
|
||||
.withAdditionalProperties({ name: this._name })
|
||||
.send();
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ export class CustomDialogService {
|
||||
dialogModal.open();
|
||||
}
|
||||
|
||||
public showWizard(wizard: Wizard, options?: IModalOptions): void {
|
||||
public showWizard(wizard: Wizard, options?: IModalOptions, source?: string): void {
|
||||
let wizardModal = this._instantiationService.createInstance(WizardModal, wizard, options || DefaultWizardOptions);
|
||||
this._wizardModals.set(wizard, wizardModal);
|
||||
wizardModal.render();
|
||||
wizardModal.open();
|
||||
wizardModal.open(source);
|
||||
}
|
||||
|
||||
public closeDialog(dialog: Dialog): void {
|
||||
|
||||
@@ -261,9 +261,13 @@ export class WizardModal extends Modal {
|
||||
() => undefined);
|
||||
}
|
||||
|
||||
public open(): void {
|
||||
/**
|
||||
* Opens the dialog to the first page
|
||||
* @param source Where the wizard was opened from for telemetry (ex: command palette, context menu)
|
||||
*/
|
||||
public open(source?: string): void {
|
||||
this.showPage(0, false, true).then(() => {
|
||||
this.show();
|
||||
this.show(source);
|
||||
}).catch(err => onUnexpectedError(err));
|
||||
}
|
||||
|
||||
|
||||
@@ -141,13 +141,14 @@ suite('ExtHostModelViewDialog Tests', () => {
|
||||
});
|
||||
|
||||
test('Opening a wizard updates its pages and buttons on the main thread', () => {
|
||||
mockProxy.setup(x => x.$openWizard(It.isAny()));
|
||||
mockProxy.setup(x => x.$openWizard(It.isAny(), It.isAny()));
|
||||
mockProxy.setup(x => x.$setWizardDetails(It.isAny(), It.isAny()));
|
||||
mockProxy.setup(x => x.$setWizardPageDetails(It.isAny(), It.isAny()));
|
||||
mockProxy.setup(x => x.$setButtonDetails(It.isAny(), It.isAny()));
|
||||
|
||||
// Create a wizard with 2 pages and 2 custom buttons
|
||||
let wizardTitle = 'wizard_title';
|
||||
let source = 'command palette';
|
||||
let wizard = extHostModelViewDialog.createWizard(wizardTitle);
|
||||
let page1Title = 'page_1';
|
||||
let page1 = extHostModelViewDialog.createWizardPage(page1Title);
|
||||
@@ -162,7 +163,7 @@ suite('ExtHostModelViewDialog Tests', () => {
|
||||
wizard.customButtons = [button1, button2];
|
||||
|
||||
// Open the wizard and verify that the correct main thread methods were called
|
||||
extHostModelViewDialog.openWizard(wizard);
|
||||
extHostModelViewDialog.openWizard(wizard, source);
|
||||
mockProxy.verify(x => x.$setButtonDetails(It.isAny(), It.is(details => {
|
||||
return details.enabled === false && details.label === button1Label;
|
||||
})), Times.atLeastOnce());
|
||||
@@ -179,7 +180,7 @@ suite('ExtHostModelViewDialog Tests', () => {
|
||||
return details.title === wizardTitle && details.pages.length === 2 && details.customButtons.length === 2 &&
|
||||
details.displayPageTitles === true;
|
||||
})), Times.atLeastOnce());
|
||||
mockProxy.verify(x => x.$openWizard(It.isAny()), Times.once());
|
||||
mockProxy.verify(x => x.$openWizard(It.isAny(), It.isAny()), Times.once());
|
||||
});
|
||||
|
||||
test('Wizard page changed events are handled correctly', () => {
|
||||
|
||||
@@ -52,6 +52,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
let page2Handle = 12;
|
||||
let wizardHandle = 13;
|
||||
let page3Handle = 14;
|
||||
let source = 'command palette';
|
||||
|
||||
setup(() => {
|
||||
mockExtHostModelViewDialog = Mock.ofInstance(<ExtHostModelViewDialogShape>{
|
||||
@@ -73,7 +74,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
mockDialogService.setup(x => x.showDialog(It.isAny(), undefined, It.isAny())).callback((dialog) => {
|
||||
openedDialog = dialog;
|
||||
});
|
||||
mockDialogService.setup(x => x.showWizard(It.isAny(), It.isAny())).callback(wizard => {
|
||||
mockDialogService.setup(x => x.showWizard(It.isAny(), It.isAny(), It.isAny())).callback(wizard => {
|
||||
openedWizard = wizard;
|
||||
// The actual service will set the page to 0 when it opens the wizard
|
||||
openedWizard.setCurrentPage(0);
|
||||
@@ -247,10 +248,10 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
|
||||
test('Creating a wizard and calling open on it causes a wizard with correct pages and buttons to open', () => {
|
||||
// If I open the wizard
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle);
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle, source);
|
||||
|
||||
// Then the opened wizard's content and buttons match what was set
|
||||
mockDialogService.verify(x => x.showWizard(It.isAny(), It.isAny()), Times.once());
|
||||
mockDialogService.verify(x => x.showWizard(It.isAny(), It.isAny(), It.isAny()), Times.once());
|
||||
assert.notEqual(openedWizard, undefined);
|
||||
assert.equal(openedWizard.title, wizardDetails.title);
|
||||
assert.equal(openedWizard.doneButton.label, okButtonDetails.label);
|
||||
@@ -281,7 +282,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
mockExtHostModelViewDialog.setup(x => x.$onWizardPageChanged(It.isAny(), It.isAny()));
|
||||
|
||||
// If I open the wizard and change the page to index 1
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle);
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle, source);
|
||||
openedWizard.setCurrentPage(1);
|
||||
|
||||
// Then a page changed event gets sent to the extension host
|
||||
@@ -314,7 +315,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
};
|
||||
|
||||
// If I open the wizard and then add a page
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle);
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle, source);
|
||||
mainThreadModelViewDialog.$setWizardPageDetails(page3Handle, page3Details);
|
||||
mainThreadModelViewDialog.$addWizardPage(wizardHandle, page3Handle, 0);
|
||||
|
||||
@@ -329,7 +330,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
mockExtHostModelViewDialog.setup(x => x.$updateWizardPageInfo(It.isAny(), It.isAny(), It.isAny()));
|
||||
|
||||
// If I open the wizard and then remove a page
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle);
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle, source);
|
||||
mainThreadModelViewDialog.$removeWizardPage(wizardHandle, 0);
|
||||
|
||||
// Then the updated page info gets sent to the extension host
|
||||
@@ -343,7 +344,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
mockExtHostModelViewDialog.setup(x => x.$validateNavigation(It.isAny(), It.isAny()));
|
||||
|
||||
// If I call validateNavigation on the wizard that gets created
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle);
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle, source);
|
||||
openedWizard.validateNavigation(1);
|
||||
|
||||
// Then the call gets forwarded to the extension host
|
||||
@@ -351,7 +352,7 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
});
|
||||
|
||||
test('Adding a message to a wizard fires events on the created wizard', () => {
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle);
|
||||
mainThreadModelViewDialog.$openWizard(wizardHandle, source);
|
||||
let newMessage: DialogMessage;
|
||||
openedWizard.onMessageChange(message => newMessage = message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user