finalize isNewAppInstall api

refs #117058
This commit is contained in:
SteVen Batten 2021-03-09 10:20:05 -08:00
parent 6438e0564a
commit 95d3c1e63b
4 changed files with 10 additions and 10 deletions

6
src/vs/vscode.d.ts vendored
View file

@ -7906,6 +7906,12 @@ declare module 'vscode' {
*/
export const sessionId: string;
/**
* Indicates that this is a fresh install of the application.
* `true` if within the first day of installation otherwise `false`.
*/
export const isNewAppInstall: boolean;
/**
* The name of a remote. Defined by extensions, popular samples are `wsl` for the Windows
* Subsystem for Linux or `ssh-remote` for remotes using a secure shell.

View file

@ -2103,11 +2103,6 @@ declare module 'vscode' {
export interface ExtensionContext {
readonly extensionRuntime: ExtensionRuntime;
/**
* Indicates that this is a fresh install of VS Code.
*/
readonly isNewInstall: boolean;
}
//#endregion

View file

@ -303,6 +303,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled(extension);
return extHostTelemetry.onDidChangeTelemetryEnabled;
},
get isNewAppInstall() {
const installAge = Date.now() - new Date(initData.telemetryInfo.firstSessionDate).getTime();
return isNaN(installAge) ? false : installAge < 1000 * 60 * 60 * 24; // install age is less than a day
},
openExternal(uri: URI, options?: { allowContributedOpeners?: boolean | string; }) {
return extHostWindow.openUri(uri, {
allowTunneling: !!initData.remote.authority,

View file

@ -388,7 +388,6 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
const extensionMode = extensionDescription.isUnderDevelopment
? (this._initData.environment.extensionTestsLocationURI ? ExtensionMode.Test : ExtensionMode.Development)
: ExtensionMode.Production;
const installAge = Date.now() - new Date(this._initData.telemetryInfo.firstSessionDate).getTime();
this._logService.trace(`ExtensionService#loadExtensionContext ${extensionDescription.identifier.value}`);
@ -425,10 +424,6 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
checkProposedApiEnabled(extensionDescription);
return that.extensionRuntime;
},
get isNewInstall() {
checkProposedApiEnabled(extensionDescription);
return isNaN(installAge) ? false : installAge < 1000 * 60 * 60 * 24; // installAge is less than a day;
},
get environmentVariableCollection() { return that._extHostTerminalService.getEnvironmentVariableCollection(extensionDescription); }
});
});