diff --git a/src/vs/platform/telemetry/common/telemetryUtils.ts b/src/vs/platform/telemetry/common/telemetryUtils.ts index 88f56ebe955..4476032db8e 100644 --- a/src/vs/platform/telemetry/common/telemetryUtils.ts +++ b/src/vs/platform/telemetry/common/telemetryUtils.ts @@ -16,11 +16,12 @@ import { ClassifiedEvent, IGDPRProperty, OmitMetadata, StrictPropertyCheck } fro import { ICustomEndpointTelemetryService, ITelemetryData, ITelemetryEndpoint, ITelemetryInfo, ITelemetryService, TelemetryConfiguration, TelemetryLevel, TELEMETRY_OLD_SETTING_ID, TELEMETRY_SETTING_ID } from 'vs/platform/telemetry/common/telemetry'; /** - * A special class used to denoate a telemetry value which should not be clean. - * This is because that value is "Trusted" not to contain identifiable information such as paths + * A special class used to denoting a telemetry value which should not be clean. + * This is because that value is "Trusted" not to contain identifiable information such as paths. + * NOTE: This is used as an API type as well, and should not be changed. */ -export class TrustedTelemetryValue { - constructor(public readonly value: any) { } +export class TrustedTelemetryValue { + constructor(public readonly value: T) { } } export class NullTelemetryServiceShape implements ITelemetryService { diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index ad6a46721f0..64fd5cae58d 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -43,6 +43,7 @@ import { ExtHostEditors } from 'vs/workbench/api/common/extHostTextEditors'; import { ExtHostTreeViews } from 'vs/workbench/api/common/extHostTreeViews'; import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters'; import * as extHostTypes from 'vs/workbench/api/common/extHostTypes'; +import { TrustedTelemetryValue } from 'vs/platform/telemetry/common/telemetryUtils'; import { ExtHostUrls } from 'vs/workbench/api/common/extHostUrls'; import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview'; import { IExtHostWindow } from 'vs/workbench/api/common/extHostWindow'; @@ -1378,6 +1379,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I TabInputWebview: extHostTypes.WebviewEditorTabInput, TabInputTerminal: extHostTypes.TerminalEditorTabInput, TabInputInteractiveWindow: extHostTypes.InteractiveWindowInput, + TrustedTelemetryValue: TrustedTelemetryValue, TerminalExitReason: extHostTypes.TerminalExitReason, LogLevel: LogLevel, EditSessionIdentityMatch: EditSessionIdentityMatch diff --git a/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts b/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts index f1ea431aa9b..f7f0e34fe3e 100644 --- a/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts +++ b/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts @@ -28,7 +28,7 @@ import { ViewContainerLocation } from 'vs/workbench/common/views'; import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile'; type TelemetryData = { - mimeType: TrustedTelemetryValue; + mimeType: TrustedTelemetryValue; ext: string; path: number; reason?: number; diff --git a/src/vs/workbench/services/timer/browser/timerService.ts b/src/vs/workbench/services/timer/browser/timerService.ts index 9b81da873fe..ef94656dbaf 100644 --- a/src/vs/workbench/services/timer/browser/timerService.ts +++ b/src/vs/workbench/services/timer/browser/timerService.ts @@ -584,7 +584,7 @@ export abstract class AbstractTimerService implements ITimerService { // event and it is "normalized" to a relative timestamp where the first mark // defines the start - type Mark = { source: string; name: TrustedTelemetryValue; startTime: number }; + type Mark = { source: string; name: TrustedTelemetryValue; startTime: number }; type MarkClassification = { owner: 'jrieken'; comment: 'Information about a performance marker'; diff --git a/src/vscode-dts/vscode.proposed.telemetryLogger.d.ts b/src/vscode-dts/vscode.proposed.telemetryLogger.d.ts index ed3c61e10df..60a366386f4 100644 --- a/src/vscode-dts/vscode.proposed.telemetryLogger.d.ts +++ b/src/vscode-dts/vscode.proposed.telemetryLogger.d.ts @@ -5,6 +5,15 @@ declare module 'vscode' { + /** + * A special value wrapper denoting a value that is safe to not clean. + * This is to be used when you can guarantee no identifiable information is contained in the value and the cleaning is improperly redacting it. + */ + export class TrustedTelemetryValue { + readonly value: T; + constructor(value: T); + } + export interface TelemetryLogger { //TODO feels weird having this on all loggers readonly onDidChangeEnableStates: Event; @@ -17,7 +26,7 @@ declare module 'vscode' { * @param eventName The event name to log * @param data The data to log */ - logUsage(eventName: string, data?: Record): void; + logUsage(eventName: string, data?: Record): void; /** * After completing cleaning, telemetry setting checks, and data mix-in calls `TelemetryAppender.logEvent` to log the event. Differs from `logUsage` in that it will log the event if the telemetry setting is Error+. @@ -25,7 +34,7 @@ declare module 'vscode' { * @param eventName The event name to log * @param data The data to log */ - logError(eventName: string, data?: Record): void; + logError(eventName: string, data?: Record): void; /** * Calls `TelemetryAppender.logException`. Does cleaning, telemetry checks, and data mix-in. @@ -34,7 +43,7 @@ declare module 'vscode' { * @param exception The error object which contains the stack trace cleaned of PII * @param data Additional data to log alongside the stack trace */ - logError(exception: Error, data?: Record): void; + logError(exception: Error, data?: Record): void; dispose(): void; }