Saner error handling in analytics/log-event

This commit is contained in:
Jeremy Dormitzer 2018-02-01 14:06:08 -07:00
parent 344e8734c1
commit bd271169ea
No known key found for this signature in database
GPG Key ID: 04F17C0F5A32C320

View File

@ -31,12 +31,14 @@
"Logs an event to Amplitude. Returns a channel that resolves with the response from Amplitude"
([event-name properties]
(let [res-channel (chan)]
(when (and (not (do-not-track)) (exists? js/amplitude))
(when (not (do-not-track))
(if-not (exists? js/amplitude)
(log/error "Unable to get Amplitude instance. Did you call init-amplitude?")
(.logEvent (.getInstance js/amplitude)
event-name
(clj->js properties)
(fn [response-code response-body]
(go (>! res-channel {:code response-code
:body response-body})))))
:body response-body}))))))
res-channel))
([event-name] (log-event event-name nil)))