Skip to content

Commit 749ed2c

Browse files
committed
fix audit and posthog: FOLDER_RESTORED action on restore, fire folder_moved event separately from file_moved
1 parent 4042b99 commit 749ed2c

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

  • apps/sim/app/api/workspaces/[id]/files

apps/sim/app/api/workspaces/[id]/files/folders/[folderId]/restore/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const POST = withRouteHandler(
4343
actorId: session.user.id,
4444
actorName: session.user.name,
4545
actorEmail: session.user.email,
46-
action: AuditAction.FOLDER_UPDATED,
46+
action: AuditAction.FOLDER_RESTORED,
4747
resourceType: AuditResourceType.FOLDER,
4848
resourceId: folderId,
4949
resourceName: folder.name,

apps/sim/app/api/workspaces/[id]/files/move/route.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,22 @@ export const POST = withRouteHandler(
4040
folderIds,
4141
targetFolderId,
4242
})
43-
captureServerEvent(
44-
session.user.id,
45-
'file_moved',
46-
{ workspace_id: workspaceId, file_count: fileIds.length, folder_count: folderIds.length },
47-
{ groups: { workspace: workspaceId } }
48-
)
43+
if (fileIds.length > 0) {
44+
captureServerEvent(
45+
session.user.id,
46+
'file_moved',
47+
{ workspace_id: workspaceId, file_count: fileIds.length, folder_count: folderIds.length },
48+
{ groups: { workspace: workspaceId } }
49+
)
50+
}
51+
if (folderIds.length > 0) {
52+
captureServerEvent(
53+
session.user.id,
54+
'folder_moved',
55+
{ workspace_id: workspaceId, file_count: fileIds.length, folder_count: folderIds.length },
56+
{ groups: { workspace: workspaceId } }
57+
)
58+
}
4959
if (fileIds.length > 0) {
5060
recordAudit({
5161
workspaceId,

0 commit comments

Comments
 (0)