MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / createAudit

Function createAudit

packages/web/src/ee/features/audit/audit.ts:9–34  ·  view source on GitHub ↗
(event: Omit<AuditEvent, 'sourcebotVersion'>)

Source from the content-addressed store, hash-verified

7const logger = createLogger('audit-service');
8
9export async function createAudit(event: Omit<AuditEvent, 'sourcebotVersion'>): Promise<Audit | null> {
10 const auditLogsEnabled = (env.SOURCEBOT_EE_AUDIT_LOGGING_ENABLED === 'true') && await hasEntitlement("audit");
11 if (!auditLogsEnabled) {
12 return null;
13 }
14
15 try {
16 const audit = await __unsafePrisma.audit.create({
17 data: {
18 action: event.action,
19 actorId: event.actor.id,
20 actorType: event.actor.type,
21 targetId: event.target.id,
22 targetType: event.target.type,
23 sourcebotVersion: SOURCEBOT_VERSION,
24 metadata: event.metadata,
25 orgId: event.orgId,
26 },
27 });
28
29 return audit;
30 } catch (error) {
31 logger.error(`Error creating audit event: ${error}`, { event });
32 return null;
33 }
34}

Callers 15

auth.tsFile · 0.90
createApiKeyFunction · 0.90
deleteApiKeyFunction · 0.90
onCreateUserFunction · 0.90
removeMemberFromOrgFunction · 0.90
leaveOrgFunction · 0.90
failAuditCallbackFunction · 0.90
approveAccountRequestFunction · 0.90
createInvitesFunction · 0.90
getFileSourceFunction · 0.90
getFileBlameFunction · 0.90
getTreeFunction · 0.90

Calls 1

hasEntitlementFunction · 0.90

Tested by

no test coverage detected