Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export type ComfyDesktop2TelemetryProperties = Record<
string,
ComfyDesktop2TelemetryValue | ComfyDesktop2TelemetryValue[]
>
export interface ComfyDesktop2Error {
message: string
stack?: string
}
export type ComfyDesktop2FirebaseAuthState =
| {
status: 'pending'
Expand Down Expand Up @@ -65,6 +69,8 @@ export interface ComfyDesktop2LogsBridge {
}
export interface ComfyDesktop2TelemetryBridge {
capture(event: string, properties?: ComfyDesktop2TelemetryProperties): void
/** Capture a hosted-frontend exception through Desktop's privacy and release-context boundary. */
captureException?(error: ComfyDesktop2Error, properties?: ComfyDesktop2TelemetryProperties): void
/** Report the hosted view's complete Firebase state for process-wide consensus. */
reportFirebaseAuthState?(state: ComfyDesktop2FirebaseAuthState): void
}
Expand Down
2 changes: 1 addition & 1 deletion packages/comfyui-desktop-bridge-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@comfyorg/comfyui-desktop-bridge-types",
"version": "0.2.0",
"version": "0.2.1",
"description": "TypeScript definitions for the Comfy Desktop hosted frontend bridge",
"type": "module",
"main": "./index.js",
Expand Down
12 changes: 11 additions & 1 deletion src/main/lib/ipc/registerTelemetryHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,24 @@ describe('registerTelemetryHandlers', () => {

listener('telemetry:captureException')(
{ sender: { id: 8 } },
{ message: 'boom', properties: { client: 'web', deployment: 'cloud' } }
{
message: 'boom',
stack: 'Error: boom\n at app.ts:1:1',
properties: {
client: 'web',
deployment: 'cloud',
error_type: 'workspace_auth_gate_initialization_failure'
}
}
)

const [err, sent] = mocks.captureExceptionAndForward.mock.calls[0]! as [
Error,
Record<string, unknown>
]
expect(err.message).toBe('boom')
expect(err.stack).toBe('Error: boom\n at app.ts:1:1')
expect(sent.error_type).toBe('workspace_auth_gate_initialization_failure')
expect(sent.deployment).toBe('local')
expect(sent.client).toBeUndefined()
})
Expand Down
6 changes: 4 additions & 2 deletions src/main/lib/telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,13 @@ describe('telemetry default event properties', () => {
setupTelemetry({ appVersion: '1.0.0', appEnv: 'prod', bind: 'id' })
exceptions.length = 0

telemetry.captureException(new Error('boom'), { foo: 'bar' })
telemetry.captureException(new Error('boom'), {
error_type: 'workspace_auth_gate_initialization_failure'
})

expect(exceptions).toHaveLength(1)
expect(exceptions[0]!.properties).toMatchObject({
foo: 'bar',
error_type: 'workspace_auth_gate_initialization_failure',
app_version: '1.0.0',
client: 'desktop',
$process_person_profile: false
Expand Down
21 changes: 21 additions & 0 deletions src/preload/comfyPreload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ function hostedBridge(): HostedFrontendBridge {
describe('comfyPreload model access bridge', () => {
beforeEach(() => {
mocks.invoke.mockReset()
mocks.send.mockReset()
})

it('forwards hosted frontend exceptions through the scrubbed Desktop telemetry channel', () => {
const bridge = hostedBridge()
const error = new Error('boom')
error.stack = 'Error: boom\n at app.ts:1:1'

bridge.Telemetry.captureException!(error, {
error_type: 'workspace_auth_gate_initialization_failure',
level: 'error'
})

expect(mocks.send).toHaveBeenCalledWith('telemetry:captureException', {
message: error.message,
stack: error.stack,
properties: {
error_type: 'workspace_auth_gate_initialization_failure',
level: 'error'
}
})
})

it('forwards the repository URL through the desktop2 IPC contract', async () => {
Expand Down
11 changes: 11 additions & 0 deletions src/preload/comfyPreload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,19 @@ const reportFirebaseAuthState: NonNullable<
ComfyDesktop2TelemetryBridge['reportFirebaseAuthState']
> = (state): void => sendTelemetry('telemetry:firebaseAuthState', state)

const captureException: NonNullable<ComfyDesktop2TelemetryBridge['captureException']> = (
error,
properties
): void =>
sendTelemetry('telemetry:captureException', {
message: error.message,
...(error.stack ? { stack: error.stack } : {}),
properties
})

const Telemetry: ComfyDesktop2TelemetryBridge = {
capture: (event, properties): void => sendTelemetry('telemetry:capture', { event, properties }),
captureException,
reportFirebaseAuthState
}

Expand Down
7 changes: 7 additions & 0 deletions src/types/comfyDesktopBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export type ComfyDesktop2TelemetryProperties = Record<
ComfyDesktop2TelemetryValue | ComfyDesktop2TelemetryValue[]
>

export interface ComfyDesktop2Error {
message: string
stack?: string
}

export type ComfyDesktop2FirebaseAuthState =
| { status: 'pending' }
| { status: 'signed_out' }
Expand All @@ -63,6 +68,8 @@ export interface ComfyDesktop2LogsBridge {

export interface ComfyDesktop2TelemetryBridge {
capture(event: string, properties?: ComfyDesktop2TelemetryProperties): void
/** Capture a hosted-frontend exception through Desktop's privacy and release-context boundary. */
captureException?(error: ComfyDesktop2Error, properties?: ComfyDesktop2TelemetryProperties): void
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
/** Report the hosted view's complete Firebase state for process-wide consensus. */
reportFirebaseAuthState?(state: ComfyDesktop2FirebaseAuthState): void
}
Expand Down
Loading