|
7 | 7 | from django.utils import timezone as django_timezone
|
8 | 8 |
|
9 | 9 | from sentry import analytics, features
|
| 10 | +from sentry.constants import InsightModules |
10 | 11 | from sentry.models.organization import Organization
|
11 | 12 | from sentry.models.organizationonboardingtask import (
|
12 | 13 | OnboardingTask,
|
|
29 | 30 | first_event_received,
|
30 | 31 | first_event_with_minified_stack_trace_received,
|
31 | 32 | first_feedback_received,
|
| 33 | + first_insight_span_received, |
32 | 34 | first_new_feedback_received,
|
33 | 35 | first_profile_received,
|
34 | 36 | first_replay_received,
|
@@ -332,6 +334,41 @@ def record_first_custom_metric(project, **kwargs):
|
332 | 334 | )
|
333 | 335 |
|
334 | 336 |
|
| 337 | +@first_insight_span_received.connect(weak=False) |
| 338 | +def record_first_insight_span(project, module, **kwargs): |
| 339 | + flag = None |
| 340 | + if module == InsightModules.HTTP: |
| 341 | + flag = Project.flags.has_insights_http |
| 342 | + elif module == InsightModules.DB: |
| 343 | + flag = Project.flags.has_insights_db |
| 344 | + elif module == InsightModules.ASSETS: |
| 345 | + flag = Project.flags.has_insights_assets |
| 346 | + elif module == InsightModules.APP_START: |
| 347 | + flag = Project.flags.has_insights_app_start |
| 348 | + elif module == InsightModules.SCREEN_LOAD: |
| 349 | + flag = Project.flags.has_insights_screen_load |
| 350 | + elif module == InsightModules.VITAL: |
| 351 | + flag = Project.flags.has_insights_vitals |
| 352 | + elif module == InsightModules.CACHE: |
| 353 | + flag = Project.flags.has_insights_caches |
| 354 | + elif module == InsightModules.QUEUE: |
| 355 | + flag = Project.flags.has_insights_queues |
| 356 | + elif module == InsightModules.LLM_MONITORING: |
| 357 | + flag = Project.flags.has_insights_llm_monitoring |
| 358 | + |
| 359 | + if flag is not None: |
| 360 | + project.update(flags=F("flags").bitor(flag)) |
| 361 | + |
| 362 | + analytics.record( |
| 363 | + "first_insight_span.sent", |
| 364 | + user_id=project.organization.default_owner_id, |
| 365 | + organization_id=project.organization_id, |
| 366 | + project_id=project.id, |
| 367 | + platform=project.platform, |
| 368 | + module=module, |
| 369 | + ) |
| 370 | + |
| 371 | + |
335 | 372 | @member_invited.connect(weak=False)
|
336 | 373 | def record_member_invited(member, user, **kwargs):
|
337 | 374 | OrganizationOnboardingTask.objects.record(
|
|
0 commit comments