Skip to content

Commit

Permalink
Merge pull request #62 from codefly67/feature/supplyment-bug-information
Browse files Browse the repository at this point in the history
Supplement bug information
  • Loading branch information
echoyang7 authored Dec 8, 2023
2 parents 48b290e + 8ac324e commit d1e3bc2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
28 changes: 26 additions & 2 deletions frontend/src/components/event/EventInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand All @@ -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'
})
Expand All @@ -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
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions lyrebird_bugit/attachment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
import os
import json
import codecs
import lyrebird
import requests
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit d1e3bc2

Please sign in to comment.