@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.
- package/README.md +29 -21
- package/bin/cli.js +1 -0
- package/package.json +1 -1
- package/src/analyze/go/astTraversal.js +22 -22
- package/src/analyze/go/eventExtractor.js +10 -7
- package/src/analyze/go/index.js +39 -19
- package/src/analyze/go/propertyExtractor.js +25 -5
- package/src/analyze/go/trackingExtractor.js +5 -5
- package/src/analyze/index.js +9 -6
- package/src/analyze/javascript/detectors/analytics-source.js +55 -2
- package/src/analyze/javascript/extractors/event-extractor.js +69 -2
- package/src/analyze/javascript/index.js +14 -8
- package/src/analyze/javascript/parser.js +87 -14
- package/src/analyze/python/index.js +32 -26
- package/src/analyze/python/pythonTrackingAnalyzer.py +113 -39
- package/src/analyze/ruby/extractors.js +46 -10
- package/src/analyze/ruby/index.js +14 -7
- package/src/analyze/ruby/visitor.js +24 -7
- package/src/analyze/typescript/detectors/analytics-source.js +4 -1
- package/src/analyze/typescript/extractors/event-extractor.js +186 -8
- package/src/analyze/typescript/extractors/property-extractor.js +53 -1
- package/src/analyze/typescript/index.js +16 -10
- package/src/analyze/typescript/parser.js +37 -14
- package/src/analyze/typescript/utils/function-finder.js +11 -0
- package/src/analyze/typescript/utils/type-resolver.js +1 -1
- package/src/analyze/utils/customFunctionParser.js +55 -0
- package/src/index.js +2 -2
|
@@ -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,
|
|
15
|
-
let events = await analyzeDirectory(targetDir,
|
|
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') {
|