def attach_tracker(self, stanza, tracker=None):
        """
        Return a new tracker or modify one to track the stanza.

        :param stanza: Stanza to track.
        :type stanza: :class:`aioxmpp.Message`
        :param tracker: Existing tracker to attach to.
        :type tracker: :class:`.tracking.MessageTracker`
        :raises ValueError: if the stanza is of type
            :attr:`~aioxmpp.MessageType.ERROR`
        :raises ValueError: if the stanza contains a delivery receipt
        :return: The message tracker for the stanza.
        :rtype: :class:`.tracking.MessageTracker`

        The `stanza` gets a :xep:`184` reciept request attached and internal
        handlers are set up to update the `tracker` state once a confirmation
        is received.

        .. warning::

           See the :ref:`api-tracking-memory`.

        """
        if stanza.xep0184_received is not None:
            raise ValueError(
                "requesting delivery receipts for delivery receipts is not "
                "allowed"
            )
        if stanza.type_ == aioxmpp.MessageType.ERROR:
            raise ValueError(
                "requesting delivery receipts for errors is not supported"
            )

        if tracker is None:
            tracker = aioxmpp.tracking.MessageTracker()

        stanza.xep0184_request_receipt = True
        stanza.autoset_id()
        self._bare_jid_maps[stanza.to, stanza.id_] = tracker
        return tracker
Return a new tracker or modify one to track the stanza.

        :param stanza: Stanza to track.
        :type stanza: :class:`aioxmpp.Message`
        :param tracker: Existing tracker to attach to.
        :type tracker: :class:`.tracking.MessageTracker`
        :raises ValueError: if the stanza is of type
            :attr:`~aioxmpp.MessageType.ERROR`
        :raises ValueError: if the stanza contains a delivery receipt
        :return: The message tracker for the stanza.
        :rtype: :class:`.tracking.MessageTracker`

        The `stanza` gets a :xep:`184` reciept request attached and internal
        handlers are set up to update the `tracker` state once a confirmation
        is received.

        .. warning::

           See the :ref:`api-tracking-memory`.