From 99ddcb33e3abe29365c34ee7db4ea211abec79d0 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 31 Jan 2018 17:23:43 -0700 Subject: [PATCH] Begin analytics.cljs; add secure api token handling --- .gitignore | 3 ++- project.clj | 32 +++++++++++++++++--------------- src/looped_in/analytics.cljs | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 src/looped_in/analytics.cljs diff --git a/.gitignore b/.gitignore index cff6207..3e6bf14 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ pom.xml.asc .hgignore .hg/ ext/js/generated/ -.cljs_rhino_repl \ No newline at end of file +.cljs_rhino_repl +profiles.clj \ No newline at end of file diff --git a/project.clj b/project.clj index d8ad167..4ddce90 100644 --- a/project.clj +++ b/project.clj @@ -9,20 +9,22 @@ [org.clojure/core.match "0.3.0-alpha5"] [cljs-ajax "0.7.3"]] :plugins [[lein-cljsbuild "1.1.7"]] - :cljsbuild {:builds [{:source-paths ["src"] - :compiler {:optimizations :simple - :pretty-print true - :source-map true - :output-dir "ext/js/generated/out" - :modules {:background - {:output-to "ext/js/generated/background.js" - :entries #{"looped-in.background"}} - :content - {:output-to "ext/js/generated/content.js" - :entries #{"looped-in.content"}} - :sidebar - {:output-to "ext/js/generated/sidebar.js" - :entries #{"looped-in.sidebar"}}}}}]} - :profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.2"] + :profiles {:cljs-shared + {:cljsbuild + {:builds [{:source-paths ["src"] + :compiler {:optimizations :simple + :pretty-print true + :source-map true + :output-dir "ext/js/generated/out" + :modules {:background + {:output-to "ext/js/generated/background.js" + :entries #{"looped-in.background"}} + :content + {:output-to "ext/js/generated/content.js" + :entries #{"looped-in.content"}} + :sidebar + {:output-to "ext/js/generated/sidebar.js" + :entries #{"looped-in.sidebar"}}}}}]}} + :dev {:dependencies [[com.cemerick/piggieback "0.2.2"] [org.clojure/tools.nrepl "0.2.10"]] :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}) diff --git a/src/looped_in/analytics.cljs b/src/looped_in/analytics.cljs new file mode 100644 index 0000000..82c2a75 --- /dev/null +++ b/src/looped_in/analytics.cljs @@ -0,0 +1,20 @@ +(ns looped-in.analytics + (:require [goog.html.SafeScript :as SafeScript] + [goog.string.Const :as Const])) + +(goog-define amplitude-api-key "FAKE_API_KEY") +(def amplitude-init-code + "function(apiKey) {(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement('script');r.type='text/javascript';r.async=true;r.src='https://cdn.amplitude.com/libs/amplitude-4.1.0-min.gz.js';r.onload=function(){if(e.amplitude.runQueuedFunctions){e.amplitude.runQueuedFunctions()}else{console.log('[Amplitude] Error: could not load SDK')}};var i=t.getElementsByTagName('script')[0];i.parentNode.insertBefore(r,i);function s(e,t){e.prototype[t]=function(){this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}var o=function(){this._q=[];return this};var a=['add','append','clearAll','prepend','set','setOnce','unset'];for(var u=0;u