-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Sending Analytics Data for file Operation and LSP features #14683
Changes from 1 commit
0fe6022
36b354b
a09cc84
f9f4abb
8a1f9db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ define(function (require, exports, module) { | |
var PreferencesManager = require("preferences/PreferencesManager"), | ||
LanguageManager = require("language/LanguageManager"), | ||
FileUtils = require("file/FileUtils"), | ||
FileSystem = require("filesystem/FileSystem"), | ||
PerfUtils = require("utils/PerfUtils"), | ||
FindUtils = require("search/FindUtils"), | ||
StringUtils = require("utils/StringUtils"), | ||
|
@@ -165,6 +166,92 @@ define(function (require, exports, module) { | |
fileEncCountMap[encoding]++; | ||
setHealthData(healthData); | ||
} | ||
|
||
|
||
sendAnalyticsData("usagefileOpen" + language._name, | ||
"usage", | ||
"fileOpen", | ||
language._name.toLowerCase() | ||
); | ||
|
||
} | ||
|
||
/** | ||
* Whenever a file is saved call this function. | ||
* The function will send the analytics Data | ||
* We only log the standard filetypes and fileSize | ||
* @param {String} filePath The path of the file to be registered | ||
*/ | ||
function fileSaved(docToSave) { | ||
if (!docToSave) { | ||
return; | ||
} | ||
var fileType = docToSave.language ? docToSave.language._name : ""; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SnchitGrover Do we want an empty string here or something like "unknown"? Empty strings are sometimes treated as null values while serialization depending on platform. Depends on your use case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @niteskum Is there ever a possibility of not having the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shubhsnov I think document will always have language. but since file save is critical operation , don't want to leave any space in code to trigger exception so I am doing null check. |
||
sendAnalyticsData("usagefileSave" + fileType, | ||
"usage", | ||
"fileSave", | ||
fileType.toLowerCase() | ||
); | ||
} | ||
|
||
/** | ||
* Whenever a file is closed call this function. | ||
* The function will send the analytics Data. | ||
* We only log the standard filetypes and fileSize | ||
* @param {String} filePath The path of the file to be registered | ||
*/ | ||
function fileClosed(file) { | ||
if (!file) { | ||
return; | ||
} | ||
var language = LanguageManager.getLanguageForPath(file._path), | ||
size = -1; | ||
|
||
function _sendData(fileSize) { | ||
var subType = ""; | ||
|
||
if(fileSize/1024 < 1) { | ||
|
||
if(fileSize === -1) { | ||
subType = ""; | ||
} | ||
if(fileSize < 10) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't the check be <=? if the file size is 10kb, it will log in 10_50KB range. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
subType = "Size_0_10KB"; | ||
} else if (fileSize < 50) { | ||
subType = "Size_10_50KB"; | ||
} else if (fileSize < 100) { | ||
subType = "Size_50_100KB"; | ||
} else if (fileSize < 500) { | ||
subType = "Size_100_500KB"; | ||
} else { | ||
subType = "Size_500KB_1MB"; | ||
} | ||
|
||
} else { | ||
fileSize = fileSize/1024; | ||
if(fileSize < 2) { | ||
subType = "Size_1_2MB"; | ||
} else if(fileSize < 5) { | ||
subType = "Size_2_5MB"; | ||
} else { | ||
subType = "Size_Above_5MB"; | ||
} | ||
} | ||
|
||
sendAnalyticsData("usagefileClose" + language._name + subType, | ||
"usage", | ||
"fileClose", | ||
language._name.toLowerCase(), | ||
subType | ||
); | ||
} | ||
|
||
file.stat(function(err, fileStat) { | ||
if(!err) { | ||
size = fileStat.size.valueOf()/1024; | ||
} | ||
_sendData(size); | ||
}); | ||
} | ||
|
||
/** | ||
|
@@ -243,6 +330,8 @@ define(function (require, exports, module) { | |
exports.getAggregatedHealthData = getAggregatedHealthData; | ||
exports.clearHealthData = clearHealthData; | ||
exports.fileOpened = fileOpened; | ||
exports.fileSaved = fileSaved; | ||
exports.fileClosed = fileClosed; | ||
exports.setProjectDetail = setProjectDetail; | ||
exports.searchDone = searchDone; | ||
exports.setHealthLogsEnabled = setHealthLogsEnabled; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niteskum can all analytics strings be moved to another file as variables and use that variable everywhere needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved all common strings constant to HealthLogger.js as earlier all constants were defined in this file