Add metrics collection for committing partial changes, undoing the last commit, and opening an expanded commit msg editor #1685
Conversation
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.
overall, looks good! Thanks for diving in on this. Left a few comments in the code.
const unstagedCount = Object.keys({...unstagedFiles, ...mergeConflictFiles}).length; | ||
addEvent('commit', { | ||
package: 'github', | ||
partial: unstagedCount > 0, |
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.
Since there are several UI options for partial staging, it would be interesting to instrument those as well. Not something you have to implement here, just something to consider for future iterations.
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.
Yeah, I had that thought but then a couple of considerations caused me to pause. Maybe you have thoughts that would help with un-pausing :).
Do you have specific questions you'd like answered by this information or examples of conclusions we might be able to draw?
These were the considerations that caused me to pause initially:
- as mentioned in the description, tracking all of the staging/unstaging events seems like it could be a lot of noise with little additional value. For example, keyboard users might stage files by hitting
enter
a bunch of times for each line/hunk/file they want to stage... so for a given partial commit, there could be a ton of staging events. Maybe this could provide valuable information, but nothing came to mind for me immediately - the distinction between partial staging as opposed to staging everything can't necessarily be inferred from instrumenting the UI controls. For example, clicking the "Stage selection" button could result in partial staging of a file, or it could result in staging all changes if the user has selected all of the changes before clicking the button.
💭 welcome if you have any!
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.
I'm curious about how users are staging files. Our file staging is extremely complex because we have many ways of performing the same action. For example, we have stage and unstage all both in the staged / unstaged changes pane and in the diff view for individual files. Ditto for hunk/line staging and unstaging.
If all of these are heavily used, great. If not, we should consider simplifying so we don't have so many different ways of performing the same operation.
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.
For example, keyboard users might stage files by hitting enter a bunch of times for each line/hunk/file they want to stage... so for a given partial commit, there could be a ton of staging events.
We'd almost have to track a flag locally (somewhere in package state... ?) that recorded a bunch of aggregate information about a commit while it's being staged, then increment actual metrics when the commit is finalized here based on their final states.
For example, when a user clicks "Stage Selection" in the FilePatchItem, we know if the file still includes unstaged changes or not, so we can update a "commit includes partial file" flag to true or false; then, at commit time, we check the flag and send a partiallyStagedFile
property on the final event.
I have no idea where those flags should live, though - we don't really have a model yet for "the commit under construction." Also the FilePatchItem is about to change drastically so... 🙃
If all of these are heavily used, great. If not, we should consider simplifying so we don't have so many different ways of performing the same operation.
Yeah, that's a great point. I'm not sure how we'd do that, though 🤔
@@ -344,6 +355,7 @@ export default class Present extends State { | |||
async () => { | |||
try { | |||
await this.git().reset('soft', 'HEAD~'); | |||
addEvent('undoLastCommit', {package: 'github'}); |
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.
nit: for the counter names, we're using dash separation. Could you make this undo-last-commit
instead?
@@ -17,6 +17,7 @@ import Remote from '../remote'; | |||
import RemoteSet from '../remote-set'; | |||
import Commit from '../commit'; | |||
import OperationStates from '../operation-states'; | |||
import {addEvent} from '../../reporter-proxy'; |
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.
one thing I worry about is, we currently have some metrics tracking in git-shell-out-strategy. Which is basically as close to the "back end" as you can go. We also have tracking on the UI layer, which is useful for seeing how many users are clicking specific buttons and whatnot. If we are adding instrumentation to the middle layers of the application, how do we ensure we're not double counting events? Would it make more sense to move this instrumentation down a layer to keep it all in one place?
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.
This is a good question. @annthurium and I discussed it in person and I'll capture the conclusions here for posterity's sake --
While it's a great rule of thumb to keep instrumentation at the boundary layers of our application (UI or lowest layer), ultimately we want to insert tracking where the information we want to track lives. In this case, we want commit metadata including whether or not the commit is a partial commit, and for this we need to count the number of unstaged files. We have logic for determining the number of unstaged files in the Repository layer, and not in the GitShellOutStrategy (we try to keep GSOS methods very basic, simply fetching data from Git and making it available to the Repository layer).
So in the end, we have a bit of duplication in that we are collecting commit events in the Repository and incrementing a counter whenever there is a commit in the GitShellOutStrategy. But, we're collecting additional metadata in the Repository layer, and we're avoiding adding complexity to our GitShellOutStrategy with duplicated logic just for the sake of gathering metrics.
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.
Okay, cool 😄 I was wondering about what we should do about this.
I'm 👍 on putting our addEvent()
calls where we have the most information about the metric we're trying to collect, as opposed to doing contortions to bring the information to the same semantic layer of the codebase. We can always git grep addEvent
to see what we're collecting and where as a sanity check, but I feel like it's be pretty messy to drill enough options around purely to be able to count the right things. 🤔
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.
Another thing we could do to keep a handle on the usefulness and non-redundancy of the metrics we're collecting might be to assert about them in our "integration"-style tests. That'd help us see a view of activity we'd see from the specific, holistic user behaviors that we're asserting against there.
stagedFiles: [], | ||
unstagedFiles: [], | ||
mergeConflictFiles: [], | ||
stagedFiles: {}, |
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.
just for my own education: why did you change this function to return objects instead of arrays? (I'm sure there's a perfectly good reason, I just don't know what it is 😃 )
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.
heh, yeah good question. it's not immediately clear.
This was to fix an oversight. I checked the format of the results
returned from this function and objects are expected rather than arrays. Probably doesn't make a difference for the error case here since they're all empty objects anyways, but consistency is good
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.
... Good catch 😄
a few more thoughts on the questions you raised in the body of the pull request:
|
test/models/repository.test.js
Outdated
assert.isFalse(args[1].partial); | ||
}); | ||
|
||
it.only('reports if the commit was an amend', async function() { |
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.
I was like "why did code coverage decrease so much" and then I was like "ohh." I do the same thing myself at least once a week.
Regarding gathering metrics on expanded commit editor usage, if we do choose to do so
You can also use a command, so the optimal location to instrument would be the
Yeah, that and/or there’s potential to improve discoverability :) |
coAuthors: coAuthors.map(author => { | ||
return {email: author.getEmail(), name: author.getFullName()}; | ||
}), | ||
}; |
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.
@smashwilson can you double check to see if I retained the logic you originally intended with this change?
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.
Yup, it looks good to me 👍
Default
options
to{}
; ifoptions
containscoAuthors
, translate it to an Array of email/name pairs.
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.
✨
@@ -17,6 +17,7 @@ import Remote from '../remote'; | |||
import RemoteSet from '../remote-set'; | |||
import Commit from '../commit'; | |||
import OperationStates from '../operation-states'; | |||
import {addEvent} from '../../reporter-proxy'; |
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.
Okay, cool 😄 I was wondering about what we should do about this.
I'm 👍 on putting our addEvent()
calls where we have the most information about the metric we're trying to collect, as opposed to doing contortions to bring the information to the same semantic layer of the codebase. We can always git grep addEvent
to see what we're collecting and where as a sanity check, but I feel like it's be pretty messy to drill enough options around purely to be able to count the right things. 🤔
coAuthors: coAuthors.map(author => { | ||
return {email: author.getEmail(), name: author.getFullName()}; | ||
}), | ||
}; |
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.
Yup, it looks good to me 👍
Default
options
to{}
; ifoptions
containscoAuthors
, translate it to an Array of email/name pairs.
const unstagedCount = Object.keys({...unstagedFiles, ...mergeConflictFiles}).length; | ||
addEvent('commit', { | ||
package: 'github', | ||
partial: unstagedCount > 0, |
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.
For example, keyboard users might stage files by hitting enter a bunch of times for each line/hunk/file they want to stage... so for a given partial commit, there could be a ton of staging events.
We'd almost have to track a flag locally (somewhere in package state... ?) that recorded a bunch of aggregate information about a commit while it's being staged, then increment actual metrics when the commit is finalized here based on their final states.
For example, when a user clicks "Stage Selection" in the FilePatchItem, we know if the file still includes unstaged changes or not, so we can update a "commit includes partial file" flag to true or false; then, at commit time, we check the flag and send a partiallyStagedFile
property on the final event.
I have no idea where those flags should live, though - we don't really have a model yet for "the commit under construction." Also the FilePatchItem is about to change drastically so... 🙃
If all of these are heavily used, great. If not, we should consider simplifying so we don't have so many different ways of performing the same operation.
Yeah, that's a great point. I'm not sure how we'd do that, though 🤔
stagedFiles: [], | ||
unstagedFiles: [], | ||
mergeConflictFiles: [], | ||
stagedFiles: {}, |
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.
... Good catch 😄
@@ -17,6 +17,7 @@ import Remote from '../remote'; | |||
import RemoteSet from '../remote-set'; | |||
import Commit from '../commit'; | |||
import OperationStates from '../operation-states'; | |||
import {addEvent} from '../../reporter-proxy'; |
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.
Another thing we could do to keep a handle on the usefulness and non-redundancy of the metrics we're collecting might be to assert about them in our "integration"-style tests. That'd help us see a view of activity we'd see from the specific, holistic user behaviors that we're asserting against there.
sinon.stub(reporterProxy, 'addEvent'); | ||
// open expanded commit message editor | ||
await wrapper.find('CommitView').prop('toggleExpandedCommitMessageEditor')('message in box'); | ||
assert.deepEqual(reporterProxy.addEvent.callCount, 1); |
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.
Nitpick: these assertions can be assert.strictEqual()
instead, or even assert.isTrue(reporterProxy.addEvent.called)
.
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.
oh haha yeah, copy/paste oversight. Thanks for pointing this out!
assert.deepEqual(reporterProxy.addEvent.callCount, 1); | ||
let args = reporterProxy.addEvent.lastCall.args; | ||
assert.deepEqual(args[0], 'open-commit-message-editor'); | ||
assert.deepEqual(args[1], {package: 'github'}); |
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.
There is also assert.isTrue(reporterProxy.addEvent.calledWith('open-commit-message-editor', {package: 'github'}))
to do these all at once! Although as I've found out the hard way those don't behave properly with things like Sets.
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.
oooh I like!
test/models/repository.test.js
Outdated
|
||
assert.deepEqual(reporterProxy.addEvent.callCount, 0); | ||
try { | ||
await repo.undoLastCommit(); |
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.
If you want to be sure this is a failure, you can replace this try-catch with:
await assert.isRejected(repo.undoLastCommit());
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.
I do want to be sure! :)
Thanks for all the great suggestions for cleaning up test assertions @smashwilson. I like the improved cleanliness and readability ✨
Description of the Change
This PR introduces some of the additional metrics discussed in #1591.
So far I've added events for the following:
Other thoughts and considerations:
Expanded commit message editor usage
I considered using the "verbatim" option passed to Repository#commit to report whether the commit was made from an expanded commit editor or the small commit box in the Git Panel because I know that is what dictates its value, but it seemed icky to be relying on that inference. It also felt not great to pass down an additional option such as
expandedCommitMessageEditor
to the repository model strictly for collecting metrics on it. If we decide this is something we really want to instrument, it's better and more direct to do so where the expanded editor is opened (such as CommitController#openCommitMessageEditor).Gathering data on button use vs. keyboard shortcuts vs. context menu use
It could be interesting and useful to gather data on how users are initiating operations in our package. This info could yield insights about how discoverable each of these entry points are. That said, the way that keybindings and context-menus are set up in Atom is based on commands which result in functions being called. We can easily instrument the function calls in this package as well as button presses, but I don't think there's an easy/straight-forward way to instrument the keyboard shortcut or context menu usage. @smashwilson @annthurium 💭s?
Alternate Designs
To gather information on partial-staging I considered tracking staging/unstaging events. At the end of the day though, I think what we care most about is how frequently users are taking advantage of the fact that you can easily make commits with partial changes using our UI. Tracking all of the staging/unstaging events seems like it would be a lot of noise with little additional value. Open to thoughts and suggestions though!
Benefits
We'll have interesting insights into user behavior, and be able to ask/answer questions such as those above in italics. This information could potentially help us identify UX issues, inform project decisions and priorities, and track the impact of future work and features introduced.
Possible Drawbacks
This PR simply introduces additional metrics collection. No drawbacks that I can think of.
Applicable Issues
#1591
TODO: