Skip to content

Commit 3084a8a

Browse files
committed
Tweaks to telemetry logging logic
1 parent a08ed8e commit 3084a8a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
- Tweaks to telemetry logging
12+
1013
## [1.2.1] - 2024-04-04
1114

1215
### Added

server

src/telemetry/TelemetryLogger.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,26 @@ export default class TelemetryLogger {
1818
constructor (private readonly extensionVersion: string) {}
1919

2020
logEvent (event: TelemetryEvent): void {
21-
if (this.shouldLogTelemetry()) {
21+
if (this.shouldLogTelemetry(event)) {
2222
this.sendEvent(event)
2323
}
2424
}
2525

26-
private shouldLogTelemetry (): boolean {
26+
private shouldLogTelemetry (event: TelemetryEvent): boolean {
27+
if (!env.isTelemetryEnabled) {
28+
// Never log when VS Code's general telemetry is disabled
29+
console.log('Logging DDUX')
30+
return false
31+
}
32+
33+
if (event.eventKey === 'ML_VS_CODE_SETTING_CHANGE') {
34+
// Do log when the `matlab.telemetry` setting changes
35+
return (event.data as { setting_name: string }).setting_name === 'telemetry'
36+
}
37+
38+
// Otherwise, adhere to the `matlab.telemetry` setting
2739
const configuration = workspace.getConfiguration('MATLAB')
28-
return env.isTelemetryEnabled && (configuration.get<boolean>('telemetry') ?? true)
40+
return configuration.get<boolean>('telemetry') ?? true
2941
}
3042

3143
private sendEvent (event: TelemetryEvent): void {

0 commit comments

Comments
 (0)