@@ -12,34 +12,34 @@ const { extractTrackingEvent } = require('./trackingExtractor');
1212 * @param {Array<Object> } events - Array to collect found tracking events (modified in place)
1313 * @param {string } filePath - Path to the file being analyzed
1414 * @param {string } functionName - Name of the current function being processed
15- * @param {string |null } customFunction - Name of custom tracking function to detect
15+ * @param {Object |null } customConfig - Parsed custom function configuration (or null)
1616 * @param {Object } typeContext - Type information context for variable resolution
1717 * @param {string } currentFunction - Current function context for type lookups
1818 */
19- function extractEventsFromBody ( body , events , filePath , functionName , customFunction , typeContext , currentFunction ) {
19+ function extractEventsFromBody ( body , events , filePath , functionName , customConfig , typeContext , currentFunction ) {
2020 for ( const stmt of body ) {
2121 if ( stmt . tag === 'exec' && stmt . expr ) {
22- processExpression ( stmt . expr , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
22+ processExpression ( stmt . expr , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
2323 } else if ( stmt . tag === 'declare' && stmt . value ) {
2424 // Handle variable declarations with tracking calls
25- processExpression ( stmt . value , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
25+ processExpression ( stmt . value , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
2626 } else if ( stmt . tag === 'assign' && stmt . rhs ) {
2727 // Handle assignments with tracking calls
28- processExpression ( stmt . rhs , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
28+ processExpression ( stmt . rhs , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
2929 } else if ( stmt . tag === 'if' && stmt . body ) {
30- extractEventsFromBody ( stmt . body , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
30+ extractEventsFromBody ( stmt . body , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
3131 } else if ( stmt . tag === 'elseif' && stmt . body ) {
32- extractEventsFromBody ( stmt . body , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
32+ extractEventsFromBody ( stmt . body , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
3333 } else if ( stmt . tag === 'else' && stmt . body ) {
34- extractEventsFromBody ( stmt . body , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
34+ extractEventsFromBody ( stmt . body , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
3535 } else if ( stmt . tag === 'for' && stmt . body ) {
36- extractEventsFromBody ( stmt . body , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
36+ extractEventsFromBody ( stmt . body , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
3737 } else if ( stmt . tag === 'foreach' && stmt . body ) {
38- extractEventsFromBody ( stmt . body , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
38+ extractEventsFromBody ( stmt . body , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
3939 } else if ( stmt . tag === 'switch' && stmt . cases ) {
4040 for ( const caseNode of stmt . cases ) {
4141 if ( caseNode . body ) {
42- extractEventsFromBody ( caseNode . body , events , filePath , functionName , customFunction , typeContext , currentFunction ) ;
42+ extractEventsFromBody ( caseNode . body , events , filePath , functionName , customConfig , typeContext , currentFunction ) ;
4343 }
4444 }
4545 }
@@ -52,44 +52,44 @@ function extractEventsFromBody(body, events, filePath, functionName, customFunct
5252 * @param {Array<Object> } events - Array to collect found tracking events (modified in place)
5353 * @param {string } filePath - Path to the file being analyzed
5454 * @param {string } functionName - Name of the current function being processed
55- * @param {string |null } customFunction - Name of custom tracking function to detect
55+ * @param {Object |null } customConfig - Parsed custom function configuration (or null)
5656 * @param {Object } typeContext - Type information context for variable resolution
5757 * @param {string } currentFunction - Current function context for type lookups
5858 * @param {number } [depth=0] - Current recursion depth (used to prevent infinite recursion)
5959 */
60- function processExpression ( expr , events , filePath , functionName , customFunction , typeContext , currentFunction , depth = 0 ) {
60+ function processExpression ( expr , events , filePath , functionName , customConfig , typeContext , currentFunction , depth = 0 ) {
6161 if ( ! expr || depth > MAX_RECURSION_DEPTH ) return ; // Prevent infinite recursion with depth limit
6262
6363 // Handle array of expressions
6464 if ( Array . isArray ( expr ) ) {
6565 for ( const item of expr ) {
66- processExpression ( item , events , filePath , functionName , customFunction , typeContext , currentFunction , depth + 1 ) ;
66+ processExpression ( item , events , filePath , functionName , customConfig , typeContext , currentFunction , depth + 1 ) ;
6767 }
6868 return ;
6969 }
7070
7171 // Handle single expression with body
7272 if ( expr . body ) {
7373 for ( const item of expr . body ) {
74- processExpression ( item , events , filePath , functionName , customFunction , typeContext , currentFunction , depth + 1 ) ;
74+ processExpression ( item , events , filePath , functionName , customConfig , typeContext , currentFunction , depth + 1 ) ;
7575 }
7676 return ;
7777 }
7878
7979 // Handle specific node types
8080 if ( expr . tag === 'call' ) {
81- const trackingCall = extractTrackingEvent ( expr , filePath , functionName , customFunction , typeContext , currentFunction ) ;
81+ const trackingCall = extractTrackingEvent ( expr , filePath , functionName , customConfig , typeContext , currentFunction ) ;
8282 if ( trackingCall ) {
8383 events . push ( trackingCall ) ;
8484 }
8585
8686 // Also process call arguments
8787 if ( expr . args ) {
88- processExpression ( expr . args , events , filePath , functionName , customFunction , typeContext , currentFunction , depth + 1 ) ;
88+ processExpression ( expr . args , events , filePath , functionName , customConfig , typeContext , currentFunction , depth + 1 ) ;
8989 }
9090 } else if ( expr . tag === 'structlit' ) {
9191 // Check if this struct literal is a tracking event
92- const trackingCall = extractTrackingEvent ( expr , filePath , functionName , customFunction , typeContext , currentFunction ) ;
92+ const trackingCall = extractTrackingEvent ( expr , filePath , functionName , customConfig , typeContext , currentFunction ) ;
9393 if ( trackingCall ) {
9494 events . push ( trackingCall ) ;
9595 }
@@ -98,21 +98,21 @@ function processExpression(expr, events, filePath, functionName, customFunction,
9898 if ( ! trackingCall && expr . fields ) {
9999 for ( const field of expr . fields ) {
100100 if ( field . value ) {
101- processExpression ( field . value , events , filePath , functionName , customFunction , typeContext , currentFunction , depth + 1 ) ;
101+ processExpression ( field . value , events , filePath , functionName , customConfig , typeContext , currentFunction , depth + 1 ) ;
102102 }
103103 }
104104 }
105105 }
106106
107107 // Process other common properties that might contain expressions
108108 if ( expr . value && expr . tag !== 'structlit' ) {
109- processExpression ( expr . value , events , filePath , functionName , customFunction , typeContext , currentFunction , depth + 1 ) ;
109+ processExpression ( expr . value , events , filePath , functionName , customConfig , typeContext , currentFunction , depth + 1 ) ;
110110 }
111111 if ( expr . lhs ) {
112- processExpression ( expr . lhs , events , filePath , functionName , customFunction , typeContext , currentFunction , depth + 1 ) ;
112+ processExpression ( expr . lhs , events , filePath , functionName , customConfig , typeContext , currentFunction , depth + 1 ) ;
113113 }
114114 if ( expr . rhs ) {
115- processExpression ( expr . rhs , events , filePath , functionName , customFunction , typeContext , currentFunction , depth + 1 ) ;
115+ processExpression ( expr . rhs , events , filePath , functionName , customConfig , typeContext , currentFunction , depth + 1 ) ;
116116 }
117117}
118118
0 commit comments