Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/lib/executionTap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,34 @@ describe('executionTap', () => {
expect(events).toContain('comfy.desktop.execution.completed')
})

it('tags every emission with source_layer="comfyui" so engine-origin events are filterable in PostHog', () => {
const tap = createExecutionTap({ installationId: 'inst-1' })
tap.ingest(
[
'got prompt',
'Prompt executed in 1.0 seconds',
'Failed to validate prompt for output 7:',
'Traceback (most recent call last):',
' File "x.py", line 1, in <module>',
' raise RuntimeError("boom")',
'RuntimeError: boom',
'',
'next-line'
].join('\n'),
'stderr'
)
tap.flushSummary()
// Cover every event family this tap emits — none should leak without the tag.
const families = new Set(captured.map((c) => c.event))
expect(families).toContain('comfy.desktop.execution.started')
expect(families).toContain('comfy.desktop.execution.completed')
expect(families).toContain('comfy.desktop.execution.error')
expect(families).toContain('comfy.desktop.execution.session_summary')
for (const c of captured) {
expect(c.ctx['source_layer']).toBe('comfyui')
}
})

it('redacts Bearer tokens and api keys from traceback messages (secret scrub)', () => {
const bearer = 'Bearer ' + 'a'.repeat(30)
const apiKey = 's' + 'k-' + 'a'.repeat(24)
Expand Down
7 changes: 6 additions & 1 deletion src/main/lib/executionTap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ export function createExecutionTap(opts: {
tracebackPhase: 'none'
}

// Every event emitted from this tap originates in the ComfyUI Python
// subprocess (parsed from its stdout/stderr). Tagging at the baseContext
// level lets PostHog separate engine-origin errors from any future
// shell-origin emissions without renaming the event family.
const baseContext = {
installation_id: state.installationId,
variant: state.variant,
release: state.release
release: state.release,
source_layer: 'comfyui' as const
}

function pushPromptStart(): void {
Expand Down
Loading