1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Adding a system for checking audited data in events, so that PII can be removed by posthog processor.

This commit is contained in:
mike12345567 2023-02-24 16:45:33 +00:00
parent a293d3842f
commit 62501b0185
18 changed files with 290 additions and 77 deletions

View file

@ -225,6 +225,7 @@ export async function platformLogout(opts: PlatformLogoutOpts) {
const sessionIds = sessions.map(({ sessionId }) => sessionId) const sessionIds = sessions.map(({ sessionId }) => sessionId)
await invalidateSessions(userId, { sessionIds, reason: "logout" }) await invalidateSessions(userId, { sessionIds, reason: "logout" })
await events.auth.logout() const user = await userCache.getUser(userId)
await events.auth.logout(user.email)
await userCache.invalidateUser(userId) await userCache.invalidateUser(userId)
} }

View file

@ -24,7 +24,15 @@ export default class AuditLogsProcessor implements EventProcessor {
JobQueue.AUDIT_LOG JobQueue.AUDIT_LOG
) )
return AuditLogsProcessor.auditLogQueue.process(async job => { return AuditLogsProcessor.auditLogQueue.process(async job => {
await writeAuditLogs(job.data.event, job.data.properties, { let properties = job.data.properties
if (properties.audited) {
properties = {
...properties,
...properties.audited,
}
delete properties.audited
}
await writeAuditLogs(job.data.event, properties, {
userId: job.data.opts.userId, userId: job.data.opts.userId,
timestamp: job.data.opts.timestamp, timestamp: job.data.opts.timestamp,
appId: job.data.opts.appId, appId: job.data.opts.appId,

View file

@ -85,6 +85,9 @@ export default class PosthogProcessor implements EventProcessor {
if (properties.email) { if (properties.email) {
delete properties.email delete properties.email
} }
if (properties.audited) {
delete properties.audited
}
return properties return properties
} }

View file

@ -19,7 +19,9 @@ const created = async (app: App, timestamp?: string | number) => {
const properties: AppCreatedEvent = { const properties: AppCreatedEvent = {
appId: app.appId, appId: app.appId,
version: app.version, version: app.version,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_CREATED, properties, timestamp) await publishEvent(Event.APP_CREATED, properties, timestamp)
} }
@ -28,7 +30,9 @@ async function updated(app: App) {
const properties: AppUpdatedEvent = { const properties: AppUpdatedEvent = {
appId: app.appId, appId: app.appId,
version: app.version, version: app.version,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_UPDATED, properties) await publishEvent(Event.APP_UPDATED, properties)
} }
@ -36,7 +40,9 @@ async function updated(app: App) {
async function deleted(app: App) { async function deleted(app: App) {
const properties: AppDeletedEvent = { const properties: AppDeletedEvent = {
appId: app.appId, appId: app.appId,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_DELETED, properties) await publishEvent(Event.APP_DELETED, properties)
} }
@ -44,7 +50,9 @@ async function deleted(app: App) {
async function published(app: App, timestamp?: string | number) { async function published(app: App, timestamp?: string | number) {
const properties: AppPublishedEvent = { const properties: AppPublishedEvent = {
appId: app.appId, appId: app.appId,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_PUBLISHED, properties, timestamp) await publishEvent(Event.APP_PUBLISHED, properties, timestamp)
} }
@ -52,7 +60,9 @@ async function published(app: App, timestamp?: string | number) {
async function unpublished(app: App) { async function unpublished(app: App) {
const properties: AppUnpublishedEvent = { const properties: AppUnpublishedEvent = {
appId: app.appId, appId: app.appId,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_UNPUBLISHED, properties) await publishEvent(Event.APP_UNPUBLISHED, properties)
} }
@ -60,7 +70,9 @@ async function unpublished(app: App) {
async function fileImported(app: App) { async function fileImported(app: App) {
const properties: AppFileImportedEvent = { const properties: AppFileImportedEvent = {
appId: app.appId, appId: app.appId,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_FILE_IMPORTED, properties) await publishEvent(Event.APP_FILE_IMPORTED, properties)
} }
@ -69,7 +81,9 @@ async function templateImported(app: App, templateKey: string) {
const properties: AppTemplateImportedEvent = { const properties: AppTemplateImportedEvent = {
appId: app.appId, appId: app.appId,
templateKey, templateKey,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_TEMPLATE_IMPORTED, properties) await publishEvent(Event.APP_TEMPLATE_IMPORTED, properties)
} }
@ -83,7 +97,9 @@ async function versionUpdated(
appId: app.appId, appId: app.appId,
currentVersion, currentVersion,
updatedToVersion, updatedToVersion,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_VERSION_UPDATED, properties) await publishEvent(Event.APP_VERSION_UPDATED, properties)
} }
@ -97,7 +113,9 @@ async function versionReverted(
appId: app.appId, appId: app.appId,
currentVersion, currentVersion,
revertedToVersion, revertedToVersion,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_VERSION_REVERTED, properties) await publishEvent(Event.APP_VERSION_REVERTED, properties)
} }
@ -105,7 +123,9 @@ async function versionReverted(
async function reverted(app: App) { async function reverted(app: App) {
const properties: AppRevertedEvent = { const properties: AppRevertedEvent = {
appId: app.appId, appId: app.appId,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_REVERTED, properties) await publishEvent(Event.APP_REVERTED, properties)
} }
@ -113,7 +133,9 @@ async function reverted(app: App) {
async function exported(app: App) { async function exported(app: App) {
const properties: AppExportedEvent = { const properties: AppExportedEvent = {
appId: app.appId, appId: app.appId,
name: app.name, audited: {
name: app.name,
},
} }
await publishEvent(Event.APP_EXPORTED, properties) await publishEvent(Event.APP_EXPORTED, properties)
} }

View file

@ -17,7 +17,9 @@ async function login(source: LoginSource, email: string) {
const properties: LoginEvent = { const properties: LoginEvent = {
userId: identity.id, userId: identity.id,
source, source,
email, audited: {
email,
},
} }
await publishEvent(Event.AUTH_LOGIN, properties) await publishEvent(Event.AUTH_LOGIN, properties)
} }
@ -26,7 +28,9 @@ async function logout(email: string) {
const identity = await identification.getCurrentIdentity() const identity = await identification.getCurrentIdentity()
const properties: LogoutEvent = { const properties: LogoutEvent = {
userId: identity.id, userId: identity.id,
email, audited: {
email,
},
} }
await publishEvent(Event.AUTH_LOGOUT, properties) await publishEvent(Event.AUTH_LOGOUT, properties)
} }

View file

@ -18,6 +18,9 @@ async function created(automation: Automation, timestamp?: string | number) {
automationId: automation._id as string, automationId: automation._id as string,
triggerId: automation.definition?.trigger?.id, triggerId: automation.definition?.trigger?.id,
triggerType: automation.definition?.trigger?.stepId, triggerType: automation.definition?.trigger?.stepId,
audited: {
name: automation.name,
},
} }
await publishEvent(Event.AUTOMATION_CREATED, properties, timestamp) await publishEvent(Event.AUTOMATION_CREATED, properties, timestamp)
} }
@ -38,6 +41,9 @@ async function deleted(automation: Automation) {
automationId: automation._id as string, automationId: automation._id as string,
triggerId: automation.definition?.trigger?.id, triggerId: automation.definition?.trigger?.id,
triggerType: automation.definition?.trigger?.stepId, triggerType: automation.definition?.trigger?.stepId,
audited: {
name: automation.name,
},
} }
await publishEvent(Event.AUTOMATION_DELETED, properties) await publishEvent(Event.AUTOMATION_DELETED, properties)
} }
@ -71,6 +77,9 @@ async function stepCreated(
triggerType: automation.definition?.trigger?.stepId, triggerType: automation.definition?.trigger?.stepId,
stepId: step.id!, stepId: step.id!,
stepType: step.stepId, stepType: step.stepId,
audited: {
name: automation.name,
},
} }
await publishEvent(Event.AUTOMATION_STEP_CREATED, properties, timestamp) await publishEvent(Event.AUTOMATION_STEP_CREATED, properties, timestamp)
} }
@ -83,6 +92,9 @@ async function stepDeleted(automation: Automation, step: AutomationStep) {
triggerType: automation.definition?.trigger?.stepId, triggerType: automation.definition?.trigger?.stepId,
stepId: step.id!, stepId: step.id!,
stepType: step.stepId, stepType: step.stepId,
audited: {
name: automation.name,
},
} }
await publishEvent(Event.AUTOMATION_STEP_DELETED, properties) await publishEvent(Event.AUTOMATION_STEP_DELETED, properties)
} }

View file

@ -15,7 +15,9 @@ import {
async function created(group: UserGroup, timestamp?: number) { async function created(group: UserGroup, timestamp?: number) {
const properties: GroupCreatedEvent = { const properties: GroupCreatedEvent = {
groupId: group._id as string, groupId: group._id as string,
name: group.name, audited: {
name: group.name,
},
} }
await publishEvent(Event.USER_GROUP_CREATED, properties, timestamp) await publishEvent(Event.USER_GROUP_CREATED, properties, timestamp)
} }
@ -23,7 +25,9 @@ async function created(group: UserGroup, timestamp?: number) {
async function updated(group: UserGroup) { async function updated(group: UserGroup) {
const properties: GroupUpdatedEvent = { const properties: GroupUpdatedEvent = {
groupId: group._id as string, groupId: group._id as string,
name: group.name, audited: {
name: group.name,
},
} }
await publishEvent(Event.USER_GROUP_UPDATED, properties) await publishEvent(Event.USER_GROUP_UPDATED, properties)
} }
@ -31,7 +35,9 @@ async function updated(group: UserGroup) {
async function deleted(group: UserGroup) { async function deleted(group: UserGroup) {
const properties: GroupDeletedEvent = { const properties: GroupDeletedEvent = {
groupId: group._id as string, groupId: group._id as string,
name: group.name, audited: {
name: group.name,
},
} }
await publishEvent(Event.USER_GROUP_DELETED, properties) await publishEvent(Event.USER_GROUP_DELETED, properties)
} }
@ -40,7 +46,9 @@ async function usersAdded(count: number, group: UserGroup) {
const properties: GroupUsersAddedEvent = { const properties: GroupUsersAddedEvent = {
count, count,
groupId: group._id as string, groupId: group._id as string,
name: group.name, audited: {
name: group.name,
},
} }
await publishEvent(Event.USER_GROUP_USERS_ADDED, properties) await publishEvent(Event.USER_GROUP_USERS_ADDED, properties)
} }
@ -49,7 +57,9 @@ async function usersDeleted(count: number, group: UserGroup) {
const properties: GroupUsersDeletedEvent = { const properties: GroupUsersDeletedEvent = {
count, count,
groupId: group._id as string, groupId: group._id as string,
name: group.name, audited: {
name: group.name,
},
} }
await publishEvent(Event.USER_GROUP_USERS_REMOVED, properties) await publishEvent(Event.USER_GROUP_USERS_REMOVED, properties)
} }
@ -65,8 +75,10 @@ async function createdOnboarding(groupId: string) {
async function permissionsEdited(group: UserGroup) { async function permissionsEdited(group: UserGroup) {
const properties: GroupPermissionsEditedEvent = { const properties: GroupPermissionsEditedEvent = {
permissions: group.roles!, permissions: group.roles!,
name: group.name,
groupId: group._id as string, groupId: group._id as string,
audited: {
name: group.name,
},
} }
await publishEvent(Event.USER_GROUP_PERMISSIONS_EDITED, properties) await publishEvent(Event.USER_GROUP_PERMISSIONS_EDITED, properties)
} }

View file

@ -11,6 +11,9 @@ async function created(screen: Screen, timestamp?: string | number) {
layoutId: screen.layoutId, layoutId: screen.layoutId,
screenId: screen._id as string, screenId: screen._id as string,
roleId: screen.routing.roleId, roleId: screen.routing.roleId,
audited: {
name: screen.routing?.route,
},
} }
await publishEvent(Event.SCREEN_CREATED, properties, timestamp) await publishEvent(Event.SCREEN_CREATED, properties, timestamp)
} }
@ -20,6 +23,9 @@ async function deleted(screen: Screen) {
layoutId: screen.layoutId, layoutId: screen.layoutId,
screenId: screen._id as string, screenId: screen._id as string,
roleId: screen.routing.roleId, roleId: screen.routing.roleId,
audited: {
name: screen.routing?.route,
},
} }
await publishEvent(Event.SCREEN_DELETED, properties) await publishEvent(Event.SCREEN_DELETED, properties)
} }

View file

@ -13,6 +13,9 @@ import {
async function created(table: Table, timestamp?: string | number) { async function created(table: Table, timestamp?: string | number) {
const properties: TableCreatedEvent = { const properties: TableCreatedEvent = {
tableId: table._id as string, tableId: table._id as string,
audited: {
name: table.name,
},
} }
await publishEvent(Event.TABLE_CREATED, properties, timestamp) await publishEvent(Event.TABLE_CREATED, properties, timestamp)
} }
@ -20,6 +23,9 @@ async function created(table: Table, timestamp?: string | number) {
async function updated(table: Table) { async function updated(table: Table) {
const properties: TableUpdatedEvent = { const properties: TableUpdatedEvent = {
tableId: table._id as string, tableId: table._id as string,
audited: {
name: table.name,
},
} }
await publishEvent(Event.TABLE_UPDATED, properties) await publishEvent(Event.TABLE_UPDATED, properties)
} }
@ -27,6 +33,9 @@ async function updated(table: Table) {
async function deleted(table: Table) { async function deleted(table: Table) {
const properties: TableDeletedEvent = { const properties: TableDeletedEvent = {
tableId: table._id as string, tableId: table._id as string,
audited: {
name: table.name,
},
} }
await publishEvent(Event.TABLE_DELETED, properties) await publishEvent(Event.TABLE_DELETED, properties)
} }
@ -35,6 +44,9 @@ async function exported(table: Table, format: TableExportFormat) {
const properties: TableExportedEvent = { const properties: TableExportedEvent = {
tableId: table._id as string, tableId: table._id as string,
format, format,
audited: {
name: table.name,
},
} }
await publishEvent(Event.TABLE_EXPORTED, properties) await publishEvent(Event.TABLE_EXPORTED, properties)
} }
@ -42,6 +54,9 @@ async function exported(table: Table, format: TableExportFormat) {
async function imported(table: Table) { async function imported(table: Table) {
const properties: TableImportedEvent = { const properties: TableImportedEvent = {
tableId: table._id as string, tableId: table._id as string,
audited: {
name: table.name,
},
} }
await publishEvent(Event.TABLE_IMPORTED, properties) await publishEvent(Event.TABLE_IMPORTED, properties)
} }

View file

@ -19,7 +19,9 @@ import {
async function created(user: User, timestamp?: number) { async function created(user: User, timestamp?: number) {
const properties: UserCreatedEvent = { const properties: UserCreatedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_CREATED, properties, timestamp) await publishEvent(Event.USER_CREATED, properties, timestamp)
} }
@ -27,7 +29,9 @@ async function created(user: User, timestamp?: number) {
async function updated(user: User) { async function updated(user: User) {
const properties: UserUpdatedEvent = { const properties: UserUpdatedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_UPDATED, properties) await publishEvent(Event.USER_UPDATED, properties)
} }
@ -35,7 +39,9 @@ async function updated(user: User) {
async function deleted(user: User) { async function deleted(user: User) {
const properties: UserDeletedEvent = { const properties: UserDeletedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_DELETED, properties) await publishEvent(Event.USER_DELETED, properties)
} }
@ -43,7 +49,9 @@ async function deleted(user: User) {
export async function onboardingComplete(user: User) { export async function onboardingComplete(user: User) {
const properties: UserOnboardingEvent = { const properties: UserOnboardingEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_ONBOARDING_COMPLETE, properties) await publishEvent(Event.USER_ONBOARDING_COMPLETE, properties)
} }
@ -53,7 +61,9 @@ export async function onboardingComplete(user: User) {
async function permissionAdminAssigned(user: User, timestamp?: number) { async function permissionAdminAssigned(user: User, timestamp?: number) {
const properties: UserPermissionAssignedEvent = { const properties: UserPermissionAssignedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent( await publishEvent(
Event.USER_PERMISSION_ADMIN_ASSIGNED, Event.USER_PERMISSION_ADMIN_ASSIGNED,
@ -65,7 +75,9 @@ async function permissionAdminAssigned(user: User, timestamp?: number) {
async function permissionAdminRemoved(user: User) { async function permissionAdminRemoved(user: User) {
const properties: UserPermissionRemovedEvent = { const properties: UserPermissionRemovedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_PERMISSION_ADMIN_REMOVED, properties) await publishEvent(Event.USER_PERMISSION_ADMIN_REMOVED, properties)
} }
@ -73,7 +85,9 @@ async function permissionAdminRemoved(user: User) {
async function permissionBuilderAssigned(user: User, timestamp?: number) { async function permissionBuilderAssigned(user: User, timestamp?: number) {
const properties: UserPermissionAssignedEvent = { const properties: UserPermissionAssignedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent( await publishEvent(
Event.USER_PERMISSION_BUILDER_ASSIGNED, Event.USER_PERMISSION_BUILDER_ASSIGNED,
@ -85,7 +99,9 @@ async function permissionBuilderAssigned(user: User, timestamp?: number) {
async function permissionBuilderRemoved(user: User) { async function permissionBuilderRemoved(user: User) {
const properties: UserPermissionRemovedEvent = { const properties: UserPermissionRemovedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_PERMISSION_BUILDER_REMOVED, properties) await publishEvent(Event.USER_PERMISSION_BUILDER_REMOVED, properties)
} }
@ -93,14 +109,20 @@ async function permissionBuilderRemoved(user: User) {
// INVITE // INVITE
async function invited(email: string) { async function invited(email: string) {
const properties: UserInvitedEvent = { email } const properties: UserInvitedEvent = {
audited: {
email,
},
}
await publishEvent(Event.USER_INVITED, properties) await publishEvent(Event.USER_INVITED, properties)
} }
async function inviteAccepted(user: User) { async function inviteAccepted(user: User) {
const properties: UserInviteAcceptedEvent = { const properties: UserInviteAcceptedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_INVITED_ACCEPTED, properties) await publishEvent(Event.USER_INVITED_ACCEPTED, properties)
} }
@ -110,7 +132,9 @@ async function inviteAccepted(user: User) {
async function passwordForceReset(user: User) { async function passwordForceReset(user: User) {
const properties: UserPasswordForceResetEvent = { const properties: UserPasswordForceResetEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_PASSWORD_FORCE_RESET, properties) await publishEvent(Event.USER_PASSWORD_FORCE_RESET, properties)
} }
@ -118,7 +142,9 @@ async function passwordForceReset(user: User) {
async function passwordUpdated(user: User) { async function passwordUpdated(user: User) {
const properties: UserPasswordUpdatedEvent = { const properties: UserPasswordUpdatedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_PASSWORD_UPDATED, properties) await publishEvent(Event.USER_PASSWORD_UPDATED, properties)
} }
@ -126,7 +152,9 @@ async function passwordUpdated(user: User) {
async function passwordResetRequested(user: User) { async function passwordResetRequested(user: User) {
const properties: UserPasswordResetRequestedEvent = { const properties: UserPasswordResetRequestedEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_PASSWORD_RESET_REQUESTED, properties) await publishEvent(Event.USER_PASSWORD_RESET_REQUESTED, properties)
} }
@ -134,7 +162,9 @@ async function passwordResetRequested(user: User) {
async function passwordReset(user: User) { async function passwordReset(user: User) {
const properties: UserPasswordResetEvent = { const properties: UserPasswordResetEvent = {
userId: user._id as string, userId: user._id as string,
email: user.email, audited: {
email: user.email,
},
} }
await publishEvent(Event.USER_PASSWORD_RESET, properties) await publishEvent(Event.USER_PASSWORD_RESET, properties)
} }

View file

@ -3,61 +3,83 @@ import { BaseEvent } from "./event"
export interface AppCreatedEvent extends BaseEvent { export interface AppCreatedEvent extends BaseEvent {
appId: string appId: string
version: string version: string
name: string audited: {
name: string
}
} }
export interface AppUpdatedEvent extends BaseEvent { export interface AppUpdatedEvent extends BaseEvent {
appId: string appId: string
version: string version: string
name: string audited: {
name: string
}
} }
export interface AppDeletedEvent extends BaseEvent { export interface AppDeletedEvent extends BaseEvent {
appId: string appId: string
name: string audited: {
name: string
}
} }
export interface AppPublishedEvent extends BaseEvent { export interface AppPublishedEvent extends BaseEvent {
appId: string appId: string
name: string audited: {
name: string
}
} }
export interface AppUnpublishedEvent extends BaseEvent { export interface AppUnpublishedEvent extends BaseEvent {
appId: string appId: string
name: string audited: {
name: string
}
} }
export interface AppFileImportedEvent extends BaseEvent { export interface AppFileImportedEvent extends BaseEvent {
appId: string appId: string
name: string audited: {
name: string
}
} }
export interface AppTemplateImportedEvent extends BaseEvent { export interface AppTemplateImportedEvent extends BaseEvent {
appId: string appId: string
templateKey: string templateKey: string
name: string audited: {
name: string
}
} }
export interface AppVersionUpdatedEvent extends BaseEvent { export interface AppVersionUpdatedEvent extends BaseEvent {
appId: string appId: string
currentVersion: string currentVersion: string
updatedToVersion: string updatedToVersion: string
name: string audited: {
name: string
}
} }
export interface AppVersionRevertedEvent extends BaseEvent { export interface AppVersionRevertedEvent extends BaseEvent {
appId: string appId: string
currentVersion: string currentVersion: string
revertedToVersion: string revertedToVersion: string
name: string audited: {
name: string
}
} }
export interface AppRevertedEvent extends BaseEvent { export interface AppRevertedEvent extends BaseEvent {
appId: string appId: string
name: string audited: {
name: string
}
} }
export interface AppExportedEvent extends BaseEvent { export interface AppExportedEvent extends BaseEvent {
appId: string appId: string
name: string audited: {
name: string
}
} }

View file

@ -7,12 +7,16 @@ export type SSOType = ConfigType.OIDC | ConfigType.GOOGLE
export interface LoginEvent extends BaseEvent { export interface LoginEvent extends BaseEvent {
userId: string userId: string
source: LoginSource source: LoginSource
email: string audited: {
email: string
}
} }
export interface LogoutEvent extends BaseEvent { export interface LogoutEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface SSOCreatedEvent extends BaseEvent { export interface SSOCreatedEvent extends BaseEvent {

View file

@ -5,6 +5,9 @@ export interface AutomationCreatedEvent extends BaseEvent {
automationId: string automationId: string
triggerId: string triggerId: string
triggerType: string triggerType: string
audited: {
name: string
}
} }
export interface AutomationTriggerUpdatedEvent extends BaseEvent { export interface AutomationTriggerUpdatedEvent extends BaseEvent {
@ -19,6 +22,9 @@ export interface AutomationDeletedEvent extends BaseEvent {
automationId: string automationId: string
triggerId: string triggerId: string
triggerType: string triggerType: string
audited: {
name: string
}
} }
export interface AutomationTestedEvent extends BaseEvent { export interface AutomationTestedEvent extends BaseEvent {
@ -35,6 +41,9 @@ export interface AutomationStepCreatedEvent extends BaseEvent {
triggerType: string triggerType: string
stepId: string stepId: string
stepType: string stepType: string
audited: {
name: string
}
} }
export interface AutomationStepDeletedEvent extends BaseEvent { export interface AutomationStepDeletedEvent extends BaseEvent {
@ -44,6 +53,9 @@ export interface AutomationStepDeletedEvent extends BaseEvent {
triggerType: string triggerType: string
stepId: string stepId: string
stepType: string stepType: string
audited: {
name: string
}
} }
export interface AutomationsRunEvent extends BaseEvent { export interface AutomationsRunEvent extends BaseEvent {

View file

@ -262,11 +262,11 @@ export const AuditedEventFriendlyName: Record<Event, string | undefined> = {
[Event.QUERY_PREVIEWED]: undefined, [Event.QUERY_PREVIEWED]: undefined,
// TABLE // TABLE
[Event.TABLE_CREATED]: `Table created`, [Event.TABLE_CREATED]: `Table "{{ name }}" created`,
[Event.TABLE_UPDATED]: `Table updated`, [Event.TABLE_UPDATED]: `Table "{{ name }}" updated`,
[Event.TABLE_DELETED]: `Table deleted`, [Event.TABLE_DELETED]: `Table "{{ name }}" deleted`,
[Event.TABLE_EXPORTED]: `Table exported`, [Event.TABLE_EXPORTED]: `Table "{{ name }}" exported`,
[Event.TABLE_IMPORTED]: `Table imported`, [Event.TABLE_IMPORTED]: `Table "{{ name }}" imported`,
[Event.TABLE_DATA_IMPORTED]: `Data imported to table`, [Event.TABLE_DATA_IMPORTED]: `Data imported to table`,
// ROWS // ROWS
@ -274,17 +274,17 @@ export const AuditedEventFriendlyName: Record<Event, string | undefined> = {
[Event.ROWS_IMPORTED]: `Rows imported`, [Event.ROWS_IMPORTED]: `Rows imported`,
// AUTOMATION // AUTOMATION
[Event.AUTOMATION_CREATED]: `Automation created`, [Event.AUTOMATION_CREATED]: `Automation "{{ name }}" created`,
[Event.AUTOMATION_DELETED]: `Automation deleted`, [Event.AUTOMATION_DELETED]: `Automation "{{ name }}" deleted`,
[Event.AUTOMATION_STEP_CREATED]: `Automation "{{ name }}" step added`,
[Event.AUTOMATION_STEP_DELETED]: `Automation "{{ name }}" step removed`,
[Event.AUTOMATION_TESTED]: undefined, [Event.AUTOMATION_TESTED]: undefined,
[Event.AUTOMATIONS_RUN]: undefined, [Event.AUTOMATIONS_RUN]: undefined,
[Event.AUTOMATION_STEP_CREATED]: undefined,
[Event.AUTOMATION_STEP_DELETED]: undefined,
[Event.AUTOMATION_TRIGGER_UPDATED]: undefined, [Event.AUTOMATION_TRIGGER_UPDATED]: undefined,
// SCREEN // SCREEN
[Event.SCREEN_CREATED]: `Screen created`, [Event.SCREEN_CREATED]: `Screen "{{ name }}" created`,
[Event.SCREEN_DELETED]: `Screen deleted`, [Event.SCREEN_DELETED]: `Screen "{{ name }}" deleted`,
// COMPONENT // COMPONENT
[Event.COMPONENT_CREATED]: `Component created`, [Event.COMPONENT_CREATED]: `Component created`,
@ -375,6 +375,11 @@ export interface BaseEvent {
installationId?: string installationId?: string
tenantId?: string tenantId?: string
hosting?: Hosting hosting?: Hosting
// any props in the audited section will be removed before passing events
// up out of system (purely for use with auditing)
audited?: {
[key: string]: any
}
} }
export type TableExportFormat = "json" | "csv" export type TableExportFormat = "json" | "csv"

View file

@ -4,10 +4,16 @@ export interface ScreenCreatedEvent extends BaseEvent {
screenId: string screenId: string
layoutId?: string layoutId?: string
roleId: string roleId: string
audited: {
name: string
}
} }
export interface ScreenDeletedEvent extends BaseEvent { export interface ScreenDeletedEvent extends BaseEvent {
screenId: string screenId: string
layoutId?: string layoutId?: string
roleId: string roleId: string
audited: {
name: string
}
} }

View file

@ -2,21 +2,36 @@ import { BaseEvent, TableExportFormat } from "./event"
export interface TableCreatedEvent extends BaseEvent { export interface TableCreatedEvent extends BaseEvent {
tableId: string tableId: string
audited: {
name: string
}
} }
export interface TableUpdatedEvent extends BaseEvent { export interface TableUpdatedEvent extends BaseEvent {
tableId: string tableId: string
audited: {
name: string
}
} }
export interface TableDeletedEvent extends BaseEvent { export interface TableDeletedEvent extends BaseEvent {
tableId: string tableId: string
audited: {
name: string
}
} }
export interface TableExportedEvent extends BaseEvent { export interface TableExportedEvent extends BaseEvent {
tableId: string tableId: string
format: TableExportFormat format: TableExportFormat
audited: {
name: string
}
} }
export interface TableImportedEvent extends BaseEvent { export interface TableImportedEvent extends BaseEvent {
tableId: string tableId: string
audited: {
name: string
}
} }

View file

@ -2,60 +2,84 @@ import { BaseEvent } from "./event"
export interface UserCreatedEvent extends BaseEvent { export interface UserCreatedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserUpdatedEvent extends BaseEvent { export interface UserUpdatedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserDeletedEvent extends BaseEvent { export interface UserDeletedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserOnboardingEvent extends BaseEvent { export interface UserOnboardingEvent extends BaseEvent {
userId: string userId: string
step?: string step?: string
email: string audited: {
email: string
}
} }
export interface UserPermissionAssignedEvent extends BaseEvent { export interface UserPermissionAssignedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserPermissionRemovedEvent extends BaseEvent { export interface UserPermissionRemovedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserInvitedEvent extends BaseEvent { export interface UserInvitedEvent extends BaseEvent {
email: string audited: {
email: string
}
} }
export interface UserInviteAcceptedEvent extends BaseEvent { export interface UserInviteAcceptedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserPasswordForceResetEvent extends BaseEvent { export interface UserPasswordForceResetEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserPasswordUpdatedEvent extends BaseEvent { export interface UserPasswordUpdatedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserPasswordResetRequestedEvent extends BaseEvent { export interface UserPasswordResetRequestedEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }
export interface UserPasswordResetEvent extends BaseEvent { export interface UserPasswordResetEvent extends BaseEvent {
userId: string userId: string
email: string audited: {
email: string
}
} }

View file

@ -2,29 +2,39 @@ import { BaseEvent } from "./event"
export interface GroupCreatedEvent extends BaseEvent { export interface GroupCreatedEvent extends BaseEvent {
groupId: string groupId: string
name: string audited: {
name: string
}
} }
export interface GroupUpdatedEvent extends BaseEvent { export interface GroupUpdatedEvent extends BaseEvent {
groupId: string groupId: string
name: string audited: {
name: string
}
} }
export interface GroupDeletedEvent extends BaseEvent { export interface GroupDeletedEvent extends BaseEvent {
groupId: string groupId: string
name: string audited: {
name: string
}
} }
export interface GroupUsersAddedEvent extends BaseEvent { export interface GroupUsersAddedEvent extends BaseEvent {
count: number count: number
groupId: string groupId: string
name: string audited: {
name: string
}
} }
export interface GroupUsersDeletedEvent extends BaseEvent { export interface GroupUsersDeletedEvent extends BaseEvent {
count: number count: number
groupId: string groupId: string
name: string audited: {
name: string
}
} }
export interface GroupAddedOnboardingEvent extends BaseEvent { export interface GroupAddedOnboardingEvent extends BaseEvent {
@ -34,6 +44,8 @@ export interface GroupAddedOnboardingEvent extends BaseEvent {
export interface GroupPermissionsEditedEvent extends BaseEvent { export interface GroupPermissionsEditedEvent extends BaseEvent {
permissions: Record<string, string> permissions: Record<string, string>
name: string
groupId: string groupId: string
audited: {
name: string
}
} }