Site.changed webhook event not working as expected

Related to my previous post on Ghost webhooks (Documentation for Webhooks might be a bit outdated), I wanted to better understand how webhooks are triggered and what content is sent. So, I ran some simple scenarios and I noticed that the site.changed event was not working as I expected; the event keeps showing up in scenarios unrelated to the settings.

Also, for some changes in Settings, the same event was sent twice for changes made in:

  1. Design → Brand (Design → Site-wide seems OK)
  2. Membership

Here the logs after changing the site description:

	ghost  | [2023-02-03 20:28:18] INFO "PUT /ghost/api/admin/custom_theme_settings/" 200 61ms
	ghost  | [2023-02-03 20:28:18] INFO Triggering webhook for "site.changed" with url "http://host.docker.internal:
	3000/site.changed"
	ghost  | [2023-02-03 20:28:18] INFO "POST /" 200 128ms
	ghost  | [2023-02-03 20:28:18] INFO "PUT /ghost/api/admin/settings/" 200 151ms
	ghost  | [2023-02-03 20:28:18] INFO "GET /members/api/member/" 204 1ms
	ghost  | [2023-02-03 20:28:18] INFO Triggering webhook for "site.changed" with url "http://host.docker.internal:
	3000/site.changed"
	ghost  | [2023-02-03 20:28:18] INFO "GET /ghost/api/content/settings/?key=e078f293cc06dd83c8cc97f709&limit=all" 
	200 21ms
	ghost  | [2023-02-03 20:28:18] INFO "GET /ghost/api/content/newsletters/?key=e078f293cc06dd83c8cc97f709&limit=al
	l" 304 25ms
	ghost  | [2023-02-03 20:28:18] INFO "GET /ghost/api/content/tiers/?key=e078f293cc06dd83c8cc97f709&limit=all&incl
	ude=monthly_price,yearly_price,benefits" 304 32ms

Below are my other scenarios and the events that were sent to my custom integration, in case anyone is interested in those.

  1. Posts
    1. Drafts
      1. Create a new draft post: site.changed :warning: and post.added
      2. Delete a draft post: post.deleted and site.changed :warning:
      3. Edit a draft post: post.edited
      4. Publish a draft post: site.changed :warning:, post.published and post.edited
      5. Add a tag to a draft post: post.tag.attached and post.edited
      6. Remove a tag from a draft post: post.tag.detached and post.edited
    2. Published
      1. Edit a published post: site.changed :warning:, post.published.edited and post.published.edited`
      2. Unpublish a published post: site.changed :warning:, post.unpublished, post.edited
      3. Add a tag to a published post: site.changed :warning:, post.tag.attached, post.published.edited and post.edited
      4. Remove a tag from a published post: site.changed :warning:, post.tag.detached, post.published.edited and post.edited
  2. Pages
    1. Drafts
      1. Create a new draft page: site.changed :warning: and page.added
      2. Delete a draft page: page.deleted and site.changed :warning:
      3. Edit a draft page: page.edited
      4. Publish a draft page: site.changed :warning:, page.published and page.edited
      5. Add a tag to a draft page: page.tag.attached et page.edited
      6. Remove a tag from a draft page: page.tag.detached et page.edited
    2. Published
      1. Unpublish a published page: site.changed :warning:, page.unpublished and page.edited
      2. Edit a published page: site.changed :warning:, page.published.edited and page.edited
      3. Add a tag to a published page: page.tag.attached and page.edited
      4. Remove a tag from a published page: page.tag.detached and page.edited
  3. Tags
    1. Public
      1. Create a new public tag: tag.added and site.changed :warning:
      2. Edit a public tag: tag.edited and site.changed :warning:
      3. Delete a public tag: tag.deleted, site.changed :warning:
    2. Internal
      1. Create a new internal tag: tag.added and site.changed :warning:
      2. Edit a internal tag: tag.edited and site.changed :warning:
      3. Delete a internal tag: tag.deleted and site.changed :warning:
  4. Members
    1. Create a new member: not tested
    2. Edit a member: member.edited
    3. Delete a new member: member.edited

Setup information

Ghost Version
5.33.5

Node.js Version
v16.19.0

How did you install Ghost?
Docker

Provide details of your host & operating system
Windows 10

Database type
SQLite 3 (development)

Looks like site.changed is firing as expected. It’s designed to trigger for any change that affects content on the site so you can listen to it and trigger a static site build or perform some other task that needs to be run on any change to the site.

From the docs:

Triggered whenever any content changes in your site data or settings

Oh, I was sure it was only if one of the settings (or the theme) changed!

In this case, the event should also be fired for all my scenarios, right? And is it normal for the event to also be sent in some scenarios involving draft posts/pages, as they shouldn’t affect the published website? :thinking:

Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.