-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(correlation): Enable person-on-events querying #9952
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ class ClickhouseFunnelBase(ABC): | |
_include_preceding_timestamp: Optional[bool] | ||
_extra_event_fields: List[ColumnName] | ||
_extra_event_properties: List[PropertyName] | ||
_include_person_properties: Optional[bool] | ||
_include_group_properties: List[int] | ||
|
||
def __init__( | ||
self, | ||
|
@@ -45,6 +47,8 @@ def __init__( | |
include_timestamp: Optional[bool] = None, | ||
include_preceding_timestamp: Optional[bool] = None, | ||
base_uri: str = "/", | ||
include_person_properties: Optional[bool] = None, | ||
include_group_properties: Optional[List[int]] = None, # group_type_index for respective group type to get | ||
) -> None: | ||
self._filter = filter | ||
self._team = team | ||
|
@@ -56,6 +60,8 @@ def __init__( | |
} | ||
self._include_timestamp = include_timestamp | ||
self._include_preceding_timestamp = include_preceding_timestamp | ||
self._include_person_properties = include_person_properties | ||
self._include_group_properties = include_group_properties or [] | ||
|
||
# handle default if window isn't provided | ||
if not self._filter.funnel_window_days and not self._filter.funnel_window_interval: | ||
|
@@ -352,11 +358,20 @@ def _get_sorting_condition(self, curr_index: int, max_steps: int): | |
return f"if({' AND '.join(conditions)}, {curr_index}, {self._get_sorting_condition(curr_index - 1, max_steps)})" | ||
|
||
def _get_inner_event_query( | ||
self, entities=None, entity_name="events", skip_entity_filter=False, skip_step_filter=False, extra_fields=[] | ||
self, entities=None, entity_name="events", skip_entity_filter=False, skip_step_filter=False, | ||
) -> str: | ||
parsed_extra_fields = f", {', '.join(extra_fields)}" if extra_fields else "" | ||
entities_to_use = entities or self._filter.entities | ||
|
||
extra_fields = [] | ||
if self._team.actor_on_events_querying_enabled: | ||
if self._include_person_properties: | ||
extra_fields.append("person_properties") | ||
|
||
for group_index in self._include_group_properties: | ||
extra_fields.append(f"group{group_index}_properties") | ||
|
||
parsed_extra_fields = f", {', '.join(extra_fields)}" if extra_fields else "" | ||
|
||
event_query, params = FunnelEventQuery( | ||
filter=self._filter, | ||
team=self._team, | ||
|
@@ -660,3 +675,28 @@ def _get_breakdown_prop(self, group_remaining=False) -> str: | |
return ", prop" | ||
else: | ||
return "" | ||
|
||
def _get_person_and_group_properties(self) -> str: | ||
fields = [] | ||
if self._team.actor_on_events_querying_enabled: | ||
if self._include_person_properties: | ||
fields.append("person_properties") | ||
|
||
for group_index in self._include_group_properties: | ||
fields.append(f"group{group_index}_properties") | ||
|
||
parsed_fields = f", {', '.join(fields)}" if fields else "" | ||
return parsed_fields | ||
|
||
def _get_person_and_group_properties_aggregate(self) -> str: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Can consider just making ** These two NITS were mainly readability. I was confused at first why it was repeating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, done! |
||
fields = [] | ||
if self._team.actor_on_events_querying_enabled: | ||
if self._include_person_properties: | ||
fields.append("any(person_properties) as person_properties") | ||
|
||
for group_index in self._include_group_properties: | ||
group_label = f"group{group_index}_properties" | ||
fields.append(f"any({group_label}) as {group_label}") | ||
|
||
parsed_fields = f", {', '.join(fields)}" if fields else "" | ||
return parsed_fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Can reuse
_get_person_and_group_properties
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra_fields is reused below, hence didn't 😅