sethtrain / raven-clj

A Clojure interface to Sentry
84 stars 29 forks source link

Ensure UTF-8 encoding #30

Open Frozenlock opened 4 years ago

Frozenlock commented 4 years ago

On a Windows machine, utf-8 strings passed to raven/capture will not be properly encoded when sent to Sentry.

As far as I can tell, this is because something in the http stack is using the default file encoding. Temporary workaround: Launch the JVM with -Dfile.encoding=utf-8

Potential solution: Explicitly encode the body into utf-8 bytes.

(defn send-packet [{:keys [ts uri project-id key secret] :as packet-info}]
  (let [url (make-sentry-url uri project-id)
        header (make-sentry-header ts key secret)
        body (dissoc packet-info :ts :uri :project-id :key :secret)]
    (http/post url
               {:throw-exceptions false
                :headers {"X-Sentry-Auth" header
                          "User-Agent" sentry-client}
                :body (util/utf8-bytes (json/generate-string body))}))) ; <------