Skip to content

Commit 3c95bae

Browse files
authored
Merge pull request #403 from Achal1607/telemetry
Enhancement in telemetry preferences flow and some telemetry maintenance changes
2 parents 6d1c399 + 13182aa commit 3c95bae

24 files changed

+605
-99
lines changed

vscode/esbuild.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ const createTelemetryConfig = () => {
5757
baseUrl: null,
5858
baseEndpoint: "/vscode/java/sendTelemetry",
5959
version: "/v1"
60+
},
61+
metadata: {
62+
consentSchemaVersion: "v1"
6063
}
6164
}
6265

@@ -73,6 +76,9 @@ const createTelemetryConfig = () => {
7376
baseUrl: process.env.TELEMETRY_API_BASE_URL,
7477
baseEndpoint: process.env.TELEMETRY_API_ENDPOINT,
7578
version: process.env.TELEMETRY_API_VERSION
79+
},
80+
metadata: {
81+
consentSchemaVersion: process.env.CONSENT_SCHEMA_VERSION
7682
}
7783
});
7884

vscode/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@
245245
"jdk.telemetry.enabled": {
246246
"type": "boolean",
247247
"description": "%jdk.configuration.telemetry.enabled.description%",
248-
"default": false
248+
"default": false,
249+
"tags": [
250+
"telemetry"
251+
]
249252
}
250253
}
251254
},

vscode/src/telemetry/config.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
import { RetryConfig, TelemetryApi } from "./types";
16+
import { RetryConfig, TelemetryApi, TelemetryConfigMetadata } from "./types";
1717
import * as path from 'path';
1818
import * as fs from 'fs';
1919
import { LOGGER } from "../logger";
@@ -24,6 +24,7 @@ export class TelemetryConfiguration {
2424
private static instance: TelemetryConfiguration;
2525
private retryConfig!: RetryConfig;
2626
private apiConfig!: TelemetryApi;
27+
private metadata!: TelemetryConfigMetadata;
2728

2829
public constructor() {
2930
this.initialize();
@@ -54,6 +55,11 @@ export class TelemetryConfiguration {
5455
baseEndpoint: config.telemetryApi.baseEndpoint,
5556
version: config.telemetryApi.version
5657
});
58+
59+
this.metadata = Object.freeze({
60+
consentSchemaVersion: config.metadata.consentSchemaVersion
61+
});
62+
5763
} catch (error: any) {
5864
LOGGER.error("Error occurred while setting up telemetry config");
5965
LOGGER.error(error.message);
@@ -68,4 +74,7 @@ export class TelemetryConfiguration {
6874
return this.apiConfig;
6975
}
7076

77+
public getTelemetryConfigMetadata(): Readonly<TelemetryConfigMetadata> {
78+
return this.metadata;
79+
}
7180
}

vscode/src/telemetry/constants.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
export const TELEMETRY_CONSENT_VERSION_SCHEMA_KEY = "telemetryConsentSchemaVersion";
17+
export const TELEMETRY_CONSENT_RESPONSE_TIME_KEY = "telemetryConsentResponseTime";
18+
export const TELEMETRY_SETTING_VALUE_KEY = "telemetrySettingValue";

vscode/src/telemetry/events/baseEvent.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ export abstract class BaseEvent<T> {
4242
get getPayload(): T & BaseEventPayload {
4343
return this._payload;
4444
}
45-
45+
4646
get getData(): T {
4747
return this._data;
4848
}
@@ -58,8 +58,8 @@ export abstract class BaseEvent<T> {
5858
protected addEventToCache = (): void => {
5959
const dataString = JSON.stringify(this.getData);
6060
const calculatedHashVal = getHashCode(dataString);
61-
const isAdded = cacheService.put(this.NAME, calculatedHashVal);
62-
63-
LOGGER.debug(`${this.NAME} added in cache ${isAdded ? "Successfully" : "Unsucessfully"}`);
61+
cacheService.put(this.NAME, calculatedHashVal).then((isAdded: boolean) => {
62+
LOGGER.debug(`${this.NAME} added in cache ${isAdded ? "Successfully" : "Unsucessfully"}`);
63+
});
6464
}
6565
}

vscode/src/telemetry/events/close.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

vscode/src/telemetry/events/jdkDownload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

vscode/src/telemetry/events/jdkFeature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

vscode/src/telemetry/events/start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

vscode/src/telemetry/events/workspaceChange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2024-2025, Oracle and/or its affiliates.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)