mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							46f2aec674
						
					
				
				
					commit
					c7433c83ff
				
			
							
								
								
									
										
											BIN
										
									
								
								static/images/integrations/errbit/001.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/images/integrations/errbit/001.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 37 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								static/images/integrations/logos/errbit.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/images/integrations/logos/errbit.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 5.2 KiB  | 
@@ -270,6 +270,7 @@ WEBHOOK_INTEGRATIONS = [
 | 
				
			|||||||
        stream_name='desk'
 | 
					        stream_name='desk'
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
    WebhookIntegration('dropbox', ['productivity'], display_name='Dropbox'),
 | 
					    WebhookIntegration('dropbox', ['productivity'], display_name='Dropbox'),
 | 
				
			||||||
 | 
					    WebhookIntegration('errbit', ['monitoring'], display_name='Errbit'),
 | 
				
			||||||
    WebhookIntegration('flock', ['customer-support'], display_name='Flock'),
 | 
					    WebhookIntegration('flock', ['customer-support'], display_name='Flock'),
 | 
				
			||||||
    WebhookIntegration('freshdesk', ['customer-support']),
 | 
					    WebhookIntegration('freshdesk', ['customer-support']),
 | 
				
			||||||
    WebhookIntegration('front', ['customer-support'], display_name='Front'),
 | 
					    WebhookIntegration('front', ['customer-support'], display_name='Front'),
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										0
									
								
								zerver/webhooks/errbit/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								zerver/webhooks/errbit/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										15
									
								
								zerver/webhooks/errbit/doc.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								zerver/webhooks/errbit/doc.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					Get Zulip notifications for the Errbit error tracker!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					1. {!create-stream.md!}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					1. {!create-bot-construct-url-indented.md!}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					1. Go to your project's settings on the Errbit site. Click on the
 | 
				
			||||||
 | 
					   **Edit** button for your Errbit app, and select **Webhook**.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					1. Enter the URL constructed above, and check **Enabled**.
 | 
				
			||||||
 | 
					   Click **Save**.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{!congrats.md!}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										40
									
								
								zerver/webhooks/errbit/fixtures/error_message.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								zerver/webhooks/errbit/fixtures/error_message.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "problem": {
 | 
				
			||||||
 | 
					        "url": "https://errbit.example.com/apps/5e1ed1ff1a603f3916f4f0de/problems/5e1fe93e1a603f3916f4f0e3",
 | 
				
			||||||
 | 
					        "_id": "5e1fe93e1a603f3916f4f0e3",
 | 
				
			||||||
 | 
					        "app_id": "5e1ed1ff1a603f3916f4f0de",
 | 
				
			||||||
 | 
					        "app_name": "ZulipIntegrationTest",
 | 
				
			||||||
 | 
					        "comments_count": 0,
 | 
				
			||||||
 | 
					        "created_at": "2020-01-15T23:40:30.989-05:00",
 | 
				
			||||||
 | 
					        "environment": "ErrbitEnvName",
 | 
				
			||||||
 | 
					        "error_class": "IllegalStateException",
 | 
				
			||||||
 | 
					        "first_notice_at": "2020-01-15T23:40:30.987-05:00",
 | 
				
			||||||
 | 
					        "hosts": {
 | 
				
			||||||
 | 
					            "382b0f5185773fa0f67a8ed8056c7759": {
 | 
				
			||||||
 | 
					                "count": 5,
 | 
				
			||||||
 | 
					                "value": "N/A"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "issue_link": null,
 | 
				
			||||||
 | 
					        "issue_type": null,
 | 
				
			||||||
 | 
					        "last_notice_at": "2020-01-16T00:30:04.835-05:00",
 | 
				
			||||||
 | 
					        "message": "Invalid state error",
 | 
				
			||||||
 | 
					        "messages": {
 | 
				
			||||||
 | 
					            "f721d9a468a891c5138eeb52c8b3831e": {
 | 
				
			||||||
 | 
					                "count": 5,
 | 
				
			||||||
 | 
					                "value": "Invalid state error"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "notices_count": 5,
 | 
				
			||||||
 | 
					        "resolved": false,
 | 
				
			||||||
 | 
					        "resolved_at": null,
 | 
				
			||||||
 | 
					        "updated_at": "2020-01-15T23:45:19.246-05:00",
 | 
				
			||||||
 | 
					        "user_agents": {
 | 
				
			||||||
 | 
					            "382b0f5185773fa0f67a8ed8056c7759": {
 | 
				
			||||||
 | 
					                "count": 5,
 | 
				
			||||||
 | 
					                "value": "N/A"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "where": "unknown"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										13
									
								
								zerver/webhooks/errbit/tests.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								zerver/webhooks/errbit/tests.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
 | 
					from zerver.lib.test_classes import WebhookTestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ErrBitHookTests(WebhookTestCase):
 | 
				
			||||||
 | 
					    STREAM_NAME = 'errbit'
 | 
				
			||||||
 | 
					    URL_TEMPLATE = u"/api/v1/external/errbit?stream={stream}&api_key={api_key}"
 | 
				
			||||||
 | 
					    FIXTURE_DIR_NAME = 'errbit'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_errbit_error_message(self) -> None:
 | 
				
			||||||
 | 
					        expected_topic = u"ZulipIntegrationTest / ErrbitEnvName"
 | 
				
			||||||
 | 
					        expected_message = u"[IllegalStateException](https://errbit.example.com/apps/5e1ed1ff1a603f3916f4f0de/problems/5e1fe93e1a603f3916f4f0e3): \"Invalid state error\" occurred."
 | 
				
			||||||
 | 
					        self.send_and_test_stream_message('error_message', expected_topic, expected_message)
 | 
				
			||||||
							
								
								
									
										33
									
								
								zerver/webhooks/errbit/view.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								zerver/webhooks/errbit/view.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					from typing import Any, Dict
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from django.http import HttpRequest, HttpResponse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from zerver.decorator import api_key_only_webhook_view
 | 
				
			||||||
 | 
					from zerver.lib.request import REQ, has_request_variables
 | 
				
			||||||
 | 
					from zerver.lib.response import json_success
 | 
				
			||||||
 | 
					from zerver.lib.webhooks.common import check_send_webhook_message
 | 
				
			||||||
 | 
					from zerver.models import UserProfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ERRBIT_TOPIC_TEMPLATE = '{project_name}'
 | 
				
			||||||
 | 
					ERRBIT_MESSAGE_TEMPLATE = '[{error_class}]({error_url}): "{error_message}" occurred.'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@api_key_only_webhook_view('Errbit')
 | 
				
			||||||
 | 
					@has_request_variables
 | 
				
			||||||
 | 
					def api_errbit_webhook(request: HttpRequest, user_profile: UserProfile,
 | 
				
			||||||
 | 
					                       payload: Dict[str, Any]=REQ(argument_type='body')) -> HttpResponse:
 | 
				
			||||||
 | 
					    subject = get_subject(payload)
 | 
				
			||||||
 | 
					    body = get_body(payload)
 | 
				
			||||||
 | 
					    check_send_webhook_message(request, user_profile, subject, body)
 | 
				
			||||||
 | 
					    return json_success()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_subject(payload: Dict[str, Any]) -> str:
 | 
				
			||||||
 | 
					    project = payload['problem']['app_name'] + ' / ' + payload['problem']['environment']
 | 
				
			||||||
 | 
					    return ERRBIT_TOPIC_TEMPLATE.format(project_name=project)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_body(payload: Dict[str, Any]) -> str:
 | 
				
			||||||
 | 
					    data = {
 | 
				
			||||||
 | 
					        'error_url': payload['problem']['url'],
 | 
				
			||||||
 | 
					        'error_class': payload['problem']['error_class'],
 | 
				
			||||||
 | 
					        'error_message': payload['problem']['message'],
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return ERRBIT_MESSAGE_TEMPLATE.format(**data)
 | 
				
			||||||
		Reference in New Issue
	
	Block a user