@flisk/analyze-tracking 0.7.0 → 0.7.2
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 +35 -61
- package/package.json +16 -3
- package/schema.json +4 -0
- package/src/analyze/analyzeGoFile.js +285 -89
- package/src/analyze/analyzeJsFile.js +20 -5
- package/src/analyze/analyzePythonFile.js +1 -0
- package/src/analyze/analyzeRubyFile.js +20 -10
- package/src/analyze/analyzeTsFile.js +138 -15
- package/src/analyze/helpers.js +462 -23
- package/src/analyze/index.js +0 -1
- package/src/analyze/pythonTrackingAnalyzer.py +149 -47
- package/.github/workflows/npm-publish.yml +0 -33
- package/.github/workflows/pr-check.yml +0 -17
- package/jest.config.js +0 -7
- package/tests/detectSource.test.js +0 -20
- package/tests/extractProperties.test.js +0 -109
- package/tests/findWrappingFunction.test.js +0 -30
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @flisk/analyze-tracking
|
|
2
2
|
|
|
3
|
-
Automatically document your analytics setup by analyzing tracking code and generating data schemas from tools like Segment, Amplitude, Mixpanel, and more
|
|
3
|
+
Automatically document your analytics setup by analyzing tracking code and generating data schemas from tools like Segment, Amplitude, Mixpanel, and more 🚀
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@flisk/analyze-tracking)
|
|
5
|
+
[](https://www.npmjs.com/package/@flisk/analyze-tracking) [](https://github.com/fliskdata/analyze-tracking/actions/workflows/tests.yml)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
## Why Use @flisk/analyze-tracking?
|
|
@@ -30,7 +30,7 @@ npx @flisk/analyze-tracking /path/to/project [options]
|
|
|
30
30
|
- `-o, --output <output_file>`: Name of the output file (default: `tracking-schema.yaml`)
|
|
31
31
|
- `-c, --customFunction <function_name>`: Specify a custom tracking function
|
|
32
32
|
|
|
33
|
-
🔑 **Important:** If you are using `generateDescription`, you must set the appropriate credentials for the provider you are using as an environment variable. OpenAI uses `OPENAI_API_KEY` and Google Vertex AI uses `GOOGLE_APPLICATION_CREDENTIALS`.
|
|
33
|
+
🔑 **Important:** If you are using `generateDescription`, you must set the appropriate credentials for the LLM provider you are using as an environment variable. OpenAI uses `OPENAI_API_KEY` and Google Vertex AI uses `GOOGLE_APPLICATION_CREDENTIALS`.
|
|
34
34
|
|
|
35
35
|
<details>
|
|
36
36
|
<summary>Note on Custom Functions 💡</summary>
|
|
@@ -96,10 +96,10 @@ See [schema.json](schema.json) for a JSON Schema of the output.
|
|
|
96
96
|
| Mixpanel | ✅ | ✅ | ✅ | ✅ |
|
|
97
97
|
| Amplitude | ✅ | ✅ | ❌ | ✅ |
|
|
98
98
|
| Rudderstack | ✅ | ✅ | ✳️ | ✳️ |
|
|
99
|
-
| mParticle | ✅ |
|
|
99
|
+
| mParticle | ✅ | ❌ | ❌ | ❌ |
|
|
100
100
|
| PostHog | ✅ | ✅ | ✅ | ✅ |
|
|
101
|
-
| Pendo | ✅ |
|
|
102
|
-
| Heap | ✅ |
|
|
101
|
+
| Pendo | ✅ | ❌ | ❌ | ❌ |
|
|
102
|
+
| Heap | ✅ | ❌ | ❌ | ❌ |
|
|
103
103
|
| Snowplow | ✅ | ✅ | ✅ | ✅ |
|
|
104
104
|
| Custom Function | ✅ | ✅ | ✅ | ✅ |
|
|
105
105
|
|
|
@@ -198,16 +198,22 @@ See [schema.json](schema.json) for a JSON Schema of the output.
|
|
|
198
198
|
|
|
199
199
|
**JavaScript/TypeScript**
|
|
200
200
|
```js
|
|
201
|
-
amplitude.
|
|
201
|
+
amplitude.track('<event_name>', {
|
|
202
202
|
<event_parameters>
|
|
203
203
|
});
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
**Python**
|
|
207
207
|
```python
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
client.track(
|
|
209
|
+
BaseEvent(
|
|
210
|
+
event_type="<event_name>",
|
|
211
|
+
user_id="<user_id>",
|
|
212
|
+
event_properties={
|
|
213
|
+
"<property_name>": "<property_value>",
|
|
214
|
+
},
|
|
215
|
+
)
|
|
216
|
+
)
|
|
211
217
|
```
|
|
212
218
|
|
|
213
219
|
**Go**
|
|
@@ -266,19 +272,10 @@ See [schema.json](schema.json) for a JSON Schema of the output.
|
|
|
266
272
|
|
|
267
273
|
**JavaScript/TypeScript**
|
|
268
274
|
```js
|
|
269
|
-
mParticle.logEvent('<event_name>', {
|
|
275
|
+
mParticle.logEvent('<event_name>', mParticle.EventType.<event_type>, {
|
|
270
276
|
'<property_name>': '<property_value>'
|
|
271
277
|
});
|
|
272
278
|
```
|
|
273
|
-
|
|
274
|
-
**Python**
|
|
275
|
-
```python
|
|
276
|
-
mParticle.logEvent('<event_name>', {
|
|
277
|
-
'<property_name>': '<property_value>'
|
|
278
|
-
})
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
|
|
282
279
|
</details>
|
|
283
280
|
|
|
284
281
|
<details>
|
|
@@ -293,13 +290,9 @@ See [schema.json](schema.json) for a JSON Schema of the output.
|
|
|
293
290
|
|
|
294
291
|
**Python**
|
|
295
292
|
```python
|
|
296
|
-
posthog.capture(
|
|
297
|
-
'
|
|
298
|
-
|
|
299
|
-
{
|
|
300
|
-
'<property_name>': '<property_value>'
|
|
301
|
-
}
|
|
302
|
-
)
|
|
293
|
+
posthog.capture('distinct_id', '<event_name>', {
|
|
294
|
+
'<property_name>': '<property_value>'
|
|
295
|
+
})
|
|
303
296
|
# Or
|
|
304
297
|
posthog.capture(
|
|
305
298
|
'distinct_id',
|
|
@@ -377,61 +370,42 @@ See [schema.json](schema.json) for a JSON Schema of the output.
|
|
|
377
370
|
|
|
378
371
|
**JavaScript/TypeScript**
|
|
379
372
|
```js
|
|
380
|
-
|
|
373
|
+
tracker.track(buildStructEvent({
|
|
374
|
+
action: '<event_name>',
|
|
381
375
|
category: '<category>',
|
|
382
|
-
action: '<action>',
|
|
383
376
|
label: '<label>',
|
|
384
377
|
property: '<property>',
|
|
385
|
-
value:
|
|
386
|
-
});
|
|
378
|
+
value: <value>
|
|
379
|
+
}));
|
|
387
380
|
```
|
|
388
381
|
|
|
389
382
|
**Python**
|
|
390
383
|
```python
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
# Builder pattern
|
|
401
|
-
buildStructEvent({
|
|
402
|
-
'category': '<category>',
|
|
403
|
-
'action': '<action>',
|
|
404
|
-
'label': '<label>',
|
|
405
|
-
'property': '<property>',
|
|
406
|
-
'value': '<value>'
|
|
407
|
-
})
|
|
408
|
-
|
|
409
|
-
# Function call pattern
|
|
410
|
-
snowplow('trackStructEvent', {
|
|
411
|
-
'category': '<category>',
|
|
412
|
-
'action': '<action>',
|
|
413
|
-
'label': '<label>',
|
|
414
|
-
'property': '<property>',
|
|
415
|
-
'value': '<value>'
|
|
416
|
-
})
|
|
384
|
+
tracker.track(StructuredEvent(
|
|
385
|
+
action="<event_name>",
|
|
386
|
+
category="<category>",
|
|
387
|
+
label="<label>",
|
|
388
|
+
property_="<property>",
|
|
389
|
+
value=<value>,
|
|
390
|
+
))
|
|
417
391
|
```
|
|
418
392
|
|
|
419
393
|
**Ruby**
|
|
420
394
|
```ruby
|
|
421
395
|
tracker.track_struct_event(
|
|
396
|
+
action: '<event_name>',
|
|
422
397
|
category: '<category>',
|
|
423
|
-
action: '<action>',
|
|
424
398
|
label: '<label>',
|
|
425
399
|
property: '<property>',
|
|
426
|
-
value:
|
|
400
|
+
value: <value>
|
|
427
401
|
)
|
|
428
402
|
```
|
|
429
403
|
|
|
430
404
|
**Go**
|
|
431
405
|
```go
|
|
432
406
|
tracker.TrackStructEvent(sp.StructuredEvent{
|
|
407
|
+
Action: sp.NewString("<event_name>"),
|
|
433
408
|
Category: sp.NewString("<category>"),
|
|
434
|
-
Action: sp.NewString("<action>"),
|
|
435
409
|
Label: sp.NewString("<label>"),
|
|
436
410
|
Property: sp.NewString("<property>"),
|
|
437
411
|
Value: sp.NewFloat64(<value>),
|
|
@@ -441,4 +415,4 @@ See [schema.json](schema.json) for a JSON Schema of the output.
|
|
|
441
415
|
|
|
442
416
|
|
|
443
417
|
## Contribute
|
|
444
|
-
We're actively improving this package. Found a bug?
|
|
418
|
+
We're actively improving this package. Found a bug? Have a feature request? Open an issue or submit a pull request!
|
package/package.json
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flisk/analyze-tracking",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Analyzes tracking code in a project and generates data schemas",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"analyze-tracking": "bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "
|
|
10
|
+
"test": "node tests",
|
|
11
|
+
"test:js": "node --test tests/analyzeJsFile.test.js",
|
|
12
|
+
"test:ts": "node --test tests/analyzeTsFile.test.js",
|
|
13
|
+
"test:python": "node --experimental-vm-modules --test tests/analyzePythonFile.test.js",
|
|
14
|
+
"test:ruby": "node --experimental-vm-modules --test tests/analyzeRubyFile.test.js",
|
|
15
|
+
"test:go": "node --test tests/analyzeGoFile.test.js",
|
|
16
|
+
"test:cli": "node --test tests/cli.test.js",
|
|
17
|
+
"test:schema": "node --test tests/schema.test.js"
|
|
11
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"bin",
|
|
21
|
+
"src",
|
|
22
|
+
"schema.json"
|
|
23
|
+
],
|
|
12
24
|
"repository": {
|
|
13
25
|
"type": "git",
|
|
14
26
|
"url": "git+https://github.com/fliskdata/analyze-tracking.git"
|
|
@@ -38,6 +50,7 @@
|
|
|
38
50
|
"zod": "^3.24.4"
|
|
39
51
|
},
|
|
40
52
|
"devDependencies": {
|
|
41
|
-
"
|
|
53
|
+
"ajv": "^8.17.1",
|
|
54
|
+
"lodash": "^4.17.21"
|
|
42
55
|
}
|
|
43
56
|
}
|