|
| 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 | + |
0 commit comments