Skip to content

Commit

Permalink
Use analytics_token instead of token
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-codecov committed Nov 12, 2024
1 parent be72579 commit 6becd24
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions upload/views/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
log = logging.getLogger(__name__)


def create_upload(serializer, repository, commit, report, is_shelter_request, token):
def create_upload(serializer, repository, commit, report, is_shelter_request, analytics_token):
version = (
serializer.validated_data["version"]
if "version" in serializer.validated_data
Expand Down Expand Up @@ -77,7 +77,7 @@ def create_upload(serializer, repository, commit, report, is_shelter_request, to
instance.save()
trigger_upload_task(repository, commit.commitid, instance, report)
activate_repo(repository)
send_analytics_data(commit, instance, version, token)
send_analytics_data(commit, instance, version, analytics_token)
return instance


Expand Down Expand Up @@ -126,7 +126,7 @@ def activate_repo(repository):
)


def send_analytics_data(commit: Commit, upload: ReportSession, version, token):
def send_analytics_data(commit: Commit, upload: ReportSession, version, analytics_token):
analytics_upload_data = {
"commit": commit.commitid,
"branch": commit.branch,
Expand All @@ -142,7 +142,7 @@ def send_analytics_data(commit: Commit, upload: ReportSession, version, token):
# therefore we are removing this for now to see if it is the source of the issue
"flags": "",
"owner": commit.repository.author.ownerid,
"token": str(token),
"token": str(analytics_token),
"version": version,
"uploader_type": "CLI",
}
Expand All @@ -154,14 +154,14 @@ def send_analytics_data(commit: Commit, upload: ReportSession, version, token):
def get_token_for_analytics(commit: Commit, request):
repo = commit.repository
if isinstance(request.auth, TokenlessAuth):
token = "tokenless_upload"
analytics_token = "tokenless_upload"
elif isinstance(request.auth, OrgLevelTokenRepositoryAuth):
token = OrganizationLevelToken.objects.filter(owner=repo.author).first().token
analytics_token = OrganizationLevelToken.objects.filter(owner=repo.author).first().token
elif isinstance(request.auth, OIDCTokenRepositoryAuth):
token = "oidc_token_upload"
analytics_token = "oidc_token_upload"
else:
token = repo.upload_token
return token
analytics_token = repo.upload_token
return analytics_token


class CanDoCoverageUploadsPermission(BasePermission):
Expand Down

0 comments on commit 6becd24

Please sign in to comment.