@flisk/analyze-tracking 0.8.5 → 0.8.6

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 CHANGED
@@ -111,6 +111,7 @@ See [schema.json](schema.json) for a JSON Schema of the output.
111
111
  | Pendo | ✅ | ❌ | ❌ | ❌ |
112
112
  | Heap | ✅ | ❌ | ❌ | ❌ |
113
113
  | Snowplow | ✅ | ✅ | ✅ | ✅ |
114
+ | Datadog RUM | ✅ | ❌ | ❌ | ❌ |
114
115
  | Custom Function | ✅ | ✅ | ✅ | ✅ |
115
116
 
116
117
  ✳️ Rudderstack's SDKs often use the same format as Segment, so Rudderstack events may be detected as Segment events.
@@ -375,6 +376,27 @@ See [schema.json](schema.json) for a JSON Schema of the output.
375
376
 
376
377
  </details>
377
378
 
379
+ <details>
380
+ <summary>Datadog RUM</summary>
381
+
382
+ **JavaScript/TypeScript**
383
+ ```js
384
+ datadogRum.addAction('<event_name>', {
385
+ '<property_name>': '<property_value>'
386
+ });
387
+
388
+ // Or via window
389
+ window.DD_RUM.addAction('<event_name>', {
390
+ '<property_name>': '<property_value>'
391
+ });
392
+
393
+ // Or via global DD_RUM
394
+ DD_RUM.addAction('<event_name>', {
395
+ '<property_name>': '<property_value>'
396
+ });
397
+ ```
398
+ </details>
399
+
378
400
  <details>
379
401
  <summary>Snowplow (Structured Events)</summary>
380
402
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flisk/analyze-tracking",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "Analyzes tracking code in a project and generates data schemas",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/schema.json CHANGED
@@ -67,6 +67,7 @@
67
67
  "pendo",
68
68
  "heap",
69
69
  "snowplow",
70
+ "datadog",
70
71
  "custom",
71
72
  "unknown"
72
73
  ],
@@ -75,6 +75,12 @@ const ANALYTICS_PROVIDERS = {
75
75
  name: 'googleanalytics',
76
76
  functionName: 'gtag',
77
77
  type: 'function'
78
+ },
79
+ DATADOG_RUM: {
80
+ name: 'datadog',
81
+ objectNames: ['datadogRum', 'DD_RUM'],
82
+ methodName: 'addAction',
83
+ type: 'member'
78
84
  }
79
85
  };
80
86
 
@@ -131,8 +131,17 @@ function detectMemberBasedProvider(node) {
131
131
  return 'unknown';
132
132
  }
133
133
 
134
- const objectName = node.callee.object.name;
135
134
  const methodName = node.callee.property.name;
135
+ let objectName = node.callee.object.name;
136
+
137
+ // Handle nested member expressions like window.DD_RUM.addAction
138
+ if (!objectName && node.callee.object.type === NODE_TYPES.MEMBER_EXPRESSION) {
139
+ // For window.DD_RUM.addAction, we want to check if it matches DD_RUM.addAction pattern
140
+ const nestedObjectName = node.callee.object.property.name;
141
+ if (nestedObjectName) {
142
+ objectName = nestedObjectName;
143
+ }
144
+ }
136
145
 
137
146
  if (!objectName || !methodName) {
138
147
  return 'unknown';
@@ -75,6 +75,12 @@ const ANALYTICS_PROVIDERS = {
75
75
  name: 'googleanalytics',
76
76
  functionName: 'gtag',
77
77
  type: 'function'
78
+ },
79
+ DATADOG_RUM: {
80
+ name: 'datadog',
81
+ objectNames: ['datadogRum', 'DD_RUM'],
82
+ methodName: 'addAction',
83
+ type: 'member'
78
84
  }
79
85
  };
80
86
 
@@ -87,8 +87,17 @@ function detectMemberBasedProvider(node) {
87
87
  return 'unknown';
88
88
  }
89
89
 
90
- const objectName = node.expression.expression?.escapedText;
91
90
  const methodName = node.expression.name?.escapedText;
91
+ let objectName = node.expression.expression?.escapedText;
92
+
93
+ // Handle nested member expressions like window.DD_RUM.addAction
94
+ if (!objectName && ts.isPropertyAccessExpression(node.expression.expression)) {
95
+ // For window.DD_RUM.addAction, we want to check if it matches DD_RUM.addAction pattern
96
+ const nestedObjectName = node.expression.expression.name?.escapedText;
97
+ if (nestedObjectName) {
98
+ objectName = nestedObjectName;
99
+ }
100
+ }
92
101
 
93
102
  if (!objectName || !methodName) {
94
103
  return 'unknown';