-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: Add webhook guard for determining when to update/add org contribs #104371
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,12 @@ | |
|
|
||
| from rest_framework.response import Response | ||
|
|
||
| from sentry import options | ||
| from sentry import features, options | ||
| from sentry.constants import ENABLE_PR_REVIEW_TEST_GENERATION_DEFAULT, HIDE_AI_FEATURES_DEFAULT | ||
| from sentry.integrations.models.repository_project_path_config import RepositoryProjectPathConfig | ||
| from sentry.models.organization import Organization | ||
| from sentry.models.repository import Repository | ||
| from sentry.seer.seer_setup import get_seer_org_acknowledgement | ||
| from sentry.utils import jwt | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
@@ -78,3 +83,34 @@ def parse_github_blob_url(repo_url: str, source_url: str) -> tuple[str, str]: | |
|
|
||
| branch, _, remainder = after_blob.partition("/") | ||
| return branch, remainder.lstrip("/") | ||
|
|
||
|
|
||
| def has_seer_and_ai_features_enabled_for_repo(organization: Organization, repo: Repository) -> bool: | ||
| """ | ||
| Check if Seer is enabled and AI features are configured for a repository. | ||
|
|
||
| Returns: | ||
| True if Seer and AI features are enabled for the repository else False | ||
| """ | ||
|
|
||
| seer_enabled = get_seer_org_acknowledgement(organization) | ||
| if not seer_enabled: | ||
| return False | ||
|
|
||
| repo_enabled = RepositoryProjectPathConfig.objects.filter( | ||
| repository=repo, | ||
| organization_id=organization.id, | ||
| ).exists() | ||
| if not repo_enabled: | ||
| return False | ||
|
|
||
| gen_ai_features = features.has( | ||
| "organizations:gen-ai-features", organization | ||
| ) and not organization.get_option("sentry:hide_ai_features", HIDE_AI_FEATURES_DEFAULT) | ||
|
|
||
| ai_code_review_enabled = organization.get_option( | ||
| "sentry:enable_pr_review_test_generation", | ||
| ENABLE_PR_REVIEW_TEST_GENERATION_DEFAULT, | ||
| ) | ||
|
|
||
| return gen_ai_features or ai_code_review_enabled | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: hide_ai_features option not respected for ai_code_review pathThe |
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can skip this toggle check for the value of the
sentry:enable_pr_review_test_generationorganization option for the purposes of billing here.We're going to keep the toggle around only for legacy seer usage based plan people so they have a way to turn on/off code review until they purchase the seat based plan. They will get code review for free if they turn this toggle on. (slack convo).
The value of the option is no longer relevant for any orgs outside of above