Closed jeromecoupe closed 4 years ago
+1 for this. I created a separate plugin that just sets a flag for cron, but this makes more sense as a feature for Webhooks and all the other benefits it provides.
I'd love this as well. Currently I do a poor man's version of @mattstein's plugin by adding a bookmark to the CP sidebar. I tell users to click it once they're done editing and all it does is generate a Guzzle endpoint call.
Just added this for the next release! As of 2.3, webhooks will have a new “Debounce Key Format”, which can optionally be set to a Twig template that defines the “debounce key” for a webhook request.
If two webhooks get triggered around the same time that generate the same debounce key, only the second webhook will actually get sent.
Webhooks 2.3.0 is out now!
Just saw this, and just to make sure, the debouncing works by checking the queue. In other words, the time period within which new webhooks calls are debounced is however long a job with the same key is in the queue for?
Asking because I was trying to check this on my local environment, which is configured with "runTasksAutomatically" and debouncing did not have the desired effect there when quickly changing multiple entries.
Ideally one could set a certain debounce duration / job delay too, so that the webhook job would not be executed for that amount of time, otherwise the only way to set this is by having the whole queue crontab set to eg. */5 * * * *
(affecting how often other jobs are picked up as well)
Thank you for making this available to the community. The webhooks plugin is a big part of using Craft in a headless mode with Static Site Generators of all kinds. It makes triggering a build when an an element is created or edited relatively trivial.
However, when someone is making updates in the CP, it can trigger quite a few builds in a row, when only the last one is really needed.
I don't have the PHP skills to implement it or to assess how easy / difficult it is to implement but I think a debounce period before triggering the webhook would help tremendously. It can be set to 0 by default so it would not break any current implementations.
I also have a related question.
As I understood, Craft Cloud will not allow plugins. Since it would be a really competitive option IMHO compared to other Sass headless CMS out there, I was wondering if webhooks are going to become part of Craft Core or if you have something else in mind to replicate this type of functionality in Craft Cloud ?