Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Revert "improved query param parsing"
This reverts commit dc7134a.
  • Loading branch information
jsbed committed Mar 16, 2019
commit ed07ce02227313247105afcfeaf0e409d1a61b3d
1 change: 0 additions & 1 deletion build.boot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[cheshire "5.0.1"]
[org.martinklepsch/clj-http-lite "0.4.1"]
[prone "1.0.1"]
[ring/ring-codec "1.1.1"]

[adzerk/bootlaces "0.1.13" :scope "test"]
[adzerk/boot-test "1.1.1" :scope "test"]])
Expand Down
3 changes: 1 addition & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
:dependencies [[org.clojure/clojure "1.5.1" :scope "provided"]
[cheshire "5.8.0"]
[clj-http-lite "0.3.0"]
[prone "1.0.1"]
[ring/ring-codec "1.1.1"]])
[prone "1.0.1"]])
31 changes: 12 additions & 19 deletions src/raven_clj/core.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
(ns raven-clj.core
(:require [cheshire.core :as json]
[clojure.walk :as walk]
[raven-clj.interfaces :as interfaces]
[clj-http.lite.client :as http]
[clojure.java.io :as io]
[clojure.string :as string]
[ring.util.codec :as ring-codec])
[clojure.string :as string])
(:import [java.util Date UUID]
[java.sql Timestamp]
[java.net InetAddress]))
Expand All @@ -20,11 +18,6 @@
(defn- generate-uuid []
(string/replace (UUID/randomUUID) #"-" ""))

(defn- parse-query-params [params]
(if params
(-> (ring-codec/form-decode params)
(walk/keywordize-keys))))

(defn make-sentry-url [uri project-id]
(format "%s/api/%s/store/"
uri project-id))
Expand Down Expand Up @@ -53,17 +46,17 @@
(defn parse-dsn [dsn]
(let [[proto-auth url] (string/split dsn #"@")
[protocol auth] (string/split proto-auth #"://")
[key secret] (string/split auth #":")
[project-id query-params] (-> (string/split url #"/")
(last)
(string/split #"\?"))]
(merge (parse-query-params query-params)
{:key key
:secret secret
:uri (format "%s://%s" protocol
(string/join
"/" (butlast (string/split url #"/"))))
:project-id (Integer/parseInt project-id)})))
[key secret] (string/split auth #":")]
{:key key
:secret secret
:uri (format "%s://%s" protocol
(string/join
"/" (butlast (string/split url #"/"))))
:project-id (-> (string/split url #"/")
(last)
(string/split #"\?")
(first)
(Integer/parseInt))}))

(defn capture
"Send a message to a Sentry server.
Expand Down
4 changes: 1 addition & 3 deletions test/raven_clj/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@
{:key "b70a31b3510c4cf793964a185cfe1fd0"
:secret "b7d80b520139450f903720eb7991bf3d"
:uri "https://example.com:9000/sentry"
:project-id 1
:environment "test"
:servername "example"}))))
:project-id 1}))))

(deftest test-capture
(testing "capture"
Expand Down