mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
rewrite consumer + testmode utils
This commit is contained in:
@@ -16,7 +16,8 @@ router.post('/keep_alive', json(jsonOptions), async (req, res) => {
|
||||
const sessionHash = createSessionHash(req.body.website, ip, req.body.userAgent);
|
||||
await RedisStreamService.addToStream(streamName, {
|
||||
...req.body, _type: 'keep_alive', sessionHash, ip,
|
||||
instant: req.body.instant + ''
|
||||
instant: req.body.instant + '',
|
||||
timestamp: Date.now()
|
||||
});
|
||||
return res.sendStatus(200);
|
||||
} catch (ex: any) {
|
||||
@@ -38,12 +39,14 @@ router.post('/metrics/push', json(jsonOptions), async (req, res) => {
|
||||
...req.body, _type: 'visit', sessionHash, ip,
|
||||
screenWidth: '0',
|
||||
screenHeight: '0',
|
||||
type: req.body.type.toString()
|
||||
type: req.body.type.toString(),
|
||||
timestamp: Date.now()
|
||||
});
|
||||
} else {
|
||||
await RedisStreamService.addToStream(streamName, {
|
||||
...req.body, _type: 'event', sessionHash, ip,
|
||||
type: req.body.type.toString()
|
||||
type: req.body.type.toString(),
|
||||
timestamp: Date.now()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ app.post('/event', express.json(jsonOptions), async (req, res) => {
|
||||
const sessionHash = createSessionHash(req.body.website, ip, req.body.userAgent);
|
||||
const flowHash = createFlowSessionHash(req.body.pid, ip, req.body.userAgent);
|
||||
await RedisStreamService.addToStream(streamName, {
|
||||
...req.body, _type: 'event', sessionHash, ip, flowHash
|
||||
...req.body, _type: 'event', sessionHash, ip, flowHash,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
return res.sendStatus(200);
|
||||
} catch (ex: any) {
|
||||
@@ -35,7 +36,7 @@ app.post('/visit', express.json(jsonOptions), async (req, res) => {
|
||||
const ip = getIPFromRequest(req);
|
||||
const sessionHash = createSessionHash(req.body.website, ip, req.body.userAgent);
|
||||
const flowHash = createFlowSessionHash(req.body.pid, ip, req.body.userAgent);
|
||||
await RedisStreamService.addToStream(streamName, { ...req.body, _type: 'visit', sessionHash, ip, flowHash });
|
||||
await RedisStreamService.addToStream(streamName, { ...req.body, _type: 'visit', sessionHash, ip, flowHash, timestamp: Date.now() });
|
||||
return res.sendStatus(200);
|
||||
} catch (ex: any) {
|
||||
return res.status(500).json({ error: ex.message });
|
||||
@@ -50,7 +51,7 @@ app.post('/keep_alive', express.json(jsonOptions), async (req, res) => {
|
||||
await RedisStreamService.addToStream(streamName, {
|
||||
...req.body, _type: 'keep_alive', sessionHash, ip,
|
||||
instant: req.body.instant + '',
|
||||
flowHash
|
||||
flowHash, timestamp: Date.now()
|
||||
});
|
||||
return res.sendStatus(200);
|
||||
} catch (ex: any) {
|
||||
|
||||
Reference in New Issue
Block a user