-
Notifications
You must be signed in to change notification settings - Fork 390
RI-7218 Add telemetry collection for Vector Search page #4811
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
valkirilov
merged 28 commits into
feature/RI-6855/vector-search
from
fe/feature/RI-7218_vector-search-telemetry-3
Aug 8, 2025
+1,170
−273
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8c75ca1
feat(ui): collect telemetry on vector search page when running a query
valkirilov 201467b
feat(ui): collect telemetry on vector search page when copy a query
valkirilov f79fe5f
Revert "feat(ui): collect telemetry on vector search page when copy a…
valkirilov 4181c8b
reafctor(ui): copy the QueryCardHeader component for the Vector Search
valkirilov ac73644
feat(ui): collect telemetry on vector search page when copy a query
valkirilov 02fbb30
feat(ui): collect telemetry on vector search page when re-run a query
valkirilov 0ce5ac1
feat(ui): collect telemetry on vector search page when toggle full-sc…
valkirilov 5b6f82a
feat(ui): collect telemetry on vector search page when collapse/uncol…
valkirilov 9fe6641
feat(ui): collect telemetry on vector search page when clearing a que…
valkirilov 9efa866
feat(ui): collect telemetry on vector search page when clearing all q…
valkirilov 45a30e8
feat(ui): collect telemetry on vector search page when clearing query
valkirilov 910e4a7
reafactor(ui): try to use real interfaces for the command execution f…
valkirilov 05ca0b2
reafactor(ui): export telemetry for "query re-run" into util
valkirilov 4159613
reafactor(ui): export telemetry for "query run" into util
valkirilov 02fde1c
reafactor(ui): export telemetry for "query clear-all" into util
valkirilov 8671bc7
reafactor(ui): export telemetry for "query clear editor" into util
valkirilov d6587d2
refactor(ui): remove copy/paste QueryCardHeader component
valkirilov 49f5bee
refactor(ui): introduce context to keep information for the view mode…
valkirilov 09b8e86
refactor(ui): use the view mode from the context to emit copy query c…
valkirilov accd720
reafactor(ui): export telemetry for "toggle query full-screen" into util
valkirilov 836641f
refactor(ui): use the view mode from the context to emit collapse/exa…
valkirilov 456ffd5
refactor(ui): use the view mode from the context to emit delete query…
valkirilov 7a7477a
test(ui): fix tests by adding the new context provider
valkirilov 822f3b4
test(ui): fix tests by adding the new context provider
valkirilov 4ab9820
test(ui): fix tests by adding the new context provider
valkirilov da82437
refactor(ui): simplify the context to not allow state change
valkirilov 044430e
refactor(ui): simplify the context
valkirilov 264e320
Merge remote-tracking branch 'origin/feature/RI-6855/vector-search' i…
valkirilov 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
45 changes: 45 additions & 0 deletions
45
redisinsight/ui/src/components/query/context/view-mode-context.spec.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,45 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
|
||
import { | ||
useViewModeContext, | ||
ViewMode, | ||
ViewModeContextProvider, | ||
} from './view-mode.context' | ||
|
||
// Test component to consume the context | ||
const TestComponent: React.FC = () => { | ||
const { viewMode } = useViewModeContext() | ||
|
||
return ( | ||
<div> | ||
<p data-testid="view-mode">Current View Mode: {viewMode}</p> | ||
</div> | ||
) | ||
} | ||
|
||
describe('ViewModeContext', () => { | ||
it('provides the default view mode', () => { | ||
render( | ||
<ViewModeContextProvider> | ||
<TestComponent /> | ||
</ViewModeContextProvider>, | ||
) | ||
|
||
expect(screen.getByTestId('view-mode')).toHaveTextContent( | ||
`Current View Mode: ${ViewMode.Workbench}`, | ||
) | ||
}) | ||
|
||
it('uses the initial view mode if provided', () => { | ||
render( | ||
<ViewModeContextProvider viewMode={ViewMode.VectorSearch}> | ||
<TestComponent /> | ||
</ViewModeContextProvider>, | ||
) | ||
|
||
expect(screen.getByTestId('view-mode')).toHaveTextContent( | ||
`Current View Mode: ${ViewMode.VectorSearch}`, | ||
) | ||
}) | ||
}) |
33 changes: 33 additions & 0 deletions
33
redisinsight/ui/src/components/query/context/view-mode.context.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,33 @@ | ||
import React, { createContext, ReactNode, useContext } from 'react' | ||
|
||
export enum ViewMode { | ||
Workbench = 'workbench', | ||
VectorSearch = 'vector-search', | ||
} | ||
|
||
interface ViewModeContextType { | ||
viewMode: ViewMode | ||
} | ||
|
||
const ViewModeContext = createContext<ViewModeContextType>({ | ||
viewMode: ViewMode.Workbench, | ||
}) | ||
|
||
// Props for the provider | ||
interface ViewModeContextProviderProps { | ||
children: ReactNode | ||
viewMode?: ViewMode | ||
} | ||
|
||
export const ViewModeContextProvider: React.FC< | ||
ViewModeContextProviderProps | ||
> = ({ children, viewMode = ViewMode.Workbench }) => { | ||
return ( | ||
<ViewModeContext.Provider value={{ viewMode }}> | ||
{children} | ||
</ViewModeContext.Provider> | ||
) | ||
} | ||
|
||
export const useViewModeContext = (): ViewModeContextType => | ||
useContext(ViewModeContext) |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So basically, this is a context that shares single value across components, right?
Is there any reason not to just add this to Redux store?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's used in different views now. It would not make sense to dispatch redux actions to update the store as you switch between Search and Workbench tabs
This context solution is the least path of resistance to reusing the QueryCard component. The other being prop drilling, which @valkirilov said was too hard (4-5 levels deep).
The pre-context solution was to copy the whole component and it's test and adjust 3-4 telemetry lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its already merged, but I still fail to see how context "dispatch" makes more sense than redux dispatch.
If anything this adds more techincal overhead