From 26f6b91fd9465c20b53e9d151cf968ee783ad8bd Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Wed, 22 Jun 2022 09:27:55 +0100 Subject: [PATCH] Chore: Type GA and Rudderstack analytics config (#51197) * Chore: Type GA and Rudderstack analytics config * rely on implicit unknown --- packages/grafana-data/src/types/config.ts | 5 +++++ packages/grafana-runtime/src/config.ts | 5 +++++ public/app/app.ts | 16 ++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/grafana-data/src/types/config.ts b/packages/grafana-data/src/types/config.ts index 0aa90132acb..4e8c86eba29 100644 --- a/packages/grafana-data/src/types/config.ts +++ b/packages/grafana-data/src/types/config.ts @@ -188,4 +188,9 @@ export interface GrafanaConfig { unifiedAlertingEnabled: boolean; angularSupportEnabled: boolean; feedbackLinksEnabled: boolean; + googleAnalyticsId: string | undefined; + rudderstackWriteKey: string | undefined; + rudderstackDataPlaneUrl: string | undefined; + rudderstackSdkUrl: string | undefined; + rudderstackConfigUrl: string | undefined; } diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index d3a0d515679..43e6fca9cdb 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -119,6 +119,11 @@ export class GrafanaBootConfig implements GrafanaConfig { reporting = { enabled: true, }; + googleAnalyticsId: undefined; + rudderstackWriteKey: undefined; + rudderstackDataPlaneUrl: undefined; + rudderstackSdkUrl: undefined; + rudderstackConfigUrl: undefined; constructor(options: GrafanaBootConfig) { const mode = options.bootData.user.lightTheme ? 'light' : 'dark'; diff --git a/public/app/app.ts b/public/app/app.ts index 08d0541485f..a137ffeaf8d 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -152,7 +152,7 @@ export class GrafanaApp { }), document.getElementById('reactRoot') ); - } catch (error: any) { + } catch (error) { console.error('Failed to start Grafana', error); window.__grafana_load_failed(); } @@ -204,22 +204,22 @@ function initEchoSrv() { ); } - if ((config as any).googleAnalyticsId) { + if (config.googleAnalyticsId) { registerEchoBackend( new GAEchoBackend({ - googleAnalyticsId: (config as any).googleAnalyticsId, + googleAnalyticsId: config.googleAnalyticsId, }) ); } - if ((config as any).rudderstackWriteKey && (config as any).rudderstackDataPlaneUrl) { + if (config.rudderstackWriteKey && config.rudderstackDataPlaneUrl) { registerEchoBackend( new RudderstackBackend({ - writeKey: (config as any).rudderstackWriteKey, - dataPlaneUrl: (config as any).rudderstackDataPlaneUrl, + writeKey: config.rudderstackWriteKey, + dataPlaneUrl: config.rudderstackDataPlaneUrl, user: config.bootData.user, - sdkUrl: (config as any).rudderstackSdkUrl, - configUrl: (config as any).rudderstackConfigUrl, + sdkUrl: config.rudderstackSdkUrl, + configUrl: config.rudderstackConfigUrl, }) ); }