@flisk/analyze-tracking 0.7.5 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ // Create new file with parser implementation
2
+ function parseCustomFunctionSignature(signature) {
3
+ if (!signature || typeof signature !== 'string') {
4
+ return null;
5
+ }
6
+
7
+ // Match function name and optional parameter list
8
+ // Supports names with module prefix like Module.func
9
+ const match = signature.match(/^\s*([A-Za-z0-9_.]+)\s*(?:\(([^)]*)\))?\s*$/);
10
+ if (!match) {
11
+ return null;
12
+ }
13
+
14
+ const functionName = match[1].trim();
15
+ const paramsPart = match[2];
16
+
17
+ // Default legacy behaviour: EVENT_NAME, PROPERTIES
18
+ if (!paramsPart) {
19
+ return {
20
+ functionName,
21
+ eventIndex: 0,
22
+ propertiesIndex: 1,
23
+ extraParams: []
24
+ };
25
+ }
26
+
27
+ // Split params by comma, trimming whitespace
28
+ const params = paramsPart.split(',').map(p => p.trim()).filter(Boolean);
29
+
30
+ const eventIndex = params.findIndex(p => p.toUpperCase() === 'EVENT_NAME');
31
+ let propertiesIndex = params.findIndex(p => p.toUpperCase() === 'PROPERTIES');
32
+
33
+ if (eventIndex === -1) {
34
+ throw new Error('EVENT_NAME is required in custom function signature');
35
+ }
36
+
37
+ if (propertiesIndex === -1) {
38
+ // If PROPERTIES is missing, assume it's at the end of the parameters
39
+ propertiesIndex = params.length;
40
+ }
41
+
42
+ const extraParams = params.map((name, idx) => ({ idx, name }))
43
+ .filter(p => !(p.idx === eventIndex || p.idx === propertiesIndex));
44
+
45
+ return {
46
+ functionName,
47
+ eventIndex,
48
+ propertiesIndex,
49
+ extraParams
50
+ };
51
+ }
52
+
53
+ module.exports = {
54
+ parseCustomFunctionSignature
55
+ };
package/src/index.js CHANGED
@@ -11,8 +11,8 @@ const { generateDescriptions } = require('./generateDescriptions');
11
11
  const { ChatOpenAI } = require('@langchain/openai');
12
12
  const { ChatVertexAI } = require('@langchain/google-vertexai');
13
13
 
14
- async function run(targetDir, outputPath, customFunction, customSourceDetails, generateDescription, provider, model, stdout, format) {
15
- let events = await analyzeDirectory(targetDir, customFunction);
14
+ async function run(targetDir, outputPath, customFunctions, customSourceDetails, generateDescription, provider, model, stdout, format) {
15
+ let events = await analyzeDirectory(targetDir, customFunctions);
16
16
  if (generateDescription) {
17
17
  let llm;
18
18
  if (provider === 'openai') {