-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add correct erroring in Event Analytics #248
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6fdabc5
Add check for properties
eugenesk24 015e773
Change logic order to support switching between match and other where…
eugenesk24 300e239
Autocomplete for data values
eugenesk24 42cafed
Fetch data values earlier and save them
eugenesk24 5c2fe07
Merge remote-tracking branch 'origin/zurich-bug' into bug-bash
eugenesk24 dc40769
Update to current status
eugenesk24 70dd322
Fetch dataValues for match early
eugenesk24 536e408
Merge remote-tracking branch 'origin/zurich-bug' into bug-bash
eugenesk24 1e2a48b
Try addError
eugenesk24 6f3a37a
Fix error messaging on Event Explorer
eugenesk24 a5b65f2
Merge remote-tracking branch 'upstream/main' into bug-bash
eugenesk24 dcf3025
Remove fielddata
eugenesk24 78039bf
Assign string to fields with fields property
eugenesk24 5f09eb0
Merge remote-tracking branch 'origin/bug-bash' into bug-bash
eugenesk24 b9db3da
Remove possible double toast and add console log back in
eugenesk24 882adb6
Merge remote-tracking branch 'upstream/main' into bug-bash
eugenesk24 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -54,10 +54,7 @@ import { selectFields, updateFields, sortFields } from './slices/field_slice'; | |
import { updateTabName } from './slices/query_tab_slice'; | ||
import { selectCountDistribution } from './slices/count_distribution_slice'; | ||
import { selectExplorerVisualization } from './slices/visualization_slice'; | ||
import PPLService from '../../services/requests/ppl'; | ||
import DSLService from '../../services/requests/dsl'; | ||
import SavedObjects from '../../services/saved_objects/event_analytics/saved_objects'; | ||
import TimestampUtils from 'public/services/timestamp/timestamp'; | ||
import { IExplorerProps } from '../../../common/types/explorer'; | ||
|
||
const TAB_EVENT_ID = 'main-content-events'; | ||
const TAB_CHART_ID = 'main-content-vis'; | ||
|
@@ -66,20 +63,6 @@ const TYPE_TAB_MAPPING = { | |
[SAVED_VISUALIZATION]: TAB_CHART_ID | ||
}; | ||
|
||
interface IExplorerProps { | ||
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. Moved to explorer.ts |
||
pplService: PPLService; | ||
dslService: DSLService; | ||
tabId: string; | ||
savedObjects: SavedObjects; | ||
timestampUtils: TimestampUtils; | ||
setToast: ( | ||
title: string, | ||
color?: string, | ||
text?: React.ReactChild | undefined, | ||
side?: string | undefined | ||
) => void; | ||
} | ||
|
||
export const Explorer = ({ | ||
pplService, | ||
dslService, | ||
|
@@ -88,6 +71,7 @@ export const Explorer = ({ | |
timestampUtils, | ||
setToast, | ||
history, | ||
notifications, | ||
savedObjectId | ||
}: IExplorerProps) => { | ||
const dispatch = useDispatch(); | ||
|
@@ -127,7 +111,7 @@ export const Explorer = ({ | |
const [tempQuery, setTempQuery] = useState(query[RAW_QUERY]); | ||
|
||
const queryRef = useRef(); | ||
const selectedPanelNameRef = useRef(); | ||
const selectedPanelNameRef = useRef(''); | ||
const explorerFieldsRef = useRef(); | ||
queryRef.current = query; | ||
selectedPanelNameRef.current = selectedPanelName; | ||
|
@@ -171,6 +155,23 @@ export const Explorer = ({ | |
}); | ||
}; | ||
|
||
const formatError = (name: string, message: string, details: string) => { | ||
return { | ||
name: name, | ||
message: message, | ||
body: { | ||
attributes: { | ||
error: { | ||
caused_by: { | ||
type: '', | ||
reason: details | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
const getSavedDataById = async (objectId: string) => { | ||
// load saved query/visualization if object id exists | ||
await savedObjects.fetchSavedObjects({ | ||
|
@@ -220,7 +221,9 @@ export const Explorer = ({ | |
|
||
}) | ||
.catch((error) => { | ||
setToast(`Cannot get saved data for object id: ${objectId}, error: ${error.message}`, 'danger'); | ||
notifications.toasts.addError(error, { | ||
title: `Cannot get saved data for object id: ${objectId}` | ||
}); | ||
}); | ||
}; | ||
|
||
|
@@ -286,10 +289,10 @@ export const Explorer = ({ | |
} else { | ||
findAutoInterval(curQuery![SELECTED_DATE_RANGE][0], curQuery![SELECTED_DATE_RANGE][1]) | ||
getEvents(undefined, (error) => { | ||
setToast( | ||
`Error fetching events: ${error?.body?.message || 'see console error for more details.'}`, | ||
'danger' | ||
); | ||
const formattedError = formatError(error.name, error.message, error.body.message); | ||
notifications.toasts.addError(formattedError, { | ||
title: 'Error fetching events' | ||
}); | ||
}); | ||
getCountVisualizations(minInterval); | ||
} | ||
|
@@ -423,8 +426,10 @@ export const Explorer = ({ | |
setToast(`Timestamp has been overridden successfully.`, 'success'); | ||
return res; | ||
}) | ||
.catch((error: any) => { | ||
setToast(`Cannot override timestamp, error: ${error.message}`, 'danger'); | ||
.catch((error: any) => { | ||
notifications.toasts.addError(error, { | ||
title: 'Cannot override timestamp' | ||
}); | ||
}) | ||
.finally(() => { | ||
setIsOverridingTimestamp(false); | ||
|
@@ -438,7 +443,9 @@ export const Explorer = ({ | |
return res; | ||
}) | ||
.catch((error: any) => { | ||
setToast(`Cannot override timestamp, error: ${error.message}`, 'danger'); | ||
notifications.toasts.addError(error, { | ||
title: 'Cannot override timestamp' | ||
}); | ||
}) | ||
.finally(() => { | ||
setIsOverridingTimestamp(false); | ||
|
@@ -698,7 +705,9 @@ export const Explorer = ({ | |
return res; | ||
}) | ||
.catch((error: any) => { | ||
setToast(`Cannot update query '${selectedPanelNameRef.current}', error: ${error.message}`, 'danger'); | ||
notifications.toasts.addError(error, { | ||
title: `Cannot update query '${selectedPanelNameRef.current}'` | ||
}); | ||
}); | ||
} else { | ||
// create new saved query | ||
|
@@ -725,7 +734,9 @@ export const Explorer = ({ | |
if (error?.body?.statusCode === 403) { | ||
showPermissionErrorToast(); | ||
} else { | ||
setToast(`Cannot save query '${selectedPanelNameRef.current}', error: ${error.message}`, 'danger'); | ||
notifications.toasts.addError(error ,{ | ||
title: `Cannot save query '${selectedPanelNameRef.current}'` | ||
}); | ||
} | ||
}); | ||
} | ||
|
@@ -753,7 +764,9 @@ export const Explorer = ({ | |
return res; | ||
}) | ||
.catch((error: any) => { | ||
setToast(`Cannot update Visualization '${selectedPanelNameRef.current}', error: ${error.message}`, 'danger'); | ||
notifications.toasts.addError(error, { | ||
title: `Cannot update Visualization '${selectedPanelNameRef.current}'` | ||
}); | ||
}); | ||
} else { | ||
// create new saved visualization | ||
|
@@ -783,7 +796,9 @@ export const Explorer = ({ | |
setToast(`New visualization '${selectedPanelNameRef.current}' has been successfully saved.`, 'success'); | ||
}) | ||
.catch((error: any) => { | ||
setToast(`Cannot save Visualization '${selectedPanelNameRef.current}', error: ${error.message}`, 'danger'); | ||
notifications.toasts.addError(error, { | ||
title: `Cannot save Visualization '${selectedPanelNameRef.current}'` | ||
}); | ||
}); | ||
} | ||
if (!has(savingVisRes, 'objectId')) return; | ||
|
@@ -797,7 +812,9 @@ export const Explorer = ({ | |
setToast(`Visualization '${selectedPanelNameRef.current}' has been successfully saved to operation panels.`, 'success'); | ||
}) | ||
.catch((error: any) => { | ||
setToast(`Cannot add Visualization '${selectedPanelNameRef.current}' to operation panels, error: ${error.message}`, 'danger'); | ||
notifications.toasts.addError(error, { | ||
title: `Cannot add Visualization '${selectedPanelNameRef.current}' to operation panels` | ||
}); | ||
}); | ||
} | ||
} | ||
|
This file contains 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
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.
Moved to line 212