-
Notifications
You must be signed in to change notification settings - Fork 499
feat: add toolkit node tracking to execution telemetry #9073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+250
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * Toolkit (Essentials) node detection constants. | ||
| * | ||
| * Used by telemetry to track toolkit node adoption and popularity. | ||
| * Only novel nodes — basic nodes (LoadImage, SaveImage, etc.) are excluded. | ||
| * | ||
| * Source: https://www.notion.so/comfy-org/2fe6d73d365080d0a951d14cdf540778 | ||
| */ | ||
|
|
||
| /** | ||
| * Canonical node type names for individual toolkit nodes. | ||
| */ | ||
| export const TOOLKIT_NODE_NAMES: ReadonlySet<string> = new Set([ | ||
| // Image Tools | ||
| 'ImageCrop', | ||
| 'ImageRotate', | ||
| 'ImageBlur', | ||
| 'ImageInvert', | ||
| 'ImageCompare', | ||
| 'Canny', | ||
|
|
||
| // Video Tools | ||
| 'Video Slice', | ||
|
|
||
| // API Nodes | ||
| 'RecraftRemoveBackgroundNode', | ||
| 'RecraftVectorizeImageNode', | ||
| 'KlingOmniProEditVideoNode' | ||
| ]) | ||
|
|
||
| /** | ||
| * python_module values that identify toolkit blueprint nodes. | ||
| * Essentials blueprints are registered with node_pack 'comfy_essentials', | ||
| * which maps to python_module on the node def. | ||
| */ | ||
| export const TOOLKIT_BLUEPRINT_MODULES: ReadonlySet<string> = new Set([ | ||
| 'comfy_essentials' | ||
| ]) | ||
181 changes: 181 additions & 0 deletions
181
src/platform/telemetry/providers/cloud/MixpanelTelemetryProvider.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import type { LGraphNode } from '@/lib/litegraph/src/litegraph' | ||
|
|
||
| vi.mock('vue', async () => { | ||
| const actual = await vi.importActual('vue') | ||
| return { | ||
| ...actual, | ||
| watch: vi.fn() | ||
| } | ||
| }) | ||
|
|
||
| vi.mock('@/composables/auth/useCurrentUser', () => ({ | ||
| useCurrentUser: () => ({ | ||
| onUserResolved: vi.fn() | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock('@/platform/telemetry/topupTracker', () => ({ | ||
| checkForCompletedTopup: vi.fn(), | ||
| clearTopupTracking: vi.fn(), | ||
| startTopupTracking: vi.fn() | ||
| })) | ||
|
|
||
| const hoisted = vi.hoisted(() => ({ | ||
| mockNodeDefsByName: {} as Record<string, unknown>, | ||
| mockNodes: [] as Pick<LGraphNode, 'type' | 'isSubgraphNode'>[] | ||
| })) | ||
|
|
||
| vi.mock('@/stores/nodeDefStore', () => ({ | ||
| useNodeDefStore: () => ({ | ||
| nodeDefsByName: hoisted.mockNodeDefsByName | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock('@/platform/workflow/management/stores/workflowStore', () => ({ | ||
| useWorkflowStore: () => ({ | ||
| activeWorkflow: null | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock( | ||
| '@/platform/workflow/templates/repositories/workflowTemplatesStore', | ||
| () => ({ | ||
| useWorkflowTemplatesStore: () => ({ | ||
| knownTemplateNames: new Set() | ||
| }) | ||
| }) | ||
| ) | ||
|
|
||
| function mockNode( | ||
| type: string, | ||
| isSubgraph = false | ||
| ): Pick<LGraphNode, 'type' | 'isSubgraphNode'> { | ||
| return { | ||
| type, | ||
| isSubgraphNode: (() => isSubgraph) as LGraphNode['isSubgraphNode'] | ||
| } | ||
| } | ||
|
|
||
| vi.mock('@/utils/graphTraversalUtil', () => ({ | ||
| reduceAllNodes: vi.fn((_graph, reducer, initial) => { | ||
| let result = initial | ||
| for (const node of hoisted.mockNodes) { | ||
| result = reducer(result, node) | ||
| } | ||
| return result | ||
| }) | ||
| })) | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| vi.mock('@/scripts/app', () => ({ | ||
| app: { rootGraph: {} } | ||
| })) | ||
|
|
||
| vi.mock('@/platform/remoteConfig/remoteConfig', () => ({ | ||
| remoteConfig: { value: null } | ||
| })) | ||
|
|
||
| import { MixpanelTelemetryProvider } from './MixpanelTelemetryProvider' | ||
|
|
||
| describe('MixpanelTelemetryProvider.getExecutionContext', () => { | ||
| let provider: MixpanelTelemetryProvider | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
| hoisted.mockNodes.length = 0 | ||
| for (const key of Object.keys(hoisted.mockNodeDefsByName)) { | ||
| delete hoisted.mockNodeDefsByName[key] | ||
| } | ||
| provider = new MixpanelTelemetryProvider() | ||
| }) | ||
|
|
||
| it('returns has_toolkit_nodes false when no toolkit nodes are present', () => { | ||
| hoisted.mockNodes.push(mockNode('KSampler'), mockNode('LoadImage')) | ||
| hoisted.mockNodeDefsByName['KSampler'] = { | ||
| name: 'KSampler', | ||
| python_module: 'nodes' | ||
| } | ||
| hoisted.mockNodeDefsByName['LoadImage'] = { | ||
| name: 'LoadImage', | ||
| python_module: 'nodes' | ||
| } | ||
|
|
||
| const context = provider.getExecutionContext() | ||
|
|
||
| expect(context.has_toolkit_nodes).toBe(false) | ||
| expect(context.toolkit_node_names).toEqual([]) | ||
| expect(context.toolkit_node_count).toBe(0) | ||
| }) | ||
|
|
||
| it('detects individual toolkit nodes by type name', () => { | ||
| hoisted.mockNodes.push(mockNode('Canny'), mockNode('KSampler')) | ||
| hoisted.mockNodeDefsByName['Canny'] = { | ||
| name: 'Canny', | ||
| python_module: 'comfy_extras.nodes_canny' | ||
| } | ||
| hoisted.mockNodeDefsByName['KSampler'] = { | ||
| name: 'KSampler', | ||
| python_module: 'nodes' | ||
| } | ||
|
|
||
| const context = provider.getExecutionContext() | ||
|
|
||
| expect(context.has_toolkit_nodes).toBe(true) | ||
| expect(context.toolkit_node_names).toEqual(['Canny']) | ||
| expect(context.toolkit_node_count).toBe(1) | ||
| }) | ||
|
|
||
| it('detects blueprint toolkit nodes via python_module', () => { | ||
| const blueprintType = 'SubgraphBlueprint.text_to_image' | ||
| hoisted.mockNodes.push(mockNode(blueprintType, true)) | ||
| hoisted.mockNodeDefsByName[blueprintType] = { | ||
| name: blueprintType, | ||
| python_module: 'comfy_essentials' | ||
| } | ||
|
|
||
| const context = provider.getExecutionContext() | ||
|
|
||
| expect(context.has_toolkit_nodes).toBe(true) | ||
| expect(context.toolkit_node_names).toEqual([blueprintType]) | ||
| expect(context.toolkit_node_count).toBe(1) | ||
| }) | ||
|
|
||
| it('deduplicates toolkit_node_names when same type appears multiple times', () => { | ||
| hoisted.mockNodes.push(mockNode('Canny'), mockNode('Canny')) | ||
| hoisted.mockNodeDefsByName['Canny'] = { | ||
| name: 'Canny', | ||
| python_module: 'comfy_extras.nodes_canny' | ||
| } | ||
|
|
||
| const context = provider.getExecutionContext() | ||
|
|
||
| expect(context.toolkit_node_names).toEqual(['Canny']) | ||
| expect(context.toolkit_node_count).toBe(2) | ||
| }) | ||
|
|
||
| it('allows a node to appear in both api_node_names and toolkit_node_names', () => { | ||
| hoisted.mockNodes.push(mockNode('RecraftRemoveBackgroundNode')) | ||
| hoisted.mockNodeDefsByName['RecraftRemoveBackgroundNode'] = { | ||
| name: 'RecraftRemoveBackgroundNode', | ||
| python_module: 'comfy_extras.nodes_api', | ||
| api_node: true | ||
| } | ||
|
|
||
| const context = provider.getExecutionContext() | ||
|
|
||
| expect(context.has_api_nodes).toBe(true) | ||
| expect(context.api_node_names).toEqual(['RecraftRemoveBackgroundNode']) | ||
| expect(context.has_toolkit_nodes).toBe(true) | ||
| expect(context.toolkit_node_names).toEqual(['RecraftRemoveBackgroundNode']) | ||
| }) | ||
|
|
||
| it('uses node.type as tracking name when nodeDef is missing', () => { | ||
| hoisted.mockNodes.push(mockNode('ImageCrop')) | ||
|
|
||
| const context = provider.getExecutionContext() | ||
|
|
||
| expect(context.has_toolkit_nodes).toBe(true) | ||
| expect(context.toolkit_node_names).toEqual(['ImageCrop']) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirm canonical casing for
image compare.Set membership is case-sensitive; if the node type is actually
Image Compare(or similar), this entry won’t match and toolkit detection will miss it. Please verify the canonical node type and adjust or normalize casing in detection.🤖 Prompt for AI Agents