Skip to content

Commit ef1a665

Browse files
fix(telemetry): session_end not caching events
When the user shutdown their extension gracefully our mechanism that would cache any pending metrics for the next startup would not save to disk. This was due to the VS Code FS implementation being used, but it will not work since the function it is called in is called by `deactivate()` which does not have access to vscode apis on shutdown. Solution is to swap it with the node fs implementation Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 17e951c commit ef1a665

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/core/src/shared/telemetry/telemetryService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ClassToInterfaceType } from '../utilities/tsUtils'
2020
import { getClientId, validateMetricEvent } from './util'
2121
import { telemetry, MetricBase } from './telemetry'
2222
import fs from '../fs/fs'
23+
import fsNode from 'fs/promises'
2324
import * as collectionUtil from '../utilities/collectionUtils'
2425

2526
export type TelemetryService = ClassToInterfaceType<DefaultTelemetryService>
@@ -116,7 +117,10 @@ export class DefaultTelemetryService {
116117
})
117118

118119
try {
119-
await fs.writeFile(this.persistFilePath, JSON.stringify(this._eventQueue))
120+
/**
121+
* This function runs in deactivate() so we must use node fs. See the vscode behavior doc for more info.
122+
*/
123+
await fsNode.writeFile(this.persistFilePath, JSON.stringify(this._eventQueue))
120124
} catch {}
121125
}
122126
}

0 commit comments

Comments
 (0)