Skip to content

Commit d29ab10

Browse files
committed
Implements telemetry for bracket colorizer 2 extension usage
1 parent 4b0d6f3 commit d29ab10

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

build/lib/i18n.resources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@
298298
"name": "vs/workbench/contrib/deprecatedExtensionMigrator",
299299
"project": "vscode-workbench"
300300
},
301+
{
302+
"name": "vs/workbench/contrib/bracketPairColorizer2Telemetry",
303+
"project": "vscode-workbench"
304+
},
301305
{
302306
"name": "vs/workbench/contrib/offline",
303307
"project": "vscode-workbench"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 { onUnexpectedError } from 'vs/base/common/errors';
7+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
8+
import { Registry } from 'vs/platform/registry/common/platform';
9+
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
10+
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
11+
import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
12+
import { EnablementState } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
13+
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
14+
15+
class BracketPairColorizer2TelemetryContribution {
16+
constructor(
17+
@IConfigurationService private readonly configurationService: IConfigurationService,
18+
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
19+
@ITelemetryService private readonly telemetryService: ITelemetryService
20+
) {
21+
this.init().catch(onUnexpectedError);
22+
}
23+
24+
private async init(): Promise<void> {
25+
const bracketPairColorizerId = 'coenraads.bracket-pair-colorizer-2';
26+
27+
await this.extensionsWorkbenchService.queryLocal();
28+
const extension = this.extensionsWorkbenchService.installed.find(e => e.identifier.id === bracketPairColorizerId);
29+
if (
30+
!extension ||
31+
((extension.enablementState !== EnablementState.EnabledGlobally) &&
32+
(extension.enablementState !== EnablementState.EnabledWorkspace))
33+
) {
34+
return;
35+
}
36+
37+
const nativeBracketPairColorizationEnabledKey = 'editor.bracketPairColorization.enabled';
38+
const nativeColorizationEnabled = !!this.configurationService.getValue(nativeBracketPairColorizationEnabledKey);
39+
40+
type BracketPairColorizer2InstalledClassification = {
41+
owner: 'hediet';
42+
nativeColorizationEnabled: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
43+
};
44+
type BracketPairColorizer2Event = {
45+
nativeColorizationEnabled: boolean;
46+
};
47+
this.telemetryService.publicLog2<BracketPairColorizer2Event, BracketPairColorizer2InstalledClassification>('bracketPairColorizer2Usage', {
48+
nativeColorizationEnabled
49+
});
50+
}
51+
}
52+
53+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(BracketPairColorizer2TelemetryContribution, LifecyclePhase.Restored);
54+

src/vs/workbench/workbench.common.main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,8 @@ import 'vs/workbench/contrib/audioCues/browser/audioCues.contribution';
347347
// Deprecated Extension Migrator
348348
import 'vs/workbench/contrib/deprecatedExtensionMigrator/browser/deprecatedExtensionMigrator.contribution';
349349

350+
// Bracket Pair Colorizer 2 Telemetry
351+
import 'vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution';
352+
353+
350354
//#endregion

0 commit comments

Comments
 (0)