knubie 2020-06-14T13:17:36.386600Z

I had an idea recently to store the last ~10-20 re-frame events in memory and send them up to my issue tracker (sentry) whenever an exception occurs. Does a library like this already exist?

solf 2020-06-14T13:49:39.390800Z

Not that I know of. You'll have to be careful to remove sensitive data though


@steedman87 Yeah, we do this. I won't share the code because there's now a better way because the latest version of re-frame allows you to install a global interceptor using reg-global-interceptor. The docs are still a little lacking. Code sketch ... (untested and no attempt made to limit the number of events collected)

(def  recent-events atom([]))

; will collect events as they are processed and add them to the atom above
(def event-collector
  (re-frame.core/->interceptor {
    :id      :event-collector
    :before  (fn [context]  
               (swap! recent-events conj (re-frame.core/get-coeffect context :event))

; register the global interceptor early in program's booting
(re-frame.core/reg-global-interceptor event-collector)

knubie 2020-06-14T14:09:30.394300Z

Cool, good to know it’s not a silly idea. Yeah I remember some discussion about global interceptors, glad to hear they’ve been added 😊 thanks for the code sketch