Idiomatic Clojure wrapper for the Segment.io 2.x Java client
For full documentation on the Segment.io 2.x Java client, see analytics-java.
[circleci/analytics-clj "0.7.1"]
View the full API.
(use '[circleci.analytics-clj.core])
(def analytics (initialize "<writeKey>"))
With logging:
(defn logger []
(reify com.segment.analytics.Log
(print [this level format args]
(println (str (java.util.Date.) "\t" level "\t" args)))
(print [this level error format args]
(println error))))
(def analytics (initialize "<writeKey>" {:log (logger)}))
All of the message types can take options
. See Spec: Common Fields for a list of common fields between all message types.
(identify analytics "user-id")
With traits:
(identify analytics "user-id" {:email "bob@acme.com"})
(track analytics "user-id" "signup")
With properties:
(track analytics "user-id" "signup" {:company "Acme Inc."})
A full example:
(track analytics (:id user) "signup" {:company "Acme Inc."} {:context {:language "en-us"}
:integrations {"AdRoll" false}
:integration-options {"Amplitude" {:session-id (:id session)}}})
(screen analytics "1234" "Login Page")
With properties:
(screen analytics "1234" "Login Page" {:path "/users/login"})
(group analytics "1234" "group-5678")
With traits:
(group analytics "1234" "group-5678" {:name "Segment"})
(alias analytics "anonymous_user" "5678")
We provided a top level enqueue
function to allow you to do the following:
(enqueue analytics (doto (YourMessageType/builder)
(.userId "user-id")
(.properties {"company" "Acme Inc."})))
Copyright © 2017 CircleCI
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close