|
@@ -20,7 +20,8 @@ from django.utils.encoding import force_text
|
|
|
from sentry import buffer, eventtypes, eventstream, features, tsdb, filters
|
|
|
from sentry.constants import (
|
|
|
CLIENT_RESERVED_ATTRS, LOG_LEVELS, LOG_LEVELS_MAP, DEFAULT_LOG_LEVEL,
|
|
|
- DEFAULT_LOGGER_NAME, MAX_CULPRIT_LENGTH, VALID_PLATFORMS, MAX_TAG_VALUE_LENGTH
|
|
|
+ DEFAULT_LOGGER_NAME, MAX_CULPRIT_LENGTH, VALID_PLATFORMS, MAX_TAG_VALUE_LENGTH,
|
|
|
+ CLIENT_IGNORED_ATTRS,
|
|
|
)
|
|
|
from sentry.coreapi import (
|
|
|
APIError,
|
|
@@ -56,7 +57,7 @@ from sentry.utils.data_filters import (
|
|
|
from sentry.utils.dates import to_timestamp
|
|
|
from sentry.utils.db import is_postgres, is_mysql
|
|
|
from sentry.utils.meta import Meta
|
|
|
-from sentry.utils.safe import safe_execute, trim, trim_dict, get_path, set_path, setdefault_path
|
|
|
+from sentry.utils.safe import ENABLE_TRIMMING, safe_execute, trim, trim_dict, get_path, set_path, setdefault_path
|
|
|
from sentry.utils.strings import truncatechars
|
|
|
from sentry.utils.geo import rust_geoip
|
|
|
from sentry.utils.validators import is_float
|
|
@@ -458,22 +459,18 @@ class EventManager(object):
|
|
|
stacktrace_frames_hard_limit=settings.SENTRY_STACKTRACE_FRAMES_HARD_LIMIT,
|
|
|
valid_platforms=list(VALID_PLATFORMS),
|
|
|
max_secs_in_future=MAX_SECS_IN_FUTURE,
|
|
|
- max_secs_in_past=MAX_SECS_IN_PAST
|
|
|
+ max_secs_in_past=MAX_SECS_IN_PAST,
|
|
|
+ enable_trimming=ENABLE_TRIMMING,
|
|
|
)
|
|
|
|
|
|
self._data = CanonicalKeyDict(rust_normalizer.normalize_event(dict(self._data)))
|
|
|
+
|
|
|
+ normalize_user_agent(self._data)
|
|
|
+
|
|
|
return
|
|
|
|
|
|
data = self._data
|
|
|
|
|
|
- if self._for_store:
|
|
|
- if self._project is not None:
|
|
|
- data['project'] = self._project.id
|
|
|
- if self._key is not None:
|
|
|
- data['key_id'] = self._key.id
|
|
|
- if self._auth is not None:
|
|
|
- data['sdk'] = data.get('sdk') or parse_client_as_sdk(self._auth.client)
|
|
|
-
|
|
|
# Before validating with a schema, attempt to cast values to their desired types
|
|
|
# so that the schema doesn't have to take every type variation into account.
|
|
|
text = six.text_type
|
|
@@ -538,8 +535,8 @@ class EventManager(object):
|
|
|
|
|
|
# Ignore all top-level None and empty values, regardless whether
|
|
|
# they are interfaces or not. For all other unrecognized attributes,
|
|
|
- # we emit an explicit error.
|
|
|
- if not value:
|
|
|
+ # we emit an explicit error, unless they are explicitly ignored.
|
|
|
+ if not value or k in CLIENT_IGNORED_ATTRS:
|
|
|
continue
|
|
|
|
|
|
try:
|
|
@@ -555,6 +552,13 @@ class EventManager(object):
|
|
|
|
|
|
# Additional data coercion and defaulting we only do for store.
|
|
|
if self._for_store:
|
|
|
+ if self._project is not None:
|
|
|
+ data['project'] = self._project.id
|
|
|
+ if self._key is not None:
|
|
|
+ data['key_id'] = self._key.id
|
|
|
+ if self._auth is not None:
|
|
|
+ data['sdk'] = data.get('sdk') or parse_client_as_sdk(self._auth.client)
|
|
|
+
|
|
|
level = data.get('level') or DEFAULT_LOG_LEVEL
|
|
|
if isinstance(level, int) or (isinstance(level, six.string_types) and level.isdigit()):
|
|
|
level = LOG_LEVELS.get(int(level), DEFAULT_LOG_LEVEL)
|
|
@@ -663,7 +667,7 @@ class EventManager(object):
|
|
|
if server_name is not None:
|
|
|
set_tag(data, 'server_name', server_name)
|
|
|
|
|
|
- for key in ('fingerprint', 'modules', 'tags', 'extra'):
|
|
|
+ for key in ('fingerprint', 'modules', 'tags', 'extra', 'contexts'):
|
|
|
if not data.get(key):
|
|
|
data.pop(key, None)
|
|
|
|
|
@@ -683,7 +687,7 @@ class EventManager(object):
|
|
|
elif '_meta' in data:
|
|
|
del data['_meta']
|
|
|
|
|
|
- self._data = prune_empty_keys(data)
|
|
|
+ self._data = CanonicalKeyDict(prune_empty_keys(data))
|
|
|
|
|
|
def should_filter(self):
|
|
|
'''
|