-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(integrations): add option to filter by integration type #78656
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
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 |
|---|---|---|
|
|
@@ -125,6 +125,56 @@ class IntegrationFeatures(Enum): | |
| DEPLOYMENT = "deployment" | ||
|
|
||
|
|
||
| # Integration Types | ||
| MESSAGING = "messaging" | ||
| PROJECT_MANAGEMENT = "project_management" | ||
| SOURCE_CODE_MANAGEMENT = "source_code_management" | ||
| ON_CALL_SCHEDULING = "on_call_scheduling" | ||
|
|
||
|
|
||
| class IntegrationProviderSlug(Enum): | ||
| SLACK = "slack" | ||
| DISCORD = "discord" | ||
| MSTeams = "msteams" | ||
| JIRA = "jira" | ||
| JIRA_SERVER = "jira_server" | ||
| AZURE_DEVOPS = "vsts" | ||
| GITHUB = "github" | ||
| GITHUB_ENTERPRISE = "github_enterprise" | ||
| GITLAB = "gitlab" | ||
| BITBUCKET = "bitbucket" | ||
| PAGERDUTY = "pagerduty" | ||
| OPSGENIE = "opsgenie" | ||
|
|
||
|
|
||
| INTEGRATION_TYPE_TO_PROVIDER = { | ||
| MESSAGING: [ | ||
| IntegrationProviderSlug.SLACK, | ||
| IntegrationProviderSlug.DISCORD, | ||
| IntegrationProviderSlug.MSTeams, | ||
| ], | ||
| PROJECT_MANAGEMENT: [ | ||
|
Member
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. Many (or all) of source code management integrations are also project management ones. At least Github and Azure are. @cathteng can confirm which ones for sure.
Member
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. are we grouping integrations by the main focus or by a particular feature? i would say the ticketing aspect of SCMs is a feature
Member
Author
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. @sentaur-athena @cathteng I just grouped them based on our integration feature list
Member
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. @cathteng we can come back and update this list since it's not really used anywhere in code other than messaging. My thought is for example if we want to build onboarding and tell people we have these ticket management integrations we still want to return github in that list.
Member
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. ok |
||
| IntegrationProviderSlug.JIRA, | ||
| IntegrationProviderSlug.JIRA_SERVER, | ||
| IntegrationProviderSlug.GITHUB, | ||
| IntegrationProviderSlug.GITHUB_ENTERPRISE, | ||
| IntegrationProviderSlug.GITLAB, | ||
| IntegrationProviderSlug.AZURE_DEVOPS, | ||
| ], | ||
| SOURCE_CODE_MANAGEMENT: [ | ||
| IntegrationProviderSlug.GITHUB, | ||
| IntegrationProviderSlug.GITHUB_ENTERPRISE, | ||
| IntegrationProviderSlug.GITLAB, | ||
| IntegrationProviderSlug.BITBUCKET, | ||
| IntegrationProviderSlug.AZURE_DEVOPS, | ||
| ], | ||
| ON_CALL_SCHEDULING: [ | ||
| IntegrationProviderSlug.PAGERDUTY, | ||
| IntegrationProviderSlug.OPSGENIE, | ||
| ], | ||
| } | ||
|
|
||
|
|
||
| class IntegrationProvider(PipelineProvider, abc.ABC): | ||
| """ | ||
| An integration provider describes a third party that can be registered within Sentry. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,11 +15,29 @@ def setUp(self): | |
| name="Example", | ||
| external_id="example:1", | ||
| ) | ||
| self.msteams_integration = self.create_integration( | ||
| organization=self.organization, | ||
| provider="msteams", | ||
| name="MS Teams", | ||
| external_id="msteams:1", | ||
| ) | ||
| self.opsgenie = self.create_integration( | ||
| organization=self.organization, | ||
| provider="opsgenie", | ||
| name="Opsgenie", | ||
| external_id="opsgenie:1", | ||
| ) | ||
| self.slack_integration = self.create_integration( | ||
| organization=self.organization, | ||
| provider="slack", | ||
| name="Slack", | ||
| external_id="slack:1", | ||
| ) | ||
|
|
||
| def test_simple(self): | ||
| response = self.get_success_response(self.organization.slug) | ||
|
|
||
| assert len(response.data) == 1 | ||
| assert len(response.data) == 4 | ||
| assert response.data[0]["id"] == str(self.integration.id) | ||
| assert "configOrganization" in response.data[0] | ||
|
|
||
|
|
@@ -51,3 +69,40 @@ def test_provider_key(self): | |
| self.organization.slug, qs_params={"provider_key": "vercel"} | ||
| ) | ||
| assert response.data == [] | ||
|
|
||
| def test_integration_type(self): | ||
|
Collaborator
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. nit: maybe add a test for what happens when u pass both |
||
| response = self.get_success_response( | ||
| self.organization.slug, qs_params={"integrationType": "messaging"} | ||
| ) | ||
| assert len(response.data) == 2 | ||
| assert response.data[0]["id"] == str(self.msteams_integration.id) | ||
| assert response.data[1]["id"] == str(self.slack_integration.id) | ||
| response = self.get_success_response( | ||
| self.organization.slug, qs_params={"integrationType": "on_call_scheduling"} | ||
| ) | ||
| assert len(response.data) == 1 | ||
| assert response.data[0]["id"] == str(self.opsgenie.id) | ||
| response = self.get_error_response( | ||
| self.organization.slug, qs_params={"integrationType": "third_party"} | ||
| ) | ||
| assert response.data == {"detail": "Invalid integration type"} | ||
| assert response.status_code == 400 | ||
|
|
||
| def test_provider_key_and_integration_type(self): | ||
| response = self.get_success_response( | ||
| self.organization.slug, | ||
| qs_params={"providerKey": "slack", "integrationType": "messaging"}, | ||
| ) | ||
| assert len(response.data) == 1 | ||
| assert response.data[0]["id"] == str(self.slack_integration.id) | ||
| response = self.get_success_response( | ||
| self.organization.slug, | ||
| qs_params={"providerKey": "vercel", "integrationType": "messaging"}, | ||
| ) | ||
| assert response.data == [] | ||
| response = self.get_error_response( | ||
| self.organization.slug, | ||
| qs_params={"providerKey": "slack", "integrationType": "third_party"}, | ||
| ) | ||
| assert response.data == {"detail": "Invalid integration type"} | ||
| assert response.status_code == 400 | ||
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.
hmm i would love to do something so that when you register the integrations here
sentry/src/sentry/runner/initializer.py
Lines 59 to 76 in c92f4b8
you also register the integration type... cc @RyanSkonnord if you have thoughts