const log = require("../utils/logger");

var applist = [];

function addHandlers(server) {
    // Set up the lifeforce heartbeat listener
    server.get("/api/lifeforce/heartbeat/:appname", (req, res, next) => {
        if (req.params.appname) {
            var timestamp = new Date().getTime();
            log.debug("Heartbeat from " + req.params.appname + " at " + Date(timestamp.toLocaleString()));
            res.send(200, "OK");
            applist[req.params.appname] = timestamp;
        } else {
            res.send(400, "Please supply an application name");
        }
    });

    server.get("/api/lifeforce/heartbeat/:appname/last", (req, res, next) => {
        if (req.params.appname) {
            if (applist.hasOwnProperty(req.params.appname)) {
                res.send(200, applist[req.params.appname]);
            } else {
                res.send(400, 0);
            }
        } else {
            res.send(400, "Please supply an application name");
        }
    });
}


/**
 * This set of properties defines this as a plugin
 * You must have an enabled, name, and start property defined
 */
module.exports = {
    enabled: true,
    name: "heartbeat",
    start: (server) => {
        addHandlers(server);
    }
}

@@ -582,16 +582,524 @@
    %7D);%0A%0A
+    // Set up the lifeforce heartbeat listener%0A    server.get(%22/api/lifeforce/analytics/:appname%22, (req, res, next) =%3E %7B%0A        if (req.params.appname) %7B%0A            var timestamp = new Date().getTime();%0A            log.debug(%22Page view analytics from %22 + req.params.appname + %22 at %22 + Date(timestamp.toLocaleString()));%0A            res.send(200, %22OK%22);%0A            applist%5Breq.params.appname%5D = timestamp;%0A        %7D else %7B%0A            res.send(400, %22Please supply an application name%22);%0A        %7D%0A    %7D);%0A%0A
     serv

Add an analytics endpoint