For a while we have been experiencing difficulties with Courier auditing, as there is no way to log Courier deployments out of the box.
Unfortunately it seems like all Courier events are executed in a background thread without access to current user context. That prevents developer from simply subscribing to an event and logging from there, as described here.
I came up with a quick and simple solution, although it requires modification in Courier files.
1) Create API controller as below:
public class CourierController : UmbracoAuthorizedApiController
{
[HttpGet]
public void AuditLog(Guid itemid)
{
var audit = Services.AuditService;
var item = Services.ContentService.GetById(itemid);
audit.Add(AuditType.Publish, "Deployed using Courier", Security.CurrentUser.Id, item.Id);
}
}
2) Add call to the controller from within Umbraco\Plugins\courier\dialogs\CommitItem.aspx
After the deployment you will be able to see Courier events in the audit trail:
As you can see, any deployment attempt will be audited immediately once a user clicks the "Deploy" button, even if the deployment was not successful. You can improve the solution, by moving the call to API so it will be performed only after successful deployment.
Adding Courier events into audit log.
For a while we have been experiencing difficulties with Courier auditing, as there is no way to log Courier deployments out of the box.
Unfortunately it seems like all Courier events are executed in a background thread without access to current user context. That prevents developer from simply subscribing to an event and logging from there, as described here.
I came up with a quick and simple solution, although it requires modification in Courier files.
1) Create API controller as below:
2) Add call to the controller from within Umbraco\Plugins\courier\dialogs\CommitItem.aspx
After the deployment you will be able to see Courier events in the audit trail:
As you can see, any deployment attempt will be audited immediately once a user clicks the "Deploy" button, even if the deployment was not successful. You can improve the solution, by moving the call to API so it will be performed only after successful deployment.
is working on a reply...