scratch-api
scratch-api copied to clipboard
You should be able to get the username of the person who set a variable
using cloud.on('set',...
you should be able to get the username of the person who set a variable, but I do not see that feature in your API. You should consider adding it :)
via callback?
As far as I'm aware, the only way to get to username is by making another request to the cloud monitor page, which is not a reliable way to get the username. Unless something has changed, I do not feel that such an implementation belongs in this library.
@trumank You could add a method that allows you to fetch the username via the cloud logs after the event is received and pass it into the callback. That way it doesn't run by default and can easily be used.
@trumank You could add a method that allows you to fetch the username via the cloud logs after the event is received and pass it into the callback. That way it doesn't run by default and can easily be used.
How would you pass it into the callback at a different time than the rest of the data?
Personally I would leave this to the end developer to implement a way to do this but if I were to implement it internally I would make it an option in the constructor to attempt to get values after they are set, before firing the event.
That said, I think it's pretty fragile like trumank said. It also risks getting rate limited depending on how often cloud variables are set.
If the values are set rarely then I can see that this could be really useful, but again I think as far as a project like this which seems to be a pretty "bare minimum" library, I would leave this to the developer to implement.