diff --git a/apps/server/src/api-integration/integration.controller.ts b/apps/server/src/api-integration/integration.controller.ts index 390c4f11d..9039bc299 100644 --- a/apps/server/src/api-integration/integration.controller.ts +++ b/apps/server/src/api-integration/integration.controller.ts @@ -54,18 +54,15 @@ const actionHandlers: Record = { if (typeof property !== 'string' || value === undefined) { throw new Error('Invalid property or value'); } - // parseProperty is async because of the data lock - parseProperty(property, value).then((newObjectProperty) => { - const key = Object.keys(newObjectProperty)[0] as keyof OntimeEvent; - shouldThrottle = willCauseRegeneration(key) || shouldThrottle; - - if (patchEvent.custom && newObjectProperty.custom) { - Object.assign(patchEvent.custom, newObjectProperty.custom); - } else { - Object.assign(patchEvent, newObjectProperty); - } - }); + const newObjectProperty = parseProperty(property, value); + const key = Object.keys(newObjectProperty)[0] as keyof OntimeEvent; + shouldThrottle = shouldThrottle || willCauseRegeneration(key); + if (patchEvent.custom && newObjectProperty.custom) { + Object.assign(patchEvent.custom, newObjectProperty.custom); + } else { + Object.assign(patchEvent, newObjectProperty); + } }); if (shouldThrottle) { diff --git a/apps/server/src/api-integration/integration.utils.ts b/apps/server/src/api-integration/integration.utils.ts index ff217636a..eaa455eb8 100644 --- a/apps/server/src/api-integration/integration.utils.ts +++ b/apps/server/src/api-integration/integration.utils.ts @@ -42,7 +42,7 @@ const propertyConversion = { timeEnd: (value: unknown) => clampDuration(coerceNumber(value)), }; -export async function parseProperty(property: string, value: unknown) { +export function parseProperty(property: string, value: unknown) { if (property.startsWith('custom:')) { const customKey = property.split(':')[1].toLocaleLowerCase(); // all custom fields keys are lowercase const customFields = getDataProvider().getCustomFields();