author Chris H-C <>
Tue, 12 Nov 2019 20:13:54 +0000
changeset 501647 5205263485b69a2a9661a8a3a8572c829053df31
parent 476082 f810234fde067d4d8cb11976c41dc08710c5988d
child 501655 2ea61656154e395c149f6a025cf53f1b0fd2b878
permissions -rw-r--r--
Bug 1585410 - Implement and document 'deletion-request' ping r=janerik,Dexter The 'deletion-request' ping, which supercedes the 'optout' ping, notifies the pipeline when a profile opts out of FHR upload. (IOW, when a user on a specific profile unchecks the box in about:preferences#privacy about sharing technical and interaction data with Mozilla). This ping tries its best to reach the pipeline to let them know that we need to delete data associated with the provided clientId. This means it will remain pending on the client even after opt out and it will try to resend if upload is ever re-enabled. Differential Revision:

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

class PingFilter(object):
    """Ping filter that accepts any pings."""

    def __call__(self, ping):
        return True

class DeletionRequestPingFilter(PingFilter):
    """Ping filter that accepts deletion-request pings."""

    def __call__(self, ping):
        if not super(DeletionRequestPingFilter, self).__call__(ping):
            return False

        return ping["type"] == "deletion-request"

class EventPingFilter(PingFilter):
    """Ping filter that accepts event pings."""

    def __call__(self, ping):
        if not super(EventPingFilter, self).__call__(ping):
            return False

        return ping["type"] == "event"

class FirstShutdownPingFilter(PingFilter):
    """Ping filter that accepts first-shutdown pings."""

    def __call__(self, ping):
        if not super(FirstShutdownPingFilter, self).__call__(ping):
            return False

        return ping["type"] == "first-shutdown"

class MainPingFilter(PingFilter):
    """Ping filter that accepts main pings."""

    def __call__(self, ping):
        if not super(MainPingFilter, self).__call__(ping):
            return False

        return ping["type"] == "main"

class MainPingReasonFilter(MainPingFilter):
    """Ping filter that accepts main pings that match the
    specified reason.

    def __init__(self, reason):
        super(MainPingReasonFilter, self).__init__()
        self.reason = reason

    def __call__(self, ping):
        if not super(MainPingReasonFilter, self).__call__(ping):
            return False

        return ping["payload"]["info"]["reason"] == self.reason

ANY_PING = PingFilter()
DELETION_REQUEST_PING = DeletionRequestPingFilter()
EVENT_PING = EventPingFilter()
FIRST_SHUTDOWN_PING = FirstShutdownPingFilter()
MAIN_PING = MainPingFilter()
MAIN_SHUTDOWN_PING = MainPingReasonFilter("shutdown")
MAIN_ENVIRONMENT_CHANGE_PING = MainPingReasonFilter("environment-change")