Repository navigation
Reimplement baseline stashing metrics on top of last prod release #7470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b8b4b5f
f87a008
9186e64
336ecce
bb897fb
c480510
846b730
667be3d
6a012e2
c18c15b
5f96f11
54ecb4c
175447e
0fa8d88
2a6cc47
4128566
664dfdf
d60925d
96000e3
4f17a6e
99ea298
e48b89a
4ea0bd6
3c6b505
aff4b78
d7ffb02
7ab2181
20b993c
88ef0ef
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { Repository } from '../../models/repository' | ||
| import { git } from '.' | ||
|
|
||
| /** | ||
| * RegEx for determining if a stash entry is created by Desktop | ||
| * | ||
| * This is done by looking for a magic string with the following | ||
| * format: `!!GitHub_Desktop<branch>` | ||
| */ | ||
| const desktopStashEntryMessageRe = /!!GitHub_Desktop<(.+)>$/ | ||
|
|
||
| /** | ||
| * Gets the number of stash entries for the given repository | ||
| */ | ||
| export async function getStashSize(repository: Repository): Promise<number> { | ||
| const delimiter = '1F' | ||
| const format = ['%gd', '%H', '%gs'].join(`%x${delimiter}`) | ||
|
|
||
| const result = await git( | ||
| ['log', '-g', '-z', `--pretty=${format}`, 'refs/stash'], | ||
| repository.path, | ||
| 'getStashSize', | ||
| { | ||
| successExitCodes: new Set([0, 128]), | ||
| } | ||
| ) | ||
|
|
||
| // There's no refs/stashes reflog in the repository or it's not | ||
| // even a repository. In either case we don't care | ||
| if (result.exitCode === 128) { | ||
| return 0 | ||
| } | ||
|
|
||
| const stashEntries = result.stdout | ||
| .split('\0') | ||
| .filter(s => s !== '') | ||
| .filter(s => !desktopStashEntryMessageRe.test(s)) | ||
|
|
||
| return stashEntries.length | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,6 +193,8 @@ import { | |
| import { BranchPruner } from './helpers/branch-pruner' | ||
| import { enableBranchPruning, enablePullWithRebase } from '../feature-flag' | ||
| import { Banner, BannerType } from '../../models/banner' | ||
| import * as moment from 'moment' | ||
| import { getStashSize } from '../git/stash' | ||
|
|
||
| /** | ||
| * As fast-forwarding local branches is proportional to the number of local | ||
|
|
@@ -1139,6 +1141,7 @@ export class AppStore extends TypedBaseStore<IAppState> { | |
| return Promise.resolve(null) | ||
| } | ||
|
|
||
| this.updateStashEntryCountMetric(repository) | ||
|
Member
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. Hey @iAmWillShepherd, me and @billygriffin just looked through this today in our sync-up and noticed that there's a key difference between this and what's being proposed for 1.7 (#7438) in that the 1.7 release will trigger The potential problem that we see with this is for the subset of our users that have a workflow similar to my own, i.e. they work primarily in one repository (rarely switch) and they keep their desktop instances running for a long time (weeks in my case) this approach will lead to us checking and incrementing the count pretty infrequently whereas the proposed solution for 1.7 we will check once every 24 hours regardless of whether they switch or not. The end result here could be that if the segment we're talking about isn't trivial in size (I would personally guess that it's a decent chunk of our user base) we'd see a spike in stashes created outside of desktop once we ship 1.7 which would be the opposite of what we'd want. I would propose we amend the 1.6.6 branch with a change that moves this check to the same place as it will be in 1.7 in an effort to avoid collection inconsistencies between versions.
Contributor
Author
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.
I'd rather move the check in the 1.7 PR to I'm going to link this comment in the PR for 1.7 to make sure I make this change.
Contributor
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. @iAmWillShepherd It doesn't seem like you addressed @niik's feedback here.
|
||
| setNumber(LastSelectedRepositoryIDKey, repository.id) | ||
|
|
||
| // if repository might be marked missing, try checking if it has been restored | ||
|
|
@@ -3576,6 +3579,24 @@ export class AppStore extends TypedBaseStore<IAppState> { | |
| this.emitUpdate() | ||
| } | ||
| } | ||
| private async updateStashEntryCountMetric(repository: Repository) { | ||
| const lastStashEntryCheck = await this.repositoriesStore.getLastStashCheckDate( | ||
| repository | ||
| ) | ||
| const dateNow = moment() | ||
| const threshold = dateNow.subtract(24, 'hours') | ||
| if (lastStashEntryCheck == null || threshold.isAfter(lastStashEntryCheck)) { | ||
| // `lastStashEntryCheck` being equal to null means we've never checked for | ||
| // the given repo | ||
|
|
||
| try { | ||
| const stashSize = await getStashSize(repository) | ||
| this.statsStore.addStashEntriesCreatedOutsideDesktop(stashSize) | ||
| } finally { | ||
| await this.repositoriesStore.updateLastStashCheckDate(repository) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public _reportStats() { | ||
| // ensure the user has seen and acknowledged the current usage stats setting | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.