1
0
mirror of https://github.com/adobe/brackets.git synced 2024-11-20 18:02:54 +01:00

Saurabh95/log encoding data (#13506)

* Now encoding of file opened is also logged in Health Data

* Fixed error on console if encoding field is not present in the state

* minor changes
This commit is contained in:
Saurabh Kathpalia 2017-07-03 16:49:40 +05:30 committed by Swagatam Mitra
parent ce77877676
commit 077e10dc60
3 changed files with 18 additions and 4 deletions

View File

@ -467,7 +467,7 @@ define(function (require, exports, module) {
_doOpenWithOptionalPath(fileInfo.path, silent, paneId, commandData && commandData.options)
.done(function (file) {
HealthLogger.fileOpened(file._path);
HealthLogger.fileOpened(file._path, false, file._encoding);
if (!commandData || !commandData.options || !commandData.options.noPaneActivate) {
MainViewManager.setActivePaneId(paneId);
}

View File

@ -527,7 +527,8 @@ define(function (require, exports, module) {
};
var encoding = PreferencesManager.getViewState("encoding", context);
if (!encoding) {
PreferencesManager.setViewState("encoding", {}, context);
encoding = {};
PreferencesManager.setViewState("encoding", encoding, context);
}
Async.doSequentially(Object.keys(encoding), function (filePath, index) {
return _checkFileExistance(filePath, index, encoding);

View File

@ -129,7 +129,7 @@ define(function (require, exports, module) {
* @param {boolean} addedToWorkingSet set to true if extensions of files added to the
* working set needs to be logged
*/
function fileOpened(filePath, addedToWorkingSet) {
function fileOpened(filePath, addedToWorkingSet, encoding) {
if (!shouldLogHealthData()) {
return;
}
@ -139,7 +139,8 @@ define(function (require, exports, module) {
fileExtCountMap = [];
healthData.fileStats = healthData.fileStats || {
openedFileExt : {},
workingSetFileExt : {}
workingSetFileExt : {},
openedFileEncoding: {}
};
if (language.getId() !== "unknown") {
fileExtCountMap = addedToWorkingSet ? healthData.fileStats.workingSetFileExt : healthData.fileStats.openedFileExt;
@ -149,6 +150,18 @@ define(function (require, exports, module) {
fileExtCountMap[fileExtension]++;
setHealthData(healthData);
}
if (encoding) {
var fileEncCountMap = healthData.fileStats.openedFileEncoding;
if (!fileEncCountMap) {
healthData.fileStats.openedFileEncoding = {};
fileEncCountMap = healthData.fileStats.openedFileEncoding;
}
if (!fileEncCountMap[encoding]) {
fileEncCountMap[encoding] = 0;
}
fileEncCountMap[encoding]++;
setHealthData(healthData);
}
}
/**