Add Desktop telemetry event sink#12802
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds desktop telemetry: bridge types, a DesktopTelemetryProvider with payload sanitization and many track* methods plus tests, a desktop-only initializer wired into startup, narrows the Desktop2 model-download bridge typing, and removes cloud-only telemetry guards so events emit for all distributions. ChangesDesktop Telemetry Infrastructure
Sequence Diagram(s)sequenceDiagram
participant AppCode as Application Code
participant Provider as DesktopTelemetryProvider
participant Sanitizer as Sanitize Properties
participant DesktopHost as window.__comfyDesktop2.Telemetry
AppCode->>Provider: trackRunButton() / trackWorkflowImported() / etc.
Provider->>Sanitizer: filter properties to primitives/arrays
Sanitizer-->>Provider: sanitized properties
Provider->>DesktopHost: capture(eventName, sanitizedProperties)
DesktopHost-->>Provider: (optional response)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright: ✅ 1667 passed, 0 failed · 3 flaky📊 Browser Reports
|
🎨 Storybook: ✅ Built — View Storybook |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #12802 +/- ##
===========================================
- Coverage 76.57% 61.57% -15.01%
===========================================
Files 1565 1456 -109
Lines 103439 75289 -28150
Branches 30579 21254 -9325
===========================================
- Hits 79212 46360 -32852
- Misses 23388 28575 +5187
+ Partials 839 354 -485
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1173 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
|
I agree with the goal of routing Desktop-hosted frontend telemetry through the Desktop telemetry pipeline, but I’m concerned about extending The recent missing-model download work treated this bridge as a pragmatic escape hatch to get off DOM/aria scraping. In particular, Comfy-Desktop#1044 describes the Desktop injection path as a stopgap/backwards-compatibility safety net, and ComfyUI_frontend#12710 lists defining/documenting the FE/Desktop2 bridge contract as follow-up work. This PR adds telemetry to the same surface. Telemetry is more cross-cutting than missing-model download capability, and once FE starts calling I think we should clarify this before merging:
I’m not opposed to a preload-exposed Desktop capability API in principle. My concern is that this PR turns a temporary bridge into a de facto official API without making the ownership, compatibility, and privacy/safety contract explicit. |
christian-byrne
left a comment
There was a problem hiding this comment.
I don't think desktop is a provider of tele.etry really. Can we just have posthog telemetry provider and have desktop opt in? Then we can remove the duplication. The global window bridge shouldn't exist either
|
@jaeone94 There is a misunderstanding here. The "stopgap" described in Comfy-Org/Comfy-Desktop#1044 is
On your specific questions:
Yes. Desktop 2 deliberately ships the stock released frontend — no fork, no Capability detection/versioning: key presence is the capability flag. FE calls Canonical typing: this PR already moves the bridge type out of the ad-hoc ambient declaration in Clone-safety: the FE provider filters properties to primitives and primitive arrays before invoking ( On the bridge contract, yes this wasn't documented, I added it to the PR now. |
|
There is an interesting issue, however. These two statements cannot be true at the same time:
What we will have to concede here is that the gate on this desktop telemetry provider will hinge on window.__comfyDesktop2?.Telemetry, but that is a telemetry reference in local-git. |
|
@christian-byrne This is the MAR-240 direction (Jacob's EventSink proposal, confirmed with Deep): the frontend keeps the event layer, Desktop registers as the sink and relays to PostHog. Desktop is the relay because it already owns the PostHog client, the person/device identity, and the consent toggle — and the frontend it hosts is the stock build, which ships no telemetry SDK. "Have desktop opt in" is how this works: Desktop opts in by exposing The bridge is the only channel Electron offers a hosted page short of forking the frontend — same pattern v1 used with Agreed the provider surface can be changed to a thin generic-capture refactor as a follow-up, if we want this. |
Summary
Paired change
MAR-240