-
Notifications
You must be signed in to change notification settings - Fork 0
/
converter.py
34 lines (27 loc) · 959 Bytes
/
converter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
logger = logging.getLogger('converter')
def convert_sentry(data):
attachment = dict()
attachment['color'] = "#f43f20"
attachment['fields'] = list()
attachment['fields'].append({
'title': 'Culprit',
'value': data['culprit'],
'short': False,
})
attachment['fields'].append({
'title': 'Project',
'value': data['project'],
'short': False,
})
try:
attachment['fallback'] = '[{}] {}'.format({data["project"]}, data['event']['metadata'].get('title', ''))
attachment['title_link'] = data['url']
attachment['title'] = data['event']['metadata'].get('title', '')
except Exception:
logger.warning('Can not extract title from data: {}'.format(data))
discord_data = dict()
# discord_data['username'] = 'Sentry'
discord_data['attachments'] = list()
discord_data['attachments'].append(attachment)
return discord_data