Skip to content

Commit 80cdd12

Browse files
committed
fix(posthog): capture currentWorkflowId synchronously before async import to avoid stale closure
1 parent b1a5816 commit 80cdd12

File tree

1 file changed

+4
-2
lines changed
  • apps/sim/stores/workflows/workflow

1 file changed

+4
-2
lines changed

apps/sim/stores/workflows/workflow/store.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,12 @@ export const useWorkflowStore = create<WorkflowStore>()(
317317
}
318318

319319
if (blocks.length === 1) {
320+
const workflowId = get().currentWorkflowId ?? 'unknown'
320321
import('@/lib/posthog/client')
321322
.then(({ captureClientEvent }) => {
322323
captureClientEvent('block_added', {
323324
block_type: blocks[0].type,
324-
workflow_id: get().currentWorkflowId ?? 'unknown',
325+
workflow_id: workflowId,
325326
})
326327
})
327328
.catch(() => {})
@@ -389,11 +390,12 @@ export const useWorkflowStore = create<WorkflowStore>()(
389390
if (ids.length === 1) {
390391
const blockType = currentBlocks[ids[0]]?.type
391392
if (blockType) {
393+
const workflowId = get().currentWorkflowId ?? 'unknown'
392394
import('@/lib/posthog/client')
393395
.then(({ captureClientEvent }) => {
394396
captureClientEvent('block_removed', {
395397
block_type: blockType,
396-
workflow_id: get().currentWorkflowId ?? 'unknown',
398+
workflow_id: workflowId,
397399
})
398400
})
399401
.catch(() => {})

0 commit comments

Comments
 (0)