mirror of https://github.com/grafana/grafana
Alerting: log some basic user interactions (#55401)
* Log leaving rule group edit without saving * Log filtering alert instances by label Also debouncing the search to prevent sending too many log requests * Log loading the Alert Rules list * Move log messages to centralized location * Add tests on log trackings * Fix lintingpull/55678/head
parent
fb66439c3e
commit
003a1cdaa0
@ -0,0 +1,5 @@ |
|||||||
|
export const LogMessages = { |
||||||
|
filterByLabel: 'filtering alert instances by label', |
||||||
|
loadedList: 'loaded Alert Rules list', |
||||||
|
leavingRuleGroupEdit: 'leaving rule group edit without saving', |
||||||
|
}; |
@ -0,0 +1,25 @@ |
|||||||
|
import { render, screen } from '@testing-library/react'; |
||||||
|
import userEvent from '@testing-library/user-event'; |
||||||
|
import lodash from 'lodash'; // eslint-disable-line lodash/import-scope
|
||||||
|
import React from 'react'; |
||||||
|
|
||||||
|
import { logInfo } from '@grafana/runtime'; |
||||||
|
|
||||||
|
import { LogMessages } from '../../Analytics'; |
||||||
|
|
||||||
|
import { MatcherFilter } from './MatcherFilter'; |
||||||
|
|
||||||
|
jest.mock('@grafana/runtime'); |
||||||
|
|
||||||
|
describe('Analytics', () => { |
||||||
|
it('Sends log info when filtering alert instances by label', async () => { |
||||||
|
lodash.debounce = jest.fn().mockImplementation((fn) => fn); |
||||||
|
|
||||||
|
render(<MatcherFilter onFilterChange={jest.fn()} />); |
||||||
|
|
||||||
|
const searchInput = screen.getByTestId('search-query-input'); |
||||||
|
await userEvent.type(searchInput, 'job='); |
||||||
|
|
||||||
|
expect(logInfo).toHaveBeenCalledWith(LogMessages.filterByLabel); |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue