forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.15] [Search] Notebooks Telemetry (elastic#188007) (elastic#188055)
# Backport This will backport the following commits from `main` to `8.15`: - [[Search] Notebooks Telemetry (elastic#188007)](elastic#188007) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Rodney Norris","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-11T07:40:41Z","message":"[Search] Notebooks Telemetry (elastic#188007)\n\n## Summary\r\n\r\nAdded telemetry tracking with usageCollection for opening notebooks\r\nview, viewing a specific notebook and errors fetching notebooks.\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)","sha":"b11e9eeb6d8fd7579d95b2515ab0eb2d64523504","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Search","v8.15.0","v8.16.0"],"title":"[Search] Notebooks Telemetry","number":188007,"url":"https://github.com/elastic/kibana/pull/188007","mergeCommit":{"message":"[Search] Notebooks Telemetry (elastic#188007)\n\n## Summary\r\n\r\nAdded telemetry tracking with usageCollection for opening notebooks\r\nview, viewing a specific notebook and errors fetching notebooks.\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)","sha":"b11e9eeb6d8fd7579d95b2515ab0eb2d64523504"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188007","number":188007,"mergeCommit":{"message":"[Search] Notebooks Telemetry (elastic#188007)\n\n## Summary\r\n\r\nAdded telemetry tracking with usageCollection for opening notebooks\r\nview, viewing a specific notebook and errors fetching notebooks.\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)","sha":"b11e9eeb6d8fd7579d95b2515ab0eb2d64523504"}}]}] BACKPORT--> Co-authored-by: Rodney Norris <[email protected]>
- Loading branch information
1 parent
dd6a8ff
commit 216aa79
Showing
12 changed files
with
169 additions
and
42 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
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
67 changes: 67 additions & 0 deletions
67
x-pack/plugins/search_notebooks/public/components/search_notebook_error.tsx
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,67 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { EuiEmptyPrompt, EuiCodeBlock } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import type { AppMetricsTracker } from '../types'; | ||
import { getErrorMessage } from '../utils/get_error_message'; | ||
|
||
export interface SearchNotebookErrorProps { | ||
error: unknown; | ||
notebookId: string; | ||
usageTracker: AppMetricsTracker; | ||
} | ||
|
||
export const SearchNotebookError = ({ | ||
error, | ||
notebookId, | ||
usageTracker, | ||
}: SearchNotebookErrorProps) => { | ||
React.useEffect(() => { | ||
usageTracker.count(['notebookViewError', `error-${notebookId}`]); | ||
}, [usageTracker, notebookId]); | ||
|
||
return ( | ||
<EuiEmptyPrompt | ||
iconType="warning" | ||
iconColor="danger" | ||
title={ | ||
<h2> | ||
<FormattedMessage | ||
id="xpack.searchNotebooks.notebook.fetchError.title" | ||
defaultMessage="Error loading notebook" | ||
/> | ||
</h2> | ||
} | ||
titleSize="l" | ||
body={ | ||
<> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.searchNotebooks.notebook.fetchError.body" | ||
defaultMessage="We can't fetch the notebook from Kibana due to the following error:" | ||
/> | ||
</p> | ||
{error !== undefined && typeof error === 'object' ? ( | ||
<EuiCodeBlock css={{ textAlign: 'left' }}>{JSON.stringify(error)}</EuiCodeBlock> | ||
) : ( | ||
<p> | ||
{getErrorMessage( | ||
error, | ||
i18n.translate('xpack.searchNotebooks.notebook.fetchError.unknownError', { | ||
defaultMessage: 'Unknown error fetching notebook', | ||
}) | ||
)} | ||
</p> | ||
)} | ||
</> | ||
} | ||
/> | ||
); | ||
}; |
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
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/search_notebooks/public/hooks/use_usage_tracker.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,15 @@ | ||
/* | ||
* 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 { useKibanaServices } from './use_kibana'; | ||
import { AppMetricsTracker } from '../types'; | ||
|
||
export const useUsageTracker = (): AppMetricsTracker => { | ||
const { usageTracker } = useKibanaServices(); | ||
|
||
return usageTracker; | ||
}; |
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
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/search_notebooks/public/utils/usage_tracker.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,33 @@ | ||
/* | ||
* 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 { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics'; | ||
import type { | ||
UsageCollectionSetup, | ||
UsageCollectionStart, | ||
} from '@kbn/usage-collection-plugin/public'; | ||
import { AppMetricsTracker } from '../types'; | ||
|
||
const APP_TRACKER_NAME = 'searchNotebooks'; | ||
|
||
export function createUsageTracker( | ||
usageCollection?: UsageCollectionSetup | UsageCollectionStart | ||
): AppMetricsTracker { | ||
const track = (type: UiCounterMetricType, name: string | string[]) => | ||
usageCollection?.reportUiCounter(APP_TRACKER_NAME, type, name); | ||
return { | ||
click: (eventName: string | string[]) => { | ||
track(METRIC_TYPE.CLICK, eventName); | ||
}, | ||
count: (eventName: string | string[]) => { | ||
track(METRIC_TYPE.COUNT, eventName); | ||
}, | ||
load: (eventName: string | string[]) => { | ||
track(METRIC_TYPE.LOADED, eventName); | ||
}, | ||
}; | ||
} |
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