Files
posthog/bin/build-taxonomy-json.py

24 lines
771 B
Python

import os
import sys
import json
import subprocess
# Add the project root to Python path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from posthog.taxonomy.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP
filename = "frontend/src/taxonomy/core-filter-definitions-by-group.json"
# Make CORE_FILTER_DEFINITIONS_BY_GROUP accessible frontend-side
with open(filename, "w") as json_file:
with_comment = {
"//": "THIS FILE IS AUTOGENERATED. DO NOT EDIT MANUALLY. To update: pnpm run taxonomy:build",
**CORE_FILTER_DEFINITIONS_BY_GROUP, # Unpack the dictionary to include its contents
}
json.dump(with_comment, json_file, indent=4, sort_keys=True)
subprocess.run(
["pnpm", "prettier", "--write", filename],
)