@flisk/analyze-tracking 0.5.2 → 0.7.0

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
@@ -6,9 +6,9 @@ Automatically document your analytics setup by analyzing tracking code and gener
6
6
 
7
7
 
8
8
  ## Why Use @flisk/analyze-tracking?
9
- 📊 **Understand Your Tracking** – Effortlessly analyze your codebase for `track` calls so you can see all your analytics events, properties, and triggers in one place. No more guessing whats being tracked!
9
+ 📊 **Understand Your Tracking** – Effortlessly analyze your codebase for `track` calls so you can see all your analytics events, properties, and triggers in one place. No more guessing what's being tracked!
10
10
 
11
- 🔍 **Auto-Document Events** – Generates a complete YAML schema that captures all events and properties, including where theyre implemented in your codebase.
11
+ 🔍 **Auto-Document Events** – Generates a complete YAML schema that captures all events and properties, including where they're implemented in your codebase.
12
12
 
13
13
  🕵️‍♂️ **Track Changes Over Time** – Easily spot unintended changes or ensure your analytics setup remains consistent across updates.
14
14
 
@@ -38,17 +38,26 @@ npx @flisk/analyze-tracking /path/to/project [options]
38
38
  Use this if you have your own in-house tracker or a wrapper function that calls other tracking libraries.
39
39
 
40
40
  We currently only support functions that follow the following format:
41
+
42
+ **JavaScript/TypeScript/Python/Ruby:**
41
43
  ```js
42
44
  yourCustomTrackFunctionName('<event_name>', {
43
45
  <event_parameters>
44
46
  });
45
47
  ```
48
+
49
+ **Go:**
50
+ ```go
51
+ yourCustomTrackFunctionName("<event_name>", map[string]any{}{
52
+ "<property_name>": "<property_value>",
53
+ })
54
+ ```
46
55
  </details>
47
56
 
48
57
 
49
- ## Whats Generated?
58
+ ## What's Generated?
50
59
  A clear YAML schema that shows where your events are tracked, their properties, and more.
51
- Heres an example:
60
+ Here's an example:
52
61
 
53
62
  ```yaml
54
63
  version: 1
@@ -71,21 +80,41 @@ events:
71
80
  type: <property_type>
72
81
  ```
73
82
 
74
- Use this to understand where your events live in the code and how theyre being tracked.
83
+ Use this to understand where your events live in the code and how they're being tracked.
75
84
 
76
85
  Your LLM of choice is used for generating descriptions of events, properties, and implementations.
77
86
 
78
87
  See [schema.json](schema.json) for a JSON Schema of the output.
88
+
89
+
90
+ ## Supported tracking libraries & languages
91
+
92
+ | Library | JavaScript/TypeScript | Python | Ruby | Go |
93
+ |---------|:---------------------:|:------:|:----:|:--:|
94
+ | Google Analytics | ✅ | ❌ | ❌ | ❌ |
95
+ | Segment | ✅ | ✅ | ✅ | ✅ |
96
+ | Mixpanel | ✅ | ✅ | ✅ | ✅ |
97
+ | Amplitude | ✅ | ✅ | ❌ | ✅ |
98
+ | Rudderstack | ✅ | ✅ | ✳️ | ✳️ |
99
+ | mParticle | ✅ | ✅ | ❌ | ❌ |
100
+ | PostHog | ✅ | ✅ | ✅ | ✅ |
101
+ | Pendo | ✅ | ✅ | ❌ | ❌ |
102
+ | Heap | ✅ | ✅ | ❌ | ❌ |
103
+ | Snowplow | ✅ | ✅ | ✅ | ✅ |
104
+ | Custom Function | ✅ | ✅ | ✅ | ✅ |
79
105
 
106
+ ✳️ Rudderstack's SDKs often use the same format as Segment, so Rudderstack events may be detected as Segment events.
80
107
 
81
- ## Supported tracking libraries
108
+
109
+ ## SDKs for supported libraries
82
110
 
83
111
  <details>
84
112
  <summary>Google Analytics</summary>
85
113
 
114
+ **JavaScript/TypeScript**
86
115
  ```js
87
116
  gtag('event', '<event_name>', {
88
- <event_parameters>
117
+ '<property_name>': '<property_value>'
89
118
  });
90
119
  ```
91
120
  </details>
@@ -93,126 +122,323 @@ See [schema.json](schema.json) for a JSON Schema of the output.
93
122
  <details>
94
123
  <summary>Segment</summary>
95
124
 
125
+ **JavaScript/TypeScript**
96
126
  ```js
97
127
  analytics.track('<event_name>', {
98
- <event_parameters>
128
+ '<property_name>': '<property_value>'
99
129
  });
100
130
  ```
131
+
132
+ **Python**
133
+ ```python
134
+ analytics.track('<event_name>', {
135
+ '<property_name>': '<property_value>'
136
+ })
137
+ ```
138
+
139
+ **Ruby**
140
+ ```ruby
141
+ Analytics.track(
142
+ event: '<event_name>',
143
+ properties: {
144
+ '<property_name>': '<property_value>'
145
+ }
146
+ )
147
+ ```
148
+
149
+ **Go**
150
+ ```go
151
+ client.Enqueue(analytics.Track{
152
+ UserId: "user-id",
153
+ Event: "<event_name>",
154
+ Properties: analytics.NewProperties().
155
+ Set("<property_name>", "<property_value>"),
156
+ })
157
+ ```
101
158
  </details>
102
159
 
103
160
  <details>
104
161
  <summary>Mixpanel</summary>
105
162
 
163
+ **JavaScript/TypeScript**
106
164
  ```js
107
165
  mixpanel.track('<event_name>', {
108
- <event_parameters>
166
+ '<property_name>': '<property_value>'
109
167
  });
110
168
  ```
169
+
170
+ **Python**
171
+ ```python
172
+ mixpanel.track('<event_name>', {
173
+ '<property_name>': '<property_value>'
174
+ })
175
+ ```
176
+
177
+ **Ruby**
178
+ ```ruby
179
+ tracker.track('<distinct_id>', '<event_name>', {
180
+ '<property_name>': '<property_value>'
181
+ })
182
+ ```
183
+
184
+ **Go**
185
+ ```go
186
+ ctx := context.Background()
187
+ mp := mixpanel.NewApiClient("YOUR_PROJECT_TOKEN")
188
+ mp.Track(ctx, []*mixpanel.Event{
189
+ mp.NewEvent("<event_name>", "", map[string]any{}{
190
+ "<property_name>": "<property_value>",
191
+ }),
192
+ })
193
+ ```
111
194
  </details>
112
195
 
113
196
  <details>
114
197
  <summary>Amplitude</summary>
115
198
 
199
+ **JavaScript/TypeScript**
116
200
  ```js
117
201
  amplitude.logEvent('<event_name>', {
118
202
  <event_parameters>
119
203
  });
120
204
  ```
205
+
206
+ **Python**
207
+ ```python
208
+ amplitude.track('<event_name>', {
209
+ '<property_name>': '<property_value>'
210
+ })
211
+ ```
212
+
213
+ **Go**
214
+ ```go
215
+ client.Track(amplitude.Event{
216
+ UserID: "<user_id>",
217
+ EventType: "<event_name>",
218
+ EventProperties: map[string]any{}{
219
+ "<property_name>": "<property_value>",
220
+ },
221
+ })
222
+ ```
121
223
  </details>
122
224
 
123
225
  <details>
124
226
  <summary>Rudderstack</summary>
125
227
 
228
+ **JavaScript/TypeScript**
126
229
  ```js
127
230
  rudderanalytics.track('<event_name>', {
128
231
  <event_parameters>
129
232
  });
130
233
  ```
234
+
235
+ **Python**
236
+ ```python
237
+ rudder_analytics.track('<event_name>', {
238
+ '<property_name>': '<property_value>'
239
+ })
240
+ ```
241
+
242
+ **Ruby**
243
+ ```ruby
244
+ analytics.track(
245
+ user_id: '<user_id>',
246
+ event: '<event_name>',
247
+ properties: {
248
+ '<property_name>': '<property_value>'
249
+ }
250
+ )
251
+ ```
252
+
253
+ **Go**
254
+ ```go
255
+ client.Enqueue(analytics.Track{
256
+ UserId: "<user_id>",
257
+ Event: "<event_name>",
258
+ Properties: analytics.NewProperties().
259
+ Set("<property_name>", "<property_value>"),
260
+ })
261
+ ```
131
262
  </details>
132
263
 
133
264
  <details>
134
265
  <summary>mParticle</summary>
135
266
 
267
+ **JavaScript/TypeScript**
136
268
  ```js
137
269
  mParticle.logEvent('<event_name>', {
138
- <event_parameters>
270
+ '<property_name>': '<property_value>'
139
271
  });
140
272
  ```
273
+
274
+ **Python**
275
+ ```python
276
+ mParticle.logEvent('<event_name>', {
277
+ '<property_name>': '<property_value>'
278
+ })
279
+ ```
280
+
281
+
141
282
  </details>
142
283
 
143
284
  <details>
144
285
  <summary>PostHog</summary>
145
286
 
287
+ **JavaScript/TypeScript**
146
288
  ```js
147
289
  posthog.capture('<event_name>', {
148
- <event_parameters>
290
+ '<property_name>': '<property_value>'
149
291
  });
150
292
  ```
293
+
294
+ **Python**
295
+ ```python
296
+ posthog.capture(
297
+ 'distinct_id',
298
+ '<event_name>',
299
+ {
300
+ '<property_name>': '<property_value>'
301
+ }
302
+ )
303
+ # Or
304
+ posthog.capture(
305
+ 'distinct_id',
306
+ event='<event_name>',
307
+ properties={
308
+ '<property_name>': '<property_value>'
309
+ }
310
+ )
311
+ ```
312
+
313
+ **Ruby**
314
+ ```ruby
315
+ posthog.capture({
316
+ distinct_id: '<distinct_id>',
317
+ event: '<event_name>',
318
+ properties: {
319
+ '<property_name>': '<property_value>'
320
+ }
321
+ })
322
+ ```
323
+
324
+ **Go**
325
+ ```go
326
+ client.Enqueue(posthog.Capture{
327
+ DistinctId: "<distinct_id>",
328
+ Event: "<event_name>",
329
+ Properties: posthog.NewProperties().
330
+ Set("<property_name>", "<property_value>"),
331
+ })
332
+ ```
151
333
  </details>
152
334
 
153
335
  <details>
154
336
  <summary>Pendo</summary>
155
337
 
338
+ **JavaScript/TypeScript**
156
339
  ```js
157
340
  pendo.track('<event_name>', {
158
341
  <event_parameters>
159
342
  });
160
343
  ```
344
+
345
+ **Python**
346
+ ```python
347
+ pendo.track('<event_name>', {
348
+ '<property_name>': '<property_value>'
349
+ })
350
+ ```
351
+
352
+
161
353
  </details>
162
354
 
163
355
  <details>
164
356
  <summary>Heap</summary>
165
357
 
358
+ **JavaScript/TypeScript**
166
359
  ```js
167
360
  heap.track('<event_name>', {
168
361
  <event_parameters>
169
362
  });
170
363
  ```
364
+
365
+ **Python**
366
+ ```python
367
+ heap.track('<event_name>', {
368
+ '<property_name>': '<property_value>'
369
+ })
370
+ ```
371
+
372
+
171
373
  </details>
172
374
 
173
375
  <details>
174
- <summary>Snowplow (struct events)</summary>
376
+ <summary>Snowplow (Structured Events)</summary>
175
377
 
378
+ **JavaScript/TypeScript**
176
379
  ```js
177
380
  snowplow('trackStructEvent', {
178
381
  category: '<category>',
179
382
  action: '<action>',
180
383
  label: '<label>',
181
384
  property: '<property>',
182
- value: '<value> '
385
+ value: '<value>'
183
386
  });
184
387
  ```
185
388
 
186
- ```js
389
+ **Python**
390
+ ```python
391
+ # Direct tracking
187
392
  trackStructEvent({
188
- category: '<category>',
189
- action: '<action>',
190
- label: '<label>',
191
- property: '<property>',
192
- value: '<value>'
193
- });
393
+ 'category': '<category>',
394
+ 'action': '<action>',
395
+ 'label': '<label>',
396
+ 'property': '<property>',
397
+ 'value': '<value>'
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
+ })
194
417
  ```
195
418
 
196
- ```js
197
- buildStructEvent({
419
+ **Ruby**
420
+ ```ruby
421
+ tracker.track_struct_event(
198
422
  category: '<category>',
199
423
  action: '<action>',
200
424
  label: '<label>',
201
425
  property: '<property>',
202
426
  value: '<value>'
203
- });
427
+ )
204
428
  ```
205
429
 
206
- _Note: Snowplow Self Describing Events are coming soon!_
430
+ **Go**
431
+ ```go
432
+ tracker.TrackStructEvent(sp.StructuredEvent{
433
+ Category: sp.NewString("<category>"),
434
+ Action: sp.NewString("<action>"),
435
+ Label: sp.NewString("<label>"),
436
+ Property: sp.NewString("<property>"),
437
+ Value: sp.NewFloat64(<value>),
438
+ })
439
+ ```
207
440
  </details>
208
441
 
209
442
 
210
- ## Supported languages
211
-
212
- - JavaScript
213
- - TypeScript
214
- - Ruby (Experimental - only supports Segment for now)
215
-
216
-
217
443
  ## Contribute
218
- Were actively improving this package. Found a bug? Want to request a feature? Open an issue or contribute directly!
444
+ We're actively improving this package. Found a bug? Want to request a feature? Open an issue or contribute directly!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flisk/analyze-tracking",
3
- "version": "0.5.2",
3
+ "version": "0.7.0",
4
4
  "description": "Analyzes tracking code in a project and generates data schemas",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -33,6 +33,7 @@
33
33
  "command-line-usage": "^7.0.3",
34
34
  "isomorphic-git": "^1.27.1",
35
35
  "js-yaml": "^4.1.0",
36
+ "pyodide": "^0.27.6",
36
37
  "typescript": "^5.5.4",
37
38
  "zod": "^3.24.4"
38
39
  },