-
Notifications
You must be signed in to change notification settings - Fork 495
Add more telemetry for project import & workspaces hash #4177
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,8 @@ | |
|
|
||
| import * as net from 'net'; | ||
| import * as path from 'path'; | ||
| import { CancellationToken, CodeActionKind, commands, ConfigurationTarget, DocumentSelector, EventEmitter, ExtensionContext, extensions, languages, Location, ProgressLocation, TextEditor, Uri, ViewColumn, window, workspace } from "vscode"; | ||
| import { ConfigurationParams, ConfigurationRequest, LanguageClientOptions, Location as LSLocation, MessageType, Position as LSPosition, TextDocumentPositionParams, WorkspaceEdit, StaticFeature, ClientCapabilities, FeatureState } from "vscode-languageclient"; | ||
| import { CancellationToken, CodeActionKind, commands, ConfigurationTarget, DocumentSelector, EventEmitter, ExtensionContext, extensions, languages, Location, ProgressLocation, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceConfiguration } from "vscode"; | ||
| import { ConfigurationParams, ConfigurationRequest, LanguageClientOptions, Location as LSLocation, MessageType, Position as LSPosition, TextDocumentPositionParams, WorkspaceEdit, StaticFeature, ClientCapabilities, FeatureState, TelemetryEventNotification } from "vscode-languageclient"; | ||
| import { LanguageClient, StreamInfo } from "vscode-languageclient/node"; | ||
| import { apiManager } from "./apiManager"; | ||
| import * as buildPath from './buildpath'; | ||
|
|
@@ -336,10 +336,45 @@ export class StandardLanguageClient { | |
| return result; | ||
| }); | ||
|
|
||
| function getJavaSettingsForTelemetry(config: WorkspaceConfiguration) { | ||
| // settings whose values we can record | ||
| const SETTINGS_BASIC = [ | ||
| "java.quickfix.showAt", "java.symbols.includeSourceMethodDeclarations", | ||
| "java.completion.collapseCompletionItems", "java.completion.guessMethodArguments", | ||
| "java.cleanup.actionsOnSave", "java.completion.postfix.enabled", | ||
| "java.sharedIndexes.enabled", "java.inlayHints.parameterNames.enabled", | ||
| "java.server.launchMode", "java.autobuild.enabled" | ||
| ]; | ||
| // settings where we only record their existence | ||
| const SETTINGS_CUSTOM = [ | ||
| "java.settings.url", "java.format.settings.url" | ||
| ]; | ||
|
|
||
| let value: any; | ||
| const properties = {}; | ||
|
|
||
| for (const key of SETTINGS_CUSTOM) { | ||
| if (config.get(key)) { | ||
| properties[key] = true; | ||
| } | ||
| } | ||
| for (const key of SETTINGS_BASIC) { | ||
| value = config.get(key); | ||
| if (value !== undefined) { | ||
| properties[key] = value; | ||
| } | ||
| } | ||
|
|
||
| return properties; | ||
| } | ||
|
|
||
| this.languageClient.onTelemetry(async (e: TelemetryEvent) => { | ||
| apiManager.fireTraceEvent(e); | ||
| if (e.name === Telemetry.SERVER_INITIALIZED_EVT) { | ||
| return Telemetry.sendTelemetry(Telemetry.STARTUP_EVT, e.properties); | ||
| const javaSettings = getJavaSettingsForTelemetry(workspace.getConfiguration()); | ||
|
|
||
| const properties= { ...e.properties, ...javaSettings }; | ||
| await Telemetry.sendTelemetry(Telemetry.STARTUP_EVT, ); | ||
|
||
| } else if (e.name === Telemetry.LS_ERROR) { | ||
| const tags = []; | ||
| const exception: string = e?.properties.exception; | ||
|
|
@@ -357,7 +392,7 @@ export class StandardLanguageClient { | |
|
|
||
| if (tags.length > 0 || DEBUG || isPrereleaseOrInsiderVersion(context)) { | ||
| e.properties['tags'] = tags; | ||
| return Telemetry.sendTelemetry(Telemetry.LS_ERROR, e.properties); | ||
| await Telemetry.sendTelemetry(Telemetry.LS_ERROR, e.properties); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { TelemetryService, getRedHatService } from "@redhat-developer/vscode-redhat-telemetry"; | ||
| import { ExtensionContext, workspace, WorkspaceConfiguration } from "vscode"; | ||
| import { cyrb53 } from "./utils"; | ||
|
|
||
| /** | ||
| * Wrap vscode-redhat-telemetry to suit vscode-java | ||
|
|
@@ -10,7 +11,10 @@ export namespace Telemetry { | |
| export const COMPLETION_EVENT = "textCompletion"; | ||
| export const SERVER_INITIALIZED_EVT = "java.workspace.initialized"; | ||
| export const LS_ERROR = "java.ls.error"; | ||
| export const IMPORT_PROJECT = "java.workspace.importProject"; | ||
|
||
|
|
||
| let telemetryManager: TelemetryService = null; | ||
| let workspaceHash; | ||
|
|
||
| /** | ||
| * Starts the telemetry service | ||
|
|
@@ -22,6 +26,10 @@ export namespace Telemetry { | |
| if (!!telemetryManager) { | ||
| throw new Error("The telemetry service for vscode-java has already been started"); | ||
| } | ||
| workspaceHash = cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|')); | ||
| workspace.onDidChangeWorkspaceFolders(() => { | ||
| workspaceHash = cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|')); | ||
| }); | ||
| const redhatService = await getRedHatService(context); | ||
| const telemService = await redhatService.getTelemetryService(); | ||
| telemetryManager = telemService; | ||
|
|
@@ -35,23 +43,17 @@ export namespace Telemetry { | |
| * @param data the telemetry data | ||
| * @throws Error if the telemetry service has not been started yet | ||
| */ | ||
| export async function sendTelemetry(eventName: string, data?: any): Promise<void> { | ||
| export async function sendTelemetry(eventName: string, data?: object): Promise<void> { | ||
| console.log(`Sending telemetry event: ${eventName} with data: ${JSON.stringify(data)}`); | ||
|
||
| if (!telemetryManager) { | ||
| throw new Error("The telemetry service for vscode-java has not been started yet"); | ||
| } | ||
| const javaSettings = getJavaSettingsForTelemetry(workspace.getConfiguration()); | ||
|
|
||
| let properties: any; | ||
| if (eventName === STARTUP_EVT) { | ||
| properties= { ...data, ...javaSettings }; | ||
| } else { | ||
| properties= { ...data}; | ||
| } | ||
|
|
||
| return telemetryManager.send({ | ||
| const event = { | ||
| name: eventName, | ||
| properties | ||
| }); | ||
| properties: { workspaceHash, ...data} | ||
| }; | ||
| return telemetryManager.send(event); | ||
| } | ||
|
|
||
| function getJavaSettingsForTelemetry(config: WorkspaceConfiguration) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.