   (fn [db _]
     (localstorage/delete-all-keys!)
     (js/location.reload)
-    db))
-
-(rf/reg-event-db
-  :settings/clear-epochs
-  (fn [db _]
-    (reset! traces [])
-    (reset! total-traces 0)
     db))
 
 (rf/reg-event-db

  (re-frame.trace/remove-trace-cb ::cb))

(defn enable-tracing! []
  (re-frame.trace/register-trace-cb ::cb (fn [new-traces]
                                           (when-let [new-traces (->> (filter log-trace? new-traces)
                                                                      (sort-by :id))]
                                             (swap! total-traces + (count new-traces))
                                             (swap! traces
                                                    (fn [existing]
                                                      (let [new  (reduce conj existing new-traces)
                                                            size (count new)]
                                                        (if (< 8000 size)
                                                          (let [new2 (subvec new (- size 4000))]
                                                            (if (< @total-traces 40000) ;; Create a new vector to avoid structurally sharing all traces forever
                                                              (do (reset! total-traces 0)
                                                                  (into [] new2))))
                                                          new))))
                                             ;; TODO: there is a bit of double handling here with retaining the last n epochs,
                                             ;; that will be cleaned up when the epoch parsing is refactored.
                                             (let [matches            (:matches (metam/parse-traces @traces))
                                                   matches            (remove (fn [match]
                                                                                (let [event (get-in (metam/matched-event match) [:tags :event])]
                                                                                  (contains? @events-to-ignore (first event)))) matches)
                                                   retained-epochs    (take-last @number-of-epochs-to-retain matches)
                                                   first-id-to-retain (:id (ffirst retained-epochs))
                                                   new-traces         (into [] (drop-while #(< (:id %) first-id-to-retain)) @traces)]
                                               (reset! traces new-traces)
                                               (reset! total-traces (count new-traces))
                                               (rf/dispatch [:traces/update-traces new-traces])
                                               (rf/dispatch [:epochs/update-epochs {:matches retained-epochs}]))))))

(defn dissoc-in
  "Dissociates an entry from a nested associative structure returning a new

(def default-number-of-epochs-to-retain 5)

(defonce traces (r/atom []))

(defn log-trace? [trace]
  (let [render-operation? (or (= (:op-type trace) :render)
