Add setting to drop low level traces from being stored
This commit is contained in:
parent
70cefc4022
commit
39f038f8d5
|
@ -6,10 +6,12 @@ All notable changes to this project will be documented in this file. This change
|
|||
### Added
|
||||
|
||||
* Debugging instructions if re-frame-trace fails to start.
|
||||
* Setting to drop low level traces. This reduces the memory overhead of re-frame-trace as we can drop more traces that you are unlikely to want most of the time.
|
||||
|
||||
### Changed
|
||||
|
||||
* The version of Garden that re-frame-trace uses is now bundled as a source dependency so you should no longer get conflicts.
|
||||
* The version of Garden that re-frame-trace uses is now bundled as a source dependency so you should no longer get conflicts if you use Garden 2.
|
||||
* Refactored re-frame-trace trace parsing internals to incrementally parse new traces.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
external-window? (localstorage/get "external-window?" false)
|
||||
using-trace? (localstorage/get "using-trace?" true)
|
||||
ignored-events (localstorage/get "ignored-events" {})
|
||||
low-level-trace (localstorage/get "low-level-trace" {:reagent true :re-frame true})
|
||||
filtered-view-trace (localstorage/get "filtered-view-trace" (let [id1 (random-uuid)
|
||||
id2 (random-uuid)]
|
||||
{id1 {:id id1 :ns-str "re-com.box" :ns 're-com.box :sort 0}
|
||||
|
@ -25,6 +26,7 @@
|
|||
(rf/dispatch [:settings/selected-tab selected-tab])
|
||||
(rf/dispatch [:settings/set-ignored-events ignored-events])
|
||||
(rf/dispatch [:settings/set-filtered-view-trace filtered-view-trace])
|
||||
(rf/dispatch [:settings/set-low-level-trace low-level-trace])
|
||||
(rf/dispatch [:settings/set-number-of-retained-epochs num-epochs])
|
||||
(when external-window?
|
||||
(rf/dispatch [:global/launch-external]))
|
||||
|
|
|
@ -185,9 +185,17 @@
|
|||
(fn [_ [_ ignored-events]]
|
||||
ignored-events))
|
||||
|
||||
(def low-level-trace-mw [(rf/path [:settings :low-level-trace]) (rf/after #(localstorage/save! "low-level-trace" %))])
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/set-low-level-trace
|
||||
low-level-trace-mw
|
||||
(fn [_ [_ low-level]]
|
||||
low-level))
|
||||
|
||||
(rf/reg-event-db
|
||||
:settings/low-level-trace
|
||||
[(rf/path [:settings :low-level-trace])]
|
||||
low-level-trace-mw
|
||||
(fn [low-level [_ trace-type capture?]]
|
||||
(assoc low-level trace-type capture?)))
|
||||
|
||||
|
@ -491,6 +499,7 @@
|
|||
events-to-ignore (->> (get-in db [:settings :ignored-events]) vals (map :event-id) set)
|
||||
previous-traces (get-in db [:traces :all-traces] [])
|
||||
parse-state (get-in db [:epochs :parse-state] metam/initial-parse-state)
|
||||
{drop-re-frame :re-frame drop-reagent :reagent} (get-in db [:settings :low-level-trace])
|
||||
all-traces (reduce conj previous-traces filtered-traces)
|
||||
parse-state (metam/parse-traces parse-state filtered-traces)
|
||||
new-matches (:partitions parse-state)
|
||||
|
@ -502,7 +511,9 @@
|
|||
all-matches (reduce conj previous-matches new-matches)
|
||||
retained-matches (into [] (take-last number-of-epochs-to-retain all-matches))
|
||||
first-id-to-retain (:id (ffirst retained-matches))
|
||||
retained-traces (into [] (drop-while #(< (:id %) first-id-to-retain)) all-traces)]
|
||||
retained-traces (into [] (comp (drop-while #(< (:id %) first-id-to-retain))
|
||||
(remove (fn [trace] (or (when drop-reagent (metam/low-level-reagent-trace? trace))
|
||||
(when drop-re-frame (metam/low-level-re-frame-trace? trace)))))) all-traces)]
|
||||
(-> db
|
||||
(assoc-in [:traces :all-traces] retained-traces)
|
||||
(update :epochs (fn [epochs]
|
||||
|
|
|
@ -142,6 +142,18 @@
|
|||
(defn subscription-not-run? [trace]
|
||||
false)
|
||||
|
||||
(defn low-level-re-frame-trace?
|
||||
"Is this part of re-frame internals?"
|
||||
[trace]
|
||||
(case (:op-type trace)
|
||||
(:re-frame.router/fsm-trigger) true
|
||||
false))
|
||||
|
||||
(defn low-level-reagent-trace?
|
||||
"Is this part of reagent internals?"
|
||||
[trace]
|
||||
(= :componentWillUnmount (:op-type trace)))
|
||||
|
||||
(defn render? [trace]
|
||||
(= :render (:op-type trace)))
|
||||
|
||||
|
|
|
@ -149,9 +149,8 @@
|
|||
[:p "Nominate one or more namespaces."]]
|
||||
settings-box-131]
|
||||
|
||||
;; TODO: remove low level trace
|
||||
#_[rc/line]
|
||||
#_(let [low-level-trace @(rf/subscribe [:settings/low-level-trace])]
|
||||
[rc/line]
|
||||
(let [low-level-trace @(rf/subscribe [:settings/low-level-trace])]
|
||||
[settings-box
|
||||
[[rc/label :label "Remove low level trace"]
|
||||
[rc/checkbox
|
||||
|
|
Loading…
Reference in New Issue