Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/actions/browser/actionbar.ts
13397 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { ActionBar, IActionBarOptions } from '../../../base/browser/ui/actionbar/actionbar.js';
7
import { WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from '../../../base/common/actions.js';
8
import { ITelemetryService } from '../../telemetry/common/telemetry.js';
9
10
export interface IWorkbenchActionBarOptions extends IActionBarOptions {
11
/**
12
* When set the `workbenchActionExecuted` is automatically sent for each invoked action. The `from` property
13
* of the event will be the passed `telemetrySource`-value.
14
*/
15
telemetrySource?: string;
16
}
17
18
/**
19
* A {@link ActionBar action bar} that automatically sends `workbenchActionExecuted` telemetry
20
* events for each invoked action, like {@link import('./toolbar.js').WorkbenchToolBar WorkbenchToolBar} does.
21
*/
22
export class WorkbenchActionBar extends ActionBar {
23
24
constructor(
25
container: HTMLElement,
26
options: IWorkbenchActionBarOptions,
27
@ITelemetryService telemetryService: ITelemetryService,
28
) {
29
super(container, options);
30
31
const telemetrySource = options.telemetrySource;
32
if (telemetrySource) {
33
this._store.add(this.onDidRun(e => telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>(
34
'workbenchActionExecuted',
35
{ id: e.action.id, from: telemetrySource })
36
));
37
}
38
}
39
}
40
41