improve(buffer): do not create profile for each event
This commit is contained in:
@@ -81,6 +81,7 @@ export class ProfileBuffer extends BaseBuffer {
|
||||
['created_at'],
|
||||
['properties', 'brand'],
|
||||
['properties', 'browser_version'],
|
||||
['properties', 'browserVersion'],
|
||||
['properties', 'browser'],
|
||||
['properties', 'city'],
|
||||
['properties', 'country'],
|
||||
@@ -89,10 +90,13 @@ export class ProfileBuffer extends BaseBuffer {
|
||||
['properties', 'longitude'],
|
||||
['properties', 'model'],
|
||||
['properties', 'os_version'],
|
||||
['properties', 'osVersion'],
|
||||
['properties', 'os'],
|
||||
['properties', 'path'],
|
||||
['properties', 'referrer_name'],
|
||||
['properties', 'referrerName'],
|
||||
['properties', 'referrer_type'],
|
||||
['properties', 'referrerType'],
|
||||
['properties', 'referrer'],
|
||||
['properties', 'region'],
|
||||
];
|
||||
|
||||
@@ -278,7 +278,7 @@ export async function createEvent(payload: IServiceCreateEventPayload) {
|
||||
}
|
||||
|
||||
if (payload.profileId) {
|
||||
await upsertProfile({
|
||||
const profile = {
|
||||
id: String(payload.profileId),
|
||||
isExternal: payload.profileId !== payload.deviceId,
|
||||
projectId: payload.projectId,
|
||||
@@ -300,7 +300,14 @@ export async function createEvent(payload: IServiceCreateEventPayload) {
|
||||
referrer_name: payload.referrerName,
|
||||
referrer_type: payload.referrerType,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (
|
||||
profile.isExternal ||
|
||||
(profile.isExternal === false && payload.name === 'session_start')
|
||||
) {
|
||||
await upsertProfile(profile);
|
||||
}
|
||||
}
|
||||
|
||||
const event: IClickhouseEvent = {
|
||||
|
||||
Reference in New Issue
Block a user