
    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m	Z	 d dl
mZ erd dlmZ d dl
mZ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)api)Hook)FlagEvaluationDetails)HookContext	HookHintszOpenFeature is not installedc                        e Zd ZdZed        Zy)OpenFeatureIntegrationopenfeaturec                      t        j                         } | j                  t               t	        j
                  t               g       y )N)hooks)
sentry_sdkget_current_scopeadd_error_processorr   r   	add_hooksOpenFeatureHook)scopes    gC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\sentry_sdk/integrations/openfeature.py
setup_oncez!OpenFeatureIntegration.setup_once   s5     ,,.!!"67 	_./0    N)__name__
__module____qualname__
identifierstaticmethodr    r   r   r   r      s    J1 1r   r   c                       e Zd Zd Zd Zy)r   c                     t        |j                  t              rEt        j                         j
                  }|j                  |j                  |j                         y y N)
isinstancevalueboolr   r   flagssetflag_key)selfhook_contextdetailshintsr&   s        r   afterzOpenFeatureHook.after!   sA    gmmT*00288EIIg&&6 +r   c                     t        |j                  t              rEt        j                         j
                  }|j                  |j                  |j                         y y r"   )r#   default_valuer%   r   r   r&   r'   r(   )r)   r*   	exceptionr,   r&   s        r   errorzOpenFeatureHook.error'   sE    l00$700288EIIl++\-G-GH 8r   N)r   r   r   r-   r1   r   r   r   r   r      s    7Ir   r   )typingr   r   sentry_sdk.integrationsr   r   sentry_sdk.flag_utilsr   r   r   openfeature.hookr   openfeature.flag_evaluationr	   r
   r   ImportErrorr   r   r   r   r   <module>r8      s\       = 67%E;

1[ 
1Id I#  7
5
667s   A A