This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Sending Analytics Data for file Operation and LSP features #14683
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0fe6022
Sending Analytics Data for file Operation and LSP features
36b354b
Addressed review comments
a09cc84
Addressed review comments
f9f4abb
Addressed review comments
8a1f9db
Merge branch 'master' of https://github.com/adobe/brackets into lspAn…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
|
@@ -38,6 +39,14 @@ define(function (require, exports, module) { | |
HEALTH_DATA_STATE_KEY = "HealthData.Logs", | ||
logHealthData = true; | ||
|
||
var commonStrings = { USAGE: "usage", | ||
FILE_OPEN: "fileOpen", | ||
FILE_SAVE: "fileSave", | ||
FILE_CLOSE: "fileClose", | ||
LANGUAGE_CHANGE: "languageChange", | ||
LANGUAGE_SERVER_PROTOCOL: "languageServerProtocol" | ||
}; | ||
|
||
EventDispatcher.makeEventDispatcher(exports); | ||
|
||
/** | ||
|
@@ -165,6 +174,92 @@ define(function (require, exports, module) { | |
fileEncCountMap[encoding]++; | ||
setHealthData(healthData); | ||
} | ||
|
||
|
||
sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_OPEN + language._name, | ||
commonStrings.USAGE, | ||
commonStrings.FILE_OPEN, | ||
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 : ""; | ||
sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_SAVE + fileType, | ||
commonStrings.USAGE, | ||
commonStrings.FILE_SAVE, | ||
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(commonStrings.USAGE + commonStrings.FILE_CLOSE + language._name + subType, | ||
commonStrings.USAGE, | ||
commonStrings.FILE_CLOSE, | ||
language._name.toLowerCase(), | ||
subType | ||
); | ||
} | ||
|
||
file.stat(function(err, fileStat) { | ||
if(!err) { | ||
size = fileStat.size.valueOf()/1024; | ||
} | ||
_sendData(size); | ||
}); | ||
} | ||
|
||
/** | ||
|
@@ -243,11 +338,14 @@ 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; | ||
exports.shouldLogHealthData = shouldLogHealthData; | ||
exports.init = init; | ||
exports.sendAnalyticsData = sendAnalyticsData; | ||
|
||
// constants | ||
// searchType for searchDone() | ||
|
@@ -262,5 +360,5 @@ define(function (require, exports, module) { | |
exports.SEARCH_CASE_SENSITIVE = "searchCaseSensitive"; | ||
// A new search context on search bar up-Gives an idea of number of times user did a discrete search | ||
exports.SEARCH_NEW = "searchNew"; | ||
exports.sendAnalyticsData = sendAnalyticsData; | ||
exports.commonStrings = commonStrings; | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@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 comment
The reason will be displayed to describe this comment to others. Learn more.
@niteskum Is there ever a possibility of not having the
language
property in a document object?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.
@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.