Events #9565
Replies: 4 comments 15 replies
-
Maybe this and https://github.com/remix-run/RFC-Internal/discussions/10 should be designed together. Also, would it make sense to allow developers to fire their own events? Do we want a generic Remix event handling system that goes beyond error reporting? |
Beta Was this translation helpful? Give feedback.
-
I would love this feature to better be able to track page-load metrics in react-router land! At the moment I don't think there is a good way to figure out |
Beta Was this translation helpful? Give feedback.
-
TBH, I'm really looking forward to this Events API becoming a reality. In my particular case, this events proposal would make scroll restore simpler and more reliable, as the locationState could be augmented with a scrollPosition, and we could depend on location state as a single source of truth for this sort of thing, rather than needing to track scroll positions separately, as is done now (in sessionStorage and in a module-level variable). Having the |
Beta Was this translation helpful? Give feedback.
-
I would love if there was a way to listen to these events on the client using |
Beta Was this translation helpful? Give feedback.
-
Overview/Problem
Setting up error monitoring, analytics, etc. is cumbersome and full of footguns (especially in Remix like double counting errors since we serialize and send it over the network so both server and client monitoring counts the error).
Scope
This is only for React Router for now, there are open questions to resolve for Remix.
Use Cases
API/Examples
The goal for monitoring integrations is to let them create a single function that plugs in so app developers don't have more than one entry point to deal with.
While a router emits changes to state with
router.subscribe
, multiple monitoring events may be triggered from a single routing event emission. For example: if two loaders fail monitoring would like to know that, even though React Router only tells the UI about the first error.Emitted events
This list isn't exhaustive, but here are a few examples:
Remix
Clientside
I'm not sure how we're hydrating after RRR work is done, but I imagine it will look like this:
Again, not sure if
createBrowserRouter
is exposed in our newentry.client.tsx
but I suspect it will need to be.Serverside
I'm not sure where this stuff should shake out for Remix yet. I've long thought our
entry.server
needs to be revisited completely. Trying to think about implementing monitoring like sentry I'm a bit at a loss to capture everything in one place.Perhaps exploring this later will guide that conversation or I'll realize I'm being dense. I do have a couple extra thoughts though:
It would be interesting for monitoring to track loader start/end both client and serverside so you can see the amount of time the user's network is responsible for in the client stats
Open Questions
Implementation Notes
I think it'll be pretty straightforward, we just call the
onEvent
whenever stuff happens with the payload.Issues/PRs/Discussions
#8327, #9688 (related)
Beta Was this translation helpful? Give feedback.
All reactions