Skip to content

record metrics for protected branch scenarios due for 1.7 - #7595

Merged
shiftkey merged 35 commits into
developmentfrom
shiftkey/add-metrics/when-protected-branch-committed-to
May 29, 2019
Merged

shiftkey merged 35 commits into
developmentfrom
shiftkey/add-metrics/when-protected-branch-committed-to

Conversation

@shiftkey

@shiftkey shiftkey commented May 21, 2019 •

Copy link
Copy Markdown
Member

Overview

Second PR to address #7091

Description

I believe this is feature-complete now, and will go out with the next beta. I'll follow up with a PR to enable it for production based on how further testing on beta looks.

Release notes

Notes: no-notes

@shiftkey

Copy link
Copy Markdown
Member Author

@nerdneha @desktop/engineering if you've got time today/tomorrow, could you sanity check that these commitsToProtectedBranch and commitWithBranchProtectionsEnabled make sense with respect to the list of things we want to capture in the original issue?

Here's the original list, with my current thoughts about how this PR addresses them:

  1. How many users fit the above category (people who have committed to a repo with at least one protected branch)

I think this is covered by commitWithBranchProtectionsEnabled - this will be set to true when the user makes a commit and the repository has branch protections. This will reset every day after the usage stats are submitted.

  1. How many commits per user to a protected branch

This should be covered by commitsToProtectedBranch - this will increment whenever a commit is shown to belong to a protected branch.

  1. How frequently it's occurring for people

We have various related commit metrics already - commits is the absolute count, and dotcomCommits and enterpriseCommits are the subset of these for known remotes. "Frequently" here suggests there's a time dimension to this, but I'm not sure if we have a good precedence for this.

To put this simply as a percentage value (so from "never" to "always") this could be computed by

  • commitsToProtectedBranch / commits to include all commits
  • commitsToProtectedBranch / (dotcomCommits + enterpriseCommits) is a bit more accurate (excludes commits for local-only and non-GitHub remotes)
  1. % of people accidentally committing to a protected branch

I think this just represents all users with commitsToProtectedBranch > 0.

  1. On repos with protected branches, % of commits to those branches

This feels like #3 but filtered only to users where commitWithBranchProtectionsEnabled is true.

@shiftkey
shiftkey changed the base branch from shiftkey/store-branch-information-for-repository to development May 22, 2019 11:07
@shiftkey
shiftkey force-pushed the shiftkey/add-metrics/when-protected-branch-committed-to branch 2 times, most recently from 55a35cd to afb1f00 Compare May 22, 2019 11:22
@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label May 22, 2019
@shiftkey

Copy link
Copy Markdown
Member Author

Marking this as ready-for-review while we confirm the captured metrics satisfy the goals of the issue

@mido1966

This comment was marked as off-topic.

Comment thread app/src/lib/stats/stats-database.ts Resolved
Comment thread app/src/lib/stores/app-store.ts Resolved
@outofambit

Copy link
Copy Markdown
Contributor

if you've got time today/tomorrow, could you sanity check that these commitsToProtectedBranch and commitWithBranchProtectionsEnabled make sense with respect to the list of things we want to capture in the original issue?

these all look good to me, but i have questions about:

How frequently it's occurring for people

is that how often they're committing to protected branches? or how often they try to push to a protected branch and get rejected? its pretty vague in #7091 but i'm leaning towards the former, which i believe is covered with the calculation @shiftkey outlined above (and thus by the implementation in this PR). @nerdneha can double check this in case we're reading this wrong?

@outofambit outofambit self-assigned this May 22, 2019
@shiftkey

shiftkey commented May 24, 2019 •

Copy link
Copy Markdown
Member Author

How frequently it's occurring for people

is that how often they're committing to protected branches? or how often they try to push to a protected branch and get rejected? its pretty vague in #7091 but i'm leaning towards the former,

This is also my feeling too, because the check for "the push was rejected" is much later in the flow, and was separate enough from the rest of the questions about commit time that I didn't focus on anything push-related.

I wrote up some notes about how we could detect failing pushes being related to protected branches in #7023 (comment), if you want to understand the potential extra work here.

@nerdneha

nerdneha commented May 27, 2019 •

Copy link
Copy Markdown
Contributor
  1. How many users fit the above category (people who have committed to a repo with at least one protected branch)

We have commitWithBranchProtectionsEnabled set to true.

This should be fine since the userId is sent along in the package. If I understand correctly, from the consumption side, we could just count the number of users who have had this set to true in the last month.

  1. How many commits per user to a protected branch

We have commitsToProtectedBranch for the number of commits to a protected branch.

Would this be per repo or across the entire user's account? It might be helpful to also know how many repos that is across also but I'm not 100% sure here.

  1. How frequently it's occurring for people

We're probably looking for whether the amount of times people commit to a protected branch increases or decreases over time. I think having commitsToProtectedBranch is sufficient here, but I think distilling it down to a per repo basis might give us some extra granularity (see question for 4).

is that how often they're committing to protected branches? or how often they try to push to a protected branch and get rejected? its pretty vague in #7091 but i'm leaning towards the former, which i believe is covered with the calculation @shiftkey outlined above (and thus by the implementation in this PR). @nerdneha can double check this in case we're reading this wrong?

i think this is "attempted commits" (aka committing to protected branches, as @outofambit said) -- so it covers commits and rejections

  1. % of people accidentally committing to a protected branch

I agree, it's # of users with commitsToProtectedBranch > 0 / # of users with commitsWithProtectedBranchesEnabled = true. (or potentially # of users period)

  1. On repos with protected branches, % of commits to those branches

I think this is #4 but on a repo level instead of a user level; we'd need to know the number of commits to a protected branch per user per repo to answer this.

@shiftkey

Copy link
Copy Markdown
Member Author

@nerdneha thanks for the extra context!

  1. How many commits per user to a protected branch

We have commitsToProtectedBranch for the number of commits to a protected branch.

Would this be per repo or across the entire user's account? It might be helpful to also know how many repos that is across also but I'm not 100% sure here.

This metric is not broken down per-repository, and I'd love to unpack what "per repo" means here because I don't think I have a good grasp on how this should be computed. Could you elaborate?

i think this is "attempted commits" (aka committing to protected branches, as @outofambit said) -- so it covers commits and rejections

Based on my understanding of what you're saying here, are you interesting in how may times a git push is rejected because of branch protection issues? Because that's not supported currently in this PR, and is a separate area to our current focus on commit authoring in #7023 and #7091.

niik
niik previously requested changes May 28, 2019

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment based on mine and @nerdneha's reading of this PR. Feel free to dismiss my PR when there's consensus about the state of this PR since I'll likely be sleeping by then.

Comment thread app/src/lib/stores/app-store.ts Resolved
@nerdneha

nerdneha commented May 28, 2019 •

Copy link
Copy Markdown
Contributor

@shiftkey thanks for the great points there. addressing the "per repo" piece here and will address the "attempted commits" piece in a subsequent comment. @niik and I took a look at the metrics you're collecting and have a change that can address the "per repo" piece elegantly without actually having to collect each commit on a per repo basis.

  1. On repos with protected branches, % of commits to those branches

This metric is not broken down per-repository, and I'd love to unpack what "per repo" means here because I don't think I have a good grasp on how this should be computed. Could you elaborate?

Ultimately, we want to know the number of attempted commits to a protected branch / commits overall to repositories with branch protected enabled

number of attempted commits to a protected branch: this is commitsToProtectedBranch

commits overall to repositories with branch protected enabled: since we right now have commitWithBranchProtectionsEnabled as a boolean, if we turn this into an incremented number, that will provide this measurement and then, for the boolean case, we can just see if it's >0.

Would this be too big of a change to make today?

@nerdneha

nerdneha commented May 28, 2019 •

Copy link
Copy Markdown
Contributor

i think this is "attempted commits" (aka committing to protected branches, as @outofambit said) -- so it covers commits and rejections

Based on my understanding of what you're saying here, are you interesting in how may times a git push is rejected because of branch protection issues? Because that's not supported currently in this PR, and is a separate area to our current focus on commit authoring in #7023 and #7091.

English language is hard y'all. Sorry about the confusion, what I was trying to say is that we shouldn't have to worry about any case where a push is rejected. What we have is sufficient and no extra work is needed.

When we said How frequently it's occurring for people, honestly I think we're trying to measure the amount of wasted effort people experience with protected branches. That happens the minute they click on the commit button, regardless of whether or not it gets eventually rejected (ex: someone could realize before they push but they still have to put in extra work). If we collect "attempted commits" aka, commitsToProtectedBranch, then I think we have the right metric to measure the problem and eventually the impact.

@shiftkey

Copy link
Copy Markdown
Member Author

@nerdneha

Would this be too big of a change to make today?

Not too big of a change, just wanted to understand the context as it wasn't familiar to me and make sure I didn't head down the wrong path.

What we have is sufficient and no extra work is needed.

👍

@nerdneha

Copy link
Copy Markdown
Contributor

Not too big of a change, just wanted to understand the context as it wasn't familiar to me and make sure I didn't head down the wrong path.

totally, this was a super valid clarification and I'm glad we could take a step back and avoid actually collecting metrics on a per repo basis for this feature! thank you!!! 🙏 🙇‍♀

@shiftkey
shiftkey force-pushed the shiftkey/add-metrics/when-protected-branch-committed-to branch from 0fb09df to 006d484 Compare May 28, 2019 17:29
@shiftkey

Copy link
Copy Markdown
Member Author

I've update this PR to add two commits:

  • 6520ce8 - this commit changes the previous flag to a counter now named commitsToRepositoryWithBranchProtections - hopefully that name is clear enough to differentiate it from the existing commitsToProtectedBranch
  • 006d484 - this commit refactors the flow to always check whether branch protections are found for the current repository, and performs a simpler check on the current branch to see if it would be considered "protected"

I'm still refining the flow to confirm the logic is correct and it's caching as much as possible, but I wanted to get this out for other 👀 while it's fresh.

The goal with this last commit was to relax the flow a bit to:

  • favour the GitHub API over whatever remote is found in application state
  • check the upstream as well as the fork if both are found in the GitHub API
  • use the local branch name if no tracking branch is found

Feel free to challenge those assumptions if you think there's a better flow here

@shiftkey
shiftkey requested review from niik and outofambit and removed request for outofambit May 28, 2019 19:01
@shiftkey
shiftkey force-pushed the shiftkey/add-metrics/when-protected-branch-committed-to branch from 72c57c6 to 60a5cb7 Compare May 28, 2019 20:14
@shiftkey
shiftkey dismissed niik’s stale review May 29, 2019 12:30

Dropping this because I believe we've settled on the right approach for what we're measuring here

@shiftkey

Copy link
Copy Markdown
Member Author

Just updated the PR description to indicate this will be enabled for the next beta release, and I'll follow up with a PR to enable it for production if we're happy to turn it on for 1.7.

@shiftkey
shiftkey merged commit 6ffbbd8 into development May 29, 2019
@shiftkey
shiftkey deleted the shiftkey/add-metrics/when-protected-branch-committed-to branch May 29, 2019 14:00
@outofambit outofambit added the metrics measuring user behavior for better decisions label Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics measuring user behavior for better decisions ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants