improve(queue): how we handle incoming events and session ends
This commit is contained in:
@@ -55,15 +55,6 @@ export async function postEvent(
|
||||
return;
|
||||
}
|
||||
|
||||
const isScreenView = request.body.name === 'screen_view';
|
||||
// this will ensure that we don't have multiple events creating sessions
|
||||
const LOCK_DURATION = 1000;
|
||||
const locked = await getLock(
|
||||
`request:priority:${currentDeviceId}-${previousDeviceId}:${isScreenView ? 'screen_view' : 'other'}`,
|
||||
'locked',
|
||||
LOCK_DURATION,
|
||||
);
|
||||
|
||||
await eventsQueue.add(
|
||||
'event',
|
||||
{
|
||||
@@ -79,7 +70,6 @@ export async function postEvent(
|
||||
geo,
|
||||
currentDeviceId,
|
||||
previousDeviceId,
|
||||
priority: locked,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -88,10 +78,6 @@ export async function postEvent(
|
||||
type: 'exponential',
|
||||
delay: 200,
|
||||
},
|
||||
// Prioritize 'screen_view' events by setting no delay
|
||||
// This ensures that session starts are created from 'screen_view' events
|
||||
// rather than other events, maintaining accurate session tracking
|
||||
delay: isScreenView ? undefined : LOCK_DURATION - 100,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user