Add last interaction tracking for Snap requests#3147
Conversation
| * @param snapId - ID of a Snap. | ||
| * @param handlerType - Type of Snap handler. | ||
| */ | ||
| updateLastInteraction(snapId: SnapId, handlerType: HandlerType): void { |
There was a problem hiding this comment.
We already have some code that tracks this, we just don't persist it in state, it is only stored in memory:
snaps/packages/snaps-controllers/src/snaps/SnapController.ts
Lines 3807 to 3822 in 4b6dadb
Side-note: I wonder how many extra state updates this will cause? May be somewhat excessive and cause load on the clients 🤔
There was a problem hiding this comment.
I'm not sure if it would be any better if we use SnapRuntimeData and that process around RPC. Since, we need to get this straight into the UI, easily available through the Snap object, and we need to filter which requests we want to track before recording it to state. Last request seems to be updated in different context under different use cases.
On the note: My idea was to build something that would somehow debounce the state update. If state is already available at the moment of potential timestamp update, it should be cheaper operation to first check if the update has been done in the last minute or so, then update the state only if it's not updated for more than a minute or similar timespan. Feedback and ideas on this are also welcome.
Add way of tracking last interaction with Snap on certain request types.