diff --git a/src/client/common/persistentState.ts b/src/client/common/persistentState.ts index 2959a2dc8216..ea86b2e145ba 100644 --- a/src/client/common/persistentState.ts +++ b/src/client/common/persistentState.ts @@ -108,7 +108,7 @@ export class PersistentState implements IPersistentState { export const GLOBAL_PERSISTENT_KEYS_DEPRECATED = 'PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS'; export const WORKSPACE_PERSISTENT_KEYS_DEPRECATED = 'PYTHON_EXTENSION_WORKSPACE_STORAGE_KEYS'; -const GLOBAL_PERSISTENT_KEYS = 'PYTHON_GLOBAL_STORAGE_KEYS'; +export const GLOBAL_PERSISTENT_KEYS = 'PYTHON_GLOBAL_STORAGE_KEYS'; const WORKSPACE_PERSISTENT_KEYS = 'PYTHON_WORKSPACE_STORAGE_KEYS'; type KeysStorageType = 'global' | 'workspace'; export type KeysStorage = { key: string; defaultValue: unknown }; diff --git a/src/client/extension.ts b/src/client/extension.ts index a4c31d91eb3b..b9f32187413b 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -46,6 +46,7 @@ import { WorkspaceService } from './common/application/workspace'; import { disposeAll } from './common/utils/resourceLifecycle'; import { ProposedExtensionAPI } from './proposedApiTypes'; import { buildProposedApi } from './proposedApi'; +import { GLOBAL_PERSISTENT_KEYS } from './common/persistentState'; durations.codeLoadingTime = stopWatch.elapsedTime; @@ -62,7 +63,9 @@ export async function activate(context: IExtensionContext): Promise; let serviceContainer: IServiceContainer; + let isFirstSession: boolean | undefined; try { + isFirstSession = context.globalState.get(GLOBAL_PERSISTENT_KEYS, []).length === 0; const workspaceService = new WorkspaceService(); context.subscriptions.push( workspaceService.onDidGrantWorkspaceTrust(async () => { @@ -79,8 +82,7 @@ export async function activate(context: IExtensionContext): Promise { +async function getActivationTelemetryProps( + serviceContainer: IServiceContainer, + isFirstSession?: boolean, +): Promise { // TODO: Not all of this data is showing up in the database... // TODO: If any one of these parts fails we send no info. We should @@ -88,7 +92,7 @@ async function getActivationTelemetryProps(serviceContainer: IServiceContainer): const terminalHelper = serviceContainer.get(ITerminalHelper); const terminalShellType = terminalHelper.identifyTerminalShell(); if (!workspaceService.isTrusted) { - return { workspaceFolderCount, terminal: terminalShellType }; + return { workspaceFolderCount, terminal: terminalShellType, isFirstSession }; } const interpreterService = serviceContainer.get(IInterpreterService); const mainWorkspaceUri = workspaceService.workspaceFolders?.length @@ -132,5 +136,6 @@ async function getActivationTelemetryProps(serviceContainer: IServiceContainer): usingUserDefinedInterpreter, usingGlobalInterpreter, appName, + isFirstSession, }; } diff --git a/src/client/telemetry/constants.ts b/src/client/telemetry/constants.ts index 3321653c3bd7..b405143c0ba3 100644 --- a/src/client/telemetry/constants.ts +++ b/src/client/telemetry/constants.ts @@ -64,7 +64,7 @@ export enum EventName { EXTENSION_SURVEY_PROMPT = 'EXTENSION_SURVEY_PROMPT', LANGUAGE_SERVER_ENABLED = 'LANGUAGE_SERVER.ENABLED', - LANGUAGE_SERVER_TRIGGER_DURATION = 'LANGUAGE_SERVER.TRIGGER_DURATION', + LANGUAGE_SERVER_TRIGGER_TIME = 'LANGUAGE_SERVER_TRIGGER_TIME', LANGUAGE_SERVER_STARTUP = 'LANGUAGE_SERVER.STARTUP', LANGUAGE_SERVER_READY = 'LANGUAGE_SERVER.READY', LANGUAGE_SERVER_TELEMETRY = 'LANGUAGE_SERVER.EVENT', diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index b2ed37939fa9..bb2cd6d77896 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -723,6 +723,11 @@ export interface IEventNamePropertyMapping { * If global interpreter is being used */ usingGlobalInterpreter?: boolean; + /** + * Carries `true` if it is the very first session of the user. We check whether persistent cache is empty + * to approximately guess if it's the first session. + */ + isFirstSession?: boolean; }; /** * Telemetry event sent when substituting Environment variables to calculate value of variables @@ -1329,11 +1334,17 @@ export interface IEventNamePropertyMapping { * Track how long it takes to trigger language server activation code, after Python extension starts activating. */ /* __GDPR__ - "language_server_trigger_duration" : { - "duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "owner": "karrtikr", "isMeasurement": true } + "language_server_trigger_time" : { + "duration" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "karrtikr" }, + "triggerTime" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true, "owner": "karrtikr" } } */ - [EventName.LANGUAGE_SERVER_TRIGGER_DURATION]: unknown; + [EventName.LANGUAGE_SERVER_TRIGGER_TIME]: { + /** + * Time it took to trigger language server startup. + */ + triggerTime: number; + }; /** * Telemetry event sent when starting Node.js server */