Browse Source

create function, move into file and align

Simon Hellmayr 15 hours ago
parent
commit
bf8de909e6

+ 3 - 6
src/sentry/api/endpoints/team_projects.py

@@ -13,6 +13,7 @@ from sentry.api.base import EnvironmentMixin, region_silo_endpoint
 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
@@ -203,6 +204,8 @@ class TeamProjectsEndpoint(TeamEndpoint, EnvironmentMixin):
             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,
@@ -222,10 +225,4 @@ class TeamProjectsEndpoint(TeamEndpoint, EnvironmentMixin):
             if project_is_seer_eligible(project):
                 project.update_option("sentry:similarity_backfill_completed", int(time.time()))
 
-            # Add electron symbol server by default to both electron and javascript-electron projects
-            if project.platform and project.platform in ["electron", "javascript-electron"]:
-                project.update_option(
-                    "sentry:builtin_symbol_sources", ["ios", "microsoft", "electron"]
-                )
-
         return Response(serialize(project, request.user), status=201)

+ 14 - 0
src/sentry/api/helpers/default_symbol_sources.py

@@ -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 - 5
src/sentry/projects/services/project/impl.py

@@ -2,6 +2,7 @@ from __future__ import annotations
 
 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
@@ -126,17 +127,14 @@ class DatabaseBackedProjectService(ProjectService):
                 if team:
                     project.add_team(team)
 
+            set_default_symbol_sources(project)
+
             project_created.send(
                 project=project,
                 default_rules=True,
                 sender=self.create_project_for_organization,
                 user_id=user_id,
             )
-            # Add electron symbol server by default to both electron and javascript-electron projects
-            if project.platform and project.platform in ["electron", "javascript-electron"]:
-                project.update_option(
-                    "sentry:builtin_symbol_sources", ["ios", "microsoft", "electron"]
-                )
 
             return serialize_project(project)