@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.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Custom function detection for Swift
3
+ */
4
+
5
+ const { normalizeChainPart, endsWithChain, extractStringLiteral, isIdentifier } = require('./utils');
6
+
7
+ function matchCustomSignature(call, customFunctionSignatures) {
8
+ if (!Array.isArray(customFunctionSignatures) || customFunctionSignatures.length === 0) return null;
9
+ const chain = Array.isArray(call.calleeChain) ? call.calleeChain.map(normalizeChainPart) : [];
10
+
11
+ for (const cfg of customFunctionSignatures) {
12
+ if (!cfg || !cfg.functionName) continue;
13
+ const sigParts = cfg.functionName.split('.').map(normalizeChainPart).filter(Boolean);
14
+ if (sigParts.length === 0) continue;
15
+ if (endsWithChain(chain, sigParts)) return cfg;
16
+ }
17
+ return null;
18
+ }
19
+
20
+ function matchImplicitCustom(call) {
21
+ const chain = Array.isArray(call.calleeChain) ? call.calleeChain.map(normalizeChainPart) : [];
22
+ const last = chain[chain.length - 1] || '';
23
+ if (last === 'module' || last === 'func') {
24
+ return { functionName: chain.join('.'), eventIndex: 0, propertiesIndex: 1, extraParams: [] };
25
+ }
26
+ const name = call.name || '';
27
+ if (/^customTrackFunction\d*$/.test(name)) {
28
+ return { functionName: name, eventIndex: 0, propertiesIndex: 1, extraParams: [] };
29
+ }
30
+ if (name === 'customTrackNoProps') {
31
+ return { functionName: name, eventIndex: 0, propertiesIndex: 9999, extraParams: [] };
32
+ }
33
+ return null;
34
+ }
35
+
36
+ module.exports = { matchCustomSignature, matchImplicitCustom };