diff --git a/sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_delete_events_v2/query.sql b/sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_delete_events_v2/query.sql index 6220db9d2b..25238b2824 100644 --- a/sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_delete_events_v2/query.sql +++ b/sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_delete_events_v2/query.sql @@ -11,7 +11,7 @@ WITH hmac_key AS ( key_id = 'fxa_hmac_prod' ) SELECT - `timestamp` AS submission_timestamp, + MIN(`timestamp`) AS submission_timestamp, TO_HEX(SHA256(jsonPayload.fields.uid)) AS user_id, TO_HEX( udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.uid AS BYTES)) @@ -25,6 +25,10 @@ WHERE AND DATE_ADD(@submission_date, INTERVAL 1 DAY) ) AND DATE(`timestamp`) = @submission_date - AND jsonPayload.type = 'activityEvent' - AND jsonPayload.fields.event = 'account.deleted' + AND ( + jsonPayload.type IN ('accountDeleted', 'accountDeleted.byRequest', 'DB.deleteAccount') + OR (jsonPayload.type = 'activityEvent' AND jsonPayload.fields.event = 'account.deleted') + ) AND jsonPayload.fields.uid IS NOT NULL +GROUP BY + jsonPayload.fields.uid