|
14 | 14 | from sentry.integrations.base import (
|
15 | 15 | FeatureDescription,
|
16 | 16 | IntegrationData,
|
| 17 | + IntegrationDomain, |
17 | 18 | IntegrationFeatures,
|
18 | 19 | IntegrationInstallation,
|
19 | 20 | IntegrationMetadata,
|
|
26 | 27 | from sentry.integrations.opsgenie.tasks import migrate_opsgenie_plugin
|
27 | 28 | from sentry.integrations.pipeline import IntegrationPipeline
|
28 | 29 | from sentry.integrations.types import IntegrationProviderSlug
|
| 30 | +from sentry.integrations.utils.metrics import ( |
| 31 | + IntegrationPipelineViewEvent, |
| 32 | + IntegrationPipelineViewType, |
| 33 | +) |
29 | 34 | from sentry.organizations.services.organization.model import RpcOrganization
|
30 | 35 | from sentry.pipeline.views.base import PipelineView
|
31 | 36 | from sentry.shared_integrations.exceptions import (
|
@@ -105,24 +110,30 @@ class InstallationForm(forms.Form):
|
105 | 110 |
|
106 | 111 |
|
107 | 112 | class InstallationConfigView:
|
108 |
| - def dispatch(self, request: HttpRequest, pipeline: IntegrationPipeline) -> HttpResponseBase: |
109 |
| - if request.method == "POST": |
110 |
| - form = InstallationForm(request.POST) |
111 |
| - if form.is_valid(): |
112 |
| - form_data = form.cleaned_data |
113 |
| - |
114 |
| - pipeline.bind_state("installation_data", form_data) |
115 |
| - |
116 |
| - return pipeline.next_step() |
117 |
| - else: |
118 |
| - form = InstallationForm() |
119 |
| - |
120 |
| - return render_to_response( |
121 |
| - template="sentry/integrations/opsgenie-config.html", |
122 |
| - context={"form": form}, |
123 |
| - request=request, |
| 113 | + def record_event(self, event: IntegrationPipelineViewType): |
| 114 | + return IntegrationPipelineViewEvent( |
| 115 | + event, IntegrationDomain.ON_CALL_SCHEDULING, OpsgenieIntegrationProvider.key |
124 | 116 | )
|
125 | 117 |
|
| 118 | + def dispatch(self, request: HttpRequest, pipeline: IntegrationPipeline) -> HttpResponseBase: |
| 119 | + with self.record_event(IntegrationPipelineViewType.INSTALLATION_CONFIGURATION).capture(): |
| 120 | + if request.method == "POST": |
| 121 | + form = InstallationForm(request.POST) |
| 122 | + if form.is_valid(): |
| 123 | + form_data = form.cleaned_data |
| 124 | + |
| 125 | + pipeline.bind_state("installation_data", form_data) |
| 126 | + |
| 127 | + return pipeline.next_step() |
| 128 | + else: |
| 129 | + form = InstallationForm() |
| 130 | + |
| 131 | + return render_to_response( |
| 132 | + template="sentry/integrations/opsgenie-config.html", |
| 133 | + context={"form": form}, |
| 134 | + request=request, |
| 135 | + ) |
| 136 | + |
126 | 137 |
|
127 | 138 | class OpsgenieIntegration(IntegrationInstallation):
|
128 | 139 | def get_keyring_client(self, keyid: int | str) -> OpsgenieClient:
|
|
0 commit comments