diff --git a/frontend/src/components/event/EventInspector.vue b/frontend/src/components/event/EventInspector.vue index d516cfc..9338aaa 100644 --- a/frontend/src/components/event/EventInspector.vue +++ b/frontend/src/components/event/EventInspector.vue @@ -191,7 +191,7 @@ export default { if (eventObj.message) { this.$bus.$emit('addMessage', { channel: eventObj.channel, - message: eventObj.message, + message: this.get_event_message(eventObj), id: eventObj.id, sender: eventObj.sender }) @@ -210,7 +210,7 @@ export default { let fileName = `${eventObj.channel}_${eventObj.id}` this.$bus.$emit('addExportAttachments', { attachmentName: fileName, - attachmentObj: eventObj, + attachmentObj: this.getAttachmentObj(eventObj), // TODO: How to get other type's of file attachmentType: 'json' }) @@ -233,6 +233,30 @@ export default { onContextMenuShowAll () { this.$store.dispatch('showAll') this.isContextMenuShown = false + }, + get_event_message (eventObj) { + if (eventObj.channel !== 'flow') { + return eventObj.message + } + let url = eventObj.flow.request.url + let method = eventObj.flow.request.method + let requestData = JSON.stringify(eventObj.flow.request.data) + if (requestData === undefined) { + requestData = JSON.stringify({}) + } + let response = JSON.stringify(eventObj.flow.response) + let message = `URL: ${url}\nMethod: ${method}\nRequestData: ${requestData}\nResponse: ${response}` + return message + }, + getAttachmentObj (eventObj) { + if (eventObj.channel === 'flow') { + const newEventobj = { + 'request': eventObj.flow.request, + 'response': eventObj.flow.response + } + return newEventobj + } + return eventObj } } } diff --git a/lyrebird_bugit/attachment.py b/lyrebird_bugit/attachment.py index 31f14c4..9077ec5 100644 --- a/lyrebird_bugit/attachment.py +++ b/lyrebird_bugit/attachment.py @@ -1,5 +1,6 @@ from pathlib import Path import os +import json import codecs import lyrebird import requests @@ -37,15 +38,16 @@ def export_snapshot(snapshot): def export_attachment_file(attachment_obj): _check_dir() full_name = f'{attachment_obj.get("name", "")}.{attachment_obj.get("attachmentType", "json")}' - res = requests.post(EVENT_EXPORT_URL, json=attachment_obj['eventObj'], stream=True) - if res.json().get('code', 1000) == 3000: + + try: + with codecs.open(str(ATTACHMENT_ROOT / full_name), 'w') as f: + json.dump(attachment_obj['eventObj'], f, indent=4) + except Exception: return { 'name': full_name, 'path': str(ATTACHMENT_ROOT / full_name) } - with codecs.open(str(ATTACHMENT_ROOT / full_name), 'wb') as f: - for chunk in res.iter_content(): - f.write(chunk) + return { 'id': str(uuid4()), 'name': full_name, diff --git a/setup.py b/setup.py index 751c58b..f672197 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='lyrebird-bugit', - version='1.15.0', + version='1.16.0', packages=['lyrebird_bugit'], url='https://github.com/Meituan-Dianping/lyrebird-bugit', author='HBQA',