Skip to content

Commit 3abc7a8

Browse files
psincraianclaude
andauthored
feat(cli): add Klyne tracking to all CLI commands (#10)
* feat(cli): add Klyne tracking to all CLI commands Track all myfy CLI command usage with Klyne analytics: - myfy run: tracks host, port, reload, app_path - myfy start: tracks host, port, workers, app_path - myfy routes: tracks command execution - myfy modules: tracks command execution - myfy doctor: tracks command execution - myfy frontend init: tracks interactive, templates_dir, static_dir - myfy frontend build: tracks command execution This enables analytics on CLI command usage patterns. * style(cli): apply ruff formatting to tracking code Format klyne.track() calls for better readability. * fix(cli): update klyne version requirement to >=0.1.0 Changed klyne dependency from >=0.2.0 to >=0.1.0 to match the actual available versions on PyPI. The latest version is 0.1.0a107. This fixes type checking errors by using klyne's built-in type hints instead of custom stubs. * fix(cli): use correct klyne API and update to v0.3.0 Fix klyne tracking by using the correct API method: - Changed klyne.track() to klyne.track_event() - This is the correct method name in the klyne SDK Also update klyne dependency to >=0.3.0 to use the published version. * fix(cli): correct klyne API to use track() in v0.3.0 In klyne 0.3.0, the method is track(), not track_event(). Changed all tracking calls to use the correct API. --------- Co-authored-by: Claude <[email protected]>
1 parent 8fe690f commit 3abc7a8

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

packages/myfy-cli/myfy_cli/commands/frontend.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sys
44

5+
import klyne
56
import typer
67
from rich.console import Console
78

@@ -144,6 +145,15 @@ def init(
144145
myfy frontend init -i # Interactive mode
145146
myfy frontend init --templates-dir my/templates
146147
"""
148+
klyne.track(
149+
"myfy_frontend_init",
150+
{
151+
"interactive": interactive,
152+
"templates_dir": templates_dir,
153+
"static_dir": static_dir,
154+
},
155+
)
156+
147157
# Check if frontend module is installed
148158
if not HAS_FRONTEND:
149159
_show_missing_module_error()
@@ -192,6 +202,8 @@ def build() -> None:
192202
Examples:
193203
myfy frontend build
194204
"""
205+
klyne.track("myfy_frontend_build", {})
206+
195207
# Check if frontend module is installed
196208
if not HAS_FRONTEND:
197209
_show_missing_module_error()

packages/myfy-cli/myfy_cli/main.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ def run(
190190
191191
Runs the ASGI application with uvicorn.
192192
"""
193+
klyne.track(
194+
"myfy_run",
195+
{
196+
"host": host,
197+
"port": port,
198+
"reload": reload,
199+
"app_path": app_path,
200+
},
201+
)
193202
console.print("🚀 Starting myfy development server...")
194203

195204
if app_path:
@@ -292,6 +301,15 @@ def start(
292301
myfy frontend build
293302
myfy start --host 0.0.0.0 --port 8000 --workers 4
294303
"""
304+
klyne.track(
305+
"myfy_start",
306+
{
307+
"host": host,
308+
"port": port,
309+
"workers": workers,
310+
"app_path": app_path,
311+
},
312+
)
295313
console.print("🚀 Starting myfy production server...")
296314

297315
# Set production environment
@@ -456,6 +474,7 @@ def routes():
456474
457475
Shows a table of routes with methods, paths, and handler names.
458476
"""
477+
klyne.track("myfy_routes", {})
459478
application, _, _ = find_application()
460479

461480
if not application._initialized:
@@ -504,6 +523,7 @@ def modules():
504523
505524
Displays modules and their configuration.
506525
"""
526+
klyne.track("myfy_modules", {})
507527
application, _, _ = find_application()
508528

509529
if not application._initialized:
@@ -528,6 +548,7 @@ def doctor():
528548
529549
Checks for common issues and provides recommendations.
530550
"""
551+
klyne.track("myfy_doctor", {})
531552
console.print("🔍 Running myfy doctor...")
532553

533554
try:

packages/myfy-cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies = [
99
"typer>=0.12",
1010
"rich>=13.0",
1111
"uvicorn[standard]>=0.30",
12-
"klyne>=0.2.0",
12+
"klyne>=0.3.0",
1313
]
1414

1515
[project.optional-dependencies]

0 commit comments

Comments
 (0)