@flisk/analyze-tracking 0.8.8 → 0.9.1
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 +120 -19
- package/package.json +5 -3
- package/schema.json +10 -0
- package/src/analyze/index.js +20 -13
- package/src/analyze/javascript/detectors/analytics-source.js +38 -4
- package/src/analyze/javascript/extractors/event-extractor.js +29 -12
- package/src/analyze/javascript/parser.js +26 -8
- package/src/analyze/swift/constants.js +61 -0
- package/src/analyze/swift/custom.js +36 -0
- package/src/analyze/swift/index.js +708 -0
- package/src/analyze/swift/providers.js +51 -0
- package/src/analyze/swift/runtime.js +46 -0
- package/src/analyze/swift/utils.js +75 -0
- package/src/analyze/typescript/detectors/analytics-source.js +37 -3
- package/src/analyze/typescript/extractors/event-extractor.js +59 -31
- package/src/analyze/typescript/extractors/property-extractor.js +129 -91
- package/src/analyze/typescript/parser.js +27 -8
- package/src/analyze/typescript/utils/type-resolver.js +600 -21
- package/src/analyze/utils/customFunctionParser.js +29 -0
|
@@ -6,6 +6,35 @@ function parseCustomFunctionSignature(signature) {
|
|
|
6
6
|
|
|
7
7
|
const trimmed = signature.trim();
|
|
8
8
|
|
|
9
|
+
// Check for method-as-event pattern: objectName.EVENT_NAME(PROPERTIES)
|
|
10
|
+
// This pattern means the method name itself is the event name
|
|
11
|
+
const methodAsEventMatch = trimmed.match(/^([^.]+)\.EVENT_NAME\s*\(([^)]*)\)\s*$/);
|
|
12
|
+
if (methodAsEventMatch) {
|
|
13
|
+
const objectName = methodAsEventMatch[1].trim();
|
|
14
|
+
const paramsPart = methodAsEventMatch[2].trim();
|
|
15
|
+
|
|
16
|
+
// Parse the parameters inside EVENT_NAME(...)
|
|
17
|
+
const params = paramsPart ? paramsPart.split(',').map(p => p.trim()).filter(Boolean) : [];
|
|
18
|
+
|
|
19
|
+
// Find PROPERTIES index (default to 0 if not specified)
|
|
20
|
+
let propertiesIndex = params.findIndex(p => p.toUpperCase() === 'PROPERTIES');
|
|
21
|
+
if (propertiesIndex === -1) {
|
|
22
|
+
// If PROPERTIES is not explicitly listed, it's the first parameter (index 0)
|
|
23
|
+
propertiesIndex = 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const extraParams = params.map((name, idx) => ({ idx, name }))
|
|
27
|
+
.filter(p => p.idx !== propertiesIndex);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
functionName: objectName, // Use objectName for matching the object part
|
|
31
|
+
objectName, // Store separately for clarity
|
|
32
|
+
isMethodAsEvent: true, // Flag indicating method name is event name
|
|
33
|
+
propertiesIndex,
|
|
34
|
+
extraParams
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
9
38
|
// Two cases:
|
|
10
39
|
// 1) Full signature with params at the end (e.g., Module.track(EVENT_NAME, PROPERTIES)) → parse params
|
|
11
40
|
// 2) Name-only (including chains with internal calls, e.g., getService().track) → no params
|