Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Onboarding] Increasing telemetry coverage #195741

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const ApiKeyForm: React.FC<ApiKeyFormProps> = ({ hasTitle = true }) => {
value={displayedApiKey}
copyValue={apiKey}
dataTestSubj="apiKeyFormAPIKey"
copyValueDataTestSubj="APIKeyButtonCopy"
actions={[
<EuiButtonIcon
iconType={apiKeyIsVisible ? 'eyeClosed' : 'eye'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface TryInConsoleButtonProps {
content?: string | React.ReactElement;
showIcon?: boolean;
type?: 'link' | 'button' | 'emptyButton';
telemetryId?: string;
onClick?: () => void;
}
export const TryInConsoleButton = ({
request,
Expand All @@ -38,6 +40,8 @@ export const TryInConsoleButton = ({
content = RUN_IN_CONSOLE,
showIcon = true,
type = 'emptyButton',
telemetryId,
onClick: onClickProp,
}: TryInConsoleButtonProps) => {
const url = sharePlugin?.url;
const canShowDevtools = !!application?.capabilities?.dev_tools?.show;
Expand Down Expand Up @@ -65,6 +69,7 @@ export const TryInConsoleButton = ({
} else {
window.open(consolePreviewLink, '_blank', 'noreferrer');
}
onClickProp?.();
};

const getAriaLabel = () => {
Expand All @@ -84,6 +89,7 @@ export const TryInConsoleButton = ({
const commonProps = {
'data-test-subj': type === 'link' ? 'tryInConsoleLink' : 'tryInConsoleButton',
'aria-label': getAriaLabel(),
'data-telemetry-id': telemetryId,
Copy link
Member Author

Choose a reason for hiding this comment

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

this is so we have extra information in the click to capture information about the language and code example, when we use the UI-browser-events table.

onClick,
};
const iconType = showIcon ? 'play' : undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface FormInfoFieldProps {
value: string;
copyValue?: string;
dataTestSubj?: string;
copyValueDataTestSubj?: string;
}

export const FormInfoField: React.FC<FormInfoFieldProps> = ({
Expand All @@ -31,6 +32,7 @@ export const FormInfoField: React.FC<FormInfoFieldProps> = ({
value,
copyValue,
dataTestSubj,
copyValueDataTestSubj,
}) => {
const { euiTheme } = useEuiTheme();

Expand Down Expand Up @@ -71,6 +73,7 @@ export const FormInfoField: React.FC<FormInfoFieldProps> = ({
<EuiButtonIcon
onClick={copy}
iconType="copy"
data-test-subj={copyValueDataTestSubj}
aria-label={i18n.translate('xpack.searchSharedUI.formInfoField.copyMessage', {
defaultMessage: 'Copy to clipboard',
})}
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/search_indices/public/analytics/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ export enum AnalyticsEvents {
startPageOpened = 'start_page_opened',
startPageShowCodeClick = 'start_page_show_code',
startPageShowCreateIndexUIClick = 'start_page_show_create_index_ui',
startCreateIndexPageModifyIndexName = 'start_modify_index_name',
startCreateIndexClick = 'start_create_index',
startCreateIndexLanguageSelect = 'start_code_lang_select',
startCreateIndexCodeCopyInstall = 'start_code_copy_install',
startCreateIndexCodeCopy = 'start_code_copy',
startCreateIndexRunInConsole = 'start_cta_run_in_console',
startCreateIndexCreatedRedirect = 'start_index_created_api',
startFileUploadClick = 'start_file_upload',
indexDetailsInstallCodeCopy = 'index_details_code_copy_install',
indexDetailsAddMappingsCodeCopy = 'index_details_add_mappings_code_copy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const ConnectionDetails: React.FC = () => {
value={elasticsearchUrl}
copyValue={elasticsearchUrl}
dataTestSubj="connectionDetailsEndpoint"
copyValueDataTestSubj="connectionDetailsEndpointCopy"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const CreateIndexForm = ({
}: CreateIndexFormProps) => {
const { application } = useKibana().services;
const [indexNameHasError, setIndexNameHasError] = useState<boolean>(false);
const [defaultIndexName] = useState<string>(formState.indexName);
joemcelroy marked this conversation as resolved.
Show resolved Hide resolved
const usageTracker = useUsageTracker();
const { createIndex, isLoading } = useCreateIndex();
const onCreateIndex = useCallback(
Expand All @@ -63,9 +64,14 @@ export const CreateIndexForm = ({
return;
}
usageTracker.click(AnalyticsEvents.startCreateIndexClick);

if (defaultIndexName !== formState.indexName) {
usageTracker.click(AnalyticsEvents.startCreateIndexPageModifyIndexName);
}

createIndex({ indexName: formState.indexName });
},
[usageTracker, createIndex, formState.indexName]
[usageTracker, createIndex, formState.indexName, defaultIndexName]
);
const onIndexNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newIndexName = e.target.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ export const CreateIndexCodeView = ({
application={application}
sharePlugin={share}
consolePlugin={consolePlugin}
telemetryId={`${selectedLanguage}_create_index`}
onClick={() => {
usageTracker.click([
AnalyticsEvents.startCreateIndexRunInConsole,
`${AnalyticsEvents.startCreateIndexRunInConsole}_${selectedLanguage}`,
]);
}}
/>
</EuiFlexItem>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import type { IndicesStatusResponse } from '../../../../common';
import { useKibana } from '../../../hooks/use_kibana';

import { navigateToIndexDetails } from './utils';
import { useUsageTracker } from '../../../contexts/usage_tracker_context';
import { AnalyticsEvents } from '../../../analytics/constants';

export const useIndicesRedirect = (indicesStatus?: IndicesStatusResponse) => {
const { application, http } = useKibana().services;
const [lastStatus, setLastStatus] = useState<IndicesStatusResponse | undefined>(() => undefined);
const [hasDoneRedirect, setHasDoneRedirect] = useState(() => false);
const usageTracker = useUsageTracker();
return useEffect(() => {
if (hasDoneRedirect) {
return;
Expand All @@ -36,9 +39,18 @@ export const useIndicesRedirect = (indicesStatus?: IndicesStatusResponse) => {
if (indicesStatus.indexNames.length === 1) {
navigateToIndexDetails(application, http, indicesStatus.indexNames[0]);
setHasDoneRedirect(true);
usageTracker.click(AnalyticsEvents.startCreateIndexCreatedRedirect);
joemcelroy marked this conversation as resolved.
Show resolved Hide resolved
return;
}
application.navigateToApp('management', { deepLinkId: 'index_management' });
setHasDoneRedirect(true);
}, [application, http, indicesStatus, lastStatus, hasDoneRedirect]);
}, [
application,
http,
indicesStatus,
lastStatus,
setHasDoneRedirect,
usageTracker,
hasDoneRedirect,
]);
};