var log = {
    add: function(eventType, payload) {
        var timestamp = new Date();
        var event = {
            type: eventType,
            instanceID: Florence.instanceID,
            created: timestamp.toISOString(),
            timestamp: timestamp.getTime(),
            payload: payload || null
        }
        websocket.send("log:" + JSON.stringify(event));
    },
    eventTypes: {
        appInitialised: "APP_INITIALISED",
        requestSent: "REQUEST_SENT",
        requestReceived: "REQUEST_RECEIVED",
        requestFailed: "REQUEST_FAILED",
        pingSent: "PING_SENT",
        pingReceived: "PING_RECEIVED",
        pingFailed: "PING_FAILED",
        socketOpen: "SOCKET_OPEN",
        socketBufferFull: "SOCKET_BUFFER_FULL",
        socketError: "SOCKET_ERROR",
        unexpectedRuntimeError: "UNEXPECTED_RUNTIME_ERROR",
        runtimeWarning: "RUNTIME_WARNING"
    }
}

@@ -314,16 +314,256 @@
       %7D%0A
+%0A        // Add unrecognised log type to log event%0A        if (!log.eventTypesMap%5BeventType%5D) %7B%0A            console.log(%22Unrecognised log type: %22, eventType, payload);%0A            event.type = log.eventTypes.unrecognisedLogType;%0A        %7D%0A%0A
         
@@ -1131,13 +1131,1060 @@
 ING%22
-%0A    %7D%0A%7D
+,%0A        unrecognisedLogType: %22UNRECOGNISED_LOG_TYPE%22%0A    %7D,%0A    eventTypesMap: %7B%7D%0A%7D%0A%0A// Create a map for event type values to property name %0A// so that we can detect when we're logging an unrecognised event%0Afor (var eventType in log.eventTypes) %7B%0A    log.eventTypesMap%5Blog.eventTypes%5BeventType%5D%5D = eventType;%0A%7D%0A%0A$.ajaxSetup(%7B%0A    beforeSend: function(request) %7B%0A        var requestID = (S4() + S4());%0A        request.setRequestHeader(%22X-Request-ID%22, requestID);%0A        request.uniqueID = requestID;%0A        log.add(%0A            log.eventTypes.requestSent, %7B%0A                requestID%0A            %7D%0A        );%0A    %7D%0A%7D);%0A%0A$(document).ajaxSuccess(function(event, request, settings) %7B%0A    log.add(%0A        log.eventTypes.requestReceived, %7B%0A            requestID: request.uniqueID,%0A            status: request.statusText%0A        %7D%0A    );%0A%7D);%0A%0A$(document).ajaxError(function(event, request, settings) %7B%0A    log.add(%0A        log.eventTypes.requestReceived, %7B%0A            requestID: request.uniqueID,%0A            status: request.statusText%0A        %7D%0A    );%0A%7D);
 %0A

Add request ID to every ajax in legacy Florence