sentry
sentry copied to clipboard
feat(codegen): increment org contributors and assign seat in PR webhook handler
fixes ENG-5942
depends on https://github.com/getsentry/sentry/pull/104371
Track an active contributor on a PR event webhook, if the repo has Seer and AI features enabled.
- Always increment the contributor's num actions.
- Only assign a seat to the contributor if it is not a bot or an external contributor.
- Assign a seat to a contributor on the second PR event (not the first).
- Seat assignment occurs in a task for robustness. We log a warning if it fails.
Extra notes
Info about the user's type (ie, bot or not) and association (ie, external contributor or not) can be obtained from the webhook payload, per the gh docs and gh enterprise docs.
-
payload["pull_request"]["author_association"]is a required field for allpull_request,pull_request_review, andpull_request_review_commentaction types, and also in gh enterprise. ✅ -> Added to all gh and gh enterprise fixtures. -
payload["pull_request"]["user"]["type"]is required for thepull_request.openedandpull_request.closedaction types. ✅ -
payload["pull_request"]["user"]["type"]is not required forpull_request.edited, or anypull_request_revieworpull_request_review_commentaction types. But I set up a gh app and triggeredpull_request.editedandpull_request_review.submittedwebhooks and the field was indeed present. It's also already present in the fixtures used in the tests. I'm assuming we can expect it for the majority of webhooks, unless the user somehow hasn't been "classified" already (?). If we can't find the user type we just assume the user isn't a bot (feedback welcome on this behavior).
:x: 1 Tests Failed:
| Tests completed | Failed | Passed | Skipped |
|---|---|---|---|
| 29283 | 1 | 29282 | 234 |
View the top 1 failed test(s) by shortest run time
tests.sentry.integrations.github.test_utils.ShouldCreateOrIncrementContributorSeatTest::test_returns_false_when_seat_based_seer_disabledStack Traces | 2.5s run time
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/unittest/case.py#x1B[0m:58: in testPartExecutor yield #x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/unittest/case.py#x1B[0m:651: in run self._callTestMethod(testMethod) #x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/unittest/case.py#x1B[0m:606: in _callTestMethod if method() is not None: #x1B[1m#x1B[31mE TypeError: ShouldCreateOrIncrementContributorSeatTest.test_returns_false_when_seat_based_seer_disabled() missing 1 required positional argument: 'mock_quota'#x1B[0m
To view more test analytics, go to the Test Analytics Dashboard 📋 Got 3 mins? Take this short survey to help us improve Test Analytics.