-
Notifications
You must be signed in to change notification settings - Fork 84
Bugfix: Event Analytics Filters #538
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
Changes from all commits
b21f9af
8266c0d
354a2a9
837f15c
6ff533a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| */ | ||
|
|
||
| import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiLink, EuiText } from '@elastic/eui'; | ||
| import React, { useContext, useState } from 'react'; | ||
| import React, { useContext, useEffect, useState } from 'react'; | ||
| import { connect, useDispatch } from 'react-redux'; | ||
| import { | ||
| FILTERED_PATTERN, | ||
|
|
@@ -25,15 +25,13 @@ export interface LogPatternProps { | |
| text: string; | ||
| value: string; | ||
| }; | ||
| setTempQuery: () => string; | ||
| handleTimeRangePickerRefresh: (flag: boolean) => {}; | ||
| patterns: PatternTableData[]; | ||
| query: IQuery; | ||
| } | ||
|
|
||
| const EventPatterns = ({ | ||
| selectedIntervalUnit, | ||
| setTempQuery, | ||
| handleTimeRangePickerRefresh, | ||
| patterns, | ||
| query, | ||
|
|
@@ -49,21 +47,35 @@ const EventPatterns = ({ | |
| requestParams: { tabId }, | ||
| }); | ||
|
|
||
| // refresh patterns on opening page | ||
| useEffect(() => { | ||
| getPatterns(selectedIntervalUnit?.value?.replace(/^auto_/, '') || 'y'); | ||
| }, []); | ||
|
|
||
| const onPatternSelection = async (pattern: string) => { | ||
| if (query[FILTERED_PATTERN] === pattern) { | ||
| return; | ||
| } | ||
| dispatch( | ||
| // await here allows react to render update properly and display it. | ||
| // it forces the query to be changed before running it, without await the visual wont update. | ||
| await dispatch( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment here on why this works and also remove the commented out tempQuery and its comment to reduce tech debt going forward? Why did await work on a dispatch call even though the IDE is saying it has no effect, why do we not need to worry about tempquery anymore, etc.?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding comment above, but some reference on why it is needed: |
||
| changeQuery({ | ||
| tabId, | ||
| query: { | ||
| [FILTERED_PATTERN]: pattern, | ||
| }, | ||
| }) | ||
| ); | ||
| // workaround to refresh callback and trigger fetch data | ||
| await setTempQuery(query[RAW_QUERY]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment here about the tempquery - can we remove it all together? If it is necessary can we consolidate it into the query in redux instead of having a separate useState variable?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed tempQuery from log patterns, It is still used in explorer to handle query searches and changes. |
||
| await handleTimeRangePickerRefresh(true); | ||
| handleTimeRangePickerRefresh(true); | ||
| // after rendering the patterns visual, we want the pattern to be reset for future searches | ||
| await dispatch( | ||
| changeQuery({ | ||
| tabId, | ||
| query: { | ||
| [FILTERED_PATTERN]: '', | ||
| }, | ||
| }) | ||
| ); | ||
| }; | ||
|
|
||
| const showToastError = (errorMsg: string) => { | ||
|
|
||
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.
Can you create an issue/discussion point regarding this change? I think with this change all instances of fetchdata will be called with startTime/endTime, so we can remove the dependency on startTime/endTime from the query in redux - or vice versa. In my opinion it is bad to have two references/sources of truth to anything (timerange/patterns, etc.), so either we should remove it from the redux query if it is not being used, or only rely on time from query in redux - not both @mengweieric thoughts?
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.
Agreed with an issue to track and document this and to have a consistent way of set time range in both app and explorer sides. We may want to remove explicit start/end time dependency for explorer and instead, dispatch timerange to app query state. This only does the trick to make it work but would potentially cause more issues and bugs