Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Telemetry type #917

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/languageserver/handlers/settingsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/languageserver/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/documentSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlCodeLens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions src/languageservice/services/yamlHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 1 addition & 2 deletions src/languageservice/services/yamlValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
24 changes: 0 additions & 24 deletions src/languageservice/telemetry.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/languageservice/utils/schemaUrls.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
21 changes: 20 additions & 1 deletion src/languageservice/yamlLanguageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/yamlServerInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
LanguageService,
SchemaRequestService,
WorkspaceContextService,
Telemetry,
} from './languageservice/yamlLanguageService';
import { workspaceFoldersChanged } from './languageservice/utils/paths';
import { URI } from 'vscode-uri';
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/settingsHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion test/utils/testsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 */
Expand Down
2 changes: 1 addition & 1 deletion test/yamlCodeLens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/yamlDefinition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading