-
Notifications
You must be signed in to change notification settings - Fork 14
/
README.md
109 lines (64 loc) · 2.51 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# 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
[![CircleCI](https://circleci.com/gh/circleci/analytics-clj/tree/master.svg?style=svg)](https://circleci.com/gh/circleci/analytics-clj/tree/master)
## Installation
`[circleci/analytics-clj "0.8.1"]`
## Usage
View the full [API](https://circleci.github.io/analytics-clj/).
### Initialize an analytics client
```
(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)}))
```
### 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."})))
```
## License
Copyright © 2019 CircleCI
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.