-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Cloud Security] Adding telemetry collection condition based on render condition #208758
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
f27fd78
79f4ef8
e46bdd0
6ad1171
8927342
1749092
b972974
b4f4a9a
12eb8de
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 |
|---|---|---|
|
|
@@ -87,19 +87,19 @@ export const MisconfigurationsInsight: React.FC<MisconfigurationsInsightProps> = | |
| 'newExpandableFlyoutNavigationEnabled' | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| if (telemetryKey) { | ||
| uiMetricService.trackUiMetric(METRIC_TYPE.COUNT, telemetryKey); | ||
| } | ||
| }, [telemetryKey, renderingId]); | ||
|
|
||
| const passedFindings = data?.count.passed || 0; | ||
| const failedFindings = data?.count.failed || 0; | ||
| const totalFindings = useMemo( | ||
| () => passedFindings + failedFindings, | ||
| [passedFindings, failedFindings] | ||
| ); | ||
| const hasMisconfigurationFindings = totalFindings > 0; | ||
| const shouldRender = totalFindings > 0; // this component only renders if there are findings | ||
|
|
||
| useEffect(() => { | ||
|
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. While it's a fix over the previous version where we tracked even when the particular insight wasn't even rendered, I wonder what do we want to track overall? With this change the counter will go up with every re-render of the component, for example when a user expands the left pane, switches between Overview, Table, JSON tabs and who knows when else as it's hard to reason about reliable component rerender in React. If our goal is to understand how many users had the component showing up at least once, I guess the current approach would do. But it's harder to make more complex conclusions from this telemetry. Probably not for this PR, but we have a preview link in the component from the counter. We could count clicks to track actual interactions with the component. Or if we want to see for how many alerts per user the data is present, we need to add an alert uuid to tracking to be able to then group by re-renders for the same alerts
Contributor
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. good point max. I believe this was solved by [Cloud Security] Collecting telemetry of graph visualization usage
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. I’m curious why the condition is checked in
Contributor
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. not sure what you mean, this is exactly whats happening. flow is: Checking we have findings, which is also the render condition const shouldRender = totalFindings > 0; // this component only renders if there are findingsif shouldRender is true (meaning we have findings), report metric if (shouldRender && telemetryKey) {
uiMetricService.trackUiMetric(METRIC_TYPE.COUNT, telemetryKey);
}Meaning we only call the function if there are findings
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. @JordanSh I checked and every switch between Overview/Table/JSON tabs still increases the counter. Again, not sure if it's a problem concerning this particular PR, I'm just wondering what we actually want to count with the current approach and if we are able to clean those meaningful counts on the reporting side
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.
Contributor
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. We can add that as well, i dont think it replaces this view count that we are trying to measure. Thanks for letting me know! |
||
| if (shouldRender && telemetryKey) { | ||
|
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. Have you considered typing
Contributor
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.
ended up not doing that, it isn't required for tests, and in general only required for telemetry and not for the component it self in order to function. for those reasons i've decided to keep it optional for now. |
||
| uiMetricService.trackUiMetric(METRIC_TYPE.COUNT, telemetryKey); | ||
| } | ||
| }, [shouldRender, telemetryKey, renderingId]); | ||
|
|
||
| const misconfigurationsStats = useMemo( | ||
| () => getFindingsStats(passedFindings, failedFindings), | ||
|
|
@@ -161,7 +161,7 @@ export const MisconfigurationsInsight: React.FC<MisconfigurationsInsightProps> = | |
| ] | ||
| ); | ||
|
|
||
| if (!hasMisconfigurationFindings) return null; | ||
| if (!shouldRender) return null; | ||
|
|
||
| return ( | ||
| <EuiFlexItem data-test-subj={dataTestSubj}> | ||
|
|
||
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.
As requested by @CohenIdo, added version to namings so it will be easier to track fixed version telemetry reports