diff --git a/packages/backend-core/src/auth/auth.ts b/packages/backend-core/src/auth/auth.ts index 4bdf0e0cd3..f34d54a879 100644 --- a/packages/backend-core/src/auth/auth.ts +++ b/packages/backend-core/src/auth/auth.ts @@ -225,12 +225,6 @@ export async function platformLogout(opts: PlatformLogoutOpts) { const sessionIds = sessions.map(({ sessionId }) => sessionId) await invalidateSessions(userId, { sessionIds, reason: "logout" }) - let user: User | undefined - try { - user = await userCache.getUser(userId) - } catch { - user = undefined - } - await events.auth.logout(user?.email) + await events.auth.logout(ctx.user?.email) await userCache.invalidateUser(userId) } diff --git a/packages/backend-core/src/events/events.ts b/packages/backend-core/src/events/events.ts index dc8c5482fb..c2f7cf66ec 100644 --- a/packages/backend-core/src/events/events.ts +++ b/packages/backend-core/src/events/events.ts @@ -3,10 +3,6 @@ import { processors } from "./processors" import identification from "./identification" import * as backfill from "./backfill" -export function isAudited(event: Event) { - return !!AuditedEventFriendlyName[event] -} - export const publishEvent = async ( event: Event, properties: any, diff --git a/packages/backend-core/src/events/index.ts b/packages/backend-core/src/events/index.ts index dd687304d8..d0d59a5b22 100644 --- a/packages/backend-core/src/events/index.ts +++ b/packages/backend-core/src/events/index.ts @@ -3,7 +3,6 @@ export * as processors from "./processors" export * as analytics from "./analytics" export { default as identification } from "./identification" export * as backfillCache from "./backfill" -export { isAudited } from "./events" import { processors } from "./processors" diff --git a/packages/backend-core/src/events/processors/AuditLogsProcessor.ts b/packages/backend-core/src/events/processors/AuditLogsProcessor.ts index f2c2cd04d7..326e476544 100644 --- a/packages/backend-core/src/events/processors/AuditLogsProcessor.ts +++ b/packages/backend-core/src/events/processors/AuditLogsProcessor.ts @@ -4,11 +4,10 @@ import { Group, IdentityType, AuditLogQueueEvent, - AuditLogFn, + AuditLogFn, AuditedEventFriendlyName, } from "@budibase/types" import { EventProcessor } from "./types" import { getAppId } from "../../context" -import { isAudited } from "../events" import BullQueue from "bull" import { createQueue, JobQueue } from "../../queue" @@ -41,13 +40,17 @@ export default class AuditLogsProcessor implements EventProcessor { }) } + isAudited(event: Event) { + return !!AuditedEventFriendlyName[event] + } + async processEvent( event: Event, identity: Identity, properties: any, timestamp?: string ): Promise { - if (AuditLogsProcessor.auditLogsEnabled && isAudited(event)) { + if (AuditLogsProcessor.auditLogsEnabled && this.isAudited(event)) { // only audit log actual events, don't include backfills const userId = identity.type === IdentityType.USER ? identity.id : undefined diff --git a/packages/server/src/startup.ts b/packages/server/src/startup.ts index e6784c5a82..6cdbf87c2c 100644 --- a/packages/server/src/startup.ts +++ b/packages/server/src/startup.ts @@ -17,7 +17,6 @@ import * as pro from "@budibase/pro" import * as api from "./api" import sdk from "./sdk" const pino = require("koa-pino-logger") -import { sdk as proSdk } from "@budibase/pro" let STARTUP_RAN = false @@ -127,7 +126,7 @@ export async function startup(app?: any, server?: any) { let queuePromises = [] // configure events to use the pro audit log write // can't integrate directly into backend-core due to cyclic issues - queuePromises.push(events.processors.init(proSdk.auditLogs.write)) + queuePromises.push(events.processors.init(pro.sdk.auditLogs.write)) queuePromises.push(automations.init()) queuePromises.push(initPro()) if (app) {