diff --git a/static/images/integrations/bot_avatars/opbeat.png b/static/images/integrations/bot_avatars/opbeat.png deleted file mode 100644 index bd004dec91..0000000000 Binary files a/static/images/integrations/bot_avatars/opbeat.png and /dev/null differ diff --git a/static/images/integrations/logos/opbeat.svg b/static/images/integrations/logos/opbeat.svg deleted file mode 100644 index ffd36ca2bf..0000000000 Binary files a/static/images/integrations/logos/opbeat.svg and /dev/null differ diff --git a/static/images/integrations/opbeat/001.png b/static/images/integrations/opbeat/001.png deleted file mode 100644 index f7735bddc4..0000000000 Binary files a/static/images/integrations/opbeat/001.png and /dev/null differ diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py index 83ae76613d..e04956db16 100644 --- a/zerver/lib/integrations.py +++ b/zerver/lib/integrations.py @@ -444,13 +444,6 @@ WEBHOOK_INTEGRATIONS: list[WebhookIntegration] = [ WebhookIntegration("mention", ["marketing"], display_name="Mention"), WebhookIntegration("netlify", ["continuous-integration", "deployment"], display_name="Netlify"), WebhookIntegration("newrelic", ["monitoring"], display_name="New Relic"), - WebhookIntegration( - "opbeat", - ["monitoring"], - display_name="Opbeat", - stream_name="opbeat", - function="zerver.webhooks.opbeat.view.api_opbeat_webhook", - ), WebhookIntegration("opencollective", ["communication"], display_name="Open Collective"), WebhookIntegration("opsgenie", ["meta-integration", "monitoring"]), WebhookIntegration("pagerduty", ["monitoring"], display_name="PagerDuty"), @@ -785,7 +778,6 @@ DOC_SCREENSHOT_CONFIG: dict[str, list[BaseScreenshotConfig]] = { ScreenshotConfig("incident_acknowledged_new.json", "002.png"), ScreenshotConfig("incident_closed_new.json", "003.png"), ], - "opbeat": [ScreenshotConfig("error_reopen.json")], "opencollective": [ScreenshotConfig("one_time_donation.json")], "opsgenie": [ScreenshotConfig("addrecipient.json", image_name="000.png")], "pagerduty": [ScreenshotConfig("trigger_v2.json")], diff --git a/zerver/webhooks/opbeat/__init__.py b/zerver/webhooks/opbeat/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/zerver/webhooks/opbeat/doc.md b/zerver/webhooks/opbeat/doc.md deleted file mode 100644 index adc83757c1..0000000000 --- a/zerver/webhooks/opbeat/doc.md +++ /dev/null @@ -1,16 +0,0 @@ -Get Zulip notifications for your Opbeat events! - -1. {!create-channel.md!} - -1. {!create-an-incoming-webhook.md!} - -1. {!generate-integration-url.md!} - -1. Go to your Opbeat **Organization Settings**. - -1. Under **HTTP Hook (Experimental)**, set **Hook target** - to the URL constructed above, and click **Save settings**. - -{!congrats.md!} - -![](/static/images/integrations/opbeat/001.png) diff --git a/zerver/webhooks/opbeat/fixtures/error_fixed.json b/zerver/webhooks/opbeat/fixtures/error_fixed.json deleted file mode 100644 index 7ea08abb77..0000000000 --- a/zerver/webhooks/opbeat/fixtures/error_fixed.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "id": "bf991a45d9184b0ca6fb3d48d3db4c38", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/activities/bf991a45d9184b0ca6fb3d48d3db4c38", - "html_url": "https://opbeat.com/test_org/test-flask-app/errors/2/#activity-bf991a45d9184b0ca6fb3d48d3db4c38", - "author": { - "id": "5802edc6e84b4843b23edff00c6d300a", - "legacy_id": 14883, - "first_name": "foo", - "last_name": "E", - "email": "ivchepro@gmail.com", - "avatar": { - "40": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=40", - "80": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=80", - "180": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=180", - "240": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=240", - "120": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=120" - }, - "html_url": "https://opbeat.com/account/settings/", - "type_name": "user" - }, - "created": "2017-12-10T18:15:07Z", - "occurred": "2017-12-10T18:15:07Z", - "title": "foo marked E#2 as fixed", - "summary": "foo marked the error group as fixed", - "organization": { - "id": "f9a77c5e6b044c2686612539fe4a3a6f", - "name": "test_org", - "short_name": "test_org", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f", - "type_name": "organization" - }, - "app": { - "id": "53daf84bfc", - "name": "Test-flask-app", - "short_name": "test-flask-app", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc", - "type_name": "app" - }, - "subject_type": "errorgroup", - "subject": { - "id": "eac027998bc44fb0b2f6269eb0ab0418", - "number": 2, - "created": "2017-12-10T17:52:48Z", - "first_seen": "2017-12-10T17:52:47Z", - "last_seen": "2017-12-10T18:07:55Z", - "times_seen": { - "this_release": 10, - "total": 10, - "24h": 10.0, - "72h": 10.0 - }, - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418", - "html_url": "https://opbeat.com/test_org/test-flask-app/errors/2/", - "links": { - "activities": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/activities", - "undo-mark-as-fixed": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-mark-fixed", - "mark-as-temporarily-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/temporarily-ignore", - "comments": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/comments", - "mark-as-fixed": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/mark-fixed", - "assignable-users": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/assignable-users", - "undo-mark-as-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-ignore", - "mark-as-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/ignore", - "undo-mark-as-temporarily-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-temporarily-ignore", - "assign": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/assign" - }, - "last_occurrence": { - "id": "24210da90e5b4d659965b2e3ebf360f4", - "created": "2017-12-10T18:07:55Z", - "culprit": "", - "message": "A warning occurred (42 apples)", - "logger": "__main__", - "client_supplied_id": "13a4410d11724b30af92cd6ef1d556e8", - "extra": { - "thread": "140621113497408", - "process": "6120", - "threadName": "MainThread", - "stack_info": "None", - "module": "app", - "funcName": "foo", - "processName": "MainProcess", - "pathname": "app.py", - "lineno": "17", - "message": "A warning occurred (42 apples)", - "filename": "app.py" - }, - "type_name": "errorlog" - }, - "resolved_state": "fixed", - "allowed_resolve_transitions": [ - "undo-mark-as-fixed", - "mark-as-regression" - ], - "is_alarm": false, - "num_comments": 4, - "is_expired": false, - "type_name": "errorgroup", - "first_error": { - "id": "24210da90e5b4d659965b2e3ebf360f4", - "created": "2017-12-10T18:07:55Z", - "culprit": "", - "message": "A warning occurred (42 apples)", - "logger": "__main__", - "client_supplied_id": "13a4410d11724b30af92cd6ef1d556e8", - "extra": { - "thread": "140621113497408", - "process": "6120", - "threadName": "MainThread", - "stack_info": "None", - "module": "app", - "funcName": "foo", - "processName": "MainProcess", - "pathname": "app.py", - "lineno": "17", - "message": "A warning occurred (42 apples)", - "filename": "app.py" - }, - "type_name": "errorlog" - } - }, - "action": "fixed", - "type_name": "activity" -} diff --git a/zerver/webhooks/opbeat/fixtures/error_reopen.json b/zerver/webhooks/opbeat/fixtures/error_reopen.json deleted file mode 100644 index 53b1bb194d..0000000000 --- a/zerver/webhooks/opbeat/fixtures/error_reopen.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "id": "38a556dfc0b04a59a586359bbce1463d", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/activities/38a556dfc0b04a59a586359bbce1463d", - "html_url": "https://opbeat.com/test_org/test-flask-app/errors/2/#activity-38a556dfc0b04a59a586359bbce1463d", - "author": { - "id": "5802edc6e84b4843b23edff00c6d300a", - "legacy_id": 14883, - "first_name": "foo", - "last_name": "E", - "email": "ivchepro@gmail.com", - "avatar": { - "40": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=40", - "80": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=80", - "180": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=180", - "240": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=240", - "120": "https://secure.gravatar.com/avatar/cf936cf5a05314e692830f4d17ec434e?d=https%3A%2F%2Fopbeat.com%2Fstatic%2Fimages%2Fcommon%2Favatars%2Favatar_default_user.png&size=120" - }, - "html_url": "https://opbeat.com/account/settings/", - "type_name": "user" - }, - "created": "2017-12-10T18:15:39Z", - "occurred": "2017-12-10T18:15:39Z", - "title": "foo reopened E#2", - "summary": "foo reopened the error group", - "organization": { - "id": "f9a77c5e6b044c2686612539fe4a3a6f", - "name": "test_org", - "short_name": "test_org", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f", - "type_name": "organization" - }, - "app": { - "id": "53daf84bfc", - "name": "Test-flask-app", - "short_name": "test-flask-app", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc", - "type_name": "app" - }, - "subject_type": "errorgroup", - "subject": { - "id": "eac027998bc44fb0b2f6269eb0ab0418", - "number": 2, - "created": "2017-12-10T17:52:48Z", - "first_seen": "2017-12-10T17:52:47Z", - "last_seen": "2017-12-10T18:07:55Z", - "times_seen": { - "this_release": 10, - "total": 10, - "24h": 10.0, - "72h": 10.0 - }, - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418", - "html_url": "https://opbeat.com/test_org/test-flask-app/errors/2/", - "links": { - "activities": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/activities", - "undo-mark-as-fixed": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-mark-fixed", - "mark-as-temporarily-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/temporarily-ignore", - "comments": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/comments", - "mark-as-fixed": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/mark-fixed", - "assignable-users": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/assignable-users", - "undo-mark-as-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-ignore", - "mark-as-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/ignore", - "undo-mark-as-temporarily-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-temporarily-ignore", - "assign": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/assign" - }, - "last_occurrence": { - "id": "24210da90e5b4d659965b2e3ebf360f4", - "created": "2017-12-10T18:07:55Z", - "culprit": "", - "message": "A warning occurred (42 apples)", - "logger": "__main__", - "client_supplied_id": "13a4410d11724b30af92cd6ef1d556e8", - "extra": { - "thread": "140621113497408", - "process": "6120", - "threadName": "MainThread", - "stack_info": "None", - "module": "app", - "funcName": "foo", - "processName": "MainProcess", - "pathname": "app.py", - "lineno": "17", - "message": "A warning occurred (42 apples)", - "filename": "app.py" - }, - "type_name": "errorlog" - }, - "resolved_state": "open", - "allowed_resolve_transitions": [ - "mark-as-temporarily-ignored", - "mark-as-fixed", - "mark-as-ignored" - ], - "is_alarm": false, - "num_comments": 4, - "is_expired": false, - "type_name": "errorgroup", - "first_error": { - "id": "24210da90e5b4d659965b2e3ebf360f4", - "created": "2017-12-10T18:07:55Z", - "culprit": "", - "message": "A warning occurred (42 apples)", - "logger": "__main__", - "client_supplied_id": "13a4410d11724b30af92cd6ef1d556e8", - "extra": { - "thread": "140621113497408", - "process": "6120", - "threadName": "MainThread", - "stack_info": "None", - "module": "app", - "funcName": "foo", - "processName": "MainProcess", - "pathname": "app.py", - "lineno": "17", - "message": "A warning occurred (42 apples)", - "filename": "app.py" - }, - "type_name": "errorlog" - } - }, - "action": "reopened", - "type_name": "activity" -} diff --git a/zerver/webhooks/opbeat/fixtures/new_app.json b/zerver/webhooks/opbeat/fixtures/new_app.json deleted file mode 100644 index cb5fffc80b..0000000000 --- a/zerver/webhooks/opbeat/fixtures/new_app.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "id": "47f1f10158d94cbf93a0b539abc64b0f", - "html_url": null, - "title": "foo", - "summary": "App foo created", - "organization": { - "id": "27a4c0633f5c4a24a15a8896754145c4", - "name": "bar", - "short_name": "bar", - "url": "https://opbeat.com/api/v2/organizations/27a4c0633f5c4a24a15a8896754145c4", - "type_name": "organization" - }, - "app": { - "id": "bdb4751769", - "name": "foo", - "short_name": "foo", - "url": "https://opbeat.com/api/v2/organizations/27a4c0633f5c4a24a15a8896754145c4/apps/bdb4751769", - "type_name": "app" - }, - "subject_type": "app", - "subject": { - "id": "bdb4751769", - "created": "2018-01-03T11:16:49Z", - "name": "foo", - "short_name": "foo", - "settings": null, - "url": "https://opbeat.com/api/v2/organizations/27a4c0633f5c4a24a15a8896754145c4/apps/bdb4751769", - "html_url": "/bar/foo/", - "has_unread_notifications": false, - "has_metrics_available": false, - "language": "nodejs", - "framework": "custom", - "type_name": "app" - }, - "action": "created", - "type_name": "activity" -} diff --git a/zerver/webhooks/opbeat/fixtures/new_comment.json b/zerver/webhooks/opbeat/fixtures/new_comment.json deleted file mode 100644 index 66c49f0af2..0000000000 --- a/zerver/webhooks/opbeat/fixtures/new_comment.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "id": "5df00003ea4e42458db48446692f6d37", - "html_url": "https://opbeat.com/foo/test-flask-app/errors/2/#activity-5df00003ea4e42458db48446692f6d37", - "author": { - "first_name": "foo", - "last_name": "bar" - }, - "title": "foo commented on E#2", - "summary": "test comment", - "subject_type": "comment", - "subject": { - "id": "ca45bf96cd674b3eaa914251f0a08773", - "text": "test comment", - "author": { - "id": "5802edc6e84b4843b23edff00c6d300a", - "first_name": "foo", - "last_name": "barE" - }, - "html_url": "https://opbeat.com/foo/test-flask-app/errors/2/#activity-5df00003ea4e42458db48446692f6d37", - "subject_type": "errorgroup", - "subject": { - "id": "eac027998bc44fb0b2f6269eb0ab0418", - "number": 2, - "html_url": "https://opbeat.com/foo/test-flask-app/errors/2/", - "last_occurrence": { - "id": "24210da90e5b4d659965b2e3ebf360f4", - "created": "2017-12-10T18:07:55Z", - "culprit": "", - "message": "A warning occurred (42 apples)", - "logger": "__main__", - "client_supplied_id": "13a4410d11724b30af92cd6ef1d556e8", - "extra": { - "module": "app", - "funcName": "foo", - "processName": "MainProcess", - "pathname": "app.py", - "lineno": "17", - "message": "A warning occurred (42 apples)" - }, - "type_name": "errorlog" - } - }, - "type_name": "comment" - }, - "action": "created", - "type_name": "activity" -} diff --git a/zerver/webhooks/opbeat/fixtures/new_error.json b/zerver/webhooks/opbeat/fixtures/new_error.json deleted file mode 100644 index 9047a44fb4..0000000000 --- a/zerver/webhooks/opbeat/fixtures/new_error.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "id": "c0396f38323a4fa7b314f87d5ed9cdd2", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/activities/c0396f38323a4fa7b314f87d5ed9cdd2", - "html_url": "https://opbeat.com/test_org/test-flask-app/errors/2/#activity-c0396f38323a4fa7b314f87d5ed9cdd2", - "created": "2017-12-10T18:07:55Z", - "occurred": "2017-12-10T18:07:55Z", - "title": "E#2 regressed", - "summary": "The error group regressed", - "organization": { - "id": "f9a77c5e6b044c2686612539fe4a3a6f", - "name": "test_org", - "short_name": "test_org", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f", - "type_name": "organization" - }, - "app": { - "id": "53daf84bfc", - "name": "Test-flask-app", - "short_name": "test-flask-app", - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc", - "type_name": "app" - }, - "subject_type": "errorgroup", - "subject": { - "id": "eac027998bc44fb0b2f6269eb0ab0418", - "number": 2, - "created": "2017-12-10T17:52:48Z", - "first_seen": "2017-12-10T17:52:47Z", - "last_seen": "2017-12-10T17:58:20Z", - "times_seen": { - "this_release": 10, - "total": 9, - "24h": 10.0, - "72h": 10.0 - }, - "url": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418", - "html_url": "https://opbeat.com/test_org/test-flask-app/errors/2/", - "links": { - "activities": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/activities", - "undo-mark-as-fixed": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-mark-fixed", - "mark-as-temporarily-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/temporarily-ignore", - "comments": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/comments", - "mark-as-fixed": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/mark-fixed", - "assignable-users": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/assignable-users", - "undo-mark-as-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-ignore", - "mark-as-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/ignore", - "undo-mark-as-temporarily-ignored": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/undo-temporarily-ignore", - "assign": "https://opbeat.com/api/v2/organizations/f9a77c5e6b044c2686612539fe4a3a6f/apps/53daf84bfc/errorgroups/eac027998bc44fb0b2f6269eb0ab0418/actions/assign" - }, - "last_occurrence": { - "id": "24210da90e5b4d659965b2e3ebf360f4", - "created": "2017-12-10T18:07:55Z", - "culprit": "", - "message": "A warning occurred (42 apples)", - "logger": "__main__", - "client_supplied_id": "13a4410d11724b30af92cd6ef1d556e8", - "extra": { - "thread": "140621113497408", - "process": "6120", - "threadName": "MainThread", - "stack_info": "None", - "module": "app", - "funcName": "foo", - "processName": "MainProcess", - "pathname": "app.py", - "lineno": "17", - "message": "A warning occurred (42 apples)", - "filename": "app.py" - }, - "type_name": "errorlog" - }, - "resolved_state": "regressed", - "allowed_resolve_transitions": [ - "mark-as-temporarily-ignored", - "mark-as-fixed", - "mark-as-ignored" - ], - "is_alarm": false, - "num_comments": 3, - "is_expired": false, - "type_name": "errorgroup", - "first_error": { - "id": "24210da90e5b4d659965b2e3ebf360f4", - "created": "2017-12-10T18:07:55Z", - "culprit": "", - "message": "A warning occurred (42 apples)", - "logger": "__main__", - "client_supplied_id": "13a4410d11724b30af92cd6ef1d556e8", - "extra": { - "thread": "140621113497408", - "process": "6120", - "threadName": "MainThread", - "stack_info": "None", - "module": "app", - "funcName": "foo", - "processName": "MainProcess", - "pathname": "app.py", - "lineno": "17", - "message": "A warning occurred (42 apples)", - "filename": "app.py" - }, - "type_name": "errorlog" - } - }, - "action": "regressed", - "type_name": "activity" -} diff --git a/zerver/webhooks/opbeat/fixtures/unsupported_object.json b/zerver/webhooks/opbeat/fixtures/unsupported_object.json deleted file mode 100644 index 4f6ef0aec2..0000000000 --- a/zerver/webhooks/opbeat/fixtures/unsupported_object.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "id": "47f1f10158d94cbf93a0b539abc64b0f", - "html_url": null, - "title": "test title", - "summary": "test summary", - "organization": { - "id": "27a4c0633f5c4a24a15a8896754145c4", - "name": "bar", - "short_name": "bar", - "url": "https://opbeat.com/api/v2/organizations/27a4c0633f5c4a24a15a8896754145c4", - "type_name": "organization" - }, - "app": { - "id": "bdb4751769", - "name": "foo", - "short_name": "foo", - "url": "https://opbeat.com/api/v2/organizations/27a4c0633f5c4a24a15a8896754145c4/apps/bdb4751769", - "type_name": "app" - }, - "subject_type": "foo", - "subject": { - "id": "bdb4751769", - "created": "2018-01-03T11:16:49Z", - "name": "foo", - "short_name": "foo", - "settings": null - }, - "action": "created", - "type_name": "activity" -} diff --git a/zerver/webhooks/opbeat/tests.py b/zerver/webhooks/opbeat/tests.py deleted file mode 100644 index 6ef1f2e4a2..0000000000 --- a/zerver/webhooks/opbeat/tests.py +++ /dev/null @@ -1,99 +0,0 @@ -from zerver.lib.test_classes import WebhookTestCase -from zerver.lib.validator import wrap_wild_value -from zerver.webhooks.opbeat.view import get_value - - -class OpbeatHookTests(WebhookTestCase): - CHANNEL_NAME = "opbeat" - URL_TEMPLATE = "/api/v1/external/opbeat?api_key={api_key}&stream={stream}" - WEBHOOK_DIR_NAME = "opbeat" - - def test_comment(self) -> None: - expected_topic_name = "foo commented on E#2" - expected_message = """\ -**[foo commented on E#2](https://opbeat.com/foo/test-flask-app/errors/2/#activity-5df00003ea4e42458db48446692f6d37)** -test comment - - -**[E#2](https://opbeat.com/foo/test-flask-app/errors/2/)** - ->**Most recent Occurrence** ->in app.py ->A warning occurred (42 apples)""" - self.check_webhook( - "new_comment", expected_topic_name, expected_message, content_type="application/json" - ) - - def test_new_app(self) -> None: - expected_topic_name = "foo" - expected_message = """\ -**foo** -App foo created - -**[foo](https://opbeat.com/bar/foo/)** ->language: nodejs ->framework: custom""" - self.check_webhook( - "new_app", expected_topic_name, expected_message, content_type="application/json" - ) - - def test_get_empty_value(self) -> None: - test_dictionary = wrap_wild_value("test_dictionary", {"key": "value"}) - self.assertEqual(get_value(test_dictionary, "foo"), "") - - def test_no_subject_type(self) -> None: - expected_topic_name = "test title" - expected_message = """\ -**test title** -test summary""" - self.check_webhook( - "unsupported_object", - expected_topic_name, - expected_message, - content_type="application/json", - ) - - def test_error_fixed(self) -> None: - expected_topic_name = "foo marked E#2 as fixed" - expected_message = """\ -**[foo marked E#2 as fixed](https://opbeat.com/test_org/test-flask-app/errors/2/#activity-bf991a45d9184b0ca6fb3d48d3db4c38)** -foo marked the error group as fixed - -**[E#2](https://opbeat.com/test_org/test-flask-app/errors/2/)** - ->**Most recent Occurrence** ->in app.py ->A warning occurred (42 apples)""" - self.check_webhook( - "error_fixed", expected_topic_name, expected_message, content_type="application/json" - ) - - def test_error_reopened(self) -> None: - expected_topic_name = "foo reopened E#2" - expected_message = """\ -**[foo reopened E#2](https://opbeat.com/test_org/test-flask-app/errors/2/#activity-38a556dfc0b04a59a586359bbce1463d)** -foo reopened the error group - -**[E#2](https://opbeat.com/test_org/test-flask-app/errors/2/)** - ->**Most recent Occurrence** ->in app.py ->A warning occurred (42 apples)""" - self.check_webhook( - "error_reopen", expected_topic_name, expected_message, content_type="application/json" - ) - - def test_error_regressed(self) -> None: - expected_topic_name = "E#2 regressed" - expected_message = """\ -**[E#2 regressed](https://opbeat.com/test_org/test-flask-app/errors/2/#activity-c0396f38323a4fa7b314f87d5ed9cdd2)** -The error group regressed - -**[E#2](https://opbeat.com/test_org/test-flask-app/errors/2/)** - ->**Most recent Occurrence** ->in app.py ->A warning occurred (42 apples)""" - self.check_webhook( - "new_error", expected_topic_name, expected_message, content_type="application/json" - ) diff --git a/zerver/webhooks/opbeat/view.py b/zerver/webhooks/opbeat/view.py deleted file mode 100644 index 0bf5f9a064..0000000000 --- a/zerver/webhooks/opbeat/view.py +++ /dev/null @@ -1,121 +0,0 @@ -# Webhooks for external integrations. - -from django.http import HttpRequest, HttpResponse - -from zerver.decorator import webhook_view -from zerver.lib.response import json_success -from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint -from zerver.lib.validator import WildValue, check_int, check_none_or, check_string, check_union -from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import UserProfile - -subject_types: dict[str, list[list[str]]] = { - "app": [ # Object type name - ["name"], # Title - ["html_url"], # Automatically put into title - ["language"], # Other properties. - ["framework"], - ], - "base": [ - ["title"], - ["html_url"], - ["#summary"], - ["subject"], - ], - "comment": [ - [""], - ["subject"], - ], - "errorgroup": [ - ["E#{}", "number"], - ["html_url"], - ["last_occurrence:error"], - ], - "error": [ - [""], - ['">**Most recent Occurrence**'], - ["in {}", "extra/pathname"], - ["!message"], - ], -} - - -def get_value(_obj: WildValue, key: str) -> str: - for _key in key.lstrip("!").split("/"): - if _key in _obj: - _obj = _obj[_key] - else: - return "" - return str(_obj.tame(check_union([check_string, check_int]))) - - -def format_object( - obj: WildValue, - subject_type: str, - message: str, -) -> str: - if subject_type not in subject_types: - return message - keys: list[list[str]] = subject_types[subject_type][1:] - title = subject_types[subject_type][0] - if title[0] != "": - title_str = "" - if len(title) > 1: - title_str = title[0].format(get_value(obj, title[1])) - else: - title_str = obj[title[0]].tame(check_string) - - url = obj["html_url"].tame(check_none_or(check_string)) - if url is not None: - if "opbeat.com" not in url: - url = "https://opbeat.com/" + url.lstrip("/") - message += f"\n**[{title_str}]({url})**" - else: - message += f"\n**{title_str}**" - for key_list in keys: - if len(key_list) > 1: - value = key_list[0].format(get_value(obj, key_list[1])) - message += f"\n>{value}" - else: - key = key_list[0] - key_raw = key.lstrip("!").lstrip("#").lstrip('"') - if key_raw not in {"html_url", "subject"} and ":" not in key_raw: - value = get_value(obj, key_raw) - if key.startswith("!"): - message += f"\n>{value}" - elif key.startswith("#"): - message += f"\n{value}" - elif key.startswith('"'): - message += f"\n{key_raw}" - else: - message += f"\n>{key}: {value}" - if key == "subject": - message = format_object( - obj["subject"], obj["subject_type"].tame(check_string), message + "\n" - ) - if ":" in key: - value, value_type = key.split(":") - message = format_object(obj[value], value_type, message + "\n") - return message - - -@webhook_view("Opbeat") -@typed_endpoint -def api_opbeat_webhook( - request: HttpRequest, - user_profile: UserProfile, - *, - payload: JsonBodyPayload[WildValue], -) -> HttpResponse: - """ - This uses the subject name from opbeat to make the topic, - and the summary from Opbeat as the message body, with - details about the object mentioned. - """ - - topic_name = payload["title"].tame(check_string) - - message = format_object(payload, "base", "") - - check_send_webhook_message(request, user_profile, topic_name, message) - return json_success(request)