Merge pull request #3157 from DavidVentura/allowCreatedDate
Allow populating event's createdAt on the send endpoint
This commit is contained in:
@@ -122,14 +122,14 @@ export async function POST(request: Request) {
|
||||
}
|
||||
|
||||
// Visit info
|
||||
const now = Math.floor(new Date().getTime() / 1000);
|
||||
const createdAt = Math.floor((reqCreatedAt || new Date()).getTime() / 1000);
|
||||
let visitId = cache?.visitId || uuid(sessionId, visitSalt());
|
||||
let iat = cache?.iat || now;
|
||||
let iat = cache?.iat || createdAt;
|
||||
|
||||
// Expire visit after 30 minutes
|
||||
if (now - iat > 1800) {
|
||||
if (createdAt - iat > 1800) {
|
||||
visitId = uuid(sessionId, visitSalt());
|
||||
iat = now;
|
||||
iat = createdAt;
|
||||
}
|
||||
|
||||
if (type === COLLECTION_TYPE.event) {
|
||||
|
||||
@@ -83,6 +83,7 @@ async function relationalQuery(data: {
|
||||
pageTitle: pageTitle?.substring(0, PAGE_TITLE_LENGTH),
|
||||
eventType: eventName ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
|
||||
eventName: eventName ? eventName?.substring(0, EVENT_NAME_LENGTH) : null,
|
||||
createdAt,
|
||||
tag,
|
||||
createdAt,
|
||||
},
|
||||
@@ -193,7 +194,7 @@ async function clickhouseQuery(data: {
|
||||
urlPath: urlPath?.substring(0, URL_LENGTH),
|
||||
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||
eventData,
|
||||
createdAt,
|
||||
createdAt: createdAtUTC,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user