Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Gleb Kaplan 49 posts 125 karma points
    May 09, 2016 @ 11:09
    Gleb Kaplan

    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:

    public class CourierController : UmbracoAuthorizedApiController
        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

        jQuery(document).ready(function () {
            jQuery("#buttons input").click(function () {
                //LOG AUDIT EVENT
                    type: "GET",
                    url: "/umbraco/backoffice/api/Courier/AuditLog?itemid=<%=Request["itemid"]%>"
               //END LOG AUDIT EVENT
                    var msg = jQuery("#loadingMsg").html();
                    if (msg != '')

    After the deployment you will be able to see Courier events in the audit trail:

    enter image description here

    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.

Please Sign in or register to post replies

Write your reply to: