Log closed event from background.cljs instead of content.cljs

This commit is contained in:
Jeremy Dormitzer 2018-02-01 14:06:52 -07:00
parent 0ea66897d4
commit bb99c1a33d
No known key found for this signature in database
GPG Key ID: 04F17C0F5A32C320
2 changed files with 6 additions and 2 deletions

View File

@ -3,6 +3,7 @@
[ajax.core :refer [GET]]
[goog.string :as gstring]
[looped-in.hackernews :as hn]
[looped-in.analytics :as analytics]
[looped-in.logging :as log]
[looped-in.promises :refer [channel->promise promise->channel]]))
@ -85,7 +86,8 @@
"hits" (channel->promise (go @hits))
"fetchItem" (channel->promise
(go (clj->js (<! (hn/fetch-item (.-id msg))))))
"getUserId" (channel->promise (get-user-id))))
"getUserId" (channel->promise (get-user-id))
"logEvent" (analytics/log-event (.-eventType msg) (.-eventProperties msg))))
(-> js/browser
(.-tabs)
@ -107,3 +109,4 @@
(.-onMessage)
(.addListener handle-message))
(analytics/init-amplitude)

View File

@ -35,7 +35,8 @@
(defn close-sidebar []
(let [$html (.-documentElement js/document)
$sidebar (dom/getElement "loopedInSidebar")]
(analytics/log-event "CLOSED_SIDEBAR")
(-> js/browser (.-runtime) (.sendMessage (clj->js {:type "logEvent"
:eventType "CLOSED_SIDEBAR"})))
(dom/removeNode $sidebar)
(set! (-> $html (.-style) (.-paddingLeft)) @old-html-padding)))