From 89b10dcb833e1f1dddec65e4bb44939e4ba82dcb Mon Sep 17 00:00:00 2001 From: Florian Margaine Date: Thu, 13 Nov 2025 15:39:16 +0100 Subject: [PATCH 1/3] Add insights enablement check and hide InsightsCard when disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add checkInsightsEnabled() API method to check if insights are enabled for a service - Check insights status on component mount before fetching data - Hide entire InsightsCard component when insights are not enabled - Update refresh and time range handlers to respect insights status - Uses Fastly API endpoint: /enabled-products/v1/log_explorer_insights/services/{service_id} 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/components/project/InsightsCard.vue | 35 +++++++++++++++++++---- src/components/project/project.service.ts | 11 +++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/components/project/InsightsCard.vue b/src/components/project/InsightsCard.vue index d915aaa..c5daba1 100644 --- a/src/components/project/InsightsCard.vue +++ b/src/components/project/InsightsCard.vue @@ -65,6 +65,9 @@ const lock = ref(false); /** Store the insights data */ const insightsData = ref | null>(null); +/** Track whether insights are enabled for this service */ +const isInsightsEnabled = ref(null); + /** Chart configurations for each insight metric */ const charts = ref>(new Map()); @@ -98,12 +101,28 @@ const visualizations = [ ]; /** - * Component lifecycle hook - fetches initial data when component is mounted + * Component lifecycle hook - checks insights enablement and fetches initial data when component is mounted */ -onMounted(() => { - fetchInsights(); +onMounted(async () => { + await checkInsightsEnabledStatus(); + if (isInsightsEnabled.value) { + fetchInsights(); + } }); +/** + * Checks if insights are enabled for this service + */ +async function checkInsightsEnabledStatus() { + try { + const projectService = new ProjectAPIService(credentialsStore.getServiceId(), credentialsStore.getServiceToken()); + isInsightsEnabled.value = await projectService.checkInsightsEnabled(); + } catch (error) { + console.error('Error checking insights enabled status:', error); + isInsightsEnabled.value = false; + } +} + /** * Calculates start and end times based on selected time range */ @@ -866,19 +885,23 @@ function getColorForIndex(index: number, alpha: number = 1): string { * Manual refresh handler */ function handleRefresh() { - fetchInsights(); + if (isInsightsEnabled.value) { + fetchInsights(); + } } /** * Handle time range change */ function handleTimeRangeChange() { - fetchInsights(); + if (isInsightsEnabled.value) { + fetchInsights(); + } }