https://github.com/circleci/analytics-clj
Idiomatic Clojure wrapper for the Segment.io 2.x Java client
https://github.com/circleci/analytics-clj
Last synced: about 1 year ago
JSON representation
Idiomatic Clojure wrapper for the Segment.io 2.x Java client
- Host: GitHub
- URL: https://github.com/circleci/analytics-clj
- Owner: circleci
- License: epl-1.0
- Created: 2017-01-12T18:44:15.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-02-20T19:40:15.000Z (over 1 year ago)
- Last Synced: 2025-03-29T05:09:12.740Z (about 1 year ago)
- Language: Clojure
- Homepage:
- Size: 261 KB
- Stars: 21
- Watchers: 69
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# analytics-clj
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](https://github.com/segmentio/analytics-java).
## Build Status
[](https://circleci.com/gh/circleci/analytics-clj/tree/master)
## Installation
`[circleci/analytics-clj ""]`
To find the most recent published version, see https://clojars.org/circleci/analytics-clj
## Usage
View the full [API](https://circleci.github.io/analytics-clj/).
### Initialize an analytics client
```
(use '[circleci.analytics-clj.core])
(def analytics (initialize ""))
```
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 "" {:log (logger)}))
```
### Messages
All of the message types can take `options`. See [Spec: Common Fields](https://segment.com/docs/spec/common/) for a list of common fields between all message types.
#### Identify
`(identify analytics "user-id")`
With traits:
`(identify analytics "user-id" {:email "bob@acme.com"})`
#### Track
`(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
`(screen analytics "1234" "Login Screen")`
With properties:
`(screen analytics "1234" "Login Screen" {:path "/users/login"})`
#### Page
`(page analytics "1234" "Login Page")`
With properties:
`(page analytics "1234" "Login Page" {:path "/users/login"})`
#### Group
`(group analytics "1234" "group-5678")`
With traits:
`(group analytics "1234" "group-5678" {:name "Segment"})`
#### Alias
`(alias analytics "anonymous_user" "5678")`
### Did we miss something?
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."})))
```
## Releasing
New git tags are automatically published to [clojars](https://clojars.org/circleci/bond).
The following should be updated on the main/master branch before tagging:
- `project.clj` - version
- `CHANGELOG.md` - summary of changes
## License
Copyright © 2019 CircleCI
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.