Skip to content

Commit

Permalink
generate descriptions for fields
Browse files Browse the repository at this point in the history
  • Loading branch information
skarim committed Oct 6, 2024
1 parent f2bc6c8 commit 124aa72
Show file tree
Hide file tree
Showing 7 changed files with 463 additions and 12 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ npx @flisk/analyze-tracking /path/to/project [options]
```

### Key Options:
- `-g, --generateDescription`: Generate descriptions of fields (default: `false`)
- `-o, --output <output_file>`: Name of the output file (default: `tracking-schema.yaml`)
- `-c, --customFunction <function_name>`: Specify a custom tracking function

🔑&nbsp; **Important:** you must set the `OPENAI_API_KEY` environment variable to use `generateDescription`

<details>
<summary>Note on Custom Functions 💡</summary>

Expand All @@ -53,18 +56,23 @@ source:
timestamp: <commit_timestamp>
events:
<event_name>:
description: <ai_generated_description>
implementations:
- path: <path_to_file>
- description: <ai_generated_description>
path: <path_to_file>
line: <line_number>
function: <function_name>
destination: <platform_name>
properties:
<property_name>:
description: <ai_generated_description>
type: <property_type>
```
Use this to understand where your events live in the code and how they’re being tracked.
[GPT-4o mini](https://platform.openai.com/docs/models/gpt-4o-mini) is used for generating descriptions of events, properties, and implementations.
See [schema.json](schema.json) for a JSON Schema of the output.
Expand Down
16 changes: 15 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ const optionDefinitions = [
type: String,
defaultOption: true,
},
{
name: 'generateDescription',
alias: 'g',
type: Boolean,
defaultValue: false,
},
{
name: 'output',
alias: 'o',
Expand Down Expand Up @@ -48,6 +54,7 @@ const optionDefinitions = [
const options = commandLineArgs(optionDefinitions);
const {
targetDir,
generateDescription,
output,
customFunction,
repositoryUrl,
Expand All @@ -73,4 +80,11 @@ if (!targetDir) {
process.exit(1);
}

run(path.resolve(targetDir), output, customFunction, customSourceDetails);
if (generateDescription) {
if (!process.env.OPENAI_API_KEY) {
console.error('Please set the `OPENAI_API_KEY` environment variable to use `generateDescription`.');
process.exit(1);
}
}

run(path.resolve(targetDir), output, customFunction, customSourceDetails, generateDescription);
10 changes: 9 additions & 1 deletion bin/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ const helpContent = [
description: 'Display this usage guide.',
type: Boolean
},
{
name: 'generateDescription',
alias: 'g',
description: 'Generate descriptions of fields.',
type: Boolean,
defaultValue: false,
typeLabel: '{underline false}'
},
{
name: 'output',
alias: 'o',
Expand All @@ -51,7 +59,7 @@ const helpContent = [
alias: 'c',
description: 'Specify a custom tracking function.',
type: String,
typeLabel: '{underline yourCustomFunctionName}'
typeLabel: '{italic yourCustomFunctionName}'
}
]
},
Expand Down
Loading

0 comments on commit 124aa72

Please sign in to comment.