From 2e0a05d0783c1baa1d5e6aed3350c412608c940e Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Wed, 16 Jul 2025 13:19:19 +0200 Subject: [PATCH] Use key deletion from client application store --- src/lib/db/client-instance-store.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/lib/db/client-instance-store.ts b/src/lib/db/client-instance-store.ts index 1ec463c7bc..76f435b785 100644 --- a/src/lib/db/client-instance-store.ts +++ b/src/lib/db/client-instance-store.ts @@ -32,15 +32,26 @@ const mapRow = (row): IClientInstance => ({ environment: row.environment, }); -const mapToDb = (client: INewClientInstance) => ({ - app_name: client.appName, - instance_id: client.instanceId, - sdk_version: client.sdkVersion || '', - sdk_type: client.sdkType, - client_ip: client.clientIp, - last_seen: client.lastSeen || 'now()', - environment: client.environment || 'default', -}); +const mapToDb = (client: INewClientInstance) => { + const initialMap = { + app_name: client.appName, + instance_id: client.instanceId, + sdk_version: client.sdkVersion, + sdk_type: client.sdkType, + client_ip: client.clientIp, + last_seen: client.lastSeen || 'now()', + environment: client.environment, + }; + + Object.keys(initialMap).forEach((k) => { + if (initialMap[k] === undefined) { + // not using !temp[k] to allow false and null values to get through + delete initialMap[k]; + } + }); + + return initialMap; +}; export default class ClientInstanceStore implements IClientInstanceStore { private db: Db;