Skip to content

[Cloud Security] Adding telemetry collection condition based on render condition#208758

Merged
JordanSh merged 9 commits intoelastic:mainfrom
JordanSh:telemetry-improvements
Feb 11, 2025
Merged

[Cloud Security] Adding telemetry collection condition based on render condition#208758
JordanSh merged 9 commits intoelastic:mainfrom
JordanSh:telemetry-improvements

Conversation

@JordanSh
Copy link
Copy Markdown
Contributor

@JordanSh JordanSh commented Jan 29, 2025

Summary

Insight components telemetry is now reporting based on the rendering condition of the component

@JordanSh JordanSh added release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related backport:prev-minor labels Jan 29, 2025
@JordanSh JordanSh self-assigned this Jan 29, 2025
@JordanSh JordanSh requested a review from a team as a code owner January 29, 2025 14:43
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

const hasMisconfigurationFindings = totalFindings > 0;
const shouldRender = totalFindings > 0; // this component only renders if there are findings

useEffect(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m curious why the condition is checked in MisconfigurationsInsight (and in VulnerabilitiesInsight) before calling them. In other words, why not call these functions only if there are findings?

Copy link
Copy Markdown
Contributor Author

@JordanSh JordanSh Feb 2, 2025

Choose a reason for hiding this comment

The 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 findings

if 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JordanSh I have a PR open to update the count badges: when user clicks on the count, it will go to the respective cloud insight table. If you do want to track clicks, you can do it in that call back.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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!
@CohenIdo do we want to add tracker for those counter clicks?

@JordanSh JordanSh requested a review from a team as a code owner February 2, 2025 12:05
Comment on lines +13 to +14
export const MISCONFIGURATION_INSIGHT = 'misconfiguration-insight-v2' as const;
export const VULNERABILITIES_INSIGHT = 'vulnerabilities-insight-v2' as const;
Copy link
Copy Markdown
Contributor Author

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

@JordanSh
Copy link
Copy Markdown
Contributor Author

JordanSh commented Feb 2, 2025

/ci

@CohenIdo
Copy link
Copy Markdown
Contributor

CohenIdo commented Feb 2, 2025

@JordanSh, please add a backport to 8.x and 9.0, we should ensure it’s included in the next BC. Otherwise, we might lose track of it for the upcoming release.

const shouldRender = totalFindings > 0; // this component only renders if there are findings

useEffect(() => {
if (shouldRender && telemetryKey) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered typing telemetryKey it as required? Looks like it is always passed

Copy link
Copy Markdown
Contributor Author

@JordanSh JordanSh Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah makes sense, can do that

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.

const hasMisconfigurationFindings = totalFindings > 0;
const shouldRender = totalFindings > 0; // this component only renders if there are findings

useEffect(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JordanSh I have a PR open to update the count badges: when user clicks on the count, it will go to the respective cloud insight table. If you do want to track clicks, you can do it in that call back.

@JordanSh
Copy link
Copy Markdown
Contributor Author

/ci

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 21.4MB 21.4MB +55.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 92.3KB 92.3KB +6.0B

History

cc @JordanSh

@JordanSh JordanSh requested a review from CohenIdo February 11, 2025 14:27
@JordanSh JordanSh requested review from animehart and removed request for animehart February 11, 2025 14:29
@JordanSh JordanSh enabled auto-merge (squash) February 11, 2025 16:28
@JordanSh JordanSh merged commit c1aaf6f into elastic:main Feb 11, 2025
11 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.18, 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/13267784020

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.18
8.x
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 11, 2025
… render condition (#208758) (#210636)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Cloud Security] Adding telemetry collection condition based on
render condition
(#208758)](#208758)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Jordan","email":"51442161+JordanSh@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-11T16:33:02Z","message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud
Security","backport:prev-minor","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Cloud
Security] Adding telemetry collection condition based on render
condition","number":208758,"url":"https://github.com/elastic/kibana/pull/208758","mergeCommit":{"message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208758","number":208758,"mergeCommit":{"message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jordan <51442161+JordanSh@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Feb 11, 2025
…n render condition (#208758) (#210634)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Cloud Security] Adding telemetry collection condition based on
render condition
(#208758)](#208758)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Jordan","email":"51442161+JordanSh@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-11T16:33:02Z","message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud
Security","backport:prev-minor","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Cloud
Security] Adding telemetry collection condition based on render
condition","number":208758,"url":"https://github.com/elastic/kibana/pull/208758","mergeCommit":{"message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208758","number":208758,"mergeCommit":{"message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jordan <51442161+JordanSh@users.noreply.github.com>
kapral18 added a commit to agusruidiazgd/kibana that referenced this pull request Feb 11, 2025
…on-206439

* main: (402 commits)
  [Search]: Fix Number type field to have correct property (elastic#210462)
  Change filter for rule monitoring gaps (elastic#209983)
  Update Logs Explorer deprecation messages (elastic#201307)
  [APM] Remove `error.id` in `getErrorGroupMainStatistics` query as it's not used (elastic#210613)
  [Embeddable] Fix presentation panel styles (elastic#210113)
  [ci] enable Scout reporter for on-merge-unsupported-ftrs (elastic#210627)
  [Fix][Synonyms UI]Add navigation link to the Detail breadcrumb. (elastic#209574)
  chore(dep): bump `store2` from `2.12.0` to `2.14.4` (elastic#210530)
  [scout] adding test helper `@kbn/scout-oblt` package and uptate onboarding tests (elastic#209761)
  [Cloud Security] Asset Inventory table flyout controls  (elastic#208452)
  [ML] Fix model deployment check in file uploader (elastic#209585)
  Updates archive again (elastic#209828)
  [Security Solution] Added concurrency limits and request throttling to prebuilt rule routes (elastic#209551)
  [Search] [Onboarding] Update search api to use EventEmitter instead of Provider (elastic#209784)
  [maps] lazy load map actions (elastic#210252)
  [Cloud Security] Adding telemetry collection condition based on render condition (elastic#208758)
  [Solution nav] Use flyout for Stack Management in Search and Observability solutions (elastic#208632)
  [Search] Fix Add Inference Endpoint API call (elastic#210243)
  [Agentless Connectors] Integration overview panel (elastic#210222)
  [Lens] Restore dynamic colouring by value for Last value agg (elastic#209110)
  ...
kibanamachine added a commit that referenced this pull request Feb 12, 2025
… render condition (#208758) (#210635)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Cloud Security] Adding telemetry collection condition based on
render condition
(#208758)](#208758)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Jordan","email":"51442161+JordanSh@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-11T16:33:02Z","message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud
Security","backport:prev-minor","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Cloud
Security] Adding telemetry collection condition based on render
condition","number":208758,"url":"https://github.com/elastic/kibana/pull/208758","mergeCommit":{"message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208758","number":208758,"mergeCommit":{"message":"[Cloud
Security] Adding telemetry collection condition based on render
condition
(#208758)","sha":"c1aaf6f38cfbe5c4093c7ffd7a1a3ec56b2787dc"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jordan <51442161+JordanSh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v8.18.0 v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants