mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
feat: add analytics events before each return statement in main()
This commit is contained in:
parent
7b34d9e4f4
commit
accde0bfd0
1 changed files with 27 additions and 0 deletions
|
@ -64,6 +64,7 @@ def guessed_wrong_repo(io, git_root, fnames, git_dname):
|
|||
try:
|
||||
check_repo = Path(GitRepo(io, fnames, git_dname).root).resolve()
|
||||
except (OSError,) + ANY_GIT_ERROR:
|
||||
analytics.event("exit", reason="Processed message file")
|
||||
return
|
||||
|
||||
# we had no guess, rely on the "true" repo result
|
||||
|
@ -148,6 +149,7 @@ def check_gitignore(git_root, io, ask=True):
|
|||
try:
|
||||
repo = git.Repo(git_root)
|
||||
if repo.ignored(".aider") and repo.ignored(".env"):
|
||||
analytics.event("exit", reason="Normal completion")
|
||||
return
|
||||
except ANY_GIT_ERROR:
|
||||
pass
|
||||
|
@ -547,9 +549,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
|
||||
if args.gui and not return_coder:
|
||||
if not check_streamlit_install(io):
|
||||
analytics.event("exit", reason="Streamlit not installed")
|
||||
return
|
||||
analytics.event("gui session")
|
||||
launch_gui(argv)
|
||||
analytics.event("exit", reason="GUI session ended")
|
||||
return
|
||||
|
||||
if args.verbose:
|
||||
|
@ -576,6 +580,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
io.tool_output(
|
||||
"Provide either a single directory of a git repo, or a list of one or more files."
|
||||
)
|
||||
analytics.event("exit", reason="Invalid directory input")
|
||||
return 1
|
||||
|
||||
git_dname = None
|
||||
|
@ -586,6 +591,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
fnames = []
|
||||
else:
|
||||
io.tool_error(f"{all_files[0]} is a directory, but --no-git selected.")
|
||||
analytics.event("exit", reason="Directory with --no-git")
|
||||
return 1
|
||||
|
||||
# We can't know the git repo for sure until after parsing the args.
|
||||
|
@ -594,18 +600,22 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
if args.git and not force_git_root:
|
||||
right_repo_root = guessed_wrong_repo(io, git_root, fnames, git_dname)
|
||||
if right_repo_root:
|
||||
analytics.event("exit", reason="Recursing with correct repo")
|
||||
return main(argv, input, output, right_repo_root, return_coder=return_coder)
|
||||
|
||||
if args.just_check_update:
|
||||
update_available = check_version(io, just_check=True, verbose=args.verbose)
|
||||
analytics.event("exit", reason="Just checking update")
|
||||
return 0 if not update_available else 1
|
||||
|
||||
if args.install_main_branch:
|
||||
success = install_from_main_branch(io)
|
||||
analytics.event("exit", reason="Installed main branch")
|
||||
return 0 if success else 1
|
||||
|
||||
if args.upgrade:
|
||||
success = install_upgrade(io)
|
||||
analytics.event("exit", reason="Upgrade completed")
|
||||
return 0 if success else 1
|
||||
|
||||
if args.check_update:
|
||||
|
@ -613,6 +623,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
|
||||
if args.list_models:
|
||||
models.print_matching_models(io, args.list_models)
|
||||
analytics.event("exit", reason="Listed models")
|
||||
return 0
|
||||
|
||||
if args.git:
|
||||
|
@ -656,6 +667,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
if len(parts) != 2:
|
||||
io.tool_error(f"Invalid alias format: {alias_def}")
|
||||
io.tool_output("Format should be: alias:model-name")
|
||||
analytics.event("exit", reason="Invalid alias format error")
|
||||
return 1
|
||||
alias, model = parts
|
||||
models.MODEL_ALIASES[alias.strip()] = model.strip()
|
||||
|
@ -684,6 +696,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
|
||||
lint_cmds = parse_lint_cmds(args.lint_cmd, io)
|
||||
if lint_cmds is None:
|
||||
analytics.event("exit", reason="Invalid lint command format")
|
||||
return 1
|
||||
|
||||
if args.show_model_warnings:
|
||||
|
@ -696,6 +709,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
io.offer_url(urls.model_warnings, "Open documentation url for more info?")
|
||||
io.tool_output()
|
||||
except KeyboardInterrupt:
|
||||
analytics.event("exit", reason="Keyboard interrupt during model warnings")
|
||||
return 1
|
||||
|
||||
repo = None
|
||||
|
@ -719,6 +733,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
|
||||
if not args.skip_sanity_check_repo:
|
||||
if not sanity_check_repo(repo, io):
|
||||
analytics.event("exit", reason="Repository sanity check failed")
|
||||
return 1
|
||||
|
||||
if repo:
|
||||
|
@ -786,12 +801,15 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
except UnknownEditFormat as err:
|
||||
io.tool_error(str(err))
|
||||
io.offer_url(urls.edit_formats, "Open documentation about edit formats?")
|
||||
analytics.event("exit", reason="Unknown edit format")
|
||||
return 1
|
||||
except ValueError as err:
|
||||
io.tool_error(str(err))
|
||||
analytics.event("exit", reason="ValueError during coder creation")
|
||||
return 1
|
||||
|
||||
if return_coder:
|
||||
analytics.event("exit", reason="Returning coder object")
|
||||
return coder
|
||||
|
||||
coder.show_announcements()
|
||||
|
@ -802,6 +820,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
]
|
||||
messages = coder.format_messages().all_messages()
|
||||
utils.show_messages(messages)
|
||||
analytics.event("exit", reason="Showed prompts")
|
||||
return
|
||||
|
||||
if args.lint:
|
||||
|
@ -810,6 +829,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
if args.test:
|
||||
if not args.test_cmd:
|
||||
io.tool_error("No --test-cmd provided.")
|
||||
analytics.event("exit", reason="No test command provided")
|
||||
return 1
|
||||
test_errors = coder.commands.cmd_test(args.test_cmd)
|
||||
if test_errors:
|
||||
|
@ -822,20 +842,24 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
coder.commands.cmd_commit()
|
||||
|
||||
if args.lint or args.test or args.commit:
|
||||
analytics.event("exit", reason="Completed lint/test/commit")
|
||||
return
|
||||
|
||||
if args.show_repo_map:
|
||||
repo_map = coder.get_repo_map()
|
||||
if repo_map:
|
||||
io.tool_output(repo_map)
|
||||
analytics.event("exit", reason="Showed repo map")
|
||||
return
|
||||
|
||||
if args.apply:
|
||||
content = io.read_text(args.apply)
|
||||
if content is None:
|
||||
analytics.event("exit", reason="Failed to read apply content")
|
||||
return
|
||||
coder.partial_response_content = content
|
||||
coder.apply_updates()
|
||||
analytics.event("exit", reason="Applied updates")
|
||||
return
|
||||
|
||||
if args.apply_clipboard_edits:
|
||||
|
@ -888,13 +912,16 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
coder.run(with_message=message_from_file)
|
||||
except FileNotFoundError:
|
||||
io.tool_error(f"Message file not found: {args.message_file}")
|
||||
analytics.event("exit", reason="Message file not found")
|
||||
return 1
|
||||
except IOError as e:
|
||||
io.tool_error(f"Error reading message file: {e}")
|
||||
analytics.event("exit", reason="Message file IO error")
|
||||
return 1
|
||||
return
|
||||
|
||||
if args.exit:
|
||||
analytics.event("exit", reason="Exit flag set")
|
||||
return
|
||||
|
||||
analytics.event("cli session", main_model=main_model, edit_format=main_model.edit_format)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue