Skip to content
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

chore(surveys): do not double charge for survey sent events #18698

Merged
merged 8 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions posthog/tasks/test/__snapshots__/test_usage_report.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
FROM events
WHERE timestamp between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59'
AND event != '$feature_flag_called'
AND event != 'survey sent'
GROUP BY team_id
'
---
Expand Down Expand Up @@ -196,6 +197,7 @@
FROM events
WHERE timestamp between '2022-01-01 00:00:00' AND '2022-01-10 23:59:59'
AND event != '$feature_flag_called'
AND event != 'survey sent'
GROUP BY team_id
'
---
Expand Down
22 changes: 22 additions & 0 deletions posthog/tasks/test/test_usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ def _create_sample_usage_data(self) -> None:
team=self.org_1_team_1,
)

_create_event(
distinct_id=distinct_id,
event="survey sent",
properties={"$survey_response": "cooool"},
timestamp=now() - relativedelta(hours=12),
team=self.org_1_team_1,
)

# Events before the period
for _ in range(0, 10):
_create_event(
Expand Down Expand Up @@ -291,6 +299,13 @@ def _create_sample_usage_data(self) -> None:
timestamp=now() - relativedelta(hours=12),
team=self.org_1_team_2,
)
_create_event(
distinct_id=distinct_id,
event="survey sent",
properties={"$survey_response": "cooool"},
timestamp=now() - relativedelta(hours=12),
team=self.org_1_team_2,
)

# Events for org 2 team 3
distinct_id = str(uuid4())
Expand All @@ -311,6 +326,13 @@ def _create_sample_usage_data(self) -> None:
timestamp=now() - relativedelta(hours=12),
team=self.org_2_team_3,
)
_create_event(
distinct_id=distinct_id,
event="survey sent",
properties={"$survey_response": "cooool"},
timestamp=now() - relativedelta(hours=12),
team=self.org_2_team_3,
)

flush_persons_and_events()

Expand Down
2 changes: 1 addition & 1 deletion posthog/tasks/usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def get_teams_with_billable_event_count_in_period(
f"""
SELECT team_id, count({distinct_expression}) as count
FROM events
WHERE timestamp between %(begin)s AND %(end)s AND event != '$feature_flag_called'
WHERE timestamp between %(begin)s AND %(end)s AND event != '$feature_flag_called' AND event != 'survey sent'
liyiy marked this conversation as resolved.
Show resolved Hide resolved
GROUP BY team_id
""",
{"begin": begin, "end": end},
Expand Down
Loading