From 4a715e473a536fc66062d824baa72a05d54d5d7b Mon Sep 17 00:00:00 2001 From: Daniel Grajeda Date: Tue, 21 Sep 2021 21:56:46 -0600 Subject: [PATCH] Add guids to RunAll and RunCell events (#17123) Add guids to RunAll and RunCell events --- .../workbench/contrib/notebook/browser/notebookActions.ts | 7 ++++++- .../contrib/notebook/test/browser/notebookActions.test.ts | 4 ++++ src/sql/workbench/services/notebook/browser/models/cell.ts | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/contrib/notebook/browser/notebookActions.ts b/src/sql/workbench/contrib/notebook/browser/notebookActions.ts index 276d83e59f..2af1d1ad2b 100644 --- a/src/sql/workbench/contrib/notebook/browser/notebookActions.ts +++ b/src/sql/workbench/contrib/notebook/browser/notebookActions.ts @@ -375,8 +375,13 @@ export class RunAllCellsAction extends Action { } public override async run(context: URI): Promise { try { - this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Notebook, TelemetryKeys.NbTelemetryAction.RunAll); const editor = this._notebookService.findNotebookEditor(context); + + const azdata_notebook_guid: string = editor.model.getMetaValue('azdata_notebook_guid'); + this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Notebook, TelemetryKeys.NbTelemetryAction.RunAll) + .withAdditionalProperties({ azdata_notebook_guid }) + .send(); + await editor.runAllCells(); } catch (e) { this.notificationService.error(getErrorMessage(e)); diff --git a/src/sql/workbench/contrib/notebook/test/browser/notebookActions.test.ts b/src/sql/workbench/contrib/notebook/test/browser/notebookActions.test.ts index eff36fddf4..cc2f35a0ed 100644 --- a/src/sql/workbench/contrib/notebook/test/browser/notebookActions.test.ts +++ b/src/sql/workbench/contrib/notebook/test/browser/notebookActions.test.ts @@ -189,6 +189,10 @@ suite('Notebook Actions', function (): void { }); test('Run All Cells Action', async function (): Promise { + const testNotebookModel = TypeMoq.Mock.ofType(NotebookModelStub); + testNotebookModel.setup(x => x.getMetaValue(TypeMoq.It.isAny())).returns(() => undefined); + mockNotebookEditor.setup(x => x.model).returns(() => testNotebookModel.object); + let mockNotification = TypeMoq.Mock.ofType(TestNotificationService); mockNotification.setup(n => n.notify(TypeMoq.It.isAny())); diff --git a/src/sql/workbench/services/notebook/browser/models/cell.ts b/src/sql/workbench/services/notebook/browser/models/cell.ts index 46130ed54a..7e17bf78db 100644 --- a/src/sql/workbench/services/notebook/browser/models/cell.ts +++ b/src/sql/workbench/services/notebook/browser/models/cell.ts @@ -561,8 +561,9 @@ export class CellModel extends Disposable implements ICellModel { this._outputCounter = 0; // Hide IntelliSense suggestions list when running cell to match SSMS behavior this._commandService.executeCommand('hideSuggestWidget'); + const azdata_notebook_guid: string = this.notebookModel.getMetaValue('azdata_notebook_guid'); this._telemetryService?.createActionEvent(TelemetryKeys.TelemetryView.Notebook, TelemetryKeys.NbTelemetryAction.RunCell) - .withAdditionalProperties({ cell_language: kernel.name }) + .withAdditionalProperties({ cell_language: kernel.name, azdata_cell_guid: this._cellGuid, azdata_notebook_guid }) .send(); // If cell is currently running and user clicks the stop/cancel button, call kernel.interrupt() // This matches the same behavior as JupyterLab