    (try
       (client/post metabase-usage-url {:form-params stats, :content-type :json, :throw-entire-message? true})
       (catch Throwable e
-       (log/error "Sending usage stats FAILED: " (.getMessage e)))))
+       (log/error "Sending usage stats FAILED:" (.getMessage e)))))
 
 
 (defn phone-home-stats!
   "Collect usage stats and phone them home"
   []
-  (when (anon-tracking-enabled?)
-    (let [stats (anonymous-usage-stats)]
-      (send-stats! stats))))
+  (when (public-settings/anon-tracking-enabled)
+    (send-stats! (anonymous-usage-stats))))

  "generate a map of the usage stats for this instance"
  []
  (merge (instance-settings)
           {:uuid anonymous-id :timestamp (new java.util.Date)}
            {:stats {:user (user-metrics)
                     :question (question-metrics)
                     :dashboard (dashboard-metrics)
                     :database (database-metrics)
                     :table (table-metrics)
                     :field (field-metrics)
                     :pulse (pulse-metrics)
                     :segment (segment-metrics)
                     :metric (metric-metrics)
                     :group (group-metrics)
                     :label (label-metrics)
                     :collection (collection-metrics)
                     :execution (execution-metrics)}}))


(defn- send-stats!

(defn- execution-metrics
  "Get metrics based on executions.
  This should be done in a single pass, as there might
  be a LOT of query executions in a normal instance."
  ;; TODO - This looks dangerous, pulling the entire set of QueryExecutions into memory at once to calculate these metrics (!)
  []
  (let [executions (db/select [QueryExecution :executor_id :running_time :status])]
    {:executions     (count executions)
     :by_status      (frequencies (map :status executions))
     :num_per_user   (large-histogram executions :executor_id)
     :num_by_latency (bin-latencies executions)}))


