mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
## Summary Part of https://github.com/elastic/kibana-team/issues/646 Depends on https://github.com/elastic/kibana/pull/169324 Implements telemetry for fatal errors caught by KibanaErrorBoundary in: - `packages/core/application/core-application-browser-internal/src/ui/app_router.tsx` - `packages/kbn-shared-ux-utility/src/with_suspense.tsx` [*] - `packages/react/kibana_context/render/render_provider.tsx` [*] - `src/plugins/management/public/components/management_app/management_router.tsx` - `x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx` - `x-pack/plugins/security_solution/public/app/app.tsx` [*] The changes made to these allowed the `analytics` dependency to be provided optionally, to avoid a breaking API change for maintainers. ## Logging screenshot You can trigger a fatal error in the new error boundary component in most places in Kibana by adding a TypeError to a React component: `<p>{breakHere()}</p>` <img width="1586" alt="fatal error telemetry console log" src=" |
||
---|---|---|
.. | ||
eui_provider.test.tsx | ||
eui_provider.tsx | ||
index.ts | ||
jest.config.js | ||
kibana.jsonc | ||
package.json | ||
README.mdx | ||
root_provider.test.tsx | ||
root_provider.tsx | ||
tsconfig.json |
--- id: react/context/root slug: /react/context/root title: React Context - Root description: This context provider is used only used by the very base root of Kibana. Unless you're writing tests, a Storybook, or working in core code, you likely don't need this. tags: ['shared-ux', 'react', 'context'] date: 2023-07-25 --- ## Description This package contains a root context provider for Kibana rendering. It handles operations that should only happen _once_ when the browser loads a page. While it would be safer to isolate this in a `core` package, we need to use it in other contexts-- like Storybook and Jest. ```ts import React, { useEffect } from 'react'; import { BehaviorSubject } from 'rxjs'; import { I18nProvider } from '@kbn/i18n-react'; import { KibanaRootContextProvider } from '@kbn/react-kibana-context-root'; import { action } from '@storybook/addon-actions'; import type { DecoratorFn } from '@storybook/react'; import type { CoreTheme } from '@kbn/core-theme-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; const theme$ = new BehaviorSubject<CoreTheme>({ darkMode: false }); const analytics = { reportEvent: action('telemetry-report-event'), }; const i18n: I18nStart = { Context: ({ children }) => <I18nProvider>{children}</I18nProvider>, }; export const KibanaContextDecorator: DecoratorFn = (storyFn, { globals }) => { const colorMode = globals.euiTheme === 'v8.dark' ? 'dark' : 'light'; useEffect(() => { theme$.next({ darkMode: colorMode === 'dark' }); }, [colorMode]); return ( <KibanaRootContextProvider {...{ theme: { theme$ }, analytics, i18n }}> {storyFn()} </KibanaRootContextProvider> ); }; ```