Hey @gerald, thanks for the ping!
In general, our webhooks are record-level, but our localization system is field-level. When a webhook is fired, it doesn’t “know” which field (and thus which locale) triggered it. However, the update
event will cause the webhook to have both an entity
and previous_entity
object, which you can diff to see what actually changed.
For example, this is the webhook that gets sent on a record update:
Click to show whole webhook body
{
"environment": "main",
"entity_type": "item",
"event_type": "update",
"entity": {
"id": "M8lLrJjTS-qXHJgrIFJLlg",
"type": "item",
"attributes": {
"title": {
"en": "Updated English title",
"it": "Italian title"
},
"keywords": {
"en": "",
"it": ""
}
},
"relationships": {
"item_type": {
"data": {
"id": "fLNw2cmTTLOqE9lbInQPnA",
"type": "item_type"
}
},
"creator": {
"data": {
"id": "627975",
"type": "organization"
}
}
},
"meta": {
"created_at": "2024-01-02T20:52:17.041+00:00",
"updated_at": "2024-05-13T21:14:56.326+01:00",
"published_at": "2024-05-13T21:14:56.356+01:00",
"publication_scheduled_at": null,
"unpublishing_scheduled_at": null,
"first_published_at": "2024-01-02T20:53:15.622+00:00",
"is_valid": true,
"is_current_version_valid": true,
"is_published_version_valid": true,
"status": "published",
"current_version": "NFhpLgL3TrCyY3WtU0W-6Q",
"stage": null
}
},
"related_entities": [
{
"id": "fLNw2cmTTLOqE9lbInQPnA",
"type": "item_type",
"attributes": {
"name": "Post",
"singleton": false,
"sortable": false,
"api_key": "post",
"ordering_direction": null,
"ordering_meta": null,
"tree": false,
"modular_block": false,
"draft_mode_active": false,
"all_locales_required": false,
"collection_appearance": "table",
"has_singleton_item": false,
"hint": null,
"inverse_relationships_enabled": false
},
"relationships": {
"fields": {
"data": [
{
"id": "aCb4xcXaRv2j62a124OGDw",
"type": "field"
},
{
"id": "B8avCtI4R-yai5-xhWb3mQ",
"type": "field"
}
]
},
"fieldsets": {
"data": []
},
"singleton_item": {
"data": null
},
"ordering_field": {
"data": null
},
"title_field": {
"data": {
"id": "aCb4xcXaRv2j62a124OGDw",
"type": "field"
}
},
"image_preview_field": {
"data": null
},
"excerpt_field": {
"data": null
},
"workflow": {
"data": null
}
},
"meta": {
"has_singleton_item": false
}
}
],
"previous_entity": {
"id": "M8lLrJjTS-qXHJgrIFJLlg",
"type": "item",
"attributes": {
"title": {
"en": "English title",
"it": "Italian title"
},
"keywords": {
"en": "",
"it": ""
}
},
"relationships": {
"item_type": {
"data": {
"id": "fLNw2cmTTLOqE9lbInQPnA",
"type": "item_type"
}
},
"creator": {
"data": {
"id": "627975",
"type": "organization"
}
}
},
"meta": {
"created_at": "2024-01-02T20:52:17.041+00:00",
"updated_at": "2024-05-13T21:14:51.720+01:00",
"published_at": "2024-05-13T21:14:51.754+01:00",
"publication_scheduled_at": null,
"unpublishing_scheduled_at": null,
"first_published_at": "2024-01-02T20:53:15.622+00:00",
"is_valid": true,
"is_current_version_valid": true,
"is_published_version_valid": true,
"status": "published",
"current_version": "PVXC3OXNTPulJzA848zqOw",
"stage": null
}
}
}
If you diff the entity
vs previous_entity
, you can see what’s different:
However, a downside to this approach is that publish
events don’t have a previous_version
, so in that case you’d have to check the record manually via an API lookup before you update the index ![:frowning: :frowning:](https://community.datocms.com/images/emoji/apple/frowning.png?v=12)
In GraphQL, on the other hand, you can specify the locale (and an optional fallback) to get the specific one you want: Localization — DatoCMS
You can also fetch all of a field’s localizations: Localization — DatoCMS
I think it would still be good to leave this feature request up, just in case it becomes popular (please remember to vote on it yourself, at the top).
And just so you know, all feature requests are read and prioritized (usually by the # of votes), but we don’t typically respond individually to every one of them. If there’s ever something you want a direct response for, it’s best to file a support request instead: Please read me first: Best ways to get DatoCMS support (of course it’s also ok to @ping me as you did here, but support is usually better because multiple people monitor that, as opposed to just me when you @mention me).