re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
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

2020-06-14T13:56:13.392300Z

@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))
               context)))

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

4👍
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