
    Dj-                         d dl mZ d dlZd dlmZmZ d dlmZ 	 d dlZd dl	m
Z
mZ erd dlmZ d dl	mZ d dlmZ d d	l mZ  G d de      Z G d de
      Zy# e$ r	  ed
      w xY w)    )TYPE_CHECKINGN)DidNotEnableIntegration)flag_error_processor)HookMetadata)LDClient)EvaluationSeriesContext)EvaluationDetail)AnyzLaunchDarkly is not installedc                   (    e Zd ZdZddZed        Zy)LaunchDarklyIntegrationlaunchdarklyNc                     	 |xs t        j                         }|j                         st        d      |j                  t                      y# t        $ r}t        dt	        |      z         d}~ww xY w)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.)ldclientget	Exceptionr   repris_initializedadd_hookLaunchDarklyHook)self	ld_clientclientexcs       hC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\sentry_sdk/integrations/launchdarkly.py__init__z LaunchDarklyIntegration.__init__   sm    	R0(,,.F $$&HII 	(*+  	RDtCyPQQ	Rs   A 	A4A//A4c                  V    t        j                         } | j                  t               y N)
sentry_sdkget_current_scopeadd_error_processorr   )scopes    r   
setup_oncez"LaunchDarklyIntegration.setup_once)   s!     ,,.!!"67    r   )__name__
__module____qualname__
identifierr   staticmethodr$    r%   r   r   r      s     J," 8 8r%   r   c                   (    e Zd Zed        Zd Zd Zy)r   c                     t        d      S )Nzsentry-flag-auditor)name)r   )r   s    r   metadatazLaunchDarklyHook.metadata2   s     233r%   c                     t        |j                  t              rDt        j                         j
                  }|j                  |j                  |j                         |S r   )
isinstancevalueboolr    r!   flagssetkey)r   series_contextdatadetailr4   s        r   after_evaluationz!LaunchDarklyHook.after_evaluation7   sA    fllD)00288EIIn((&,,7r%   c                     |S r   r+   )r   r7   r8   s      r   before_evaluationz"LaunchDarklyHook.before_evaluation>   s    r%   N)r&   r'   r(   propertyr/   r:   r<   r+   r%   r   r   r   0   s    4 4r%   r   )typingr   r    sentry_sdk.integrationsr   r   sentry_sdk.flag_utilsr   r   ldclient.hookr   r   r	   r
   ldclient.evaluationr   r   ImportErrorr   r   r+   r%   r   <module>rD      s`       = 68,%98
8k 86t ?  8
6
778s   &A A%