Skip to content
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

[feat] Add metric to monitor app install shares #2532

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

rohitvinnakota-codecov
Copy link
Contributor

@rohitvinnakota-codecov rohitvinnakota-codecov commented Jan 23, 2024

Description

We want to track relevant metrics on Gazebo, so that we may provide better UX, performance, and detect feedback early. This PR is a first pass at adding a metric each time a user displays intent to share a request for a Codecov installation to their app admin.

Once we have a dashboard with the metric rendering on Sentry, we can start to add additional metrics we think are important.

This PR closes codecov/engineering-team#1044

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link

codecov-public-qa bot commented Jan 23, 2024

Codecov Report

Merging #2532 (7ec0273) into main (040aa92) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2532   +/-   ##
=======================================
  Coverage   98.31%   98.31%           
=======================================
  Files         803      803           
  Lines       10333    10335    +2     
  Branches     2589     2589           
=======================================
+ Hits        10159    10161    +2     
  Misses        172      172           
  Partials        2        2           
Files Coverage Δ
...ners/RequestInstallBanner/RequestInstallBanner.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 96.95% <ø> (ø)
Pages 99.26% <ø> (ø)
Services 99.55% <ø> (ø)
Shared 99.82% <100.00%> (+<0.01%) ⬆️
UI 94.23% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 040aa92...7ec0273. Read the comment docs.

Copy link

netlify bot commented Jan 23, 2024

Deploy Preview for gazebo-staging ready!

Name Link
🔨 Latest commit 7ec0273
🔍 Latest deploy log https://app.netlify.com/sites/gazebo-staging/deploys/65b27cd5ede63900081d45d1
😎 Deploy Preview https://deploy-preview-2532--gazebo-staging.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (040aa92) 98.32% compared to head (7ec0273) 98.32%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2532   +/-   ##
=====================================
  Coverage   98.32   98.32           
=====================================
  Files        803     803           
  Lines      10333   10335    +2     
  Branches    2589    2575   -14     
=====================================
+ Hits       10159   10161    +2     
  Misses       172     172           
  Partials       2       2           
Files Coverage Δ
...ners/RequestInstallBanner/RequestInstallBanner.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 96.95% <ø> (ø)
Pages 99.26% <ø> (ø)
Services 99.55% <ø> (ø)
Shared 99.82% <100.00%> (+<0.01%) ⬆️
UI 94.23% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 040aa92...7ec0273. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (040aa92) 98.31% compared to head (7ec0273) 98.31%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2532   +/-   ##
=======================================
  Coverage   98.31%   98.31%           
=======================================
  Files         803      803           
  Lines       10333    10335    +2     
  Branches     2575     2589   +14     
=======================================
+ Hits        10159    10161    +2     
  Misses        172      172           
  Partials        2        2           
Files Coverage Δ
...ners/RequestInstallBanner/RequestInstallBanner.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 96.95% <ø> (ø)
Pages 99.26% <ø> (ø)
Services 99.55% <ø> (ø)
Shared 99.82% <100.00%> (+<0.01%) ⬆️
UI 94.23% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 040aa92...7ec0273. Read the comment docs.

@codecov-staging
Copy link

codecov-staging bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2532   +/-   ##
=======================================
  Coverage   98.31%   98.31%           
=======================================
  Files         803      803           
  Lines       10333    10335    +2     
  Branches     2589     2594    +5     
=======================================
+ Hits        10159    10161    +2     
  Misses        172      172           
  Partials        2        2           
Files Coverage Δ
...ners/RequestInstallBanner/RequestInstallBanner.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 96.95% <ø> (ø)
Pages 99.26% <ø> (ø)
Services 99.55% <ø> (ø)
Shared 99.82% <100.00%> (+<0.01%) ⬆️
UI 94.23% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 040aa92...7ec0273. Read the comment docs.

@rohitvinnakota-codecov rohitvinnakota-codecov marked this pull request as ready for review January 23, 2024 20:03
@rohitvinnakota-codecov rohitvinnakota-codecov changed the title [feat] Add metric to track app install shares [feat] Add metric to monitor app install shares Jan 23, 2024
Copy link

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Thanks for giving Sentry Metrics a try! For reference docs can be found here: getsentry/sentry-javascript#9938

@@ -14,6 +15,7 @@ import TopBanner, { saveToLocalStorage } from 'ui/TopBanner'
const APP_INSTALL_BANNER_KEY = 'request-install-banner'
const COPY_APP_INSTALL_STRING =
"Hello, could you help approve the installation of the Codecov app on GitHub for our organization? Here's the link: https://github.com/apps/codecov/installations/select_target"
const SHARE_REQUEST_METRICS_KEY = 'user_shared_request'

Choose a reason for hiding this comment

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

if we have this more widespread might make sense to colocate all metrics keys in a shared file somewhere so no risk of duplicates at all.

Also in Sentry we typically use . for the delimiter, and _ to represent compound words, and use plural for metrics, so user.shared.requests in this case.

image

Do we also want to add request.install prefix or something similar?

request_install.user.shared.requests

Choose a reason for hiding this comment

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

actually we don't use plural I think I just hallucinated that - sorry for the fake news lol

request_install.user.shared.request makes the most sense to me

Copy link
Contributor

Choose a reason for hiding this comment

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

@AbhiPrasad, thoughts on moving this to our sentry.ts file and creating an as const object that contain our keys, we could also use functions to create a base key and extend the remainder of the key, something like:

 // sentry.ts
const METRIC_KEYS = {
  REQUEST_INSTALL: (key: string) => `request_install.${key}`
} as const

// random file
const handleClick = () => {
  metrics.increment(METRIC_KEYS.REQUEST_INSTALL('user.shared.request'))
}

cc @rohitvinnakota-codecov

Choose a reason for hiding this comment

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

I think a function abstraction introduces a lot of complexity that we don't need right now, let's start simple with just plain strings? We can move to introduce abstraction when there are more metrics and we feel like we need to enforce naming.

// sentry/metricKey.ts
export const REQUEST_INSTALL_USER_SHARED_REQUEST = 'request_install.user.shared.request';
// random file
import { REQUEST_INSTALL_USER_SHARED_REQUEST } from 'blah/blah/sentry/metricKey.ts';

metrics.increment(REQUEST_INSTALL_USER_SHARED_REQUEST);

You can also write a wrapper function around metrics.increment and try to enforce the key names via a string union or even TS template literal types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can document the current process(it's fairly straightforward).

It's hard to define an abstraction that makes sense without seeing more of these in the codebase so I am willing to wait till then and use this approach for now.

Copy link
Contributor

@nicholas-codecov nicholas-codecov left a comment

Choose a reason for hiding this comment

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

Just one discussion comment to chat about before merging

Comment on lines +103 to +116
it('should capture the user shared request metric', async () => {
const { user, mockGetItem } = setup({})
render(<RequestInstallBanner />, { wrapper: wrapper('/gh/codecov') })

mockGetItem.mockReturnValue(null)

const btn = screen.getByRole('button', { name: /Share Request/ })
expect(btn).toBeInTheDocument()
await user.click(btn)

expect(Sentry.metrics.increment).toHaveBeenCalledWith(
'request_install.user.shared.request'
)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more of a philosophical question, do we want to be explicitly testing that this metric gets picked up, since we're even mocking it out we're not testing any of the functionality of it? The big question is that do we gain anything meaningful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm treating Sentry.metrics as a 3rd party library relative to the gazebo repo, and think it's not necessary to test the internals of the metrics functions.

It is useful to have the tests for metrics still since we are testing whether we attempt to capture something.

If there are refactors to components in the future, the tests and descriptions should provide a way to maintain this behaviour, and also that we are capturing the right kind of metric.

@rohitvinnakota-codecov rohitvinnakota-codecov merged commit c2dfdd3 into main Jan 25, 2024
60 checks passed
@rohitvinnakota-codecov rohitvinnakota-codecov deleted the rvinnakota/add-ddm-metric-app-install branch January 25, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Gazebo] Add DDM metric to track users who have shared an app install request with their admin
3 participants