@@ -149,6 +149,10 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
149149 this . trackEvent ( eventName )
150150 }
151151
152+ trackAddApiCreditButtonClicked ( ) : void {
153+ this . trackEvent ( TelemetryEvents . ADD_API_CREDIT_BUTTON_CLICKED )
154+ }
155+
152156 trackMonthlySubscriptionSucceeded ( ) : void {
153157 this . trackEvent ( TelemetryEvents . MONTHLY_SUBSCRIPTION_SUCCEEDED )
154158 }
@@ -170,7 +174,10 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
170174 subscribe_to_run : options ?. subscribe_to_run || false ,
171175 workflow_type : executionContext . is_template ? 'template' : 'custom' ,
172176 workflow_name : executionContext . workflow_name ?? 'untitled' ,
173- total_node_count : executionContext . total_node_count
177+ total_node_count : executionContext . total_node_count ,
178+ subgraph_count : executionContext . subgraph_count ,
179+ has_api_nodes : executionContext . has_api_nodes ,
180+ api_node_names : executionContext . api_node_names
174181 }
175182
176183 this . trackEvent ( TelemetryEvents . RUN_BUTTON_CLICKED , runButtonProperties )
@@ -272,27 +279,49 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
272279 const activeWorkflow = workflowStore . activeWorkflow
273280
274281 // Calculate node metrics in a single traversal
275- 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 > (
276292 app . graph ,
277- ( acc , node ) => {
293+ ( metrics , node ) => {
278294 const nodeDef = nodeDefStore . nodeDefsByName [ node . type ]
279295 const isCustomNode =
280296 nodeDef ?. nodeSource ?. type === NodeSourceType . CustomNodes
281297 const isApiNode = nodeDef ?. api_node === true
282298 const isSubgraph = node . isSubgraphNode ?.( ) === true
283299
284- return {
285- custom_node_count : acc . custom_node_count + ( isCustomNode ? 1 : 0 ) ,
286- api_node_count : acc . api_node_count + ( isApiNode ? 1 : 0 ) ,
287- subgraph_count : acc . subgraph_count + ( isSubgraph ? 1 : 0 ) ,
288- 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+ }
289309 }
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
290317 } ,
291318 {
292319 custom_node_count : 0 ,
293320 api_node_count : 0 ,
294321 subgraph_count : 0 ,
295- total_node_count : 0
322+ total_node_count : 0 ,
323+ has_api_nodes : false ,
324+ api_node_names : [ ]
296325 }
297326 )
298327
@@ -319,21 +348,21 @@ export class MixpanelTelemetryProvider implements TelemetryProvider {
319348 template_models : englishMetadata ?. models ?? template ?. models ,
320349 template_use_case : englishMetadata ?. useCase ?? template ?. useCase ,
321350 template_license : englishMetadata ?. license ?? template ?. license ,
322- ...nodeMetrics
351+ ...nodeCounts
323352 }
324353 }
325354
326355 return {
327356 is_template : false ,
328357 workflow_name : activeWorkflow . filename ,
329- ...nodeMetrics
358+ ...nodeCounts
330359 }
331360 }
332361
333362 return {
334363 is_template : false ,
335364 workflow_name : undefined ,
336- ...nodeMetrics
365+ ...nodeCounts
337366 }
338367 }
339368}
0 commit comments