From bb99c1a33d0cf53696633eea5c29f9c43fdea3e5 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Thu, 1 Feb 2018 14:06:52 -0700 Subject: [PATCH] Log closed event from background.cljs instead of content.cljs --- src/looped_in/background.cljs | 5 ++++- src/looped_in/content.cljs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/looped_in/background.cljs b/src/looped_in/background.cljs index f5bd7ca..6817df3 100644 --- a/src/looped_in/background.cljs +++ b/src/looped_in/background.cljs @@ -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 (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) diff --git a/src/looped_in/content.cljs b/src/looped_in/content.cljs index d5bb649..4c4079a 100644 --- a/src/looped_in/content.cljs +++ b/src/looped_in/content.cljs @@ -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)))