U 췀g-@sddlmZddlZddlmZmZddlmZzPddlZddl m Z m Z er~ddlm Z ddl m Z ddlmZdd lmZWnek red YnXGd d d eZGd dde ZdS)) TYPE_CHECKINGN) DidNotEnable Integration)flag_error_processor)HookMetadata)LDClient)EvaluationSeriesContext)EvaluationDetail)AnyzLaunchDarkly is not installedc@s&eZdZdZdddZeddZdS)LaunchDarklyIntegrationZ launchdarklyNc Csdz|p t}Wn2tk rB}ztdt|W5d}~XYnX|sTtd|tdS)z :param client: An initialized LDClient instance. If a client is not provided, this integration will attempt to use the shared global instance. z#Error getting LaunchDarkly client. Nz'LaunchDarkly client is not initialized.)ldclientget ExceptionrreprZis_initializedZadd_hookLaunchDarklyHook)selfZ ld_clientclientexcrR/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/launchdarkly.py__init__s"z LaunchDarklyIntegration.__init__cCst}|tdSN) sentry_sdkget_current_scopeZadd_error_processorr)scoperrr setup_once)sz"LaunchDarklyIntegration.setup_once)N)__name__ __module__ __qualname__ identifierr staticmethodrrrrrr s r c@s(eZdZeddZddZddZdS)rcCs tddS)Nzsentry-flag-auditor)name)r)rrrrmetadata2szLaunchDarklyHook.metadatacCs*t|jtr&tj}||j|j|Sr) isinstancevalueboolrrflagssetkey)rseries_contextdatadetailr'rrrafter_evaluation7s  z!LaunchDarklyHook.after_evaluationcCs|Srr)rr*r+rrrbefore_evaluation>sz"LaunchDarklyHook.before_evaluationN)rrrpropertyr#r-r.rrrrr0s r)typingrrZsentry_sdk.integrationsrrZsentry_sdk.flag_utilsrr Z ldclient.hookrrrr Zldclient.evaluationr r ImportErrorr rrrrrs