示例#1
0
    def test_filter_event_contains_url(self):

        _create_event(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/123"},
        )

        _create_event(
            event="$pageview",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/123"},
        )

        _create_event(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/1234"},
        )

        action1 = Action.objects.create(team=self.team, name="action1")
        step1 = ActionStep.objects.create(event="$autocapture", action=action1, url="https://posthog.com/feedback/123",)
        query, params = filter_event(step1)

        full_query = EVENT_UUID_QUERY.format(" AND ".join(query))
        result = sync_execute(full_query, {**params, "team_id": self.team.pk})
        self.assertEqual(len(result), 2)
示例#2
0
    def test_filter_event_contains_url(self):

        event_target = _create_event(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/123"},
        )

        _create_event(
            event="$pageview",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/123"},
        )

        _create_event(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/1234"},
        )

        action1 = Action.objects.create(team=self.team, name="action1")
        step1 = ActionStep.objects.create(
            event="$autocapture",
            action=action1,
            url="https://posthog.com/feedback/123",
        )
        query, params, _ = filter_event(step1)

        full_query = "SELECT uuid FROM events WHERE uuid IN {}".format(query)
        result = sync_execute(full_query, {**params, "team_id": self.team.pk})
        self.assertEqual(len(result), 2)
示例#3
0
    def test_filter_event_regex_url(self):

        _create_event(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/123"},
        )

        _create_event(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://test.com/feedback"},
        )

        _create_event(
            event="$autocapture",
            team=self.team,
            distinct_id="whatever",
            properties={"$current_url": "https://posthog.com/feedback/1234"},
        )

        action1 = Action.objects.create(team=self.team, name="action1")
        step1 = ActionStep.objects.create(
            event="$autocapture",
            action=action1,
            url="/123",
            url_matching=ActionStep.REGEX,
        )
        query, params = filter_event(step1)

        full_query = "SELECT uuid FROM events WHERE {}".format(
            " AND ".join(query))
        result = sync_execute(full_query, {**params, "team_id": self.team.pk})
        self.assertEqual(len(result), 2)