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(processing): add electron symbol server to default for electron projects #81118

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/sentry/api/endpoints/team_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from sentry.api.bases.team import TeamEndpoint, TeamPermission
from sentry.api.fields.sentry_slug import SentrySerializerSlugField
from sentry.api.helpers.default_inbound_filters import set_default_inbound_filters
from sentry.api.helpers.default_symbol_sources import set_default_symbol_sources
from sentry.api.paginator import OffsetPaginator
from sentry.api.serializers import ProjectSummarySerializer, serialize
from sentry.api.serializers.models.project import OrganizationProjectResponse, ProjectSerializer
Expand Down Expand Up @@ -203,6 +204,8 @@ def post(self, request: Request, team: Team) -> Response:
if project.platform and project.platform.startswith("javascript"):
set_default_inbound_filters(project, team.organization)

set_default_symbol_sources(project)

self.create_audit_entry(
request=request,
organization=team.organization,
Expand Down
14 changes: 14 additions & 0 deletions src/sentry/api/helpers/default_symbol_sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sentry.models.project import Project
from sentry.projects.services.project import RpcProject

DEFAULT_SYMBOL_SOURCES = {
"electron": ["ios", "microsoft", "electron"],
"javascript-electron": ["ios", "microsoft", "electron"],
}


def set_default_symbol_sources(project: Project | RpcProject):
if project.platform and project.platform in DEFAULT_SYMBOL_SOURCES:
project.update_option(
"sentry:builtin_symbol_sources", DEFAULT_SYMBOL_SOURCES[project.platform]
)
3 changes: 3 additions & 0 deletions src/sentry/projects/services/project/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.db import router, transaction

from sentry.api.helpers.default_symbol_sources import set_default_symbol_sources
from sentry.api.serializers import ProjectSerializer
from sentry.auth.services.auth import AuthenticationContext
from sentry.constants import ObjectStatus
Expand Down Expand Up @@ -126,6 +127,8 @@ def create_project_for_organization(
if team:
project.add_team(team)

set_default_symbol_sources(project)

project_created.send(
project=project,
default_rules=True,
Expand Down
41 changes: 41 additions & 0 deletions tests/sentry/api/endpoints/test_team_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,44 @@ def test_similarity_project_option_invalid(self):
)
is None
)

def test_builtin_symbol_sources_electron(self):
"""
Test that project option for builtin symbol sources contains ["electron"] when creating
an Electron project, but uses defaults for other platforms.
"""
# Test Electron project
response = self.get_success_response(
self.organization.slug,
self.team.slug,
name="electron-app",
slug="electron-app",
platform="electron",
status_code=201,
)

electron_project = Project.objects.get(id=response.data["id"])
assert electron_project.platform == "electron"
symbol_sources = ProjectOption.objects.get_value(
project=electron_project, key="sentry:builtin_symbol_sources"
)
assert symbol_sources == ["ios", "microsoft", "electron"]

def test_builtin_symbol_sources_not_electron(self):
# Test non-Electron project (e.g. Python)
response = self.get_success_response(
self.organization.slug,
self.team.slug,
name="python-app",
slug="python-app",
platform="python",
status_code=201,
)

python_project = Project.objects.get(id=response.data["id"])
assert python_project.platform == "python"
# Should use default value, not ["electron"]
symbol_sources = ProjectOption.objects.get_value(
project=python_project, key="sentry:builtin_symbol_sources"
)
assert "electron" not in symbol_sources
Loading