2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 7
7
GroupMessage
8
8
IdentifyMessage
9
9
ScreenMessage
10
- TrackMessage)))
10
+ TrackMessage
11
+ PageMessage)))
11
12
12
13
(def ^:private ctx {" library" {" name" " analytics-clj"
13
- " version" " 0.4.2 " }})
14
+ " version" " 0.5.0 " }})
14
15
15
16
(defn initialize
16
17
" Start building an Analytics instance."
143
144
(common-fields (merge {:user-id user-id} options))
144
145
(cond-> (not (nil? properties)) (properties* (string-keys properties)))))))
145
146
147
+ (defn page
148
+ " The `page` method lets you record whenever a user
149
+ sees a page of your website, along with optional
150
+ extra information about the page being viewed."
151
+
152
+ {:added " 0.5.0" }
153
+
154
+ ([^Analytics analytics user-id name]
155
+ (page analytics user-id name nil nil ))
156
+
157
+ ([^Analytics analytics user-id name properties]
158
+ (page analytics user-id name properties nil ))
159
+
160
+ ([^Analytics analytics user-id name properties options]
161
+ (enqueue analytics (doto (PageMessage/builder name)
162
+ (common-fields (merge {:user-id user-id} options))
163
+ (cond-> (not (nil? properties)) (properties* (string-keys properties)))))))
164
+
146
165
(defn group
147
166
" `group` lets you associate an identified user with
148
167
a group. A group could be a company, organization, account,
Original file line number Diff line number Diff line change 111
111
(a/screen analytics " 1234" " Login Screen" {:path " /users/login" })
112
112
(is @called)))))
113
113
114
+ (deftest test-page
115
+ (testing " a simple page call"
116
+ (a/page analytics " 1234" " Login Page" ))
117
+
118
+ (testing " a apge call with custom properties"
119
+ (let [called (atom false )]
120
+ (with-redefs [e/properties* (fn [mb properties]
121
+ (is (= " path" (-> properties keys first)))
122
+ (is (= " /users/login" (-> properties vals first)))
123
+ (reset! called true ))]
124
+ (a/page analytics " 1234" " Login Page" {:path " /users/login" })
125
+ (is @called)))))
126
+
114
127
(deftest test-group
115
128
(let [called (atom false )]
116
129
(with-redefs [e/traits* (fn [mb traits]
0 commit comments