Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

feat: Track Upload Sent events for Coverage/BA/TA (attempt 2)#1195

Merged
spalmurray-codecov merged 12 commits intomainfrom
spalmurray/amplitude-upload-event
Mar 17, 2025
Merged

feat: Track Upload Sent events for Coverage/BA/TA (attempt 2)#1195
spalmurray-codecov merged 12 commits intomainfrom
spalmurray/amplitude-upload-event

Conversation

@spalmurray-codecov
Copy link
Copy Markdown
Contributor

@spalmurray-codecov spalmurray-codecov commented Mar 4, 2025

Adds event tracking of 'Upload Sent' events for Coverage, Bundles, and test results.

It seems in some cases commit may not have an author set during upload ingest. In these cases we've decided to attribute the events to a special anonymous user that has a special user id constant in shared.

Last time I merged this PR it was breaking uploads because it seems sometimes commit author is also not defined there, which we were not expecting. This second attempt adds the fallback user id to coverage uploads as well.

Note that we are using commit.id instead of the commit sha because a full commit sha is functionally identifiable information (for public repos at least). No reason to use this when we have an internal id that does the same thing but is only useful to us.

@sentry
Copy link
Copy Markdown

sentry bot commented Mar 4, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: upload/views/uploads.py

Function Unhandled Issue
send_analytics_data AttributeError: 'NoneType' object has no attribute 'ownerid' /upload/{service}/{repo}/upl...
Event Count: 9

Did you find this useful? React with a 👍 or 👎

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.87%. Comparing base (786d94a) to head (2fddc37).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1195   +/-   ##
=======================================
  Coverage   95.86%   95.87%           
=======================================
  Files         493      493           
  Lines       16871    16877    +6     
=======================================
+ Hits        16174    16180    +6     
  Misses        697      697           
Flag Coverage Δ
unit 95.87% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link
Copy Markdown

codecov-notifications bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@spalmurray-codecov spalmurray-codecov force-pushed the spalmurray/amplitude-upload-event branch from 1272b27 to 1589140 Compare March 10, 2025 20:38
@overwatch-beta
Copy link
Copy Markdown

overwatch-beta bot commented Mar 10, 2025

🚨 Sentry detected 7 potential issues in your recent changes 🚨

Lower risk findings

@spalmurray-codecov spalmurray-codecov marked this pull request as ready for review March 10, 2025 20:40
@spalmurray-codecov spalmurray-codecov requested a review from a team as a code owner March 10, 2025 20:40
Comment on lines +174 to +176
"user_ownerid": commit.author.ownerid
if commit.author
else UNKNOWN_USER_OWNERID,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the only change is these lines

if commit.author
else UNKNOWN_USER_OWNERID,
"ownerid": commit.repository.author.ownerid,
"repoid": commit.repository.repoid,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

putting a note here (mostly for myself) to figure out whether we would gain anything from using author_id and repository_id here instead of accessing those values via attrs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure I follow. Where are author_id and repository_id defined?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

they are not defined explicitly anywhere: here's some context https://docs.djangoproject.com/en/dev/ref/models/fields/#database-representation

there's nothing todo on this PR for this comment, i just wanted to make a note to revisit this and check whether we can avoid some reads from the database here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ahh okay I'm with you. I've been under the assumption that there are no reads for accessing like this. Assumed it would be populated on the already read commit in scope here (though we may need to explicitly add a select_related here to achieve that). Please lmk if I'm wrong I do not want to be doing more than one fetch for the commit's attrs. Side Q does django automatically cache any of this stuff?

Copy link
Copy Markdown
Contributor

@ajay-sentry ajay-sentry left a comment

Choose a reason for hiding this comment

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

looks good!

@seer-by-sentry
Copy link
Copy Markdown
Contributor

seer-by-sentry bot commented Mar 13, 2025

✅ Sentry found no issues in your recent changes ✅

@spalmurray-codecov spalmurray-codecov added this pull request to the merge queue Mar 17, 2025
Merged via the queue into main with commit 837aaa0 Mar 17, 2025
28 of 29 checks passed
@spalmurray-codecov spalmurray-codecov deleted the spalmurray/amplitude-upload-event branch March 17, 2025 16:14
@JerrySentry JerrySentry restored the spalmurray/amplitude-upload-event branch March 18, 2025 21:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants