From cb867d885445cf204a59e1758b447f0a857647d1 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Wed, 14 Oct 2020 13:36:12 +0200 Subject: [PATCH] Friendlier error when NR APM API Key isn't configured. --- .../NewRelicFetchComponent/NewRelicFetchComponent.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/newrelic/src/components/NewRelicFetchComponent/NewRelicFetchComponent.tsx b/plugins/newrelic/src/components/NewRelicFetchComponent/NewRelicFetchComponent.tsx index 9b3791e062..4322bba10b 100644 --- a/plugins/newrelic/src/components/NewRelicFetchComponent/NewRelicFetchComponent.tsx +++ b/plugins/newrelic/src/components/NewRelicFetchComponent/NewRelicFetchComponent.tsx @@ -107,10 +107,15 @@ const NewRelicFetchComponent: FC<{}> = () => { const configApi = useApi(configApiRef); const apiBaseUrl = configApi.getString('newrelic.api.baseUrl'); const apiKey = configApi.getString('newrelic.api.key'); + const apiKeyIsSet = apiKey && apiKey !== 'NEW_RELIC_REST_API_KEY'; const { value, loading, error } = useAsync(async (): Promise< NewRelicApplication[] > => { + if (!apiKeyIsSet) { + return []; + } + const response = await fetch(`${apiBaseUrl}/applications.json`, { headers: { 'X-Api-Key': apiKey, @@ -126,6 +131,12 @@ const NewRelicFetchComponent: FC<{}> = () => { return ; } else if (error) { return {error.message}; + } else if (!apiKeyIsSet) { + return ( + + No REST API Key configured. Check your app-config.yaml. + + ); } return ;