Skip to content

Commit

Permalink
fix: log audit events
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Jun 2, 2024
1 parent bec2e8b commit 97bb775
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export class AuditEventTableComponent implements OnInit {

convertToIcon(event: ApplicationEvent) {
switch (event.action) {
case ApplicationEventName.FLOW_RUN_FINISHED:
case ApplicationEventName.FLOW_RUN_STARTED:
return {
icon: 'assets/img/custom/dashboard/runs.svg',
tooltip: 'Flow Run',
};
case ApplicationEventName.FLOW_CREATED:
case ApplicationEventName.FLOW_DELETED:
case ApplicationEventName.FLOW_UPDATED:
Expand All @@ -81,9 +87,7 @@ export class AuditEventTableComponent implements OnInit {
icon: 'assets/img/custom/dashboard/connections.svg',
tooltip: 'Connection',
};
case ApplicationEventName.USER_SIGNED_UP_USING_EMAIL:
case ApplicationEventName.USER_SIGNED_UP_USING_MANAGED_AUTH:
case ApplicationEventName.USER_SIGNED_UP_USING_SSO:
case ApplicationEventName.USER_SIGNED_UP:
case ApplicationEventName.USER_SIGNED_IN:
case ApplicationEventName.USER_PASSWORD_RESET:
case ApplicationEventName.USER_EMAIL_VERIFIED:
Expand Down
4 changes: 3 additions & 1 deletion packages/server/api/src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ export const setupApp = async (): Promise<FastifyInstance> => {
await validateEnvPropsOnStartup()

const edition = getEdition()
logger.info(`Activepieces ${edition} Edition`)
logger.info({
edition,
}, 'Activepieces Edition')
switch (edition) {
case ApEdition.CLOUD:
await app.register(appCredentialModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AuditEventEntity } from './audit-event-entity'
import {
ApplicationEvent,
} from '@activepieces/ee-shared'
import { rejectedPromiseHandler } from '@activepieces/server-shared'
import { logger, rejectedPromiseHandler } from '@activepieces/server-shared'
import {
apId,
assertEqual,
Expand Down Expand Up @@ -70,8 +70,7 @@ export const auditLogService = {
},
}

async function saveEvent(info: MetaInformation, rawEvent: AuditEventParam ) {

async function saveEvent(info: MetaInformation, rawEvent: AuditEventParam): Promise<void> {
const platformId = info.platformId
const platform = await platformService.getOneOrThrow(platformId)
if (!platform.auditLogEnabled) {
Expand All @@ -98,7 +97,8 @@ async function saveEvent(info: MetaInformation, rawEvent: AuditEventParam ) {
}
const valid = eventSchema(eventToSave)
assertEqual(valid, true, 'Event validation', 'true')
await auditLogRepo.save(eventToSave as ApplicationEvent)
const appEvent = await auditLogRepo.save(eventToSave as ApplicationEvent)
logger.info(appEvent, '[AuditEventService#saveEvent] Audit event saved')
}

type MetaInformation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export const memoryQueueManager: MemoryQueueManager = {
)
).filter((flow): flow is FlowWithRenewWebhook => flow !== null)

logger.info(
`Adding ${enabledRepeatingFlows.length} repeated flows to the queue manager.`,
)
logger.info(
`Adding ${enabledRenewWebhookFlows.length} renew flows to the queue manager.`,
)
logger.info({
enabledRepeatingFlowsCount: enabledRepeatingFlows.length,
}, 'Adding repeated flows to the queue manager.')
logger.info({
enabledRenewWebhookFlowsCount: enabledRenewWebhookFlows.length,
}, 'Adding renew flows to the queue manager.')

enabledRenewWebhookFlows.forEach(({ flow, scheduleOptions }) => {
this.add({
Expand Down Expand Up @@ -139,7 +139,7 @@ export const memoryQueueManager: MemoryQueueManager = {
const flowRuns = await flowRunRepo.findBy({
status: FlowRunStatus.PAUSED,
})
logger.info(`Adding ${flowRuns.length} flow runs to the queue manager.`)
logger.info({ flowRunsAdded: flowRuns.length }, 'Ading flow runs to the queue manager.')

Check warning on line 142 in packages/server/api/src/app/workers/flow-worker/queues/memory/memory-queue.ts

View workflow job for this annotation

GitHub Actions / Spell Check with Typos on Changed Files

"Ading" should be "Adding".
flowRuns.forEach((flowRun) => {
if (flowRun.pauseMetadata?.type === PauseType.DELAY) {
const delayPauseMetadata = flowRun.pauseMetadata as DelayPauseMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ export const webhookResponseWatcher = {
if (listener) {
listener(parsedMessasge)
}
logger.info(
`[engineWatcher#init] message=${parsedMessasge.requestId}`,
logger.info({ requestId: parsedMessasge.requestId }, '[engineWatcher#init]',
)
},
)
},
async oneTimeListener(requestId: string, timeoutRequest: boolean): Promise<EngineHttpResponse> {
logger.info(`[engineWatcher#listen] requestId=${requestId}`)
logger.info({ requestId }, '[engineWatcher#listen]')
return new Promise((resolve) => {
let timeout: NodeJS.Timeout
if (timeoutRequest) {
Expand Down Expand Up @@ -75,7 +74,7 @@ export const webhookResponseWatcher = {
workerHandlerId: string,
httpResponse: EngineHttpResponse,
): Promise<void> {
logger.info(`[engineWatcher#publish] requestId=${requestId}`)
logger.info({ requestId }, '[engineWatcher#publish]')
const message: EngineResponseWithId = { requestId, httpResponse }
await pubSub.publish(`engine-run:sync:${workerHandlerId}`, JSON.stringify(message))
},
Expand Down
2 changes: 0 additions & 2 deletions packages/server/worker/src/lib/sandbox/isolate-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ export class IsolateSandbox extends AbstractSandbox {
const currentDir = cwd()
const fullCmd = `${currentDir}/packages/server/api/src/assets/${this.isolateExecutableName} ${cmd}`

logger.info(`sandbox, command: ${fullCmd}`)

return new Promise((resolve, reject) => {
exec(fullCmd, (error, stdout: string | PromiseLike<string>, stderr) => {
if (error) {
Expand Down

0 comments on commit 97bb775

Please sign in to comment.