mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 17:23:25 -05:00
Merge from vscode 3d67364fbfcf676d93be64f949e9b33e7f1b969e (#5028)
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* Write telemetry into a file for test purposes
|
||||
*/
|
||||
export class FileTelemetryService implements ITelemetryService {
|
||||
_serviceBrand: undefined;
|
||||
private _isFirst = true;
|
||||
|
||||
constructor(private _outputFile: string) {
|
||||
}
|
||||
|
||||
publicLog(eventName: string, data?: ITelemetryData) {
|
||||
let telemetryData = JSON.stringify(Object.assign({ eventName: eventName, data: data }));
|
||||
if (this._outputFile) {
|
||||
if (this._isFirst) {
|
||||
fs.open(this._outputFile, fs.O_WRONLY | fs.O_CREAT, (err, fr) => {
|
||||
fs.writeFileSync(this._outputFile, telemetryData + '\n');
|
||||
this._isFirst = false;
|
||||
});
|
||||
} else {
|
||||
fs.appendFileSync(this._outputFile, telemetryData + '\n');
|
||||
}
|
||||
}
|
||||
return Promise.resolve<void>(null);
|
||||
}
|
||||
isOptedIn: true;
|
||||
getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
sessionId: 'someValue.sessionId',
|
||||
machineId: 'someValue.machineId'
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user