diff --git a/packages/deeplinks/observability/locators/observability_log_explorer.ts b/packages/deeplinks/observability/locators/observability_log_explorer.ts index e5392712f76b5..37bbf75f122f2 100644 --- a/packages/deeplinks/observability/locators/observability_log_explorer.ts +++ b/packages/deeplinks/observability/locators/observability_log_explorer.ts @@ -6,9 +6,18 @@ * Side Public License, v 1. */ +import { SerializableRecord } from '@kbn/utility-types'; import { LogExplorerNavigationParams } from './log_explorer'; -export type DatasetLocatorParams = LogExplorerNavigationParams; +// Will become a union once we have more origins +export interface ObservabilityLogExplorerLocationState extends SerializableRecord { + origin?: { + id: 'application-log-onboarding'; + }; +} + +export type DatasetLocatorParams = LogExplorerNavigationParams & + ObservabilityLogExplorerLocationState; // All datasets locator export const ALL_DATASETS_LOCATOR_ID = 'ALL_DATASETS_LOCATOR'; diff --git a/x-pack/plugins/observability_log_explorer/common/locators/index.ts b/x-pack/plugins/observability_log_explorer/common/locators/index.ts index 7571731a22221..e03ca4b22ac55 100644 --- a/x-pack/plugins/observability_log_explorer/common/locators/index.ts +++ b/x-pack/plugins/observability_log_explorer/common/locators/index.ts @@ -5,6 +5,7 @@ * 2.0. */ +export type { ObservabilityLogExplorerLocationState } from '@kbn/deeplinks-observability/locators'; import { AllDatasetsLocator } from './all_datasets'; import { SingleDatasetLocator } from './single_dataset'; diff --git a/x-pack/plugins/observability_log_explorer/common/locators/utils/helpers.ts b/x-pack/plugins/observability_log_explorer/common/locators/utils/helpers.ts index c22c000732839..5a93709e76522 100644 --- a/x-pack/plugins/observability_log_explorer/common/locators/utils/helpers.ts +++ b/x-pack/plugins/observability_log_explorer/common/locators/utils/helpers.ts @@ -20,7 +20,7 @@ export const constructLocatorPath = async (params: LocatorPathCosntructionParams const { isFilterPinned } = await import('@kbn/es-query'); const { - locatorParams: { filters, query, refreshInterval, timeRange, columns, sort }, + locatorParams: { filters, query, refreshInterval, timeRange, columns, sort, origin }, index, useHash, } = params; @@ -55,6 +55,8 @@ export const constructLocatorPath = async (params: LocatorPathCosntructionParams return { app: 'observability-log-explorer', path, - state: {}, + state: { + ...(origin ? { origin } : {}), + }, }; }; diff --git a/x-pack/plugins/observability_log_explorer/public/applications/observability_log_explorer.tsx b/x-pack/plugins/observability_log_explorer/public/applications/observability_log_explorer.tsx index 562ff3ba9d109..a8c6602f9d49f 100644 --- a/x-pack/plugins/observability_log_explorer/public/applications/observability_log_explorer.tsx +++ b/x-pack/plugins/observability_log_explorer/public/applications/observability_log_explorer.tsx @@ -5,20 +5,24 @@ * 2.0. */ -import { AppMountParameters, CoreStart } from '@kbn/core/public'; +import { CoreStart } from '@kbn/core/public'; import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { Route, Router, Routes } from '@kbn/shared-ux-router'; import React from 'react'; import ReactDOM from 'react-dom'; import { ObservablityLogExplorerMainRoute } from '../routes/main'; -import { ObservabilityLogExplorerPluginStart, ObservabilityLogExplorerStartDeps } from '../types'; +import { + ObservabilityLogExplorerAppMountParameters, + ObservabilityLogExplorerPluginStart, + ObservabilityLogExplorerStartDeps, +} from '../types'; import { useKibanaContextForPluginProvider } from '../utils/use_kibana'; export const renderObservabilityLogExplorer = ( core: CoreStart, pluginsStart: ObservabilityLogExplorerStartDeps, ownPluginStart: ObservabilityLogExplorerPluginStart, - appParams: AppMountParameters + appParams: ObservabilityLogExplorerAppMountParameters ) => { ReactDOM.render( ['services']; state$: BehaviorSubject; - theme$: AppMountParameters['theme$']; + theme$: ObservabilityLogExplorerAppMountParameters['theme$']; } export const LogExplorerTopNavMenu = ({ diff --git a/x-pack/plugins/observability_log_explorer/public/plugin.ts b/x-pack/plugins/observability_log_explorer/public/plugin.ts index 0bf10b5fab5b1..f3b3cffaf9701 100644 --- a/x-pack/plugins/observability_log_explorer/public/plugin.ts +++ b/x-pack/plugins/observability_log_explorer/public/plugin.ts @@ -23,6 +23,7 @@ import { OBSERVABILITY_LOG_EXPLORER_APP_ID } from '../common/constants'; import { logExplorerAppTitle } from '../common/translations'; import { renderObservabilityLogExplorer } from './applications/observability_log_explorer'; import type { + ObservabilityLogExplorerAppMountParameters, ObservabilityLogExplorerPluginSetup, ObservabilityLogExplorerPluginStart, ObservabilityLogExplorerSetupDeps, @@ -56,7 +57,7 @@ export class ObservabilityLogExplorerPlugin : AppNavLinkStatus.hidden, searchable: true, keywords: ['logs', 'log', 'explorer', 'logs explorer'], - mount: async (appMountParams) => { + mount: async (appMountParams: ObservabilityLogExplorerAppMountParameters) => { const [coreStart, pluginsStart, ownPluginStart] = await core.getStartServices(); return renderObservabilityLogExplorer( diff --git a/x-pack/plugins/observability_log_explorer/public/routes/main/main_route.tsx b/x-pack/plugins/observability_log_explorer/public/routes/main/main_route.tsx index b4eb120ba3cae..aece8474f0390 100644 --- a/x-pack/plugins/observability_log_explorer/public/routes/main/main_route.tsx +++ b/x-pack/plugins/observability_log_explorer/public/routes/main/main_route.tsx @@ -5,16 +5,17 @@ * 2.0. */ -import { AppMountParameters, CoreStart } from '@kbn/core/public'; +import { CoreStart } from '@kbn/core/public'; import React, { useState } from 'react'; import { BehaviorSubject } from 'rxjs'; import { LogExplorerTopNavMenu } from '../../components/log_explorer_top_nav_menu'; import { ObservabilityLogExplorerPageTemplate } from '../../components/page_template'; import { noBreadcrumbs, useBreadcrumbs } from '../../utils/breadcrumbs'; import { useKibanaContextForPlugin } from '../../utils/use_kibana'; - +import { ObservabilityLogExplorerAppMountParameters } from '../../types'; +import { LazyOriginInterpreter } from '../../state_machines/origin_interpreter/src/lazy_component'; export interface ObservablityLogExplorerMainRouteProps { - appParams: AppMountParameters; + appParams: ObservabilityLogExplorerAppMountParameters; core: CoreStart; } @@ -38,6 +39,7 @@ export const ObservablityLogExplorerMainRoute = ({ state$={state$} theme$={theme$} /> + diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/index.ts b/x-pack/plugins/observability_log_explorer/public/state_machines/index.ts new file mode 100644 index 0000000000000..bad354ffa1b78 --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export { createOriginInterpreterStateMachine } from './origin_interpreter/src/state_machine'; diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/component.tsx b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/component.tsx new file mode 100644 index 0000000000000..87a96ec1dbb3f --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/component.tsx @@ -0,0 +1,29 @@ +/* + * 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 { isDevMode } from '@kbn/xstate-utils'; +import { useInterpret } from '@xstate/react'; +import { + createOriginInterpreterStateMachine, + OriginInterpreterStateMachineDependencies, +} from './state_machine'; + +export const OriginInterpreter: React.FC = ({ + history, + toasts, +}) => { + useInterpret( + () => + createOriginInterpreterStateMachine({ + history, + toasts, + }), + { devTools: isDevMode() } + ); + + return null; +}; diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/constants.ts b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/constants.ts new file mode 100644 index 0000000000000..815483cfab7b4 --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/constants.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export const FEEDBACK_DELAY_MS = 30000; // 30 seconds +export const FEEDBACK_TOAST_LIFETIME_MS = 60000; // 1 minute diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/defaults.ts b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/defaults.ts new file mode 100644 index 0000000000000..6545a48a0c846 --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/defaults.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export const DEFAULT_CONTEXT = undefined; diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/lazy_component.tsx b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/lazy_component.tsx new file mode 100644 index 0000000000000..8c157c449d1be --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/lazy_component.tsx @@ -0,0 +1,16 @@ +/* + * 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 { withSuspense } from '@kbn/shared-ux-utility'; +import React from 'react'; + +export const LazyOriginInterpreter = withSuspense( + React.lazy(async () => ({ + default: (await import('./component')).OriginInterpreter, + })), + null +); diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/location_state_service.ts b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/location_state_service.ts new file mode 100644 index 0000000000000..e0ce875d532e0 --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/location_state_service.ts @@ -0,0 +1,27 @@ +/* + * 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 { InvokeCreator } from 'xstate'; +import { ObservabilityLogExplorerHistory } from '../../../types'; +import { OriginInterpreterContext, OriginInterpreterEvent } from './types'; + +export const initializeFromLocationState = + ({ + history, + }: { + history: ObservabilityLogExplorerHistory; + }): InvokeCreator => + (context, event) => + (callback) => { + const origin = history.location?.state?.origin; + + if (!origin) { + return callback('INITIALIZED_WITH_NO_ORIGIN'); + } else if (origin.id === 'application-log-onboarding') { + return callback('INITIALIZED_WITH_ONBOARDING_ORIGIN'); + } + }; diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/notifications.tsx b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/notifications.tsx new file mode 100644 index 0000000000000..64c5dcd157a3d --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/notifications.tsx @@ -0,0 +1,53 @@ +/* + * 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 { IToasts } from '@kbn/core-notifications-browser'; +import { mountReactNode } from '@kbn/core-mount-utils-browser-internal'; +import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { LOGS_ONBOARDING_FEEDBACK_LINK } from '@kbn/observability-shared-plugin/common'; +import React from 'react'; +import { FEEDBACK_TOAST_LIFETIME_MS } from './constants'; + +export const createRequestFeedbackNotifier = (toasts: IToasts) => () => { + toasts.addInfo( + { + title: i18n.translate('xpack.observabilityLogExplorer.feedbackToast.title', { + defaultMessage: 'Tell us what you think!', + }), + text: mountReactNode( + <> +

+ {i18n.translate('xpack.observabilityLogExplorer.feedbackToast.text', { + defaultMessage: 'Share with us your onboarding experience and help us improve it.', + })} +

+ + + + + {i18n.translate('xpack.observabilityLogExplorer.feedbackToast.buttonText', { + defaultMessage: 'Take a quick survey', + })} + + + + + ), + iconType: 'editorComment', + }, + { + toastLifeTimeMs: FEEDBACK_TOAST_LIFETIME_MS, + } + ); +}; diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/state_machine.ts b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/state_machine.ts new file mode 100644 index 0000000000000..7ea65330d2a46 --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/state_machine.ts @@ -0,0 +1,88 @@ +/* + * 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 { IToasts } from '@kbn/core-notifications-browser'; +import { createMachine, InterpreterFrom } from 'xstate'; +import { ObservabilityLogExplorerHistory } from '../../../types'; +import { FEEDBACK_DELAY_MS } from './constants'; +import { DEFAULT_CONTEXT } from './defaults'; +import { initializeFromLocationState } from './location_state_service'; +import { createRequestFeedbackNotifier } from './notifications'; +import { + OriginInterpreterContext, + OriginInterpreterEvent, + OriginInterpreterTypeState, +} from './types'; + +export const createPureOriginInterpreterStateMachine = (initialContext: OriginInterpreterContext) => + /** @xstate-layout N4IgpgJg5mDOIC5QBkD2UCiAPADgG1QCcxCAFQ1AMwEs8wA6AVwDtrWAXagQz2oC9IAYgDaABgC6iUDlSxqnVMykgsiAIwAOAMz0NagEwBWUdoBsWgOxaAnEYA0IAJ7rt9UxesWD+2xf2WAXwCHNExcAmIyCho6ejZ5bl4+NigAMQoAWwBVQjxBCEUGNgA3VABrBlDsfCIScipaIo5E-hT01GzchBLUAGMuBWYxcWHlGTlB5VUEYw1dfQ1RQ30LC0NrbX0HZwQ1CwAWemtDLTV991FTPWWtIJD0aoi66Ma45p5W5jTMnLySCkI9HwA0oRAy9Cq4VqUQasXinA+yS+7U6eG6zFK-UGw1GSBA4wSiimiFm80Wy1W60220QenoxlEjP2J32alEmmsdxAkJqkXqMSaCURKQAIgMuAA1ahgADu+UKb1KFQhDyhfJecPeSVF4qlsvRmIG1EUOIkY1khKUeOmPkM9D8pkMFm0bMpFhpM3Obi0tqdxk0Fi5PKeMIFbyF2q+YvYkulcv+RCBeBBYJVYV5z1hgoRkag0dj+p6WONQwkuOkFsm1sQ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Sk8+axOz7CU0I1Z+SfFFNTlrcV9jwGoPZnexA5hiEue0+5kSx9-xgxScJXiWqFkWaWeRgtoi7NLXFXQBz6gjDPq8H7KkAkbDpd0DYfs6wTGdiC4ihpJWJFQPzJwiruwRIMf8rxXyzZmSdmPi+VyfFJawfEoYDrzan7WJi2W+xbSymWQG4Y0wnURvNYg0yiZ-ksHn20LxXsIUSMbpQ8AoVVGRXtoG05zTrmdOaDS9oshL5hkUL9D3KKVD8s2ru5Y1tj2g17OvQNtYcwZ2smy+Qp8WggrOnbCHYCLmNX6CW9eiHgb22YoG2cDqrJWR+Dwf6DQaaTG6GluJNy13nR44LUWzZROXWhq7eRAbiXnNabc7pr7zdDV7cQ+1CbthnyBkXUAA */ + createMachine( + { + context: initialContext, + predictableActionArguments: true, + id: 'OriginInterpreter', + initial: 'uninitialized', + states: { + uninitialized: { + always: 'initializingFromLocationState', + }, + initializingFromLocationState: { + invoke: { + src: 'initializeFromLocationState', + }, + on: { + INITIALIZED_WITH_NO_ORIGIN: '#done', + INITIALIZED_WITH_ONBOARDING_ORIGIN: '#onboarding', + }, + }, + onboarding: { + id: 'onboarding', + initial: 'waiting', + states: { + waiting: { + after: { + [FEEDBACK_DELAY_MS]: { + target: '#done', + actions: ['requestFeedback'], + }, + }, + }, + }, + }, + done: { + id: 'done', + type: 'final', + }, + }, + }, + { + actions: {}, + guards: {}, + } + ); + +export interface OriginInterpreterStateMachineDependencies { + initialContext?: OriginInterpreterContext; + history: ObservabilityLogExplorerHistory; + toasts: IToasts; +} + +export const createOriginInterpreterStateMachine = ({ + initialContext = DEFAULT_CONTEXT, + history, + toasts, +}: OriginInterpreterStateMachineDependencies) => + createPureOriginInterpreterStateMachine(initialContext).withConfig({ + actions: { + requestFeedback: createRequestFeedbackNotifier(toasts), + }, + services: { + initializeFromLocationState: initializeFromLocationState({ history }), + }, + }); + +export type OriginInterpreterService = InterpreterFrom; diff --git a/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/types.ts b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/types.ts new file mode 100644 index 0000000000000..47ee2d062c182 --- /dev/null +++ b/x-pack/plugins/observability_log_explorer/public/state_machines/origin_interpreter/src/types.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +export type OriginInterpreterContext = OriginInterpreterTypeState['context']; + +type DefaultOriginInterpreterContext = undefined; + +export type OriginInterpreterEvent = + | { + type: 'INITIALIZED_WITH_NO_ORIGIN'; + } + | { + type: 'INITIALIZED_WITH_ONBOARDING_ORIGIN'; + }; + +export type OriginInterpreterTypeState = + | { + value: 'uninitialized'; + context: DefaultOriginInterpreterContext; + } + | { + value: 'onboarding'; + context: DefaultOriginInterpreterContext; + } + | { + value: 'done'; + context: DefaultOriginInterpreterContext; + }; diff --git a/x-pack/plugins/observability_log_explorer/public/types.ts b/x-pack/plugins/observability_log_explorer/public/types.ts index a4596995a4a7b..82045faea76e8 100644 --- a/x-pack/plugins/observability_log_explorer/public/types.ts +++ b/x-pack/plugins/observability_log_explorer/public/types.ts @@ -11,7 +11,11 @@ import { DiscoverStart } from '@kbn/discover-plugin/public'; import { ObservabilitySharedPluginStart } from '@kbn/observability-shared-plugin/public'; import { ServerlessPluginStart } from '@kbn/serverless/public'; import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; -import { ObservabilityLogExplorerLocators } from '../common/locators'; +import { AppMountParameters, ScopedHistory } from '@kbn/core/public'; +import { + ObservabilityLogExplorerLocators, + ObservabilityLogExplorerLocationState, +} from '../common/locators'; export interface ObservabilityLogExplorerPluginSetup { locators: ObservabilityLogExplorerLocators; @@ -33,3 +37,7 @@ export interface ObservabilityLogExplorerStartDeps { serverless?: ServerlessPluginStart; share: SharePluginStart; } + +export type ObservabilityLogExplorerHistory = ScopedHistory; +export type ObservabilityLogExplorerAppMountParameters = + AppMountParameters; diff --git a/x-pack/plugins/observability_log_explorer/tsconfig.json b/x-pack/plugins/observability_log_explorer/tsconfig.json index 9a0fb5d43e7b9..a789445599923 100644 --- a/x-pack/plugins/observability_log_explorer/tsconfig.json +++ b/x-pack/plugins/observability_log_explorer/tsconfig.json @@ -23,13 +23,16 @@ "@kbn/core-chrome-browser", "@kbn/config-schema", "@kbn/kibana-utils-plugin", - "@kbn/core-application-browser", "@kbn/discover-plugin", "@kbn/es-query", "@kbn/react-kibana-mount", "@kbn/share-plugin", "@kbn/io-ts-utils", - "@kbn/deeplinks-observability" + "@kbn/deeplinks-observability", + "@kbn/core-notifications-browser", + "@kbn/core-mount-utils-browser-internal", + "@kbn/xstate-utils", + "@kbn/shared-ux-utility" ], "exclude": [ "target/**/*" diff --git a/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/install_elastic_agent.tsx b/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/install_elastic_agent.tsx index 3f2b61a833a58..bc9b34bd608f3 100644 --- a/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/install_elastic_agent.tsx +++ b/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/install_elastic_agent.tsx @@ -72,6 +72,7 @@ export function InstallElasticAgent() { await singleDatasetLocator!.navigate({ integration, dataset: enforcedDatasetName, + origin: { id: 'application-log-onboarding' }, }); } diff --git a/x-pack/plugins/observability_onboarding/public/components/app/header_action_menu/index.tsx b/x-pack/plugins/observability_onboarding/public/components/app/header_action_menu/index.tsx index 2cd68d599b48c..f4a883dd24fd7 100644 --- a/x-pack/plugins/observability_onboarding/public/components/app/header_action_menu/index.tsx +++ b/x-pack/plugins/observability_onboarding/public/components/app/header_action_menu/index.tsx @@ -7,11 +7,10 @@ import { EuiButton } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { LOGS_ONBOARDING_FEEDBACK_LINK } from '@kbn/observability-shared-plugin/common'; import React from 'react'; import { useLocation } from 'react-router-dom'; -const LOGS_ONBOARDING_FEEDBACK_LINK = 'https://ela.st/logs-onboarding-feedback'; - export function ObservabilityOnboardingHeaderActionMenu() { const location = useLocation(); const normalizedPathname = location.pathname.replace(/\/$/, ''); diff --git a/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx b/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx index 385ba48e9b3be..8e99dc2ee1f59 100644 --- a/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx +++ b/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx @@ -84,13 +84,16 @@ export function InstallElasticAgent() { async function onContinue() { if (systemIntegrationStatus === 'rejected') { - await allDataSetsLocator!.navigate({}); + await allDataSetsLocator!.navigate({ + origin: { id: 'application-log-onboarding' }, + }); return; } await singleDatasetLocator!.navigate({ integration: 'system', dataset: 'system.syslog', + origin: { id: 'application-log-onboarding' }, }); } diff --git a/x-pack/plugins/observability_shared/common/index.ts b/x-pack/plugins/observability_shared/common/index.ts index 7ecf64366dbca..c25eee3e0b02b 100644 --- a/x-pack/plugins/observability_shared/common/index.ts +++ b/x-pack/plugins/observability_shared/common/index.ts @@ -137,3 +137,5 @@ export { export { ObservabilityTriggerId } from './trigger_ids'; export { getInspectResponse } from './utils/get_inspect_response'; + +export const LOGS_ONBOARDING_FEEDBACK_LINK = 'https://ela.st/logs-onboarding-feedback';