{"action":"created","comment":{"url":"https://api.github.com/repos/adobe/brackets/pulls/comments/33619585","id":33619585,"diff_hunk":"@@ -0,0 +1,167 @@\n+/*\n+ * Copyright (c) 2015 Adobe Systems Incorporated. All rights reserved.\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a\n+ * copy of this software and associated documentation files (the \"Software\"),\n+ * to deal in the Software without restriction, including without limitation\n+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+ * and/or sell copies of the Software, and to permit persons to whom the\n+ * Software is furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n+ * DEALINGS IN THE SOFTWARE.\n+ *\n+ */\n+\n+/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */\n+/*global define, jQuery*/\n+\n+/**\n+ *  Utilities functions related to Health data loggig\n+ */\n+define(function (require, exports, module) {\n+    \"use strict\";\n+\n+    var PreferencesManager          = require(\"preferences/PreferencesManager\"),\n+        LanguageManager             = require(\"language/LanguageManager\"),\n+        FileUtils                   = require(\"file/FileUtils\"),\n+        PerfUtils                   = require(\"utils/PerfUtils\"),\n+\n+        HEALTH_DATA_STATE_KEY       = \"HealthData.Logs\",\n+        logHealthData               = true;\n+\n+    /**\n+     * Init: creates the health log preference keys in the state.json file\n+     */\n+    function init() {\n+        PreferencesManager.stateManager.definePreference(HEALTH_DATA_STATE_KEY, \"object\", {});\n+    }\n+\n+    /**\n+     * Return the Performance related data\n+     * @returns {Object} Performance Data aggregated till now\n+     */\n+    function getPerformanceData() {\n+        var perfData = PerfUtils.getHealthReport();\n+        return perfData;\n+    }\n+\n+    /**\n+     * Return the aggregate of all health data logged till now from all sources\n+     * @returns {Object} Health Data aggregated till now\n+     */\n+    function getAggregatedHealthData() {\n+        var healthData = PreferencesManager.getViewState(HEALTH_DATA_STATE_KEY);\n+        jQuery.extend(healthData, getPerformanceData());\n+        return healthData;\n+    }\n+\n+    /**\n+     * Return all health data logged till now stored in the state prefs\n+     * @returns {Object} Health Data aggregated till now\n+     */\n+    function getHealthData() {\n+        var healthData = PreferencesManager.getViewState(HEALTH_DATA_STATE_KEY);\n+        return healthData;\n+    }\n+\n+    /**\n+     * Sets the health data\n+     * @param {Object} dataObject The object to be stored as health data\n+     */\n+    function setHealthData(dataObject) {\n+        PreferencesManager.setViewState(HEALTH_DATA_STATE_KEY, dataObject);\n+    }\n+\n+    /**\n+     * Returns health data logged for the given key\n+     * @returns {Object} Health Data object for the key or undefined if no health data stored\n+     */\n+    function getHealthDataLog(key) {\n+        var healthData = getHealthData();\n+        return healthData[key];\n+    }\n+\n+    /**\n+     * Sets the health data for the given key\n+     * @param {Object} dataObject The object to be stored as health data for the key\n+     */\n+    function setHealthDataLog(key, dataObject) {\n+        var healthData = getHealthData();\n+        healthData[key] = dataObject;\n+        setHealthData(healthData);\n+    }\n+\n+    /**\n+     * Clears all the health data recorded till now\n+     */\n+    function clearHealthData() {\n+        PreferencesManager.setViewState(HEALTH_DATA_STATE_KEY, {});\n+        //clear the preformance relaed health data also\n+        PerfUtils.clear();\n+    }\n+\n+    /**\n+     * Enable or disable health data logs\n+     * @param {Boolean} enabled true to enable health logs\n+     */\n+    function setHealthLogsEnabled(enabled) {\n+        logHealthData = enabled;\n+        if (!enabled) {\n+            clearHealthData();\n+        }\n+    }\n+\n+    /**\n+     * All the logging functions should be disabled if this returns false\n+     * @returns {Boolean} true if health data can be logged\n+     */\n+    function shouldLogHealthData() {\n+        return logHealthData;\n+    }","path":"src/utils/HealthLogger.js","position":129,"original_position":129,"commit_id":"b26d604be398d8266b6e55041a60dd0f3684f9ae","original_commit_id":"b26d604be398d8266b6e55041a60dd0f3684f9ae","user":{"login":"sprintr","id":3390089,"avatar_url":"https://avatars.githubusercontent.com/u/3390089?v=3","gravatar_id":"","url":"https://api.github.com/users/sprintr","html_url":"https://github.com/sprintr","followers_url":"https://api.github.com/users/sprintr/followers","following_url":"https://api.github.com/users/sprintr/following{/other_user}","gists_url":"https://api.github.com/users/sprintr/gists{/gist_id}","starred_url":"https://api.github.com/users/sprintr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sprintr/subscriptions","organizations_url":"https://api.github.com/users/sprintr/orgs","repos_url":"https://api.github.com/users/sprintr/repos","events_url":"https://api.github.com/users/sprintr/events{/privacy}","received_events_url":"https://api.github.com/users/sprintr/received_events","type":"User","site_admin":false},"body":"This function is a simple getter that is used only once and also not being exported, so we could eliminate it and use `logHealthData` where `shouldLogHealthData` is being called.","created_at":"2015-06-30T20:27:32Z","updated_at":"2015-06-30T20:27:32Z","html_url":"https://github.com/adobe/brackets/pull/11311#discussion_r33619585","pull_request_url":"https://api.github.com/repos/adobe/brackets/pulls/11311","_links":{"self":{"href":"https://api.github.com/repos/adobe/brackets/pulls/comments/33619585"},"html":{"href":"https://github.com/adobe/brackets/pull/11311#discussion_r33619585"},"pull_request":{"href":"https://api.github.com/repos/adobe/brackets/pulls/11311"}}},"pull_request":{"url":"https://api.github.com/repos/adobe/brackets/pulls/11311","id":38544015,"html_url":"https://github.com/adobe/brackets/pull/11311","diff_url":"https://github.com/adobe/brackets/pull/11311.diff","patch_url":"https://github.com/adobe/brackets/pull/11311.patch","issue_url":"https://api.github.com/repos/adobe/brackets/issues/11311","number":11311,"state":"open","locked":false,"title":"Health Data Logs for 1.4","user":{"login":"abose","id":5336369,"avatar_url":"https://avatars.githubusercontent.com/u/5336369?v=3","gravatar_id":"","url":"https://api.github.com/users/abose","html_url":"https://github.com/abose","followers_url":"https://api.github.com/users/abose/followers","following_url":"https://api.github.com/users/abose/following{/other_user}","gists_url":"https://api.github.com/users/abose/gists{/gist_id}","starred_url":"https://api.github.com/users/abose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abose/subscriptions","organizations_url":"https://api.github.com/users/abose/orgs","repos_url":"https://api.github.com/users/abose/repos","events_url":"https://api.github.com/users/abose/events{/privacy}","received_events_url":"https://api.github.com/users/abose/received_events","type":"User","site_admin":false},"body":"Add performance-specific metrics to the [Health Data Report](https://github.com/adobe/brackets/wiki/Health-Data). Things we want to start tracking:\r\n\r\n- [x] Startup Time\r\n- [x] Average File Switching Time\r\n- [ ] Project Size (number of files)\r\n- [x] Type of file(s) opened in Brackets\r\n\r\ntracks #11055 ","created_at":"2015-06-25T12:57:21Z","updated_at":"2015-06-30T20:27:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13733ce8fedabf5daf10ff2554abd1669ebc419d","assignee":null,"milestone":{"url":"https://api.github.com/repos/adobe/brackets/milestones/36","html_url":"https://github.com/adobe/brackets/milestones/Release%201.4","labels_url":"https://api.github.com/repos/adobe/brackets/milestones/36/labels","id":1048084,"number":36,"title":"Release 1.4","description":"","creator":{"login":"ryanstewart","id":45450,"avatar_url":"https://avatars.githubusercontent.com/u/45450?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanstewart","html_url":"https://github.com/ryanstewart","followers_url":"https://api.github.com/users/ryanstewart/followers","following_url":"https://api.github.com/users/ryanstewart/following{/other_user}","gists_url":"https://api.github.com/users/ryanstewart/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanstewart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanstewart/subscriptions","organizations_url":"https://api.github.com/users/ryanstewart/orgs","repos_url":"https://api.github.com/users/ryanstewart/repos","events_url":"https://api.github.com/users/ryanstewart/events{/privacy}","received_events_url":"https://api.github.com/users/ryanstewart/received_events","type":"User","site_admin":false},"open_issues":35,"closed_issues":24,"state":"open","created_at":"2015-04-01T04:03:49Z","updated_at":"2015-06-30T07:38:49Z","due_on":"2015-06-25T18:30:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/adobe/brackets/pulls/11311/commits","review_comments_url":"https://api.github.com/repos/adobe/brackets/pulls/11311/comments","review_comment_url":"https://api.github.com/repos/adobe/brackets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adobe/brackets/issues/11311/comments","statuses_url":"https://api.github.com/repos/adobe/brackets/statuses/b26d604be398d8266b6e55041a60dd0f3684f9ae","head":{"label":"adobe:abose/HealthLogs1.4","ref":"abose/HealthLogs1.4","sha":"b26d604be398d8266b6e55041a60dd0f3684f9ae","user":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"repo":{"id":2935735,"name":"brackets","full_name":"adobe/brackets","owner":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adobe/brackets","description":"An open source code editor for the web, written in JavaScript, HTML and CSS.","fork":false,"url":"https://api.github.com/repos/adobe/brackets","forks_url":"https://api.github.com/repos/adobe/brackets/forks","keys_url":"https://api.github.com/repos/adobe/brackets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adobe/brackets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adobe/brackets/teams","hooks_url":"https://api.github.com/repos/adobe/brackets/hooks","issue_events_url":"https://api.github.com/repos/adobe/brackets/issues/events{/number}","events_url":"https://api.github.com/repos/adobe/brackets/events","assignees_url":"https://api.github.com/repos/adobe/brackets/assignees{/user}","branches_url":"https://api.github.com/repos/adobe/brackets/branches{/branch}","tags_url":"https://api.github.com/repos/adobe/brackets/tags","blobs_url":"https://api.github.com/repos/adobe/brackets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adobe/brackets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adobe/brackets/git/refs{/sha}","trees_url":"https://api.github.com/repos/adobe/brackets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adobe/brackets/statuses/{sha}","languages_url":"https://api.github.com/repos/adobe/brackets/languages","stargazers_url":"https://api.github.com/repos/adobe/brackets/stargazers","contributors_url":"https://api.github.com/repos/adobe/brackets/contributors","subscribers_url":"https://api.github.com/repos/adobe/brackets/subscribers","subscription_url":"https://api.github.com/repos/adobe/brackets/subscription","commits_url":"https://api.github.com/repos/adobe/brackets/commits{/sha}","git_commits_url":"https://api.github.com/repos/adobe/brackets/git/commits{/sha}","comments_url":"https://api.github.com/repos/adobe/brackets/comments{/number}","issue_comment_url":"https://api.github.com/repos/adobe/brackets/issues/comments{/number}","contents_url":"https://api.github.com/repos/adobe/brackets/contents/{+path}","compare_url":"https://api.github.com/repos/adobe/brackets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adobe/brackets/merges","archive_url":"https://api.github.com/repos/adobe/brackets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adobe/brackets/downloads","issues_url":"https://api.github.com/repos/adobe/brackets/issues{/number}","pulls_url":"https://api.github.com/repos/adobe/brackets/pulls{/number}","milestones_url":"https://api.github.com/repos/adobe/brackets/milestones{/number}","notifications_url":"https://api.github.com/repos/adobe/brackets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adobe/brackets/labels{/name}","releases_url":"https://api.github.com/repos/adobe/brackets/releases{/id}","created_at":"2011-12-07T21:14:40Z","updated_at":"2015-06-30T20:12:43Z","pushed_at":"2015-06-30T16:09:05Z","git_url":"git://github.com/adobe/brackets.git","ssh_url":"git@github.com:adobe/brackets.git","clone_url":"https://github.com/adobe/brackets.git","svn_url":"https://github.com/adobe/brackets","homepage":"http://brackets.io","size":326931,"stargazers_count":22661,"watchers_count":22661,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4714,"mirror_url":null,"open_issues_count":1353,"forks":4714,"open_issues":1353,"watchers":22661,"default_branch":"master"}},"base":{"label":"adobe:master","ref":"master","sha":"96f24bf81f02a64cd2bfce3e7aa2258b992bac23","user":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"repo":{"id":2935735,"name":"brackets","full_name":"adobe/brackets","owner":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adobe/brackets","description":"An open source code editor for the web, written in JavaScript, HTML and CSS.","fork":false,"url":"https://api.github.com/repos/adobe/brackets","forks_url":"https://api.github.com/repos/adobe/brackets/forks","keys_url":"https://api.github.com/repos/adobe/brackets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adobe/brackets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adobe/brackets/teams","hooks_url":"https://api.github.com/repos/adobe/brackets/hooks","issue_events_url":"https://api.github.com/repos/adobe/brackets/issues/events{/number}","events_url":"https://api.github.com/repos/adobe/brackets/events","assignees_url":"https://api.github.com/repos/adobe/brackets/assignees{/user}","branches_url":"https://api.github.com/repos/adobe/brackets/branches{/branch}","tags_url":"https://api.github.com/repos/adobe/brackets/tags","blobs_url":"https://api.github.com/repos/adobe/brackets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adobe/brackets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adobe/brackets/git/refs{/sha}","trees_url":"https://api.github.com/repos/adobe/brackets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adobe/brackets/statuses/{sha}","languages_url":"https://api.github.com/repos/adobe/brackets/languages","stargazers_url":"https://api.github.com/repos/adobe/brackets/stargazers","contributors_url":"https://api.github.com/repos/adobe/brackets/contributors","subscribers_url":"https://api.github.com/repos/adobe/brackets/subscribers","subscription_url":"https://api.github.com/repos/adobe/brackets/subscription","commits_url":"https://api.github.com/repos/adobe/brackets/commits{/sha}","git_commits_url":"https://api.github.com/repos/adobe/brackets/git/commits{/sha}","comments_url":"https://api.github.com/repos/adobe/brackets/comments{/number}","issue_comment_url":"https://api.github.com/repos/adobe/brackets/issues/comments{/number}","contents_url":"https://api.github.com/repos/adobe/brackets/contents/{+path}","compare_url":"https://api.github.com/repos/adobe/brackets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adobe/brackets/merges","archive_url":"https://api.github.com/repos/adobe/brackets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adobe/brackets/downloads","issues_url":"https://api.github.com/repos/adobe/brackets/issues{/number}","pulls_url":"https://api.github.com/repos/adobe/brackets/pulls{/number}","milestones_url":"https://api.github.com/repos/adobe/brackets/milestones{/number}","notifications_url":"https://api.github.com/repos/adobe/brackets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adobe/brackets/labels{/name}","releases_url":"https://api.github.com/repos/adobe/brackets/releases{/id}","created_at":"2011-12-07T21:14:40Z","updated_at":"2015-06-30T20:12:43Z","pushed_at":"2015-06-30T16:09:05Z","git_url":"git://github.com/adobe/brackets.git","ssh_url":"git@github.com:adobe/brackets.git","clone_url":"https://github.com/adobe/brackets.git","svn_url":"https://github.com/adobe/brackets","homepage":"http://brackets.io","size":326931,"stargazers_count":22661,"watchers_count":22661,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4714,"mirror_url":null,"open_issues_count":1353,"forks":4714,"open_issues":1353,"watchers":22661,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adobe/brackets/pulls/11311"},"html":{"href":"https://github.com/adobe/brackets/pull/11311"},"issue":{"href":"https://api.github.com/repos/adobe/brackets/issues/11311"},"comments":{"href":"https://api.github.com/repos/adobe/brackets/issues/11311/comments"},"review_comments":{"href":"https://api.github.com/repos/adobe/brackets/pulls/11311/comments"},"review_comment":{"href":"https://api.github.com/repos/adobe/brackets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adobe/brackets/pulls/11311/commits"},"statuses":{"href":"https://api.github.com/repos/adobe/brackets/statuses/b26d604be398d8266b6e55041a60dd0f3684f9ae"}}}}