"""Feature flags logic.""" from flask import g from pythonfeatures import pythonfeatures from pythonfeatures.constants import split as split_constants from analytics.constants.access import ( FEATURE_INSIGHTS_LINE_SOUNDCLOUD_COLLECTION_AS_ACTIVE, FEATURE_INSIGHTS_PUBLISHED_MAX_AVAILABLE_DATE, FEATURE_INSIGHTS_TIKTOK_FILTERS, FEATURE_INSIGHTS_TRANSFER_PRODUCT_OWNERSHIP, ) def _check_feature_flag(feature_flag): """Check if a feature flag is enabled.""" return ( pythonfeatures.get_single_feature(feature_flag, g.request_context).message == split_constants.FEATURE_ENABLED ) def is_tiktok_filters_enabled(): """Check if insights_tiktok_filters feature flag is enabled.""" return _check_feature_flag(FEATURE_INSIGHTS_TIKTOK_FILTERS) def is_insights_transfer_product_ownership_enabled(): """Check if transfer_product_ownership feature flag is enabled.""" return _check_feature_flag(FEATURE_INSIGHTS_TRANSFER_PRODUCT_OWNERSHIP) def is_insights_line_soundcloud_collection_as_active_enabled(): """Check if insights_line_soundcloud_collection_as_active flag is enabled.""" return _check_feature_flag(FEATURE_INSIGHTS_LINE_SOUNDCLOUD_COLLECTION_AS_ACTIVE) def is_insights_published_max_available_date_enabled(): """Check if insights_published_max_available_date flag is enabled.""" return _check_feature_flag(FEATURE_INSIGHTS_PUBLISHED_MAX_AVAILABLE_DATE)