Skip to content

The open alternative to Salesforce, designed for AI.

Show and filter app platform events in the log console (#28318)

martmull39d8576f2231
diff --git a/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx b/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx
index e8deb6e8450..d1256a0b86b 100644
--- a/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx
+++ b/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx
@@ -151,7 +151,7 @@ export const LogConsoleDetailPanel = () => {
})
: undefined;
- const DetailIcon = source.DetailIcon ?? source.Icon;
+ const DetailIcon = source.getDetailIcon?.(entry) ?? source.Icon;
const title = isDefined(recordIdentifier)
? recordIdentifier.name
diff --git a/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogColumns.tsx b/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogColumns.tsx
index 23918345ce8..3b75b424d43 100644
--- a/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogColumns.tsx
+++ b/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogColumns.tsx
@@ -1,6 +1,5 @@
import { msg, t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
-import { IconBrandTypescript } from 'twenty-ui/icon';
import { Status } from 'twenty-ui/primitives/data-display';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -8,6 +7,8 @@ import { LOG_CONSOLE_APPLICATION_LOG_APP_COLUMN } from '@/log-console/constants/
import { LOG_CONSOLE_LEVELS } from '@/log-console/constants/LogConsoleLevels';
import { LOG_CONSOLE_TIME_COLUMN } from '@/log-console/constants/LogConsoleTimeColumn';
import { type LogConsoleColumn } from '@/log-console/types/LogConsoleColumn';
+import { getLogConsoleApplicationLogEventIcon } from '@/log-console/utils/getLogConsoleApplicationLogEventIcon';
+import { getApplicationLogFunctionOrEventLabel } from '@/settings/application-monitoring/utils/getApplicationLogFunctionOrEventLabel';
import { SettingsTableTagCell } from '@/settings/components/SettingsTableTagCell';
import { SettingsTableTextCell } from '@/settings/components/SettingsTableTextCell';
@@ -33,18 +34,25 @@ export const LOG_CONSOLE_APPLICATION_LOG_COLUMNS: LogConsoleColumn[] = [
id: 'function',
label: msg`Function`,
gridTrack: '216px',
- renderCell: (entry) => (
- <SettingsTableTextCell
- startElement={
- <IconBrandTypescript
- size={14}
- stroke={themeCssVariables.icon.stroke.sm}
- color={themeCssVariables.font.color.tertiary}
- />
- }
- text={entry.event}
- />
- ),
+ renderCell: (entry) => {
+ const EventIcon = getLogConsoleApplicationLogEventIcon(entry.event);
+
+ return (
+ <SettingsTableTextCell
+ startElement={
+ <EventIcon
+ size={14}
+ stroke={themeCssVariables.icon.stroke.sm}
+ color={themeCssVariables.font.color.tertiary}
+ />
+ }
+ text={getApplicationLogFunctionOrEventLabel({
+ logicFunctionName: entry.event,
+ source: entry.properties?.source ?? '',
+ })}
+ />
+ );
+ },
},
{
id: 'message',
diff --git a/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogFilterFields.tsx b/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogFilterFields.tsx
index 96be40cd5cf..c2f5ce6d646 100644
--- a/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogFilterFields.tsx
+++ b/packages/twenty-front/src/modules/log-console/constants/LogConsoleApplicationLogFilterFields.tsx
@@ -9,6 +9,7 @@ import { Tag } from 'twenty-ui/primitives/data-display';
import { LOG_CONSOLE_LEVELS } from '@/log-console/constants/LogConsoleLevels';
import { type LogConsoleFilterField } from '@/log-console/types/LogConsoleFilterField';
+import { APPLICATION_LOG_SOURCE_LABELS } from '@/settings/application-monitoring/constants/ApplicationLogSourceLabels';
export const LOG_CONSOLE_APPLICATION_LOG_FILTER_FIELDS: LogConsoleFilterField[] =
[
@@ -30,6 +31,19 @@ export const LOG_CONSOLE_APPLICATION_LOG_FILTER_FIELDS: LogConsoleFilterField[]
: [],
),
},
+ {
+ id: 'source',
+ label: msg`Source`,
+ Icon: IconApps,
+ serverField: 'source',
+ getOptions: () =>
+ Object.entries(APPLICATION_LOG_SOURCE_LABELS).map(
+ ([applicationLogSource, sourceLabel]) => ({
+ label: t(sourceLabel),
+ values: [applicationLogSource],
+ }),
+ ),
+ },
{
id: 'function',
label: msg`Function`,
diff --git a/packages/twenty-front/src/modules/log-console/constants/LogConsoleSources.tsx b/packages/twenty-front/src/modules/log-console/constants/LogConsoleSources.tsx
index 88d5e67372e..702a1934914 100644
--- a/packages/twenty-front/src/modules/log-console/constants/LogConsoleSources.tsx
+++ b/packages/twenty-front/src/modules/log-console/constants/LogConsoleSources.tsx
@@ -10,11 +10,11 @@ import {
import { doNotTranslate } from 'twenty-shared/i18n';
import {
IconAddressBook,
+ IconAlertCircle,
IconAlertTriangle,
IconApps,
IconArrowUpRight,
IconBox,
- IconBrandTypescript,
IconClock,
IconCoins,
IconEye,
@@ -26,6 +26,7 @@ import {
IconSum,
IconTerminal,
IconUsers,
+ IconVersions,
IconWebhook,
} from 'twenty-ui/icon';
import { Status, Tag } from 'twenty-ui/primitives/data-display';
@@ -50,8 +51,11 @@ import { LOG_CONSOLE_USAGE_EVENT_COLUMNS } from '@/log-console/constants/LogCons
import { LOG_CONSOLE_WEBHOOK_COLUMNS } from '@/log-console/constants/LogConsoleWebhookColumns';
import { type LogConsoleDetailField } from '@/log-console/types/LogConsoleDetailField';
import { type LogConsoleSource } from '@/log-console/types/LogConsoleSource';
+import { getLogConsoleApplicationLogEventIcon } from '@/log-console/utils/getLogConsoleApplicationLogEventIcon';
import { getLogConsoleRecordLabel } from '@/log-console/utils/getLogConsoleRecordLabel';
import { getLogConsoleSecurityEvent } from '@/log-console/utils/getLogConsoleSecurityEvent';
+import { getApplicationLogFunctionOrEventLabel } from '@/settings/application-monitoring/utils/getApplicationLogFunctionOrEventLabel';
+import { getApplicationLogSourceLabel } from '@/settings/application-monitoring/utils/getApplicationLogSourceLabel';
import { getUsageOperationTypeLabel } from '@/settings/usage/utils/getUsageOperationTypeLabel';
import { NavigationButton } from '@/ui/input/components/NavigationButton';
import {
@@ -174,7 +178,7 @@ export const LOG_CONSOLE_SOURCES: LogConsoleSource[] = [
id: 'app-logs',
label: msg`App logs`,
Icon: IconTerminal,
- DetailIcon: IconBrandTypescript,
+ getDetailIcon: (entry) => getLogConsoleApplicationLogEventIcon(entry.event),
table: EventLogTable.APPLICATION_LOG,
filterFields: LOG_CONSOLE_APPLICATION_LOG_FILTER_FIELDS,
requiresAuditLogs: false,
@@ -191,6 +195,33 @@ export const LOG_CONSOLE_SOURCES: LogConsoleSource[] = [
) : null;
},
},
+ {
+ label: msg`Source`,
+ Icon: IconApps,
+ renderValue: (entry) => {
+ const sourceLabel = getApplicationLogSourceLabel(
+ entry.properties?.source ?? '',
+ );
+
+ return isDefined(sourceLabel) ? t(sourceLabel) : null;
+ },
+ },
+ {
+ label: msg`Error code`,
+ Icon: IconAlertCircle,
+ renderValue: (entry) =>
+ isNonEmptyString(entry.properties?.errorCode)
+ ? entry.properties.errorCode
+ : null,
+ },
+ {
+ label: msg`Version`,
+ Icon: IconVersions,
+ renderValue: (entry) =>
+ isNonEmptyString(entry.properties?.applicationVersion)
+ ? entry.properties.applicationVersion
+ : null,
+ },
TIME_DETAIL_FIELD,
{
label: msg`App`,
@@ -208,7 +239,11 @@ export const LOG_CONSOLE_SOURCES: LogConsoleSource[] = [
],
getSeverity: (entry) =>
LOG_CONSOLE_LEVELS[entry.properties?.level]?.severity,
- getDetailTitle: (entry) => entry.event,
+ getDetailTitle: (entry) =>
+ getApplicationLogFunctionOrEventLabel({
+ logicFunctionName: entry.event,
+ source: entry.properties?.source ?? '',
+ }),
},
{
id: 'webhooks',
diff --git a/packages/twenty-front/src/modules/log-console/types/LogConsoleSource.ts b/packages/twenty-front/src/modules/log-console/types/LogConsoleSource.ts
index e97e104fca6..d444b5ea0a1 100644
--- a/packages/twenty-front/src/modules/log-console/types/LogConsoleSource.ts
+++ b/packages/twenty-front/src/modules/log-console/types/LogConsoleSource.ts
@@ -19,7 +19,7 @@ export type LogConsoleSource = {
id: LogConsoleSourceId;
label: MessageDescriptor;
Icon: IconComponent;
- DetailIcon?: IconComponent;
+ getDetailIcon?: (entry: EventLogRecord) => IconComponent;
table: EventLogTable;
fieldFilters?: EventLogFieldFilterInput[];
filterFields?: LogConsoleFilterField[];
diff --git a/packages/twenty-front/src/modules/log-console/utils/__tests__/getLogConsoleApplicationLogEventIcon.test.ts b/packages/twenty-front/src/modules/log-console/utils/__tests__/getLogConsoleApplicationLogEventIcon.test.ts
new file mode 100644
index 00000000000..b71c3b2f264
--- /dev/null
+++ b/packages/twenty-front/src/modules/log-console/utils/__tests__/getLogConsoleApplicationLogEventIcon.test.ts
@@ -0,0 +1,15 @@
+import { IconApps, IconBrandTypescript } from 'twenty-ui/icon';
+
+import { getLogConsoleApplicationLogEventIcon } from '@/log-console/utils/getLogConsoleApplicationLogEventIcon';
+
+describe('getLogConsoleApplicationLogEventIcon', () => {
+ it('should show a function icon for logic function logs', () => {
+ expect(getLogConsoleApplicationLogEventIcon('syncContacts')).toBe(
+ IconBrandTypescript,
+ );
+ });
+
+ it('should show the app icon for platform events without a function', () => {
+ expect(getLogConsoleApplicationLogEventIcon('')).toBe(IconApps);
+ });
+});
diff --git a/packages/twenty-front/src/modules/log-console/utils/getLogConsoleApplicationLogEventIcon.ts b/packages/twenty-front/src/modules/log-console/utils/getLogConsoleApplicationLogEventIcon.ts
new file mode 100644
index 00000000000..2946b6cedc9
--- /dev/null
+++ b/packages/twenty-front/src/modules/log-console/utils/getLogConsoleApplicationLogEventIcon.ts
@@ -0,0 +1,10 @@
+import { isNonEmptyString } from '@sniptt/guards';
+import {
+ IconApps,
+ IconBrandTypescript,
+ type IconComponent,
+} from 'twenty-ui/icon';
+
+export const getLogConsoleApplicationLogEventIcon = (
+ event: string,
+): IconComponent => (isNonEmptyString(event) ? IconBrandTypescript : IconApps);
diff --git a/packages/twenty-server/src/engine/core-modules/event-logs/registry/event-log-registry.ts b/packages/twenty-server/src/engine/core-modules/event-logs/registry/event-log-registry.ts
index 832db8888a8..7535e7e8794 100644
--- a/packages/twenty-server/src/engine/core-modules/event-logs/registry/event-log-registry.ts
+++ b/packages/twenty-server/src/engine/core-modules/event-logs/registry/event-log-registry.ts
@@ -98,6 +98,7 @@ export const EVENT_LOG_TYPES: Record<EventLogTable, EventLogTypeDefinition> = {
'logicFunctionId',
'applicationId',
'executionId',
+ 'source',
],
normalize: (row) => {
const record = row as StoredRow<ApplicationLogRow>;
diff --git a/packages/twenty-server/test/integration/graphql/suites/event-logs/event-logs.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/event-logs/event-logs.integration-spec.ts
index 4821cf4661e..dfc4b39bbd5 100644
--- a/packages/twenty-server/test/integration/graphql/suites/event-logs/event-logs.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/event-logs/event-logs.integration-spec.ts
@@ -561,6 +561,43 @@ describe('Event Logs (integration)', () => {
});
});
+ describe('application log specific filters', () => {
+ it('should filter application logs by source', async () => {
+ const logicFunctionResponse = await makeEventLogsQuery({
+ table: 'APPLICATION_LOG',
+ first: 50,
+ filters: {
+ fieldFilters: [
+ { field: 'source', operand: 'IS', values: ['LOGIC_FUNCTION'] },
+ ],
+ },
+ });
+
+ expect(logicFunctionResponse.body.errors).toBeUndefined();
+ expect(
+ logicFunctionResponse.body.data.eventLogs.records.length,
+ ).toBeGreaterThan(0);
+
+ const upgradeResponse = await makeEventLogsQuery({
+ table: 'APPLICATION_LOG',
+ first: 50,
+ filters: {
+ fieldFilters: [
+ { field: 'source', operand: 'IS', values: ['UPGRADE'] },
+ ],
+ },
+ });
+
+ expect(upgradeResponse.body.errors).toBeUndefined();
+ expect(
+ upgradeResponse.body.data.eventLogs.records.filter(
+ (record: { properties: { source: string } }) =>
+ record.properties.source !== 'UPGRADE',
+ ),
+ ).toEqual([]);
+ });
+ });
+
describe('combined filters', () => {
it('should apply multiple filters together', async () => {
const now = new Date();