Path: blob/main/src/vs/platform/actions/browser/actionbar.ts
13397 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { ActionBar, IActionBarOptions } from '../../../base/browser/ui/actionbar/actionbar.js';6import { WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from '../../../base/common/actions.js';7import { ITelemetryService } from '../../telemetry/common/telemetry.js';89export interface IWorkbenchActionBarOptions extends IActionBarOptions {10/**11* When set the `workbenchActionExecuted` is automatically sent for each invoked action. The `from` property12* of the event will be the passed `telemetrySource`-value.13*/14telemetrySource?: string;15}1617/**18* A {@link ActionBar action bar} that automatically sends `workbenchActionExecuted` telemetry19* events for each invoked action, like {@link import('./toolbar.js').WorkbenchToolBar WorkbenchToolBar} does.20*/21export class WorkbenchActionBar extends ActionBar {2223constructor(24container: HTMLElement,25options: IWorkbenchActionBarOptions,26@ITelemetryService telemetryService: ITelemetryService,27) {28super(container, options);2930const telemetrySource = options.telemetrySource;31if (telemetrySource) {32this._store.add(this.onDidRun(e => telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>(33'workbenchActionExecuted',34{ id: e.action.id, from: telemetrySource })35));36}37}38}394041