Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
perf: cache org properties per orgId in processBucketEvents to avoid redundant DB calls
Devin AI70b4beb4ef6d
diff --git a/backend/src/services/telemetry/telemetry-service.ts b/backend/src/services/telemetry/telemetry-service.tsindex e2d11818d7..1301b0a53b 100644--- a/backend/src/services/telemetry/telemetry-service.ts+++ b/backend/src/services/telemetry/telemetry-service.ts@@ -298,14 +298,22 @@ To opt into telemetry, you can set "TELEMETRY_ENABLED=true" within the environmeif (eventsGrouped.size === 0) return 0;+ // Cache org group properties per orgId to avoid redundant DB/API calls+ // when multiple users share the same org within a bucket+ const orgPropertiesCache = new Map<string, Record<string, unknown>>();+for (const [eventsKey, events] of eventsGrouped) {const key = JSON.parse(eventsKey) as { id: string; org?: string };if (key.org) {try {- // Use the organizationName from the first event in the group (all events in a group share the same org)- const orgName = events[0]?.organizationName;- // eslint-disable-next-line no-await-in-loop- const groupProperties = await getOrgGroupProperties(key.org, orgName);+ let groupProperties = orgPropertiesCache.get(key.org);+ if (!groupProperties) {+ // Use the organizationName from the first event in the group (all events in a group share the same org)+ const orgName = events[0]?.organizationName;+ // eslint-disable-next-line no-await-in-loop+ groupProperties = await getOrgGroupProperties(key.org, orgName);+ orgPropertiesCache.set(key.org, groupProperties);+ }postHog.groupIdentify({groupType: "organization",groupKey: key.org,