Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean nb context menu telemetry with accurate from fields #229241

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,21 @@ export abstract class NotebookAction extends Action2 {
}

async run(accessor: ServicesAccessor, context?: any, ...additionalArgs: any[]): Promise<void> {
const isFromUI = !!context;
const from = isFromUI ? (this.isNotebookActionContext(context) ? 'notebookToolbar' : 'editorToolbar') : undefined;
let from;
if (context.source) {
from = context.source;
} else if (URI.isUri(context)) {
from = 'cellEditorContextMenu';
} else {
const contextJson = JSON.stringify(context);
if (contextJson.includes('"cellContainer"')) {
from = 'cellContainer';
} else {
from = undefined;
}
}


if (!this.isNotebookActionContext(context)) {
context = this.getEditorContextFromArgsOrActive(accessor, context, ...additionalArgs);
if (!context) {
Expand Down Expand Up @@ -252,7 +265,16 @@ export abstract class NotebookMultiCellAction extends Action2 {
if (editor) {
const selectedCellRange: ICellRange[] = editor.getSelections().length === 0 ? [editor.getFocus()] : editor.getSelections();

telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: this.desc.id, from: from });
const contextJson = JSON.stringify(context);
const telemetryService = accessor.get(ITelemetryService);
if (contextJson.includes('"cellContainer"')) {
telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: this.desc.id, from: 'cellContainer' });
} else if (URI.isUri(context)) {
const telemetryService = accessor.get(ITelemetryService);
telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: this.desc.id, from: 'cellEditorContextMenu' });
} else {
telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: this.desc.id, from: from });
}

return this.runWithContext(accessor, {
ui: false,
Expand Down Expand Up @@ -288,6 +310,16 @@ export abstract class NotebookCellAction<T = INotebookCellActionContext> extends

const activeEditorContext = this.getEditorContextFromArgsOrActive(accessor);
if (this.isCellActionContext(activeEditorContext)) {
if (URI.isUri(context)) {
const telemetryService = accessor.get(ITelemetryService);
telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: this.desc.id, from: 'cellEditorContextMenu' });
} else {
const contextJson = JSON.stringify(context);
const telemetryService = accessor.get(ITelemetryService);
if (contextJson.includes('"cellContainer"')) {
telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: this.desc.id, from: 'cellContainer' });
}
}
return this.runWithContext(accessor, activeEditorContext);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,16 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
private showListContextMenu(e: IListContextMenuEvent<CellViewModel>) {
this.contextMenuService.showContextMenu({
menuId: MenuId.NotebookCellTitle,
menuActionOptions: {
shouldForwardArgs: true
},
contextKeyService: this.scopedContextKeyService,
getAnchor: () => e.anchor
getAnchor: () => e.anchor,
getActionsContext: () => {
return {
from: 'cellContainer'
};
}
});
}

Expand Down
Loading