Skip to content

Commit e4709be

Browse files
committed
chore: add git metrics
1 parent ffe2fe2 commit e4709be

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

src/extensions/default/Git/src/ErrorHandler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ define(function (require, exports) {
33
var _ = brackets.getModule("thirdparty/lodash"),
44
Dialogs = brackets.getModule("widgets/Dialogs"),
55
Mustache = brackets.getModule("thirdparty/mustache/mustache"),
6-
NativeApp = brackets.getModule("utils/NativeApp"),
6+
Metrics = brackets.getModule("utils/Metrics"),
77
Strings = brackets.getModule("strings"),
88
Utils = require("src/Utils"),
99
errorDialogTemplate = require("text!templates/git-error-dialog.html");
@@ -41,6 +41,7 @@ define(function (require, exports) {
4141
};
4242

4343
exports.showError = function (err, title, dontStripError) {
44+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'dialog', "errorShow");
4445
if (err.__shown) { return err; }
4546

4647
exports.logError(err);

src/extensions/default/Git/src/Main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ define(function (require, exports) {
66
Menus = brackets.getModule("command/Menus"),
77
FileSystem = brackets.getModule("filesystem/FileSystem"),
88
Mustache = brackets.getModule("thirdparty/mustache/mustache"),
9+
Metrics = brackets.getModule("utils/Metrics"),
910
ProjectManager = brackets.getModule("project/ProjectManager");
1011

1112
const Constants = require("src/Constants"),
@@ -421,6 +422,7 @@ define(function (require, exports) {
421422
EventEmitter.on(Events.GIT_ENABLED, function () {
422423
_enableAllCommands(true);
423424
gitEnabled = true;
425+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'enabled', "project");
424426
});
425427
EventEmitter.on(Events.GIT_DISABLED, function () {
426428
_enableAllCommands(false);

src/extensions/default/Git/src/NoRepo.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
define(function (require) {
33

44
// Brackets modules
5-
const FileSystem = brackets.getModule("filesystem/FileSystem"),
5+
const FileSystem = brackets.getModule("filesystem/FileSystem"),
66
FileUtils = brackets.getModule("file/FileUtils"),
77
ProjectManager = brackets.getModule("project/ProjectManager"),
88
CommandManager = brackets.getModule("command/CommandManager"),
9-
StringUtils = brackets.getModule("utils/StringUtils");
9+
Metrics = brackets.getModule("utils/Metrics"),
10+
Strings = brackets.getModule("strings"),
11+
StringUtils = brackets.getModule("utils/StringUtils");
1012

1113
// Local modules
12-
const ErrorHandler = require("src/ErrorHandler"),
14+
const ErrorHandler = require("src/ErrorHandler"),
1315
Events = require("src/Events"),
1416
EventEmitter = require("src/EventEmitter"),
15-
Strings = brackets.getModule("strings"),
1617
ExpectedError = require("src/ExpectedError"),
1718
ProgressDialog = require("src/dialogs/Progress"),
1819
CloneDialog = require("src/dialogs/Clone"),
@@ -73,8 +74,10 @@ define(function (require) {
7374
return stageGitIgnore("Initial staging");
7475
}).catch(function (err) {
7576
ErrorHandler.showError(err, Strings.INIT_NEW_REPO_FAILED, true);
77+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'init', "fail");
7678
}).then(function () {
7779
EventEmitter.emit(Events.REFRESH_ALL);
80+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'init', "success");
7881
});
7982
}
8083

@@ -140,8 +143,11 @@ define(function (require) {
140143
// when dialog is cancelled, there's no error
141144
if (err) { ErrorHandler.showError(err, Strings.GIT_CLONE_REMOTE_FAILED); }
142145
});
146+
}).then(()=>{
147+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'clone', "success");
143148
}).catch(function (err) {
144149
ErrorHandler.showError(err);
150+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'clone', "fail");
145151
}).finally(function () {
146152
$cloneButton.prop("disabled", false);
147153
});

src/extensions/default/Git/src/utils/Setup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
define(function (require, exports) {
22

33
// Brackets modules
4-
const _ = brackets.getModule("thirdparty/lodash");
4+
const _ = brackets.getModule("thirdparty/lodash"),
5+
Metrics = brackets.getModule("utils/Metrics");
56

67
// Local modules
78
const Cli = require("src/Cli"),
@@ -110,10 +111,12 @@ define(function (require, exports) {
110111
getGitVersion().then(function (_version) {
111112
extensionActivated = true;
112113
resolve(extensionActivated);
114+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'installed', "yes");
113115
}).catch(function (err) {
114116
extensionActivated = false;
115117
console.warn("Failed to launch Git executable. Deactivating Git extension. Is git installed?", err);
116118
resolve(extensionActivated);
119+
Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'installed', "no");
117120
});
118121
});
119122
}

src/utils/Metrics.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ define(function (require, exports, module) {
8585
* ### Properties
8686
* `PLATFORM`, `PROJECT`, `THEMES`, `EXTENSIONS`, `EXTENSIONS`, `UI`, `UI_DIALOG`, `UI_BOTTOM_PANEL`,
8787
* `UI_SIDE_PANEL`, `LIVE_PREVIEW`, `CODE_HINTS`, `EDITOR`, `SEARCH`, `SHARING`, `PERFORMANCE`, `NEW_PROJECT`
88+
* `ERROR`, `USER`, `NODEJS`, `LINT`, `GIT`
8889
*
8990
* @typedef EVENT_TYPE
9091
* @type {Object}
@@ -114,7 +115,8 @@ define(function (require, exports, module) {
114115
ERROR: "error",
115116
USER: "user",
116117
NODEJS: "node",
117-
LINT: "lint"
118+
LINT: "lint",
119+
GIT: "git"
118120
};
119121

120122
/**

0 commit comments

Comments
 (0)