@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.
@@ -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