Skip to content

Commit a63ef81

Browse files
authored
Merge pull request #389 from Achal1607/telemetry
Fixed ids coming up as label issue in JDK Downloader
2 parents af82913 + 83a7672 commit a63ef81

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

vscode/src/webviews/jdkDownloader/action.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class JdkDownloaderAction {
3636
private readonly DOWNLOAD_DIR = path.join(__dirname, 'jdk_downloads');
3737
private startTimer: number | null = null;
3838

39-
private jdkType?: string;
39+
private jdkType!: string;
4040
private jdkVersion?: string;
4141
private osType?: string;
4242
private machineArch?: string;
@@ -132,7 +132,7 @@ export class JdkDownloaderAction {
132132

133133
private jdkInstallationManager = async () => {
134134
const startingInstallationMessage = l10n.value("jdk.downloader.message.downloadingAndCompletingSetup", {
135-
jdkType: this.jdkType,
135+
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
136136
jdkVersion: this.jdkVersion
137137
});
138138

@@ -144,7 +144,7 @@ export class JdkDownloaderAction {
144144
}
145145
await this.downloadAndVerify();
146146
const downloadSuccessLabel = l10n.value("jdk.downloader.message.downloadCompleted", {
147-
jdkType: this.jdkType,
147+
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
148148
jdkVersion: this.jdkVersion,
149149
osType: this.osType
150150
});
@@ -187,7 +187,7 @@ export class JdkDownloaderAction {
187187

188188
private downloadAndVerify = async (): Promise<void> => {
189189
const message = l10n.value("jdk.downloader.message.downloadProgressBar", {
190-
jdkType: this.jdkType,
190+
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
191191
jdkVersion: this.jdkVersion
192192
});
193193
await downloadFileWithProgressBar(this.downloadUrl!, this.downloadFilePath!, message);
@@ -196,7 +196,7 @@ export class JdkDownloaderAction {
196196
const doesMatch = await this.checksumMatch();
197197
if (!doesMatch) {
198198
const checksumMatchFailedLabel = l10n.value("jdk.downloader.message.downloadFailed", {
199-
jdkType: this.jdkType,
199+
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
200200
jdkVersion: this.jdkVersion,
201201
osType: this.osType
202202
});
@@ -230,7 +230,7 @@ export class JdkDownloaderAction {
230230
} catch (err) {
231231
LOGGER.error(`Error while extracting JDK: ${(err as Error).message}`);
232232
throw new Error(l10n.value("jdk.downloader.error_message.extractionError", {
233-
jdkType: this.jdkType,
233+
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
234234
jdkVersion: this.jdkVersion
235235
}));
236236
}
@@ -250,11 +250,11 @@ export class JdkDownloaderAction {
250250
const tempDirectoryPath = path.join(this.DOWNLOAD_DIR, matchingJdkDir[0]);
251251

252252
// If directory with same name is present in the user selected download location then ask user if they want to delete it or not?
253-
const newDirName = `${this.jdkType!.split(' ').join('_')}-${this.jdkVersion}`;
253+
const newDirName = `${this.jdkType.split(' ').join('_')}-${this.jdkVersion}`;
254254
const newDirectoryPath = await this.handleJdkPaths(newDirName, this.installationPath!, this.osType!);
255255
if (newDirectoryPath === null) {
256256
throw new Error(l10n.value('jdk.downloader.error_message.jdkNewDirectoryIssueCannotInstall', {
257-
jdkType: this.jdkType,
257+
jdkType: JdkDownloaderView.getJdkLabel(this.jdkType),
258258
jdkVersion: this.jdkVersion,
259259
newDirName
260260
}));
@@ -278,7 +278,7 @@ export class JdkDownloaderAction {
278278
private installationCleanup = (tempDirPath: string, newDirPath: string) => {
279279
const currentTime = getCurrentUTCDateInSeconds();
280280
const downloadTelemetryEvent: JdkDownloadEventData = {
281-
vendor: this.jdkType!,
281+
vendor: this.jdkType,
282282
version: this.jdkVersion!,
283283
os: this.osType!,
284284
arch: this.machineArch!,

vscode/src/webviews/jdkDownloader/view.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ export class JdkDownloaderView {
2626
public static readonly DOWNLOAD_CMD = 'downloadJDK';
2727
public static readonly JDK_TYPE = {
2828
oracleJdk: "oracleJdk",
29-
openJdk: "openJdk",
29+
openJdk: "openJdk"
30+
}
31+
32+
public static getJdkLabel = (id: string): string => {
33+
const key = "jdk.downloader.label." + id;
34+
const label = l10n.value(key);
35+
return label !== key ? label : id;
3036
}
3137

32-
private static readonly OPEN_JDK_LABEL = l10n.value("jdk.downloader.label.openJdk");
33-
private static readonly ORACLE_JDK_LABEL = l10n.value("jdk.downloader.label.oracleJdk");
3438
private readonly jdkDownloaderTitle = l10n.value("jdk.downloader.heading");
3539

3640
private jdkDownloaderWebView?: WebviewPanel;

0 commit comments

Comments
 (0)