Repository navigation
feat(app): let users permanently dismiss the metric drill-down warning #3304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| feat: let users permanently dismiss the metric drill-down warning | ||
|
|
||
| Drilling down from a metric chart whose source has no correlated log source | ||
| shows a warning. Clicking its close button now hides the warning for good in | ||
| that browser, and repeated clicks no longer stack copies of it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
packages/app/src/__tests__/metricDrilldownWarning.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import { | ||
| BuilderChartConfigWithDateRange, | ||
| DisplayType, | ||
| SourceKind, | ||
| TMetricSource, | ||
| } from '@hyperdx/common-utils/dist/types'; | ||
| import { notifications } from '@mantine/notifications'; | ||
| import { act, screen, within } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
|
|
||
| import { buildEventsSearchUrl } from '@/ChartUtils'; | ||
|
|
||
| const DISMISSED_KEY = 'drilldown-metric-correlated-log-warning'; | ||
| const TOAST_ID = 'no-log-source-associated'; | ||
|
|
||
| const dateRange: [Date, Date] = [ | ||
| new Date('2026-01-01T00:00:00.000Z'), | ||
| new Date('2026-01-01T01:00:00.000Z'), | ||
| ]; | ||
|
|
||
| const metricSource = { | ||
| id: 'metrics', | ||
| name: 'Metrics', | ||
| kind: SourceKind.Metric, | ||
| connection: 'clickhouse', | ||
| from: { databaseName: 'default', tableName: '' }, | ||
| timestampValueExpression: 'TimeUnix', | ||
| metricTables: { | ||
| gauge: 'otel_metrics_gauge', | ||
| histogram: '', | ||
| sum: '', | ||
| summary: '', | ||
| 'exponential histogram': '', | ||
| }, | ||
| resourceAttributesExpression: 'ResourceAttributes', | ||
| } satisfies TMetricSource; | ||
|
|
||
| const config = { | ||
| displayType: DisplayType.Line, | ||
| connection: 'clickhouse', | ||
| from: { databaseName: 'default', tableName: '' }, | ||
| select: [ | ||
| { | ||
| aggFn: 'avg', | ||
| aggCondition: '', | ||
| aggConditionLanguage: 'lucene', | ||
| valueExpression: 'Value', | ||
| }, | ||
| ], | ||
| where: '', | ||
| whereLanguage: 'lucene', | ||
| filters: [], | ||
| timestampValueExpression: 'TimeUnix', | ||
| metricTables: metricSource.metricTables, | ||
| dateRange, | ||
| } satisfies BuilderChartConfigWithDateRange; | ||
|
|
||
| const drillDown = () => | ||
| act(async () => | ||
| buildEventsSearchUrl({ source: metricSource, config, dateRange }), | ||
| ); | ||
|
|
||
| describe('metric drill-down warning without a correlated log source', () => { | ||
| beforeEach(() => { | ||
| localStorage.clear(); | ||
| notifications.clean(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('warns and returns null', async () => { | ||
| renderWithMantine(<div />); | ||
|
|
||
| expect(await drillDown()).toBeNull(); | ||
|
|
||
| expect( | ||
| await screen.findByText(/drill-down is unavailable/i), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('persists the dismissal when the close button is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| renderWithMantine(<div />); | ||
| await drillDown(); | ||
| const toast = await screen.findByRole('alert'); | ||
| expect(localStorage.getItem(DISMISSED_KEY)).toBeNull(); | ||
|
|
||
| await user.click(within(toast).getByRole('button')); | ||
|
|
||
| expect(localStorage.getItem(DISMISSED_KEY)).toBe('true'); | ||
| const show = jest.spyOn(notifications, 'show'); | ||
| expect(await drillDown()).toBeNull(); | ||
| expect(show).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('warns instead of throwing when localStorage is unavailable', async () => { | ||
| renderWithMantine(<div />); | ||
| jest.spyOn(Storage.prototype, 'getItem').mockImplementation(() => { | ||
| throw new DOMException('Access denied', 'SecurityError'); | ||
| }); | ||
|
|
||
| expect(await drillDown()).toBeNull(); | ||
|
|
||
| expect( | ||
| await screen.findByText(/drill-down is unavailable/i), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('does not persist when the toast closes without the close button', async () => { | ||
| renderWithMantine(<div />); | ||
| await drillDown(); | ||
| await screen.findByRole('alert'); | ||
|
|
||
| // Auto-close goes through the same hide path as notifications.hide. | ||
| act(() => { | ||
| notifications.hide(TOAST_ID); | ||
| }); | ||
|
|
||
| expect(localStorage.getItem(DISMISSED_KEY)).toBeNull(); | ||
| const show = jest.spyOn(notifications, 'show'); | ||
| await drillDown(); | ||
| expect(show).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.