-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Search]Add custom telemetry events #265310
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
Changes from 6 commits
c6caa88
bb2b956
c66be34
89b8849
7cc14cf
d25ade5
85565b9
055ee52
0b16d2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| "cloudConnect", | ||
| "console", | ||
| "serverless", | ||
| "usageCollection", | ||
| ], | ||
| "requiredBundles": [ | ||
| "kibanaReact", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * 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 enum EventType { | ||
| ENDPOINT_CREATED = 'searchInferenceEndpoints_endpoint_created', | ||
| ENDPOINT_EDITED = 'searchInferenceEndpoints_endpoint_edited', | ||
| DEFAULT_MODEL_CHANGED = 'searchInferenceEndpoints_default_model_changed', | ||
| FEATURE_SETTINGS_SAVED = 'searchInferenceEndpoints_feature_settings_saved', | ||
| FILTER_APPLIED = 'searchInferenceEndpoints_filter_applied', | ||
| GROUP_BY_CHANGED = 'searchInferenceEndpoints_group_by_changed', | ||
| EMPTY_STATE_VIEWED = 'searchInferenceEndpoints_empty_state_viewed', | ||
| FLYOUT_OPENED = 'searchInferenceEndpoints_flyout_opened', | ||
| FLYOUT_CLOSED = 'searchInferenceEndpoints_flyout_closed', | ||
| MODAL_OPENED = 'searchInferenceEndpoints_modal_opened', | ||
| MODAL_CLOSED = 'searchInferenceEndpoints_modal_closed', | ||
| EIS_MODEL_VIEWED = 'searchInferenceEndpoints_eis_model_viewed', | ||
| COPY_TO_FEATURE_TOGGLED = 'searchInferenceEndpoints_copy_to_feature_toggled', | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,12 +5,14 @@ | |
| * 2.0. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import React, { useEffect } from 'react'; | ||
| import { EuiButton, EuiLink } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template'; | ||
|
|
||
| import { docLinks } from '../../common/doc_links'; | ||
| import { useUsageTracker } from '../contexts/usage_tracker_context'; | ||
| import { EventType } from '../analytics/constants'; | ||
|
|
||
| interface ExternalInferenceEmptyPromptProps { | ||
| onFlyoutOpen: () => void; | ||
|
|
@@ -19,6 +21,10 @@ interface ExternalInferenceEmptyPromptProps { | |
| export const ExternalInferenceEmptyPrompt: React.FC<ExternalInferenceEmptyPromptProps> = ({ | ||
| onFlyoutOpen, | ||
| }) => { | ||
| const usageTracker = useUsageTracker(); | ||
| useEffect(() => { | ||
| usageTracker.count(EventType.EMPTY_STATE_VIEWED); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this use |
||
| }, [usageTracker]); | ||
| return ( | ||
| <KibanaPageTemplate.EmptyPrompt | ||
| data-test-subj="externalInferenceEmptyPrompt" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| * 2.0. | ||
| */ | ||
|
|
||
| import React, { useCallback, useMemo, useState } from 'react'; | ||
| import React, { useCallback, useEffect, useMemo, useState } from 'react'; | ||
| import { | ||
| EuiBadge, | ||
| EuiButtonEmpty, | ||
|
|
@@ -35,6 +35,8 @@ import { | |
| import { getModelId } from '../../utils/get_model_id'; | ||
| import { AddEndpointModal } from './add_endpoint_modal'; | ||
| import { ModelEndpointRow } from './model_endpoint_row'; | ||
| import { useUsageTracker } from '../../contexts/usage_tracker_context'; | ||
| import { EventType } from '../../analytics/constants'; | ||
|
|
||
| export interface ModelDetailFlyoutProps { | ||
| modelId: string; | ||
|
|
@@ -56,6 +58,11 @@ export const ModelDetailFlyout: React.FC<ModelDetailFlyoutProps> = ({ | |
| const flyoutTitleId = useGeneratedHtmlId(); | ||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const [editingEndpoint, setEditingEndpoint] = useState<InferenceAPIConfigResponse | undefined>(); | ||
| const usageTracker = useUsageTracker(); | ||
|
|
||
| useEffect(() => { | ||
| usageTracker.count([EventType.EIS_MODEL_VIEWED, `${EventType.EIS_MODEL_VIEWED}_${modelId}`]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this use |
||
| }, [usageTracker, modelId]); | ||
|
|
||
| const { endpoints, displayName, modelAuthor } = useMemo(() => { | ||
| const filtered = allEndpoints.filter((ep) => getModelId(ep) === modelId); | ||
|
|
@@ -89,19 +96,25 @@ export const ModelDetailFlyout: React.FC<ModelDetailFlyoutProps> = ({ | |
| }, [endpoints]); | ||
|
|
||
| const handleOpenAddModal = useCallback(() => { | ||
| usageTracker.count([EventType.MODAL_OPENED, `${EventType.MODAL_OPENED}_add_endpoint`]); | ||
| setEditingEndpoint(undefined); | ||
| setIsModalOpen(true); | ||
| }, []); | ||
| }, [usageTracker]); | ||
|
|
||
| const handleOpenEditModal = useCallback((endpoint: InferenceAPIConfigResponse) => { | ||
| setEditingEndpoint(endpoint); | ||
| setIsModalOpen(true); | ||
| }, []); | ||
| const handleOpenEditModal = useCallback( | ||
| (endpoint: InferenceAPIConfigResponse) => { | ||
| usageTracker.count([EventType.MODAL_OPENED, `${EventType.MODAL_OPENED}_edit_endpoint`]); | ||
| setEditingEndpoint(endpoint); | ||
| setIsModalOpen(true); | ||
| }, | ||
| [usageTracker] | ||
| ); | ||
|
|
||
| const handleCloseModal = useCallback(() => { | ||
| usageTracker.count(EventType.MODAL_CLOSED); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this track whether it's an add or edit modal being closed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point |
||
| setIsModalOpen(false); | ||
| setEditingEndpoint(undefined); | ||
| }, []); | ||
| }, [usageTracker]); | ||
|
|
||
| const descriptionListItems = [ | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These events include a prefix, but the other plugin events don't. Is it worth aligning them so they either all have a prefix or none do?