Repository: getsentry/sentry

Issue:
Add Project Platform to First Event Analytics
We have two events that are used to track first event:
* `first_event.sent`
* `first_event_for_project.sent`

The first one only fires once per organization, the second per project. Right now, we pass in `event.platform` as the `platform` attribute. However, this is not ideal because all JS platforms get grouped together. We should use a separate parameter that let's us distinguish between a NextJS app and a Vue app.

Acceptance Criteria:

Pass in a new `project_platform` parameter that reads from `project.platform`.


Discussion:

Resolving patch:
diff --git a/src/sentry/analytics/events/first_event_sent.py b/src/sentry/analytics/events/first_event_sent.py
--- a/src/sentry/analytics/events/first_event_sent.py
+++ b/src/sentry/analytics/events/first_event_sent.py
@@ -12,6 +12,7 @@ class FirstEventSentEvent(analytics.Event):
         analytics.Attribute("platform", required=False),
         analytics.Attribute("url", required=False),
         analytics.Attribute("has_minified_stack_trace", required=False),
+        analytics.Attribute("project_platform", required=False),
     )
 
 
diff --git a/src/sentry/receivers/onboarding.py b/src/sentry/receivers/onboarding.py
--- a/src/sentry/receivers/onboarding.py
+++ b/src/sentry/receivers/onboarding.py
@@ -164,6 +164,7 @@ def record_first_event(project, event, **kwargs):
         organization_id=project.organization_id,
         project_id=project.id,
         platform=event.platform,
+        project_platform=project.platform,
         url=dict(event.tags).get("url", None),
         has_minified_stack_trace=has_event_minified_stack_trace(event),
     )
@@ -176,6 +177,7 @@ def record_first_event(project, event, **kwargs):
             organization_id=project.organization_id,
             project_id=project.id,
             platform=event.platform,
+            project_platform=project.platform,
         )
         return
 
@@ -430,6 +432,7 @@ def record_event_with_first_minified_stack_trace_for_project(project, event, **k
                 organization_id=project.organization_id,
                 project_id=project.id,
                 platform=event.platform,
+                project_platform=project.platform,
                 url=dict(event.tags).get("url", None),
             )
 


Test patch:
diff --git a/tests/sentry/receivers/test_onboarding.py b/tests/sentry/receivers/test_onboarding.py
--- a/tests/sentry/receivers/test_onboarding.py
+++ b/tests/sentry/receivers/test_onboarding.py
@@ -520,7 +520,7 @@ def test_first_event_with_minified_stack_trace_received(self, record_analytics):
         a first event with minified stack trace is received
         """
         now = timezone.now()
-        project = self.create_project(first_event=now)
+        project = self.create_project(first_event=now, platform="VueJS")
         project_created.send(project=project, user=self.user, sender=type(project))
         url = "http://localhost:3000"
         event = load_data("javascript")
@@ -563,6 +563,7 @@ def test_first_event_with_minified_stack_trace_received(self, record_analytics):
             organization_id=project.organization_id,
             project_id=project.id,
             platform=event["platform"],
+            project_platform="VueJS",
             url=url,
         )