class TestFunnelStrictStepsBreakdown(ClickhouseTestMixin, funnel_breakdown_test_factory(ClickhouseFunnelStrict, ClickhouseFunnelStrictActors, _create_event, _create_action, _create_person)): # type: ignore maxDiff = None def test_strict_breakdown_events_with_multiple_properties(self): filters = { "events": [{"id": "sign up", "order": 0}, {"id": "play movie", "order": 1}], "insight": INSIGHT_FUNNELS, "date_from": "2020-01-01", "date_to": "2020-01-08", "funnel_window_days": 7, "breakdown_type": "event", "breakdown": "$browser", } filter = Filter(data=filters) funnel = ClickhouseFunnelStrict(filter, self.team) people = journeys_for( { "person1": [ {"event": "sign up", "timestamp": datetime(2020, 1, 1, 12), "properties": {"$browser": "Chrome"}}, {"event": "blah", "timestamp": datetime(2020, 1, 1, 13), "properties": {"$browser": "Chrome"}}, { "event": "play movie", "timestamp": datetime(2020, 1, 1, 14), "properties": {"$browser": "Chrome"}, }, ], "person2": [ {"event": "sign up", "timestamp": datetime(2020, 1, 2, 13), "properties": {"$browser": "Safari"}}, { "event": "play movie", "timestamp": datetime(2020, 1, 2, 14), "properties": {"$browser": "Safari"}, }, ], }, self.team, ) result = funnel.run() assert_funnel_results_equal( result[0], [ { "action_id": "sign up", "name": "sign up", "custom_name": None, "order": 0, "people": [], "count": 1, "type": "events", "average_conversion_time": None, "median_conversion_time": None, "breakdown": ["Chrome"], "breakdown_value": ["Chrome"], }, { "action_id": "play movie", "name": "play movie", "custom_name": None, "order": 1, "people": [], "count": 0, "type": "events", "average_conversion_time": None, "median_conversion_time": None, "breakdown": ["Chrome"], "breakdown_value": ["Chrome"], }, ], ) self.assertCountEqual(self._get_actor_ids_at_step(filter, 1, ["Chrome"]), [people["person1"].uuid]) self.assertCountEqual(self._get_actor_ids_at_step(filter, 2, ["Chrome"]), []) assert_funnel_results_equal( result[1], [ { "action_id": "sign up", "name": "sign up", "custom_name": None, "order": 0, "people": [], "count": 1, "type": "events", "average_conversion_time": None, "median_conversion_time": None, "breakdown": ["Safari"], "breakdown_value": ["Safari"], }, { "action_id": "play movie", "name": "play movie", "custom_name": None, "order": 1, "people": [], "count": 1, "type": "events", "average_conversion_time": 3600, "median_conversion_time": 3600, "breakdown": ["Safari"], "breakdown_value": ["Safari"], }, ], ) self.assertCountEqual(self._get_actor_ids_at_step(filter, 1, ["Safari"]), [people["person2"].uuid]) self.assertCountEqual(self._get_actor_ids_at_step(filter, 2, ["Safari"]), [people["person2"].uuid])
class TestFunnelUnorderedStepsBreakdown(ClickhouseTestMixin, funnel_breakdown_test_factory( ClickhouseFunnelUnordered, ClickhouseFunnelUnorderedPersons, _create_event, _create_person)): # type: ignore maxDiff = None def test_funnel_step_breakdown_event_single_person_events_with_multiple_properties( self): # overriden from factory filters = { "events": [{ "id": "sign up", "order": 0 }, { "id": "play movie", "order": 1 }], "insight": INSIGHT_FUNNELS, "date_from": "2020-01-01", "date_to": "2020-01-08", "funnel_window_days": 7, "breakdown_type": "event", "breakdown": "$browser", } filter = Filter(data=filters) funnel = ClickhouseFunnelUnordered(filter, self.team) # event person1 = _create_person(distinct_ids=["person1"], team_id=self.team.pk) _create_event( team=self.team, event="sign up", distinct_id="person1", properties={ "key": "val", "$browser": "Chrome" }, timestamp="2020-01-01T12:00:00Z", ) _create_event( team=self.team, event="sign up", distinct_id="person1", properties={ "key": "val", "$browser": "Safari" }, timestamp="2020-01-02T13:00:00Z", ) _create_event( team=self.team, event="play movie", distinct_id="person1", properties={ "key": "val", "$browser": "Safari" }, timestamp="2020-01-02T14:00:00Z", ) result = funnel.run() self.assertEqual( result[0], [ { "action_id": "sign up", "name": "sign up", "order": 0, "people": [], "count": 1, "type": "events", "average_conversion_time": None, "median_conversion_time": None, "breakdown": "Chrome", }, { "action_id": "play movie", "name": "play movie", "order": 1, "people": [], "count": 0, "type": "events", "average_conversion_time": None, "median_conversion_time": None, "breakdown": "Chrome", }, ], ) self.assertCountEqual(self._get_people_at_step(filter, 1, "Chrome"), [person1.uuid]) self.assertCountEqual(self._get_people_at_step(filter, 2, "Chrome"), []) self.assertEqual( result[1], [ { "action_id": "sign up", "name": "sign up", "order": 0, "people": [], "count": 1, "type": "events", "average_conversion_time": None, "median_conversion_time": None, "breakdown": "Safari", }, { "action_id": "play movie", "name": "play movie", "order": 1, "people": [], "count": 1, "type": "events", "average_conversion_time": 3600, "median_conversion_time": 3600, "breakdown": "Safari", }, ], ) self.assertCountEqual(self._get_people_at_step(filter, 1, "Safari"), [person1.uuid]) self.assertCountEqual(self._get_people_at_step(filter, 2, "Safari"), [person1.uuid])
class TestFunnelBreakdown(ClickhouseTestMixin, funnel_breakdown_test_factory( ClickhouseFunnel, ClickhouseFunnelPersons, _create_event, _create_person)): # type: ignore maxDiff = None pass