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

ref(quick-start): Remove feature flag check backend #83300

Merged
Merged
Show file tree
Hide file tree
Changes from 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db.models import Q
from django.utils import timezone

from sentry import analytics, features
from sentry import analytics
from sentry.models.options.organization_option import OrganizationOption
from sentry.models.organization import Organization
from sentry.models.organizationonboardingtask import (
Expand Down Expand Up @@ -48,24 +48,18 @@ def try_mark_onboarding_complete(
)

organization = Organization.objects.get_from_cache(id=organization_id)
if features.has("organizations:quick-start-updates", organization, actor=user):

projects = Project.objects.filter(organization=organization)
project_with_source_maps = next(
(p for p in projects if p.platform in SOURCE_MAPS), None
)
projects = Project.objects.filter(organization=organization)
project_with_source_maps = next((p for p in projects if p.platform in SOURCE_MAPS), None)

# If a project supports source maps, we require them to complete the quick start.
# It's possible that the first project doesn't have source maps,
# but the second project (which users are guided to create in the "Add Sentry to other parts of the app" step) may have source maps.
required_tasks = (
OrganizationOnboardingTask.NEW_REQUIRED_ONBOARDING_TASKS_WITH_SOURCE_MAPS
if project_with_source_maps
else OrganizationOnboardingTask.NEW_REQUIRED_ONBOARDING_TASKS
)

else:
required_tasks = OrganizationOnboardingTask.REQUIRED_ONBOARDING_TASKS
# If a project supports source maps, we require them to complete the quick start.
# It's possible that the first project doesn't have source maps,
# but the second project (which users are guided to create in the "Add Sentry to other parts of the app" step) may have source maps.
required_tasks = (
OrganizationOnboardingTask.NEW_REQUIRED_ONBOARDING_TASKS_WITH_SOURCE_MAPS
if project_with_source_maps
else OrganizationOnboardingTask.NEW_REQUIRED_ONBOARDING_TASKS
)

if completed >= required_tasks:
try:
Expand Down
5 changes: 1 addition & 4 deletions src/sentry/onboarding_tasks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from django.contrib.auth.models import AnonymousUser

from sentry import features
from sentry.models.organization import Organization
from sentry.models.organizationonboardingtask import AbstractOnboardingTask
from sentry.users.models.user import User
Expand Down Expand Up @@ -32,9 +31,7 @@ def get_status_lookup_by_key(self, key):
return self.Model.STATUS_LOOKUP_BY_KEY.get(key)

def get_skippable_tasks(self, organization: Organization, user: User | RpcUser | AnonymousUser):
if features.has("organizations:quick-start-updates", organization, actor=user):
return self.Model.NEW_SKIPPABLE_TASKS
return self.Model.SKIPPABLE_TASKS
return self.Model.NEW_SKIPPABLE_TASKS

def fetch_onboarding_tasks(self, organization, user):
raise NotImplementedError
Expand Down
52 changes: 11 additions & 41 deletions src/sentry/receivers/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,7 @@ def record_new_project(project, user=None, user_id=None, **kwargs):
organization_id=project.organization_id,
task=OnboardingTask.SECOND_PLATFORM,
user_id=user_id,
status=(
OnboardingTaskStatus.COMPLETE
if features.has(
"organizations:quick-start-updates", project.organization, actor=user
)
else OnboardingTaskStatus.PENDING
),
status=OnboardingTaskStatus.COMPLETE,
project_id=project.id,
)
analytics.record(
Expand Down Expand Up @@ -737,42 +731,18 @@ def record_integration_added(
)
return

if features.has("organizations:quick-start-updates", organization, actor=user):
integration_types = get_integration_types(integration.provider)
integration_types = get_integration_types(integration.provider)

task_mapping = {
IntegrationDomain.SOURCE_CODE_MANAGEMENT: OnboardingTask.LINK_SENTRY_TO_SOURCE_CODE,
IntegrationDomain.MESSAGING: OnboardingTask.REAL_TIME_NOTIFICATIONS,
}
task_mapping = {
IntegrationDomain.SOURCE_CODE_MANAGEMENT: OnboardingTask.LINK_SENTRY_TO_SOURCE_CODE,
IntegrationDomain.MESSAGING: OnboardingTask.REAL_TIME_NOTIFICATIONS,
}

for integration_type in integration_types:
if integration_type in task_mapping:
OrganizationOnboardingTask.objects.create(
organization_id=organization_id,
task=task_mapping[integration_type],
status=OnboardingTaskStatus.COMPLETE,
)
try_mark_onboarding_complete(organization_id, user)
else:
task = OrganizationOnboardingTask.objects.filter(
organization_id=organization_id,
task=OnboardingTask.INTEGRATIONS,
).first()

if task:
providers = task.data.get("providers", [])
if integration.provider not in providers:
providers.append(integration.provider)
task.data["providers"] = providers
if task.status != OnboardingTaskStatus.COMPLETE:
task.status = OnboardingTaskStatus.COMPLETE
task.user_id = user_id
task.date_completed = django_timezone.now()
task.save()
else:
task = OrganizationOnboardingTask.objects.create(
for integration_type in integration_types:
if integration_type in task_mapping:
OrganizationOnboardingTask.objects.create(
organization_id=organization_id,
task=OnboardingTask.INTEGRATIONS,
task=task_mapping[integration_type],
status=OnboardingTaskStatus.COMPLETE,
data={"providers": [integration.provider]},
)
try_mark_onboarding_complete(organization_id, user)
24 changes: 11 additions & 13 deletions src/sentry/receivers/rules.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

from sentry import features
from sentry.models.project import Project
from sentry.models.rule import Rule
from sentry.notifications.types import FallthroughChoiceType
Expand Down Expand Up @@ -48,18 +47,17 @@ def create_default_rules(project: Project, default_rules=True, RuleModel=Rule, *
)
return

if features.has("organizations:quick-start-updates", project.organization, actor=user):
# When a user creates a new project and opts to set up an issue alert within it,
# the corresponding task in the quick start sidebar is automatically marked as complete.
alert_rule_created.send(
user=user,
project=project,
rule_id=rule.id,
# The default rule created within a new project is always of type 'issue'
rule_type="issue",
sender=type(project),
is_api_token=False,
)
# When a user creates a new project and opts to set up an issue alert within it,
# the corresponding task in the quick start sidebar is automatically marked as complete.
alert_rule_created.send(
user=user,
project=project,
rule_id=rule.id,
# The default rule created within a new project is always of type 'issue'
rule_type="issue",
sender=type(project),
is_api_token=False,
)


project_created.connect(create_default_rules, dispatch_uid="create_default_rules", weak=False)
Loading
Loading