Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set_customdata to RaygunSender, apply process level custom data w… #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python2/raygun4py/raygunmsgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def set_client_details(self):

def set_customdata(self, user_custom_data):
if type(user_custom_data) is dict:
self.raygunMessage.details['userCustomData'] = user_custom_data
if not self.raygunMessage.details.get('userCustomData'):
self.raygunMessage.details['userCustomData'] = dict()
self.raygunMessage.details['userCustomData'].update(user_custom_data)
return self

def set_tags(self, tags):
Expand Down
8 changes: 7 additions & 1 deletion python2/raygun4py/raygunprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class RaygunSender:
endpointhost = 'api.raygun.io'
endpointpath = '/entries'
process_tags = []

process_custom_data = dict()

def __init__(self, api_key, config=None):
if (api_key):
self.api_key = api_key
Expand Down Expand Up @@ -64,6 +65,10 @@ def set_tags(self, tags):
if type(tags) is list:
self.process_tags = tags

def set_customdata(self, custom_data):
if type(custom_data) is dict:
self.process_custom_data = custom_data

def ignore_exceptions(self, exceptions):
if isinstance(exceptions, list):
self.ignored_exceptions = exceptions
Expand Down Expand Up @@ -141,6 +146,7 @@ def _create_message(self, raygunExceptionMessage, tags, user_custom_data, http_r
.set_environment_details(extra_environment_data) \
.set_tags(self.process_tags) \
.set_tags(tags) \
.set_customdata(self.process_custom_data) \
.set_customdata(user_custom_data) \
.set_request_details(http_request) \
.set_user(user_override if user_override else self.user) \
Expand Down
4 changes: 3 additions & 1 deletion python3/raygun4py/raygunmsgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def set_client_details(self):

def set_customdata(self, user_custom_data):
if type(user_custom_data) is dict:
self.raygunMessage.details['userCustomData'] = user_custom_data
if not self.raygunMessage.details.get('userCustomData'):
self.raygunMessage.details['userCustomData'] = dict()
self.raygunMessage.details['userCustomData'].update(user_custom_data)
return self

def set_tags(self, tags):
Expand Down
6 changes: 6 additions & 0 deletions python3/raygun4py/raygunprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class RaygunSender:
endpointhost = 'api.raygun.io'
endpointpath = '/entries'
process_tags = []
process_custom_data = dict()

def __init__(self, api_key, config={}):
if (api_key):
Expand Down Expand Up @@ -60,6 +61,10 @@ def set_tags(self, tags):
if type(tags) is list:
self.process_tags = tags

def set_customdata(self, custom_data):
if type(custom_data) is dict:
self.process_custom_data = custom_data

def ignore_exceptions(self, exceptions):
if isinstance(exceptions, list):
self.ignored_exceptions = exceptions
Expand Down Expand Up @@ -131,6 +136,7 @@ def _create_message(self, raygunExceptionMessage, tags, user_custom_data, http_r
.set_environment_details(extra_environment_data) \
.set_tags(self.process_tags) \
.set_tags(tags) \
.set_customdata(self.process_custom_data) \
.set_customdata(user_custom_data) \
.set_request_details(http_request) \
.set_user(user_override if user_override else self.user) \
Expand Down