def METHOD_NAME(self):
    # type: (...) -> None
    pending_sessions = self.pending_sessions
    self.pending_sessions = []
    with self._aggregate_lock:
        pending_aggregates = self.pending_aggregates
        self.pending_aggregates = {}
    envelope = Envelope()
    for session in pending_sessions:
        if len(envelope.items) == MAX_ENVELOPE_ITEMS:
            self.capture_func(envelope)
            envelope = Envelope()
        envelope.add_session(session)
    for attrs, states in pending_aggregates.items():
        if len(envelope.items) == MAX_ENVELOPE_ITEMS:
            self.capture_func(envelope)
            envelope = Envelope()
        envelope.add_sessions(make_aggregate_envelope(states, attrs))
    if len(envelope.items) > 0:
        self.capture_func(envelope)