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

Commit 5dc7191

Browse files
Revert "feat: Track Upload Sent events for Coverage/BA/TA (#1162)" (#1194)
1 parent b43c765 commit 5dc7191

File tree

6 files changed

+0
-117
lines changed

6 files changed

+0
-117
lines changed

upload/tests/views/test_bundle_analysis.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
OrganizationLevelTokenFactory,
1111
)
1212
from shared.django_apps.core.tests.factories import CommitFactory, RepositoryFactory
13-
from shared.events.amplitude import UNKNOWN_USER_OWNERID
1413

1514
from core.models import Commit
1615
from services.redis_configuration import get_redis_connection
@@ -28,9 +27,6 @@ def test_upload_bundle_analysis_success(db, client, mocker, mock_redis):
2827
"shared.storage.MinioStorageService.create_presigned_put",
2928
return_value="test-presigned-put",
3029
)
31-
mock_amplitude = mocker.patch(
32-
"shared.events.amplitude.AmplitudeEventPublisher.publish"
33-
)
3430

3531
repository = RepositoryFactory.create()
3632
commit_sha = "6fd5b89357fc8cdf34d6197549ac7c6d7e5977ef"
@@ -107,19 +103,6 @@ def test_upload_bundle_analysis_success(db, client, mocker, mock_redis):
107103
},
108104
)
109105

110-
# emits Amplitude event
111-
mock_amplitude.assert_called_with(
112-
"Upload Sent",
113-
{
114-
"user_ownerid": UNKNOWN_USER_OWNERID,
115-
"ownerid": commit.repository.author.ownerid,
116-
"repoid": commit.repository.repoid,
117-
"commitid": commit.id,
118-
"pullid": commit.pullid,
119-
"upload_type": "Bundle",
120-
},
121-
)
122-
123106

124107
@pytest.mark.django_db(databases={"default", "timeseries"})
125108
@override_settings(SHELTER_SHARED_SECRET="shelter-shared-secret")

upload/tests/views/test_test_results.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
OwnerFactory,
1414
RepositoryFactory,
1515
)
16-
from shared.events.amplitude import UNKNOWN_USER_OWNERID
1716

1817
from services.redis_configuration import get_redis_connection
1918
from services.task import TaskService
@@ -26,9 +25,6 @@ def test_upload_test_results(db, client, mocker, mock_redis):
2625
"shared.storage.MinioStorageService.create_presigned_put",
2726
return_value="test-presigned-put",
2827
)
29-
mock_amplitude = mocker.patch(
30-
"shared.events.amplitude.AmplitudeEventPublisher.publish"
31-
)
3228

3329
owner = OwnerFactory(service="github", username="codecov")
3430
repository = RepositoryFactory.create(author=owner)
@@ -119,19 +115,6 @@ def test_upload_test_results(db, client, mocker, mock_redis):
119115
},
120116
)
121117

122-
# emits Amplitude event
123-
mock_amplitude.assert_called_with(
124-
"Upload Sent",
125-
{
126-
"user_ownerid": UNKNOWN_USER_OWNERID,
127-
"ownerid": commit.repository.author.ownerid,
128-
"repoid": commit.repository.repoid,
129-
"commitid": commit.id,
130-
"pullid": commit.pullid,
131-
"upload_type": "Test results",
132-
},
133-
)
134-
135118

136119
def test_test_results_org_token(db, client, mocker, mock_redis):
137120
mocker.patch.object(TaskService, "upload")

upload/tests/views/test_uploads.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,6 @@ def test_uploads_post_tokenless(db, mocker, mock_redis, private, branch, branch_
314314
"upload.views.uploads.trigger_upload_task", return_value=True
315315
)
316316
analytics_service_mock = mocker.patch("upload.views.uploads.AnalyticsService")
317-
amplitude_mock = mocker.patch(
318-
"shared.events.amplitude.AmplitudeEventPublisher.publish"
319-
)
320317

321318
repository = RepositoryFactory(
322319
name="the_repo",
@@ -434,17 +431,6 @@ def test_uploads_post_tokenless(db, mocker, mock_redis, private, branch, branch_
434431
"uploader_type": "CLI",
435432
},
436433
)
437-
amplitude_mock.assert_called_with(
438-
"Upload Sent",
439-
{
440-
"user_ownerid": commit.author.ownerid,
441-
"ownerid": commit.repository.author.ownerid,
442-
"repoid": commit.repository.repoid,
443-
"commitid": commit.id,
444-
"pullid": commit.pullid,
445-
"upload_type": "Coverage report",
446-
},
447-
)
448434
else:
449435
assert response.status_code == 401
450436
assert response.json().get("detail") == "Not valid tokenless upload"
@@ -473,9 +459,6 @@ def test_uploads_post_token_required_auth_check(
473459
"upload.views.uploads.trigger_upload_task", return_value=True
474460
)
475461
analytics_service_mock = mocker.patch("upload.views.uploads.AnalyticsService")
476-
amplitude_mock = mocker.patch(
477-
"shared.events.amplitude.AmplitudeEventPublisher.publish"
478-
)
479462

480463
repository = RepositoryFactory(
481464
name="the_repo",
@@ -600,31 +583,18 @@ def test_uploads_post_token_required_auth_check(
600583
"uploader_type": "CLI",
601584
},
602585
)
603-
amplitude_mock.assert_called_with(
604-
"Upload Sent",
605-
{
606-
"user_ownerid": commit.author.ownerid,
607-
"ownerid": commit.repository.author.ownerid,
608-
"repoid": commit.repository.repoid,
609-
"commitid": commit.id,
610-
"pullid": commit.pullid,
611-
"upload_type": "Coverage report",
612-
},
613-
)
614586
else:
615587
assert response.status_code == 401
616588
assert response.json().get("detail") == "Not valid tokenless upload"
617589

618590

619-
@patch("shared.events.amplitude.AmplitudeEventPublisher.publish")
620591
@patch("upload.views.uploads.AnalyticsService")
621592
@patch("upload.helpers.jwt.decode")
622593
@patch("upload.helpers.PyJWKClient")
623594
def test_uploads_post_github_oidc_auth(
624595
mock_jwks_client,
625596
mock_jwt_decode,
626597
analytics_service_mock,
627-
amplitude_mock,
628598
db,
629599
mocker,
630600
mock_redis,
@@ -747,17 +717,6 @@ def test_uploads_post_github_oidc_auth(
747717
"uploader_type": "CLI",
748718
},
749719
)
750-
amplitude_mock.assert_called_with(
751-
"Upload Sent",
752-
{
753-
"user_ownerid": commit.author.ownerid,
754-
"ownerid": commit.repository.author.ownerid,
755-
"repoid": commit.repository.repoid,
756-
"commitid": commit.id,
757-
"pullid": commit.pullid,
758-
"upload_type": "Coverage report",
759-
},
760-
)
761720

762721

763722
@override_settings(SHELTER_SHARED_SECRET="shelter-shared-secret")

upload/views/bundle_analysis.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from rest_framework.views import APIView
1212
from shared.api_archive.archive import ArchiveService
1313
from shared.bundle_analysis.storage import StoragePaths, get_bucket_name
14-
from shared.events.amplitude import UNKNOWN_USER_OWNERID, AmplitudeEventPublisher
1514
from shared.metrics import Counter, inc_counter
1615

1716
from codecov_auth.authentication.repo_auth import (
@@ -221,18 +220,4 @@ def post(self, request: HttpRequest) -> Response:
221220
),
222221
)
223222

224-
AmplitudeEventPublisher().publish(
225-
"Upload Sent",
226-
{
227-
"user_ownerid": commit.author.ownerid
228-
if commit.author
229-
else UNKNOWN_USER_OWNERID,
230-
"ownerid": repo.author.ownerid,
231-
"repoid": repo.repoid,
232-
"commitid": commit.id, # Not commit.commitid, we do not want a commit SHA here!
233-
"pullid": commit.pullid,
234-
"upload_type": "Bundle",
235-
},
236-
)
237-
238223
return Response({"url": url}, status=201)

upload/views/test_results.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from rest_framework.response import Response
99
from rest_framework.views import APIView
1010
from shared.api_archive.archive import ArchiveService, MinioEndpoints
11-
from shared.events.amplitude import UNKNOWN_USER_OWNERID, AmplitudeEventPublisher
1211
from shared.metrics import inc_counter
1312

1413
from codecov_auth.authentication.repo_auth import (
@@ -188,20 +187,6 @@ def post(self, request):
188187
report_type=CommitReport.ReportType.TEST_RESULTS,
189188
)
190189

191-
AmplitudeEventPublisher().publish(
192-
"Upload Sent",
193-
{
194-
"user_ownerid": commit.author.ownerid
195-
if commit.author
196-
else UNKNOWN_USER_OWNERID,
197-
"ownerid": repo.author.ownerid,
198-
"repoid": repo.repoid,
199-
"commitid": commit.id, # Not commit.commitid, we do not want a commit SHA here!
200-
"pullid": commit.pullid,
201-
"upload_type": "Test results",
202-
},
203-
)
204-
205190
if url is None:
206191
return Response(status=201)
207192
else:

upload/views/uploads.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from rest_framework.response import Response
1111
from rest_framework.views import APIView
1212
from shared.api_archive.archive import ArchiveService, MinioEndpoints
13-
from shared.events.amplitude import AmplitudeEventPublisher
1413
from shared.metrics import inc_counter
1514
from shared.upload.utils import UploaderType, insert_coverage_measurement
1615

@@ -168,17 +167,6 @@ def send_analytics_data(
168167
AnalyticsService().account_uploaded_coverage_report(
169168
commit.repository.author.ownerid, analytics_upload_data
170169
)
171-
AmplitudeEventPublisher().publish(
172-
"Upload Sent",
173-
{
174-
"user_ownerid": commit.author.ownerid,
175-
"ownerid": commit.repository.author.ownerid,
176-
"repoid": commit.repository.repoid,
177-
"commitid": commit.id, # Not commit.commitid, we do not want a commit SHA here.
178-
"pullid": commit.pullid,
179-
"upload_type": "Coverage report",
180-
},
181-
)
182170

183171

184172
def get_token_for_analytics(commit: Commit, request: HttpRequest) -> str:

0 commit comments

Comments
 (0)