diff options
Diffstat (limited to 'lib/error_tracking')
-rw-r--r-- | lib/error_tracking/collector/payload_validator.rb | 13 | ||||
-rw-r--r-- | lib/error_tracking/collector/sentry_request_parser.rb | 10 |
2 files changed, 14 insertions, 9 deletions
diff --git a/lib/error_tracking/collector/payload_validator.rb b/lib/error_tracking/collector/payload_validator.rb new file mode 100644 index 00000000000..aae19a3635a --- /dev/null +++ b/lib/error_tracking/collector/payload_validator.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module ErrorTracking + module Collector + class PayloadValidator + PAYLOAD_SCHEMA_PATH = Rails.root.join('app', 'validators', 'json_schemas', 'error_tracking_event_payload.json').to_s + + def valid?(payload) + JSONSchemer.schema(Pathname.new(PAYLOAD_SCHEMA_PATH)).valid?(payload) + end + end + end +end diff --git a/lib/error_tracking/collector/sentry_request_parser.rb b/lib/error_tracking/collector/sentry_request_parser.rb index 29e4cc8976f..ae632ebd518 100644 --- a/lib/error_tracking/collector/sentry_request_parser.rb +++ b/lib/error_tracking/collector/sentry_request_parser.rb @@ -4,15 +4,7 @@ module ErrorTracking module Collector class SentryRequestParser def self.parse(request) - # Request body can be "" or "gzip". - # If later then body was compressed with Zlib.gzip - encoding = request.headers['Content-Encoding'] - - body = if encoding == 'gzip' - Zlib.gunzip(request.body.read) - else - request.body.read - end + body = request.body.read # Request body contains 3 json objects merged together in one StringIO. # We need to separate and parse them into array of hash objects. |