diff --git a/src/languageserver/handlers/settingsHandlers.ts b/src/languageserver/handlers/settingsHandlers.ts index e2351ea7..3d18dac3 100644 --- a/src/languageserver/handlers/settingsHandlers.ts +++ b/src/languageserver/handlers/settingsHandlers.ts @@ -7,10 +7,9 @@ import { Connection, DidChangeConfigurationNotification, DocumentFormattingReque import { convertErrorToTelemetryMsg } from '../../languageservice/utils/objects'; import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths'; import { checkSchemaURI, JSON_SCHEMASTORE_URL, KUBERNETES_SCHEMA_URL } from '../../languageservice/utils/schemaUrls'; -import { LanguageService, LanguageSettings, SchemaPriority } from '../../languageservice/yamlLanguageService'; +import { LanguageService, LanguageSettings, SchemaPriority, Telemetry } from '../../languageservice/yamlLanguageService'; import { SchemaSelectionRequests } from '../../requestTypes'; import { Settings, SettingsState } from '../../yamlSettings'; -import { Telemetry } from '../../languageservice/telemetry'; import { ValidationHandler } from './validationHandlers'; export class SettingsHandler { diff --git a/src/languageserver/telemetry.ts b/src/languageserver/telemetry.ts index b18979ff..c69650ae 100644 --- a/src/languageserver/telemetry.ts +++ b/src/languageserver/telemetry.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Connection } from 'vscode-languageserver'; -import { TelemetryEvent, Telemetry } from '../languageservice/telemetry'; +import { TelemetryEvent, Telemetry } from '../languageservice/yamlLanguageService'; export class TelemetryImpl implements Telemetry { constructor(private readonly connection: Connection) {} diff --git a/src/languageservice/services/documentSymbols.ts b/src/languageservice/services/documentSymbols.ts index e50c992c..cef2c153 100644 --- a/src/languageservice/services/documentSymbols.ts +++ b/src/languageservice/services/documentSymbols.ts @@ -10,7 +10,7 @@ import { JSONDocumentSymbols } from 'vscode-json-languageservice/lib/umd/service import { DocumentSymbolsContext } from 'vscode-json-languageservice/lib/umd/jsonLanguageTypes'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { yamlDocumentsCache } from '../parser/yaml-documents'; -import { Telemetry } from '../telemetry'; +import { Telemetry } from '../yamlLanguageService'; import { isMap, isSeq, Node } from 'yaml'; import { convertErrorToTelemetryMsg } from '../utils/objects'; diff --git a/src/languageservice/services/yamlCodeLens.ts b/src/languageservice/services/yamlCodeLens.ts index fdfde4fa..018f0b2e 100644 --- a/src/languageservice/services/yamlCodeLens.ts +++ b/src/languageservice/services/yamlCodeLens.ts @@ -9,7 +9,7 @@ import { YamlCommands } from '../../commands'; import { yamlDocumentsCache } from '../parser/yaml-documents'; import { YAMLSchemaService } from './yamlSchemaService'; import { JSONSchema } from '../jsonSchema'; -import { Telemetry } from '../telemetry'; +import { Telemetry } from '../yamlLanguageService'; import { getSchemaUrls } from '../utils/schemaUrls'; import { convertErrorToTelemetryMsg } from '../utils/objects'; import { getSchemaTitle } from '../utils/schemaUtils'; diff --git a/src/languageservice/services/yamlCompletion.ts b/src/languageservice/services/yamlCompletion.ts index 513a23d6..903460b0 100644 --- a/src/languageservice/services/yamlCompletion.ts +++ b/src/languageservice/services/yamlCompletion.ts @@ -18,13 +18,12 @@ import { TextEdit, } from 'vscode-languageserver-types'; import { Node, isPair, isScalar, isMap, YAMLMap, isSeq, YAMLSeq, isNode, Pair } from 'yaml'; -import { Telemetry } from '../telemetry'; +import { Telemetry, LanguageSettings } from '../yamlLanguageService'; import { SingleYAMLDocument, YamlDocuments } from '../parser/yaml-documents'; import { YamlVersion } from '../parser/yamlParser07'; import { filterInvalidCustomTags, matchOffsetToDocument } from '../utils/arrUtils'; import { guessIndentation } from '../utils/indentationGuesser'; import { TextBuffer } from '../utils/textBuffer'; -import { LanguageSettings } from '../yamlLanguageService'; import { YAMLSchemaService } from './yamlSchemaService'; import { ResolvedSchema } from 'vscode-json-languageservice/lib/umd/services/jsonSchemaService'; import { JSONSchema, JSONSchemaRef } from '../jsonSchema'; diff --git a/src/languageservice/services/yamlDefinition.ts b/src/languageservice/services/yamlDefinition.ts index b2f1b975..ca469da9 100644 --- a/src/languageservice/services/yamlDefinition.ts +++ b/src/languageservice/services/yamlDefinition.ts @@ -7,7 +7,7 @@ import { DefinitionParams } from 'vscode-languageserver-protocol'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { DefinitionLink, LocationLink, Range } from 'vscode-languageserver-types'; import { isAlias } from 'yaml'; -import { Telemetry } from '../telemetry'; +import { Telemetry } from '../yamlLanguageService'; import { yamlDocumentsCache } from '../parser/yaml-documents'; import { matchOffsetToDocument } from '../utils/arrUtils'; import { convertErrorToTelemetryMsg } from '../utils/objects'; diff --git a/src/languageservice/services/yamlHover.ts b/src/languageservice/services/yamlHover.ts index f02c29d1..92219ce9 100644 --- a/src/languageservice/services/yamlHover.ts +++ b/src/languageservice/services/yamlHover.ts @@ -6,7 +6,7 @@ import { Hover, MarkupContent, MarkupKind, Position, Range } from 'vscode-languageserver-types'; import { matchOffsetToDocument } from '../utils/arrUtils'; -import { LanguageSettings } from '../yamlLanguageService'; +import { LanguageSettings, Telemetry } from '../yamlLanguageService'; import { YAMLSchemaService } from './yamlSchemaService'; import { setKubernetesParserOption } from '../parser/isKubernetes'; import { TextDocument } from 'vscode-languageserver-textdocument'; @@ -16,7 +16,6 @@ import { IApplicableSchema } from '../parser/jsonParser07'; import { JSONSchema } from '../jsonSchema'; import { URI } from 'vscode-uri'; import * as path from 'path'; -import { Telemetry } from '../telemetry'; import { convertErrorToTelemetryMsg } from '../utils/objects'; import { ASTNode } from 'vscode-json-languageservice'; import { stringify as stringifyYAML } from 'yaml'; diff --git a/src/languageservice/services/yamlLinks.ts b/src/languageservice/services/yamlLinks.ts index fe22e455..5175895a 100644 --- a/src/languageservice/services/yamlLinks.ts +++ b/src/languageservice/services/yamlLinks.ts @@ -5,7 +5,7 @@ import { findLinks as JSONFindLinks } from 'vscode-json-languageservice/lib/umd/services/jsonLinks'; import { DocumentLink } from 'vscode-languageserver-types'; import { TextDocument } from 'vscode-languageserver-textdocument'; -import { Telemetry } from '../telemetry'; +import { Telemetry } from '../yamlLanguageService'; import { yamlDocumentsCache } from '../parser/yaml-documents'; import { convertErrorToTelemetryMsg } from '../utils/objects'; diff --git a/src/languageservice/services/yamlValidation.ts b/src/languageservice/services/yamlValidation.ts index 04c58edf..9d106033 100644 --- a/src/languageservice/services/yamlValidation.ts +++ b/src/languageservice/services/yamlValidation.ts @@ -5,7 +5,7 @@ *--------------------------------------------------------------------------------------------*/ import { Diagnostic, Position } from 'vscode-languageserver-types'; -import { LanguageSettings } from '../yamlLanguageService'; +import { LanguageSettings, Telemetry } from '../yamlLanguageService'; import { YAMLDocument, YamlVersion, SingleYAMLDocument } from '../parser/yamlParser07'; import { YAMLSchemaService } from './yamlSchemaService'; import { YAMLDocDiagnostic } from '../utils/parseUtils'; @@ -15,7 +15,6 @@ import { YAML_SOURCE } from '../parser/jsonParser07'; import { TextBuffer } from '../utils/textBuffer'; import { yamlDocumentsCache } from '../parser/yaml-documents'; import { convertErrorToTelemetryMsg } from '../utils/objects'; -import { Telemetry } from '../telemetry'; import { AdditionalValidator } from './validation/types'; import { UnusedAnchorsValidator } from './validation/unused-anchors'; import { YAMLStyleValidator } from './validation/yaml-style'; diff --git a/src/languageservice/telemetry.ts b/src/languageservice/telemetry.ts deleted file mode 100644 index c5c71426..00000000 --- a/src/languageservice/telemetry.ts +++ /dev/null @@ -1,24 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Red Hat, Inc. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -/** - * Due to LSP limitation this object must be JSON serializable - */ -export interface TelemetryEvent { - name: string; - type?: string; - properties?: unknown; - measures?: unknown; - traits?: unknown; - context?: unknown; -} - -export interface Telemetry { - send(event: TelemetryEvent): void; - - sendError(name: string, properties: unknown): void; - - sendTrack(name: string, properties: unknown): void; -} diff --git a/src/languageservice/utils/schemaUrls.ts b/src/languageservice/utils/schemaUrls.ts index ff474e10..63b5ad85 100644 --- a/src/languageservice/utils/schemaUrls.ts +++ b/src/languageservice/utils/schemaUrls.ts @@ -1,6 +1,6 @@ import { WorkspaceFolder } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; -import { Telemetry } from '../telemetry'; +import { Telemetry } from '../yamlLanguageService'; import { JSONSchema, JSONSchemaRef } from '../jsonSchema'; import { isBoolean } from './objects'; import { isRelativePath, relativeToAbsolutePath } from './paths'; diff --git a/src/languageservice/yamlLanguageService.ts b/src/languageservice/yamlLanguageService.ts index 457a9d09..68f4c539 100644 --- a/src/languageservice/yamlLanguageService.ts +++ b/src/languageservice/yamlLanguageService.ts @@ -46,7 +46,6 @@ import { FoldingRangesContext, SchemaVersions } from './yamlTypes'; import { YamlCodeActions } from './services/yamlCodeActions'; import { doDocumentOnTypeFormatting } from './services/yamlOnTypeFormatting'; import { YamlCodeLens } from './services/yamlCodeLens'; -import { Telemetry } from './telemetry'; import { YamlVersion } from './parser/yamlParser07'; import { YamlCompletion } from './services/yamlCompletion'; import { yamlDocumentsCache } from './parser/yaml-documents'; @@ -55,6 +54,26 @@ import { JSONSchemaSelection } from '../languageserver/handlers/schemaSelectionH import { YamlDefinition } from './services/yamlDefinition'; import { getSelectionRanges } from './services/yamlSelectionRanges'; +/** + * Due to LSP limitation this object must be JSON serializable + */ +export interface TelemetryEvent { + name: string; + type?: string; + properties?: unknown; + measures?: unknown; + traits?: unknown; + context?: unknown; +} + +export interface Telemetry { + send(event: TelemetryEvent): void; + + sendError(name: string, properties: unknown): void; + + sendTrack(name: string, properties: unknown): void; +} + export enum SchemaPriority { SchemaStore = 1, SchemaAssociation = 2, diff --git a/src/yamlServerInit.ts b/src/yamlServerInit.ts index 9640e48d..92cc7256 100644 --- a/src/yamlServerInit.ts +++ b/src/yamlServerInit.ts @@ -4,6 +4,7 @@ import { LanguageService, SchemaRequestService, WorkspaceContextService, + Telemetry, } from './languageservice/yamlLanguageService'; import { workspaceFoldersChanged } from './languageservice/utils/paths'; import { URI } from 'vscode-uri'; @@ -16,7 +17,6 @@ import { SettingsHandler } from './languageserver/handlers/settingsHandlers'; import { YamlCommands } from './commands'; import { WorkspaceHandlers } from './languageserver/handlers/workspaceHandlers'; import { commandExecutor } from './languageserver/commandExecutor'; -import { Telemetry } from './languageservice/telemetry'; import { registerCommands } from './languageservice/services/yamlCommands'; export class YAMLServerInit { diff --git a/test/settingsHandlers.test.ts b/test/settingsHandlers.test.ts index 1438aad3..31e9f483 100644 --- a/test/settingsHandlers.test.ts +++ b/test/settingsHandlers.test.ts @@ -11,7 +11,7 @@ import { Connection, RemoteClient, RemoteWorkspace } from 'vscode-languageserver import { LanguageService, LanguageSettings, SchemaConfiguration, SchemaPriority } from '../src'; import { SettingsHandler } from '../src/languageserver/handlers/settingsHandlers'; import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { Telemetry } from '../src/languageservice/telemetry'; +import { Telemetry } from '../src/languageservice/yamlLanguageService'; import { SettingsState } from '../src/yamlSettings'; import { setupLanguageService } from './utils/testHelper'; import { TestWorkspace } from './utils/testsTypes'; diff --git a/test/utils/testsTypes.ts b/test/utils/testsTypes.ts index 96761a10..8c920602 100644 --- a/test/utils/testsTypes.ts +++ b/test/utils/testsTypes.ts @@ -19,7 +19,7 @@ import { } from 'vscode-languageserver-protocol'; import { Connection, RemoteWorkspace } from 'vscode-languageserver'; import { TelemetryImpl } from '../../src/languageserver/telemetry'; -import { TelemetryEvent } from '../../src/languageservice/telemetry'; +import { TelemetryEvent } from '../../src/languageservice/yamlLanguageService'; /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ diff --git a/test/yamlCodeLens.test.ts b/test/yamlCodeLens.test.ts index 9619ad51..4a013946 100644 --- a/test/yamlCodeLens.test.ts +++ b/test/yamlCodeLens.test.ts @@ -12,7 +12,7 @@ import { JSONSchema } from '../src/languageservice/jsonSchema'; import { CodeLens, Command, Range } from 'vscode-languageserver-protocol'; import { YamlCommands } from '../src/commands'; import { TelemetryImpl } from '../src/languageserver/telemetry'; -import { Telemetry } from '../src/languageservice/telemetry'; +import { Telemetry } from '../src/languageservice/yamlLanguageService'; const expect = chai.expect; chai.use(sinonChai); diff --git a/test/yamlDefinition.test.ts b/test/yamlDefinition.test.ts index 9a80dca8..59c83f0e 100644 --- a/test/yamlDefinition.test.ts +++ b/test/yamlDefinition.test.ts @@ -7,7 +7,7 @@ import { setupTextDocument, TEST_URI } from './utils/testHelper'; import { expect } from 'chai'; import { YamlDefinition } from '../src/languageservice/services/yamlDefinition'; import { LocationLink, Position, Range } from 'vscode-languageserver-types'; -import { Telemetry } from '../src/languageservice/telemetry'; +import { Telemetry } from '../src/languageservice/yamlLanguageService'; describe('YAML Definition', () => { it('should not provide definition for non anchor node', () => {