from typing import MutableMapping
from typing import Callable
from typing import Any


def _create_before_send_filter(tags: MutableMapping[str, str]) -> Callable[[Any, Any], Any]:
    """Create a filter that adds tags to every events."""

    def do_filter(event: Any, hint: Any) -> Any:
        event.setdefault("tags", {}).update(tags)
        return event

    return do_filter