Skip to content

Commit

Permalink
No code == no problem
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Nov 19, 2020
1 parent 7a6a3d7 commit 68e4d4e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,48 +142,44 @@ def send(event, post_data, sys_info):
return event

with AllowSentryReports(value=True, description='SentryReporter.send()'):
try:
# prepare event
if CONTEXTS not in event:
event[CONTEXTS] = {}

if TAGS not in event:
event[TAGS] = {}

event[CONTEXTS][REPORTER] = {}

# tags
tags = event[TAGS]
tags['version'] = safe_get(post_data, 'version', None)
tags['machine'] = safe_get(post_data, 'machine', None)
tags['os'] = safe_get(post_data, 'os', None)
tags['platform'] = first(safe_get(sys_info, 'platform'
, None), None)
tags['platform.details'] = first(safe_get(sys_info, 'platform.details',
None), None)

# context
context = event[CONTEXTS]
reporter = context[REPORTER]
version = post_data.get('version', None) if post_data else None

context['browser'] = {
'version': version,
'name': 'Tribler'}

reporter[STACKTRACE] = parse_stacktrace(safe_get(post_data, 'stack', None))
reporter['comments'] = safe_get(post_data, 'comments', None)

reporter[OS_ENVIRON] = parse_os_environ(safe_get(sys_info, OS_ENVIRON, None))
safe_delete(sys_info, OS_ENVIRON)
reporter[SYSINFO] = sys_info

sentry_sdk.capture_event(event)

return event
except Exception as e: # pylint: disable=W0703
SentryReporter._logger.exception(e)
sentry_sdk.capture_exception(e)
# prepare event
if CONTEXTS not in event:
event[CONTEXTS] = {}

if TAGS not in event:
event[TAGS] = {}

event[CONTEXTS][REPORTER] = {}

# tags
tags = event[TAGS]
tags['version'] = safe_get(post_data, 'version', None)
tags['machine'] = safe_get(post_data, 'machine', None)
tags['os'] = safe_get(post_data, 'os', None)
tags['platform'] = first(safe_get(sys_info, 'platform'
, None), None)
tags['platform.details'] = first(safe_get(sys_info, 'platform.details',
None), None)

# context
context = event[CONTEXTS]
reporter = context[REPORTER]
version = post_data.get('version', None) if post_data else None

context['browser'] = {
'version': version,
'name': 'Tribler'}

reporter[STACKTRACE] = parse_stacktrace(safe_get(post_data, 'stack', None))
reporter['comments'] = safe_get(post_data, 'comments', None)

reporter[OS_ENVIRON] = parse_os_environ(safe_get(sys_info, OS_ENVIRON, None))
safe_delete(sys_info, OS_ENVIRON)
reporter[SYSINFO] = sys_info

sentry_sdk.capture_event(event)

return event

@staticmethod
def set_user(user_id):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_before_send(reporter):
# pylint: disable=protected-access

assert reporter._before_send({}, {}) == {}
assert reporter._before_send(None, {}) is None
assert reporter._before_send(None, {}) is None
assert reporter._before_send(None, None) is None

reporter.allow_sending(False)
Expand Down

0 comments on commit 68e4d4e

Please sign in to comment.