From 4a52a71956a8d46fcb7294ac71734504bb09bcc2 Mon Sep 17 00:00:00 2001 From: S. Solomon Darnell Date: Fri, 28 Mar 2025 21:52:21 -0500 Subject: two version of R2R are here --- .../sentry_sdk/integrations/statsig.py | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .venv/lib/python3.12/site-packages/sentry_sdk/integrations/statsig.py (limited to '.venv/lib/python3.12/site-packages/sentry_sdk/integrations/statsig.py') diff --git a/.venv/lib/python3.12/site-packages/sentry_sdk/integrations/statsig.py b/.venv/lib/python3.12/site-packages/sentry_sdk/integrations/statsig.py new file mode 100644 index 00000000..1d84eb8a --- /dev/null +++ b/.venv/lib/python3.12/site-packages/sentry_sdk/integrations/statsig.py @@ -0,0 +1,37 @@ +from functools import wraps +from typing import Any, TYPE_CHECKING + +from sentry_sdk.feature_flags import add_feature_flag +from sentry_sdk.integrations import Integration, DidNotEnable, _check_minimum_version +from sentry_sdk.utils import parse_version + +try: + from statsig import statsig as statsig_module + from statsig.version import __version__ as STATSIG_VERSION +except ImportError: + raise DidNotEnable("statsig is not installed") + +if TYPE_CHECKING: + from statsig.statsig_user import StatsigUser + + +class StatsigIntegration(Integration): + identifier = "statsig" + + @staticmethod + def setup_once(): + # type: () -> None + version = parse_version(STATSIG_VERSION) + _check_minimum_version(StatsigIntegration, version, "statsig") + + # Wrap and patch evaluation method(s) in the statsig module + old_check_gate = statsig_module.check_gate + + @wraps(old_check_gate) + def sentry_check_gate(user, gate, *args, **kwargs): + # type: (StatsigUser, str, *Any, **Any) -> Any + enabled = old_check_gate(user, gate, *args, **kwargs) + add_feature_flag(gate, enabled) + return enabled + + statsig_module.check_gate = sentry_check_gate -- cgit 1.4.1