Skip to content

Commit

Permalink
feat: sets default value for optional event fields (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein committed Apr 29, 2024
1 parent 4fa2102 commit afd2743
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/posit/connect/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ def from_usage_event(event: usage.UsageEvent) -> ViewEvent:
event.session,
content_guid=event.content_guid,
user_guid=event.user_guid,
variant_key=None,
rendering_id=None,
bundle_id=None,
started=event.started,
ended=event.ended,
data_version=event.data_version,
path=None,
)

def __init__(self, config: resources.Config, session: Session, **kwargs):
Expand Down Expand Up @@ -82,7 +86,7 @@ def variant_key(self) -> str | None:
str | None
The variant key, or None if the associated content type is static.
"""
return self.get("variant_key")
return self["variant_key"]

@property
def rendering_id(self) -> int | None:
Expand All @@ -93,7 +97,7 @@ def rendering_id(self) -> int | None:
int | None
The render id, or None if the associated content type is static.
"""
return self.get("rendering_id")
return self["rendering_id"]

@property
def bundle_id(self) -> int | None:
Expand All @@ -103,7 +107,7 @@ def bundle_id(self) -> int | None:
-------
int
"""
return self.get("bundle_id")
return self["bundle_id"]

@property
def started(self) -> str:
Expand Down Expand Up @@ -143,7 +147,7 @@ def path(self) -> str | None:
-------
str
"""
return self.get("path")
return self["path"]


class Views(resources.Resources):
Expand Down

0 comments on commit afd2743

Please sign in to comment.