Skip to content

Commit

Permalink
feat(web-analytics): Allow other session properties beyond $session_d…
Browse files Browse the repository at this point in the history
…uration (#21515)

* Allow other session properties beyond $session_duration

* Remove empty properties
  • Loading branch information
robbie-c authored Apr 15, 2024
1 parent d83d5eb commit fc4719d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4931,7 +4931,6 @@
"additionalProperties": false,
"properties": {
"key": {
"const": "$session_duration",
"type": "string"
},
"label": {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ export interface ElementPropertyFilter extends BasePropertyFilter {

export interface SessionPropertyFilter extends BasePropertyFilter {
type: PropertyFilterType.Session
key: '$session_duration'
operator: PropertyOperator
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def clean_property_group_filter(properties: dict):


def clean_property_group_filter_values(properties: list[dict]):
return [clean_property_group_filter_value(property) for property in properties]
cleaned = [clean_property_group_filter_value(property) for property in properties if property]
return cleaned


def clean_property_group_filter_value(property: dict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ def test_series_properties(self):
EventsNode(
event="$pageview",
name="$pageview",
properties=[SessionPropertyFilter(value=1, operator=PropertyOperator.gt)],
properties=[SessionPropertyFilter(key="$session_duration", value=1, operator=PropertyOperator.gt)],
),
EventsNode(
event="$pageview",
Expand Down
2 changes: 1 addition & 1 deletion posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ class SessionPropertyFilter(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
key: Literal["$session_duration"] = "$session_duration"
key: str
label: Optional[str] = None
operator: PropertyOperator
type: Literal["session"] = "session"
Expand Down

0 comments on commit fc4719d

Please sign in to comment.