macropower-analytics-panel
macropower-analytics-panel copied to clipboard
Feature suggestions for 2.x
I had some features in mind and wanted to get your take on which are interesting and what's the level of complexity to implement them.
Send panel options in the body
It would be nice to add the panel options in the body, e.g. {'heartbeat_activated': true, 'heartbeat_interval': 60}, etc
That would allow to easily spot sessions that were closed, especially with Heartbeat always activated.
Add 'in_focus' field in the heartbeat payload when 'Heartbeat always' is activated
I don't know how doable this is. The idea is to be able to know when the window is out of focus
Add the session start time in every payload
First I thought that the heartbeat paylaods shouldn't contain the objects user, host and dashboard, since they shouldn't change within a session. Then I started my listener a bit to late, it did miss the start payload and the subsequent heartbeat payload through an exception on my listener because it couldn't find the UUID in the DB. So I'd leave the complete payload in each type so that basically any heartbeat can also be a start in case the listener missed it. But in that case it would be great to have the session start time in every payload.
Add a refresh payload
In addition to the heartbeat, also send a payload of {"type": "refresh"} each time the dashboard refreshes the panels
I'm not sure what would be the added value though compared to the heartbeat.
Send panel options in the body
This is very doable and I believe I actually had panel options being forwarded in the past, but removed them because I didn't have any need for them in my own listener implementations. But I could see how they might be useful for you, so I will try to get this added back in.
Add 'in_focus' field in the heartbeat payload when 'Heartbeat always' is activated
Great idea, I think this should be possible using the exact same method currently used to detect whether or not the window is in focus. We'll just have to check it regardless of the options and include the result in the payload.
Add the session start time in every payload
In my implementations I have just treated the heartbeat as the start time if the UUID doesn't exist yet. But I can see how this might be useful for accuracy. I'll give this feature some thought and maybe play around with a few implementations and see if I can find something that makes sense here.
Add a refresh payload
I will give this some thought, I had considered in the past that this would be helpful, but haven't decided on how it would be best implemented.
Thanks as always for your contributions @jtommi 🙂
@jtommi An update for you (sorry this took an entire month lol).
Per the two referenced commits, I've added options and also a hasFocus field to the payload body. hasFocus always exists (because having a consistent schema is pretty important) but if you have Heartbeat always set to false, it will (almost) always be true.
For the session start time, I actually already had this, it's called timeOrigin. I just forgot about it. timeOrigin is the time that the user loaded the dashboard, so it's actually even more accurate than the time of the start event.
I looked at adding a refresh event, but I couldn't figure out how to actually trigger anything when a refresh happens. It seems like this should be possible so I'll leave this issue open. I'll take another look sometime, maybe between now and then someone will give a suggestion.
Somehow I missed that you published v2. That's great, we'll be putting that in production shortly. Thanks for the mention in the README