add session to visits and events

This commit is contained in:
Emily
2024-06-10 04:15:31 +02:00
parent 5a48ef53b4
commit f35e24efa8
3 changed files with 9 additions and 1 deletions

View File

@@ -77,12 +77,15 @@ async function process_visit(data: Record<string, string>, sessionHash: string)
browser: userAgentParsed.browser.name || 'NO_BROWSER',
os: userAgentParsed.os.name || 'NO_OS',
device: userAgentParsed.device.type,
session: sessionHash,
continent: geoLocation[0],
country: geoLocation[1],
});
await visit.save();
await ProjectCountModel.updateOne({ project_id: pid }, { $inc: { 'visits': 1 } }, { upsert: true });
await ProjectLimitModel.updateOne({ project_id: pid }, { $inc: { 'visits': 1 } });
@@ -118,7 +121,7 @@ async function process_event(data: Record<string, string>, sessionHash: string)
metadataObject = { error: 'Error parsing metadata' }
}
const event = new EventModel({ project_id: pid, name, metadata: metadataObject });
const event = new EventModel({ project_id: pid, name, metadata: metadataObject, session: sessionHash });
await event.save();
await ProjectCountModel.updateOne({ project_id: pid }, { $inc: { 'events': 1 } }, { upsert: true });