diff --git a/public/app/core/components/SharedPreferences/SharedPreferences.test.tsx b/public/app/core/components/SharedPreferences/SharedPreferences.test.tsx index 7daa5ab05c4..e6b4fc69fcc 100644 --- a/public/app/core/components/SharedPreferences/SharedPreferences.test.tsx +++ b/public/app/core/components/SharedPreferences/SharedPreferences.test.tsx @@ -102,6 +102,7 @@ jest.mock('app/core/services/PreferencesService', () => ({ const props = { resourceUri: '/fake-api/user/1', + preferenceType: 'user' as const, }; describe('SharedPreferences', () => { diff --git a/public/app/core/components/SharedPreferences/SharedPreferences.tsx b/public/app/core/components/SharedPreferences/SharedPreferences.tsx index f82808a350e..5a6486e250d 100644 --- a/public/app/core/components/SharedPreferences/SharedPreferences.tsx +++ b/public/app/core/components/SharedPreferences/SharedPreferences.tsx @@ -3,7 +3,7 @@ import React, { PureComponent } from 'react'; import { FeatureState, SelectableValue } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; -import { config } from '@grafana/runtime'; +import { config, reportInteraction } from '@grafana/runtime'; import { Button, Field, @@ -26,17 +26,12 @@ import { UserPreferencesDTO } from 'app/types'; export interface Props { resourceUri: string; disabled?: boolean; + preferenceType: 'org' | 'team' | 'user'; onConfirm?: () => Promise; } export type State = UserPreferencesDTO; -const themes: SelectableValue[] = [ - { value: '', label: t('shared-preferences.theme.default-label', 'Default') }, - { value: 'dark', label: t('shared-preferences.theme.dark-label', 'Dark') }, - { value: 'light', label: t('shared-preferences.theme.light-label', 'Light') }, -]; - function getLanguageOptions(): Array> { const languageOptions = LANGUAGES.map((v) => ({ value: v.code, @@ -58,6 +53,7 @@ const i18nFlag = Boolean(config.featureToggles.internationalization); export class SharedPreferences extends PureComponent { service: PreferencesService; + themeOptions: SelectableValue[]; constructor(props: Props) { super(props); @@ -70,6 +66,12 @@ export class SharedPreferences extends PureComponent { language: '', queryHistory: { homeTab: '' }, }; + + this.themeOptions = [ + { value: '', label: t('shared-preferences.theme.default-label', 'Default') }, + { value: 'dark', label: t('shared-preferences.theme.dark-label', 'Dark') }, + { value: 'light', label: t('shared-preferences.theme.light-label', 'Light') }, + ]; } async componentDidMount() { @@ -116,6 +118,11 @@ export class SharedPreferences extends PureComponent { onLanguageChanged = (language: string) => { this.setState({ language }); + + reportInteraction('grafana_preferences_language_changed', { + toLanguage: language, + preferenceType: this.props.preferenceType, + }); }; render() { @@ -131,8 +138,8 @@ export class SharedPreferences extends PureComponent {
Preferences} disabled={disabled}> item.value === theme)?.value} + options={this.themeOptions} + value={this.themeOptions.find((item) => item.value === theme)?.value} onChange={this.onThemeChanged} /> diff --git a/public/app/core/services/echo/backends/analytics/RudderstackBackend.ts b/public/app/core/services/echo/backends/analytics/RudderstackBackend.ts index a5e1217b390..b765246a391 100644 --- a/public/app/core/services/echo/backends/analytics/RudderstackBackend.ts +++ b/public/app/core/services/echo/backends/analytics/RudderstackBackend.ts @@ -75,6 +75,7 @@ export class RudderstackBackend implements EchoBackend { {canReadOrg && } {canReadPreferences && ( - + )} )} diff --git a/public/app/features/profile/UserProfileEditPage.tsx b/public/app/features/profile/UserProfileEditPage.tsx index 967dc8afa2c..82ceabbab43 100644 --- a/public/app/features/profile/UserProfileEditPage.tsx +++ b/public/app/features/profile/UserProfileEditPage.tsx @@ -62,7 +62,7 @@ export function UserProfileEditPage({ - + diff --git a/public/app/features/teams/TeamSettings.tsx b/public/app/features/teams/TeamSettings.tsx index 565a6f585e2..7e652ab1970 100644 --- a/public/app/features/teams/TeamSettings.tsx +++ b/public/app/features/teams/TeamSettings.tsx @@ -84,7 +84,7 @@ export const TeamSettings: FC = ({ team, updateTeam }) => {
)} - + ); };