-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Cloud Security] UI counter telemetry (#194390)
# Backport This will backport the following commits from `main` to `8.x`: - [[Cloud Security] UI counter telemetry](#193721) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ido Cohen","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-30T09:08:49Z","message":"[Cloud Security] UI counter telemetry","sha":"5849c86e8d4303415f9d7b8115d3efdaa965deb9","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor"],"title":"[Cloud Security] UI counter telemetry","number":193721,"url":"https://github.com/elastic/kibana/pull/193721","mergeCommit":{"message":"[Cloud Security] UI counter telemetry","sha":"5849c86e8d4303415f9d7b8115d3efdaa965deb9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193721","number":193721,"mergeCommit":{"message":"[Cloud Security] UI counter telemetry","sha":"5849c86e8d4303415f9d7b8115d3efdaa965deb9"}}]}] BACKPORT--> Co-authored-by: Ido Cohen <[email protected]>
- Loading branch information
1 parent
4e2c656
commit a2a135d
Showing
14 changed files
with
145 additions
and
14 deletions.
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
57 changes: 57 additions & 0 deletions
57
x-pack/packages/kbn-cloud-security-posture-common/utils/ui_metrics.ts
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { UiCounterMetricType } from '@kbn/analytics'; | ||
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; | ||
|
||
export const APP_NAME = 'cloud-security'; | ||
|
||
export const ENTITY_FLYOUT_MISCONFIGURATION_VIEW_VISITS = | ||
'entity-flyout-misconfiguration-view-visits'; | ||
export const NAV_TO_FINDINGS_BY_HOST_NAME_FRPOM_ENTITY_FLYOUT = | ||
'nav-to-findings-by-host-name-from-entity-flyout'; | ||
export const NAV_TO_FINDINGS_BY_RULE_NAME_FRPOM_ENTITY_FLYOUT = | ||
'nav-to-findings-by-rule-name-from-entity-flyout'; | ||
export const CREATE_DETECTION_RULE_FROM_FLYOUT = 'create-detection-rule-from-flyout'; | ||
export const CREATE_DETECTION_FROM_TABLE_ROW_ACTION = 'create-detection-from-table-row-action'; | ||
export const VULNERABILITIES_FLYOUT_VISITS = 'vulnerabilities-flyout-visits'; | ||
export const OPEN_FINDINGS_FLYOUT = 'open-findings-flyout'; | ||
export const GROUP_BY_CLICK = 'group-by-click'; | ||
export const CHANGE_RULE_STATE = 'change-rule-state'; | ||
|
||
type CloudSecurityUiCounters = | ||
| typeof ENTITY_FLYOUT_MISCONFIGURATION_VIEW_VISITS | ||
| typeof NAV_TO_FINDINGS_BY_HOST_NAME_FRPOM_ENTITY_FLYOUT | ||
| typeof VULNERABILITIES_FLYOUT_VISITS | ||
| typeof NAV_TO_FINDINGS_BY_RULE_NAME_FRPOM_ENTITY_FLYOUT | ||
| typeof OPEN_FINDINGS_FLYOUT | ||
| typeof CREATE_DETECTION_RULE_FROM_FLYOUT | ||
| typeof CREATE_DETECTION_FROM_TABLE_ROW_ACTION | ||
| typeof GROUP_BY_CLICK | ||
| typeof CHANGE_RULE_STATE; | ||
|
||
export class UiMetricService { | ||
private usageCollection: UsageCollectionSetup | undefined; | ||
|
||
public setup(usageCollection: UsageCollectionSetup) { | ||
this.usageCollection = usageCollection; | ||
} | ||
|
||
private track(metricType: UiCounterMetricType, eventName: CloudSecurityUiCounters) { | ||
if (!this.usageCollection) { | ||
// Usage collection might be disabled in Kibana config. | ||
return; | ||
} | ||
return this.usageCollection.reportUiCounter(APP_NAME, metricType, eventName); | ||
} | ||
|
||
public trackUiMetric(metricType: UiCounterMetricType, eventName: CloudSecurityUiCounters) { | ||
return this.track(metricType, eventName); | ||
} | ||
} | ||
|
||
export const uiMetricService = new UiMetricService(); |
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
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