class Sentry::Client

def dispatch_async_event(async_block, event, hint)

def dispatch_async_event(async_block, event, hint)
  # We have to convert to a JSON-like hash, because background job
  # processors (esp ActiveJob) may not like weird types in the event hash
  event_hash =
    begin
      event.to_json_compatible
    rescue => e
      log_error("Converting #{event.type} (#{event.event_id}) to JSON compatible hash failed", e, debug: configuration.debug)
      return
    end
  if async_block.arity == 2
    hint = JSON.parse(JSON.generate(hint))
    async_block.call(event_hash, hint)
  else
    async_block.call(event_hash)
  end
rescue => e
  log_error("Async #{event_hash["type"]} sending failed", e, debug: configuration.debug)
  send_event(event, hint)
end