Skip to content

Commit

Permalink
add case where config is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Sep 15, 2024
1 parent a76aff7 commit 4bf6d80
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pybamm/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ def capture(event):
if pybamm.config.is_running_tests():
return

properties = {

Check warning on line 27 in src/pybamm/telemetry.py

View check run for this annotation

Codecov / codecov/patch

src/pybamm/telemetry.py#L27

Added line #L27 was not covered by tests
"python_version": sys.version,
"pybamm_version": pybamm.__version__,
}

config = pybamm.config.read()
if config:
user_id = config["uuid"]

Check warning on line 34 in src/pybamm/telemetry.py

View check run for this annotation

Codecov / codecov/patch

src/pybamm/telemetry.py#L32-L34

Added lines #L32 - L34 were not covered by tests
else:
user_id = "anonymous-user-id"
properties["$process_person_profile"] = False

Check warning on line 37 in src/pybamm/telemetry.py

View check run for this annotation

Codecov / codecov/patch

src/pybamm/telemetry.py#L36-L37

Added lines #L36 - L37 were not covered by tests

# setting $process_person_profile to False mean that we only track what events are
# being run and don't capture anything about the user
_posthog.capture(
config["uuid"],
event,
properties={
"python_version": sys.version,
"pybamm_version": pybamm.__version__,
},
)
_posthog.capture(user_id, event, properties=properties)

Check warning on line 41 in src/pybamm/telemetry.py

View check run for this annotation

Codecov / codecov/patch

src/pybamm/telemetry.py#L41

Added line #L41 was not covered by tests

0 comments on commit 4bf6d80

Please sign in to comment.