Skip to content

Commit 79a930c

Browse files
committed
Merge branch 'cloud/tracking-v2-add-api-button' into feat/telemetry-run-button-subgraph-count
2 parents 37cd27a + aedf48d commit 79a930c

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

src/platform/telemetry/providers/cloud/MixpanelTelemetryProvider.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
175175
workflow_type: executionContext.is_template ? 'template' : 'custom',
176176
workflow_name: executionContext.workflow_name ?? 'untitled',
177177
total_node_count: executionContext.total_node_count,
178-
subgraph_count: executionContext.subgraph_count
178+
subgraph_count: executionContext.subgraph_count,
179+
has_api_nodes: executionContext.has_api_nodes,
180+
api_node_names: executionContext.api_node_names
179181
}
180182

181183
this.trackEvent(TelemetryEvents.RUN_BUTTON_CLICKED, runButtonProperties)
@@ -277,27 +279,49 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
277279
const activeWorkflow = workflowStore.activeWorkflow
278280

279281
// Calculate node metrics in a single traversal
280-
const nodeMetrics = reduceAllNodes(
282+
type NodeMetrics = {
283+
custom_node_count: number
284+
api_node_count: number
285+
subgraph_count: number
286+
total_node_count: number
287+
has_api_nodes: boolean
288+
api_node_names: string[]
289+
}
290+
291+
const nodeCounts = reduceAllNodes<NodeMetrics>(
281292
app.graph,
282-
(acc, node) => {
293+
(metrics, node) => {
283294
const nodeDef = nodeDefStore.nodeDefsByName[node.type]
284295
const isCustomNode =
285296
nodeDef?.nodeSource?.type === NodeSourceType.CustomNodes
286297
const isApiNode = nodeDef?.api_node === true
287298
const isSubgraph = node.isSubgraphNode?.() === true
288299

289-
return {
290-
custom_node_count: acc.custom_node_count + (isCustomNode ? 1 : 0),
291-
api_node_count: acc.api_node_count + (isApiNode ? 1 : 0),
292-
subgraph_count: acc.subgraph_count + (isSubgraph ? 1 : 0),
293-
total_node_count: acc.total_node_count + 1
300+
if (isApiNode) {
301+
metrics.has_api_nodes = true
302+
const canonicalName = nodeDef?.name
303+
if (
304+
canonicalName &&
305+
!metrics.api_node_names.includes(canonicalName)
306+
) {
307+
metrics.api_node_names.push(canonicalName)
308+
}
294309
}
310+
311+
metrics.custom_node_count += isCustomNode ? 1 : 0
312+
metrics.api_node_count += isApiNode ? 1 : 0
313+
metrics.subgraph_count += isSubgraph ? 1 : 0
314+
metrics.total_node_count += 1
315+
316+
return metrics
295317
},
296318
{
297319
custom_node_count: 0,
298320
api_node_count: 0,
299321
subgraph_count: 0,
300-
total_node_count: 0
322+
total_node_count: 0,
323+
has_api_nodes: false,
324+
api_node_names: []
301325
}
302326
)
303327

@@ -324,21 +348,21 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
324348
template_models: englishMetadata?.models ?? template?.models,
325349
template_use_case: englishMetadata?.useCase ?? template?.useCase,
326350
template_license: englishMetadata?.license ?? template?.license,
327-
...nodeMetrics
351+
...nodeCounts
328352
}
329353
}
330354

331355
return {
332356
is_template: false,
333357
workflow_name: activeWorkflow.filename,
334-
...nodeMetrics
358+
...nodeCounts
335359
}
336360
}
337361

338362
return {
339363
is_template: false,
340364
workflow_name: undefined,
341-
...nodeMetrics
365+
...nodeCounts
342366
}
343367
}
344368
}

src/platform/telemetry/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export interface RunButtonProperties {
4444
workflow_name: string
4545
total_node_count: number
4646
subgraph_count: number
47+
has_api_nodes: boolean
48+
api_node_names: string[]
4749
}
4850

4951
/**
@@ -64,6 +66,8 @@ export interface ExecutionContext {
6466
api_node_count: number
6567
subgraph_count: number
6668
total_node_count: number
69+
has_api_nodes: boolean
70+
api_node_names: string[]
6771
}
6872

6973
/**

0 commit comments

Comments
 (0)