Skip to content

Commit 2204697

Browse files
committed
proposed custom function syntax
1 parent 6e11917 commit 2204697

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,39 @@ Run without installation! Just use:
2323
npx @flisk/analyze-tracking /path/to/project [options]
2424
```
2525

26-
### Key Options:
26+
### Key Options
2727
- `-g, --generateDescription`: Generate descriptions of fields (default: `false`)
2828
- `-p, --provider <provider>`: Specify a provider (options: `openai`, `gemini`)
2929
- `-m, --model <model>`: Specify a model (ex: `gpt-4.1-nano`, `gpt-4o-mini`, `gemini-2.0-flash-lite-001`)
3030
- `-o, --output <output_file>`: Name of the output file (default: `tracking-schema.yaml`)
31-
- `-c, --customFunction <function_name>`: Specify a custom tracking function
31+
- `-c, --customFunction <function_signature>`: Specify the signature of your custom tracking function (see [instructions here](#custom-functions))
3232
- `--format <format>`: Output format, either `yaml` (default) or `json`. If an invalid value is provided, the CLI will exit with an error.
3333
- `--stdout`: Print the output to the terminal instead of writing to a file (works with both YAML and JSON)
3434

3535
🔑&nbsp; **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`.
3636

37-
<details>
38-
<summary>Note on Custom Functions 💡</summary>
3937

40-
Use this if you have your own in-house tracker or a wrapper function that calls other tracking libraries.
38+
### Custom Functions
4139

42-
We currently only support functions that follow the following format:
43-
44-
**JavaScript/TypeScript/Python/Ruby:**
45-
```js
46-
yourCustomTrackFunctionName('<event_name>', {
47-
<event_parameters>
48-
});
49-
```
50-
51-
**Go:**
52-
```go
53-
yourCustomTrackFunctionName("<event_name>", map[string]any{}{
54-
"<property_name>": "<property_value>",
55-
})
56-
```
57-
</details>
40+
If you have your own in-house tracker or a wrapper function that calls other tracking libraries, you can specify the function signature with the `-c` or `--customFunction` option.
41+
42+
Your function signature should be in the following format:
43+
```js
44+
yourCustomTrackFunctionName(EVENT_NAME, PROPERTIES, customFieldOne, customFieldTwo)
45+
```
46+
47+
- `EVENT_NAME` is the name of the event you are tracking. It should be a string or a pointer to a string.
48+
- `PROPERTIES` is an object of properties for that event. It should be an object / dictionary.
49+
- Any additional parameters are other fields you are tracking. They can be of any type. The names you provide for these parameters will be used as the property names in the output.
50+
51+
52+
For example, if your function has a userId parameter at the beginning, followed by the event name and properties, you would pass in the following:
53+
54+
```js
55+
yourCustomTrackFunctionName(userId, EVENT_NAME, PROPERTIES)
56+
```
57+
58+
If your function follows the format `yourCustomTrackFunctionName(EVENT_NAME, PROPERTIES)`, you can simply pass in `yourCustomTrackFunctionName` to `--customFunction` as a shorthand.
5859

5960

6061
## What's Generated?

0 commit comments

Comments
 (0)