Skip to content

Commit

Permalink
fix: Unify batch exports setting around one common setting (#25219)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Oct 3, 2024
1 parent 1f7f5d6 commit fa152e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions posthog/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@

class Notifications(TypedDict, total=False):
plugin_disabled: bool
batch_export_run_failure: bool


NOTIFICATION_DEFAULTS: Notifications = {"plugin_disabled": True, "batch_export_run_failure": True}
NOTIFICATION_DEFAULTS: Notifications = {
"plugin_disabled": True # Catch all for any Pipeline destination issue (plugins, hog functions, batch exports)
}

# We don't ned the following attributes in most cases, so we defer them by default
DEFERED_ATTRS = ["requested_password_reset_at"]
Expand Down
2 changes: 1 addition & 1 deletion posthog/tasks/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def send_batch_export_run_failure(
)
team: Team = batch_export_run.batch_export.team

memberships_to_email = get_members_to_notify(team, "batch_export_run_failure")
memberships_to_email = get_members_to_notify(team, "plugin_disabled")
if not memberships_to_email:
return

Expand Down
4 changes: 2 additions & 2 deletions posthog/tasks/test/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ def test_send_batch_export_run_failure_with_settings(self, MockEmailMessage: Mag
)

self._create_user("[email protected]")
self.user.partial_notification_settings = {"batch_export_run_failure": False}
self.user.partial_notification_settings = {"plugin_disabled": False}
self.user.save()

send_batch_export_run_failure(batch_export_run.id)
# Should only be sent to user2
assert mocked_email_messages[0].to == [{"recipient": "[email protected]", "raw_email": "[email protected]"}]

self.user.partial_notification_settings = {"batch_export_run_failure": True}
self.user.partial_notification_settings = {"plugin_disabled": True}
self.user.save()

send_batch_export_run_failure(batch_export_run.id)
Expand Down

0 comments on commit fa152e8

Please sign in to comment.