Sitecore Sidekick Audit Logger

filtering.gif

The Audit Logger Sidekick app was created to graphically track events that occur withing Sitecore.  You can see the default set of tracked events in the image above, however any event within Sitecore can be easilly tracked.  In fact, any code can trigger a tracking event using the audit logger API provided with the app.

What is sidekick?  Check out this to learn more.

Searching and filtering events

The system traces events, gathers information about those events and stores them in a special Lucene search index to provide robust searching capabilities.

  1. Search by content.  Whenever an item incurs an event that’s tracked terms are generated for the item and the specific point in time.  This allows you to see what events had to do with an item that referenced a particular word.  In addition there’s auto-complete on the field.
    autocomplete
  2. Search by item.  Each item that incurs an event has it’s id tracked.  This allows you to filter events by a particular item if you’d like to see the history of the item.
    itemfilter.png
  3. Search by user.  The user who invoked the action is recorded in the event.  This allows you to filter by a particular user.  This would be useful if someone was having trouble remembering what changes they made to an item that day.  Note that this is populated based on actions recorded, so if someone went on vacation for a week and it’s only tracking 4 days his/her name would drop off the list until they performed a tracked event.
    userfilter.png
  4. Filter by event type.  The type of event is tracked, so a user can select exctly what events they are interested in.  This filtering type that can have multiple filters applied as an “OR” operator, also this is applied alongside the previous filters.
    eventtypefilter.png

Event details

Once you have the results filtering as you want them to, if you click the Get Details button it reports a list sorted chronologically.  You will also notice an edit item button, clicking this will open a lightbox modal for the content editor for the item related to the particular event. auditlogdetails.png

Each event is color coded as defined in the filter for a quick visual sweep of activity types.  You can additionally see more details on a particular event by clicking on “see details”.  This is particularly useful for the save events as it displays an HTML diff of your change.

details.gif

Configuration

			<scsRegister>
				<processor type="ScsAuditLog.AuditLogHandler, ScsAuditLog">
					<!-- 0 for indefinately -1 for no backup-->
					<param name="keepBackups">5</param>
					<!-- 0 for indefinately-->
					<param name="keepRecords">3</param>
					<!-- leave blank for any role, seperate multiple roles by | character -->
					<param name="roles"></param>
					<!-- set to "true" to only allow admins-->
					<param name="isAdmin">true</param>
					<!-- leave blank for any users, seperate multiple users by | character -->
					<param name="users"></param>
					<events hint="raw:AddEventProcessor">
						<onSaved type="ScsAuditLog.Pipelines.OnSave, ScsAuditLog" color="blue" id="0" label="Item was saved" event="item:saved" />
						<onSaved type="ScsAuditLog.Pipelines.OnMoved, ScsAuditLog" color="brown" id="1" label="Item was moved" event="item:moved" />
						<onSaved type="ScsAuditLog.Pipelines.OnDeleted, ScsAuditLog" color="red" id="2" label="Item was deleted" event="item:deleting" />
						<onSaved type="ScsAuditLog.Pipelines.OnRename, ScsAuditLog" color="orange" id="3" label="Item was renamed" event="item:renamed" />
						<onSaved type="ScsAuditLog.Pipelines.OnCreated, ScsAuditLog" color="green" id="4" label="Item was created" event="item:created" />
						<onSaved type="ScsAuditLog.Pipelines.GeneralEvent, ScsAuditLog" color="#dd33ff" id="7" label="Item was unlocked" event="item:unlocked" />
						<onSaved type="ScsAuditLog.Pipelines.GeneralEvent, ScsAuditLog" color="#aaaaff" id="8" label="Item was locked" event="item:locked" />
					</events>
					<customEvents hint="raw:RegisterCustomEventType">
						<publish color="purple" id="5" label="Publish Initiated" />
						<!--<publish color="#eee" id="6" label="Item Published" />-->
					</customEvents>
				</processor>
			</scsRegister>

Backups and record duration can be configured in the above configuration file.  It is recommended that you keep only what would be useful as due to the volume of data collected, these logs can get get large on a site with a high number of events if keeping logs for more than a week.

Additional events can be tracked using additional onSaved nodes.  Note that new registered events need to have a unique id assigned to it and while it’s not required a unique color would be preferable from a user experience standpoint.

Custom Events

If you’d like to track something that’s not a sitecore event, such as a pipeline processor.  You can invoke a logger singleton to perform the tracking of the event.

AuditLogger.Current.Log(MyEventRelatedItem, "5", $"{HtmlForDetailedInformation");

Parameters:

  1. Sitecore Item related to the event
  2. string Id for the registered event in the configuration file
  3. Optional markup for the “see details” link to expose