mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Add telemetry for Python on Jupyter server startup (#19970)
* add telemetry for python on jupyter server startup * remove extra lines
This commit is contained in:
@@ -22,7 +22,7 @@ import { BookTocManager, IBookTocManager, quickPickResults } from './bookTocMana
|
||||
import { CreateBookDialog } from '../dialog/createBookDialog';
|
||||
import { AddTocEntryDialog } from '../dialog/addTocEntryDialog';
|
||||
import { getContentPath } from './bookVersionHandler';
|
||||
import { TelemetryReporter, BookTelemetryView, NbTelemetryActions } from '../telemetry';
|
||||
import { sendNotebookActionEvent, NbTelemetryView, NbTelemetryAction } from '../telemetry';
|
||||
|
||||
interface BookSearchResults {
|
||||
notebookPaths: string[];
|
||||
@@ -124,7 +124,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
}
|
||||
});
|
||||
}
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.TrustNotebook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.TrustNotebook);
|
||||
void vscode.window.showInformationMessage(loc.msgBookTrusted);
|
||||
} else {
|
||||
void vscode.window.showInformationMessage(loc.msgBookAlreadyTrusted);
|
||||
@@ -136,7 +136,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
let bookPathToUpdate = bookTreeItem.book?.contentPath;
|
||||
if (bookPathToUpdate) {
|
||||
let pinStatusChanged = await this.bookPinManager.pinNotebook(bookTreeItem);
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.PinNotebook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.PinNotebook);
|
||||
if (pinStatusChanged) {
|
||||
bookTreeItem.contextValue = 'pinnedNotebook';
|
||||
}
|
||||
@@ -155,7 +155,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
|
||||
async createBook(): Promise<void> {
|
||||
const dialog = new CreateBookDialog(this.bookTocManager);
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.CreateBook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.CreateBook);
|
||||
return dialog.createDialog();
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
* @param treeItems Elements to be moved
|
||||
*/
|
||||
async moveTreeItems(treeItems: BookTreeItem[]): Promise<void> {
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.MoveNotebook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.MoveNotebook);
|
||||
const selectionResults = await this.bookSectionQuickPick();
|
||||
if (selectionResults) {
|
||||
let pickedSection = selectionResults.quickPickSection;
|
||||
@@ -250,7 +250,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
await this.showPreviewFile(urlToOpen);
|
||||
}
|
||||
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.OpenBook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.OpenBook);
|
||||
} catch (e) {
|
||||
// if there is an error remove book from context
|
||||
const index = this.books.findIndex(book => book.bookPath === bookPath);
|
||||
@@ -317,7 +317,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
}
|
||||
this._onDidChangeTreeData.fire(undefined);
|
||||
}
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.CloseBook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.CloseBook);
|
||||
} catch (e) {
|
||||
void vscode.window.showErrorMessage(loc.closeBookError(book.root, e instanceof Error ? e.message : e));
|
||||
} finally {
|
||||
@@ -402,7 +402,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
this._visitedNotebooks = this._visitedNotebooks.concat([normalizedResource]);
|
||||
}
|
||||
}
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.OpenNotebookFromBook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.OpenNotebookFromBook);
|
||||
} catch (e) {
|
||||
void vscode.window.showErrorMessage(loc.openNotebookError(resource, e instanceof Error ? e.message : e));
|
||||
}
|
||||
@@ -754,7 +754,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
|
||||
async onDrop(sources: vscode.TreeDataTransfer, target: BookTreeItem): Promise<void> {
|
||||
if (target.contextValue === BookTreeItemType.savedBook || target.contextValue === BookTreeItemType.section) {
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.DragAndDrop);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.DragAndDrop);
|
||||
// gets the tree items that are dragged and dropped
|
||||
let treeItems = JSON.parse(await sources.items.get(this.supportedTypes[0])!.asString()) as BookTreeItem[];
|
||||
let rootItems = this.getLocalRoots(treeItems);
|
||||
|
||||
@@ -20,7 +20,7 @@ import { IconPathHelper } from './common/iconHelper';
|
||||
import { ExtensionContextHelper } from './common/extensionContextHelper';
|
||||
import { BookTreeItem } from './book/bookTreeItem';
|
||||
import Logger from './common/logger';
|
||||
import { TelemetryReporter, BookTelemetryView, NbTelemetryActions } from './telemetry';
|
||||
import { sendNotebookActionEvent, NbTelemetryView, NbTelemetryAction } from './telemetry';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -81,7 +81,7 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
||||
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.openRemoteBook', async () => {
|
||||
let dialog = new RemoteBookDialog(remoteBookController);
|
||||
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.AddRemoteBook);
|
||||
sendNotebookActionEvent(NbTelemetryView.Book, NbTelemetryAction.AddRemoteBook);
|
||||
return dialog.createDialog();
|
||||
}));
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import { IServerInstance } from './common';
|
||||
import { JupyterServerInstallation } from './jupyterServerInstallation';
|
||||
import * as utils from '../common/utils';
|
||||
import * as constants from '../common/constants';
|
||||
import { sendNotebookActionEvent, NbTelemetryView, NbTelemetryAction } from '../telemetry';
|
||||
|
||||
const NotebookConfigFilename = 'jupyter_notebook_config.py';
|
||||
const CustomJsFilename = 'custom.js';
|
||||
@@ -218,6 +219,7 @@ export class PerFolderServerInstance implements IServerInstance {
|
||||
|
||||
// Execute the command
|
||||
await this.executeStartCommand(startCommand);
|
||||
sendNotebookActionEvent(NbTelemetryView.Jupyter, NbTelemetryAction.JupyterServerStarted, { pythonVersion: this.options.install.installedPythonVersion, usingExistingPython: String(JupyterServerInstallation.getExistingPythonSetting()), usingConda: String(this.options.install.usingConda) });
|
||||
}
|
||||
|
||||
private executeStartCommand(startCommand: string): Promise<void> {
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import AdsTelemetryReporter from '@microsoft/ads-extension-telemetry';
|
||||
import AdsTelemetryReporter, { TelemetryEventMeasures, TelemetryEventProperties } from '@microsoft/ads-extension-telemetry';
|
||||
|
||||
const packageJson = require('../package.json');
|
||||
export const TelemetryReporter = new AdsTelemetryReporter(packageJson.name, packageJson.version, packageJson.aiKey);
|
||||
|
||||
export const BookTelemetryView = 'Book';
|
||||
export enum NbTelemetryView {
|
||||
Book = 'Book',
|
||||
Jupyter = 'Jupyter'
|
||||
}
|
||||
|
||||
export enum NbTelemetryActions {
|
||||
export enum NbTelemetryAction {
|
||||
OpenNotebook = 'NotebookOpened',
|
||||
OpenMarkdown = 'MarkdownOpened',
|
||||
OpenBook = 'BookOpened',
|
||||
@@ -22,6 +25,14 @@ export enum NbTelemetryActions {
|
||||
OpenNotebookFromBook = 'NotebookOpenedFromBook',
|
||||
MoveNotebook = 'MoveNotebook',
|
||||
DragAndDrop = 'DragAndDrop',
|
||||
AddRemoteBook = 'AddRemoteBook'
|
||||
AddRemoteBook = 'AddRemoteBook',
|
||||
JupyterServerStarted = 'JupyterServerStarted'
|
||||
}
|
||||
|
||||
export function sendNotebookActionEvent(telemetryView: NbTelemetryView, telemetryAction: NbTelemetryAction, additionalProps?: TelemetryEventProperties, additionalMeasurements?: TelemetryEventMeasures): void {
|
||||
TelemetryReporter.createActionEvent(telemetryView, telemetryAction)
|
||||
.withAdditionalProperties(additionalProps)
|
||||
.withAdditionalMeasurements(additionalMeasurements)
|
||||
.send();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user