Skip to content

Commit

Permalink
Move runner type from user property to event property
Browse files Browse the repository at this point in the history
Signed-off-by: Wei-Chun, Chang <[email protected]>
  • Loading branch information
wcchang1115 committed Jun 4, 2024
1 parent 5c0b9b0 commit 33cd51f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions recce/event/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from contextlib import contextmanager
from datetime import datetime
from json import JSONDecodeError
from typing import Union

import portalocker
import requests

from recce import __version__, is_ci_env, get_runner
from recce import __version__, is_ci_env


class Collector:
Expand All @@ -24,7 +23,6 @@ def __init__(self):
self._delete_threshold = 1000
self._upload_threshold = 10
self._is_ci: bool = is_ci_env()
self._runner: Union[str, None] = get_runner()

def is_ready(self):
if self._api_key is None or self._user_id is None:
Expand Down Expand Up @@ -61,7 +59,6 @@ def log_event(self, prop, event_type):
version=__version__,
python_version=python_version,
is_ci=self._is_ci,
runner=self._runner,
),
event_properties=prop,
platform=sys.platform,
Expand Down
6 changes: 5 additions & 1 deletion recce/event/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from rich.console import Console
from rich.markup import escape

from recce import event
from recce import event, get_runner
from recce.core import load_context

console = Console()
Expand Down Expand Up @@ -78,6 +78,7 @@ def invoke(self, ctx: Context) -> t.Any:
finally:
end_time = time.time()
duration = end_time - start_time
runner = get_runner()
command = ctx.command.name
props = dict(
command=command,
Expand All @@ -86,6 +87,9 @@ def invoke(self, ctx: Context) -> t.Any:
duration=duration,
)

if runner is not None:
props['runner_type'] = runner

try:
recce_context = load_context()
except Exception:
Expand Down

0 comments on commit 33cd51f

Please sign in to comment.