Skip to content

Commit 329f76b

Browse files
committed
fix: avoid overwrite profile properties (geo etc) when profile is from server
1 parent 3b74d8a commit 329f76b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/db/src/buffers/profile-buffer.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,30 @@ export class ProfileBuffer extends BaseBuffer {
6868

6969
const existingProfile = await this.fetchProfile(profile, logger);
7070

71+
// Delete any properties that are not server related if we have a non-server profile
72+
if (
73+
existingProfile?.properties.device !== 'server' &&
74+
profile.properties.device === 'server'
75+
) {
76+
profile.properties = omit(
77+
[
78+
'city',
79+
'country',
80+
'region',
81+
'longitude',
82+
'latitude',
83+
'os',
84+
'osVersion',
85+
'browser',
86+
'device',
87+
'isServer',
88+
'os_version',
89+
'browser_version',
90+
],
91+
profile.properties,
92+
);
93+
}
94+
7195
const mergedProfile: IClickhouseProfile = existingProfile
7296
? deepMergeObjects(existingProfile, omit(['created_at'], profile))
7397
: profile;

0 commit comments

Comments
 (0)