fix(buffer): fixed issues with buffer
This commit is contained in:
@@ -103,6 +103,7 @@ export class RedisBuffer<T> {
|
|||||||
await cb();
|
await cb();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`#2 Failed to execute callback: ${cb.name}`, e);
|
this.logger.error(`#2 Failed to execute callback: ${cb.name}`, e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,14 +161,14 @@ export class RedisBuffer<T> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('Failed to process queue while flushing buffer}:', {
|
this.logger.error('Failed to process queue while flushing buffer', {
|
||||||
error,
|
error,
|
||||||
queueSize: items.length,
|
queueSize: items.length,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
// Add back items to keep
|
// Add back items to keep
|
||||||
this.logger.debug('Adding all items back to buffer');
|
this.logger.info('Adding all items back to buffer');
|
||||||
await getRedisCache().lpush(
|
await getRedisCache().lpush(
|
||||||
this.getKey(),
|
this.getKey(),
|
||||||
...items.map((item) => JSON.stringify(item)),
|
...items.map((item) => JSON.stringify(item)),
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ export class EventBuffer extends RedisBuffer<BufferType> {
|
|||||||
return (
|
return (
|
||||||
lastEvent.project_id === item.project_id &&
|
lastEvent.project_id === item.project_id &&
|
||||||
lastEvent.profile_id === item.profile_id &&
|
lastEvent.profile_id === item.profile_id &&
|
||||||
lastEvent.path !== ''
|
lastEvent.path !== '' &&
|
||||||
|
lastEvent.name === 'screen_view'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -76,6 +77,10 @@ export class EventBuffer extends RedisBuffer<BufferType> {
|
|||||||
item,
|
item,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!event.properties) {
|
||||||
|
event.properties = {};
|
||||||
|
}
|
||||||
|
|
||||||
if (lastEventWithData) {
|
if (lastEventWithData) {
|
||||||
event.properties.__properties_from = lastEventWithData.id;
|
event.properties.__properties_from = lastEventWithData.id;
|
||||||
}
|
}
|
||||||
@@ -114,9 +119,12 @@ export class EventBuffer extends RedisBuffer<BufferType> {
|
|||||||
new Date(item.created_at).getTime();
|
new Date(item.created_at).getTime();
|
||||||
const event = {
|
const event = {
|
||||||
...item,
|
...item,
|
||||||
|
properties: {
|
||||||
|
...(item?.properties || {}),
|
||||||
|
__duration_from: nextScreenView.id,
|
||||||
|
},
|
||||||
duration,
|
duration,
|
||||||
};
|
};
|
||||||
event.properties.__duration_from = nextScreenView.id;
|
|
||||||
toInsert.add(event);
|
toInsert.add(event);
|
||||||
} else if (hasSessionEnd) {
|
} else if (hasSessionEnd) {
|
||||||
// push last event in session if we have a session_end event
|
// push last event in session if we have a session_end event
|
||||||
|
|||||||
Reference in New Issue
Block a user