Skip to content

Commit a63cfbd

Browse files
committed
Revert "[Upgrade Assistant] Refactor telemetry (#112177)"
This reverts commit 991d24b.
1 parent b91f8c8 commit a63cfbd

32 files changed

Lines changed: 809 additions & 207 deletions

File tree

x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7324,6 +7324,44 @@
73247324
}
73257325
}
73267326
}
7327+
},
7328+
"ui_open": {
7329+
"properties": {
7330+
"elasticsearch": {
7331+
"type": "long",
7332+
"_meta": {
7333+
"description": "Number of times a user viewed the list of Elasticsearch deprecations."
7334+
}
7335+
},
7336+
"overview": {
7337+
"type": "long",
7338+
"_meta": {
7339+
"description": "Number of times a user viewed the Overview page."
7340+
}
7341+
},
7342+
"kibana": {
7343+
"type": "long",
7344+
"_meta": {
7345+
"description": "Number of times a user viewed the list of Kibana deprecations"
7346+
}
7347+
}
7348+
}
7349+
},
7350+
"ui_reindex": {
7351+
"properties": {
7352+
"close": {
7353+
"type": "long"
7354+
},
7355+
"open": {
7356+
"type": "long"
7357+
},
7358+
"start": {
7359+
"type": "long"
7360+
},
7361+
"stop": {
7362+
"type": "long"
7363+
}
7364+
}
73277365
}
73287366
}
73297367
},

x-pack/plugins/upgrade_assistant/README.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -226,29 +226,4 @@ This is a non-exhaustive list of different error scenarios in Upgrade Assistant.
226226
- **Error updating deprecation logging status.** Mock a `404` status code to `PUT /api/upgrade_assistant/deprecation_logging`. Alternatively, edit [this line](https://github.com/elastic/kibana/blob/545c1420c285af8f5eee56f414bd6eca735aea11/x-pack/plugins/upgrade_assistant/public/application/lib/api.ts#L77) locally and replace `deprecation_logging` with `fake_deprecation_logging`.
227227
- **Unauthorized error fetching ES deprecations.** Mock a `403` status code to `GET /api/upgrade_assistant/es_deprecations` with the response payload: `{ "statusCode": 403 }`
228228
- **Partially upgraded error fetching ES deprecations.** Mock a `426` status code to `GET /api/upgrade_assistant/es_deprecations` with the response payload: `{ "statusCode": 426, "attributes": { "allNodesUpgraded": false } }`
229-
- **Upgraded error fetching ES deprecations.** Mock a `426` status code to `GET /api/upgrade_assistant/es_deprecations` with the response payload: `{ "statusCode": 426, "attributes": { "allNodesUpgraded": true } }`
230-
231-
### Telemetry
232-
233-
The Upgrade Assistant tracks several triggered events in the UI, using Kibana Usage Collection service's [UI counters](https://github.com/elastic/kibana/blob/master/src/plugins/usage_collection/README.mdx#ui-counters).
234-
235-
**Overview page**
236-
- Component loaded
237-
- Click event for "Create snapshot" button
238-
- Click event for "View deprecation logs in Observability" link
239-
- Click event for "Analyze logs in Discover" link
240-
- Click event for "Reset counter" button
241-
242-
**ES deprecations page**
243-
- Component loaded
244-
- Click events for starting and stopping reindex tasks
245-
- Click events for upgrading or deleting a Machine Learning snapshot
246-
- Click event for deleting a deprecated index setting
247-
248-
**Kibana deprecations page**
249-
- Component loaded
250-
- Click event for "Quick resolve" button
251-
252-
In addition to UI counters, the Upgrade Assistant has a [custom usage collector](https://github.com/elastic/kibana/blob/master/src/plugins/usage_collection/README.mdx#custom-collector). It currently is only responsible for tracking whether the user has deprecation logging enabled or not.
253-
254-
For testing instructions, refer to the [Kibana Usage Collection service README](https://github.com/elastic/kibana/blob/master/src/plugins/usage_collection/README.mdx#testing).
229+
- **Upgraded error fetching ES deprecations.** Mock a `426` status code to `GET /api/upgrade_assistant/es_deprecations` with the response payload: `{ "statusCode": 426, "attributes": { "allNodesUpgraded": true } }`

x-pack/plugins/upgrade_assistant/common/types.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,43 @@ export interface UIReindex {
141141
stop: boolean;
142142
}
143143

144+
export interface UpgradeAssistantTelemetrySavedObject {
145+
ui_open: {
146+
overview: number;
147+
elasticsearch: number;
148+
kibana: number;
149+
};
150+
ui_reindex: {
151+
close: number;
152+
open: number;
153+
start: number;
154+
stop: number;
155+
};
156+
}
157+
144158
export interface UpgradeAssistantTelemetry {
159+
ui_open: {
160+
overview: number;
161+
elasticsearch: number;
162+
kibana: number;
163+
};
164+
ui_reindex: {
165+
close: number;
166+
open: number;
167+
start: number;
168+
stop: number;
169+
};
145170
features: {
146171
deprecation_logging: {
147172
enabled: boolean;
148173
};
149174
};
150175
}
151176

177+
export interface UpgradeAssistantTelemetrySavedObjectAttributes {
178+
[key: string]: any;
179+
}
180+
152181
export type MIGRATION_DEPRECATION_LEVEL = 'none' | 'info' | 'warning' | 'critical';
153182
export interface DeprecationInfo {
154183
level: MIGRATION_DEPRECATION_LEVEL;

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/index_settings/flyout.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
* 2.0.
66
*/
77

8-
import React, { useCallback } from 'react';
8+
import React from 'react';
99
import { i18n } from '@kbn/i18n';
10-
import { METRIC_TYPE } from '@kbn/analytics';
1110
import {
1211
EuiButton,
1312
EuiButtonEmpty,
@@ -26,7 +25,6 @@ import {
2625
} from '@elastic/eui';
2726
import { EnrichedDeprecationInfo, IndexSettingAction } from '../../../../../../common/types';
2827
import type { ResponseError } from '../../../../lib/api';
29-
import { uiMetricService, UIM_INDEX_SETTINGS_DELETE_CLICK } from '../../../../lib/ui_metric';
3028
import type { Status } from '../../../types';
3129
import { DeprecationBadge } from '../../../shared';
3230

@@ -109,11 +107,6 @@ export const RemoveIndexSettingsFlyout = ({
109107
// Flag used to hide certain parts of the UI if the deprecation has been resolved or is in progress
110108
const isResolvable = ['idle', 'error'].includes(statusType);
111109

112-
const onRemoveSettings = useCallback(() => {
113-
uiMetricService.trackUiMetric(METRIC_TYPE.CLICK, UIM_INDEX_SETTINGS_DELETE_CLICK);
114-
removeIndexSettings(index!, (correctiveAction as IndexSettingAction).deprecatedSettings);
115-
}, [correctiveAction, index, removeIndexSettings]);
116-
117110
return (
118111
<>
119112
<EuiFlyoutHeader hasBorder>
@@ -197,7 +190,12 @@ export const RemoveIndexSettingsFlyout = ({
197190
fill
198191
data-test-subj="deleteSettingsButton"
199192
color="danger"
200-
onClick={onRemoveSettings}
193+
onClick={() =>
194+
removeIndexSettings(
195+
index!,
196+
(correctiveAction as IndexSettingAction).deprecatedSettings
197+
)
198+
}
201199
>
202200
{statusType === 'error'
203201
? i18nTexts.retryRemoveButtonLabel

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/ml_snapshots/flyout.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import React from 'react';
99
import { i18n } from '@kbn/i18n';
1010
import { FormattedMessage } from '@kbn/i18n/react';
11-
import { METRIC_TYPE } from '@kbn/analytics';
1211

1312
import {
1413
EuiButton,
@@ -26,11 +25,6 @@ import {
2625
} from '@elastic/eui';
2726

2827
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
29-
import {
30-
uiMetricService,
31-
UIM_ML_SNAPSHOT_UPGRADE_CLICK,
32-
UIM_ML_SNAPSHOT_DELETE_CLICK,
33-
} from '../../../../lib/ui_metric';
3428
import { DeprecationBadge } from '../../../shared';
3529
import { MlSnapshotContext } from './context';
3630
import { useAppContext } from '../../../../app_context';
@@ -179,13 +173,11 @@ export const FixSnapshotsFlyout = ({
179173
const isResolved = snapshotState.status === 'complete';
180174

181175
const onUpgradeSnapshot = () => {
182-
uiMetricService.trackUiMetric(METRIC_TYPE.CLICK, UIM_ML_SNAPSHOT_UPGRADE_CLICK);
183176
upgradeSnapshot();
184177
closeFlyout();
185178
};
186179

187180
const onDeleteSnapshot = () => {
188-
uiMetricService.trackUiMetric(METRIC_TYPE.CLICK, UIM_ML_SNAPSHOT_DELETE_CLICK);
189181
deleteSnapshot();
190182
closeFlyout();
191183
};

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/__snapshots__/checklist_step.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/checklist_step.tsx

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import React, { Fragment, useCallback } from 'react';
8+
import React, { Fragment } from 'react';
99

1010
import {
1111
EuiButton,
@@ -19,14 +19,8 @@ import {
1919
EuiTitle,
2020
} from '@elastic/eui';
2121
import { FormattedMessage } from '@kbn/i18n/react';
22-
import { METRIC_TYPE } from '@kbn/analytics';
2322

2423
import { ReindexStatus } from '../../../../../../../common/types';
25-
import {
26-
uiMetricService,
27-
UIM_REINDEX_START_CLICK,
28-
UIM_REINDEX_STOP_CLICK,
29-
} from '../../../../../lib/ui_metric';
3024
import { LoadingState } from '../../../../types';
3125
import type { ReindexState } from '../use_reindex_state';
3226
import { ReindexProgress } from './progress';
@@ -80,16 +74,6 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
8074
const hasFetchFailed = status === ReindexStatus.fetchFailed;
8175
const hasReindexingFailed = status === ReindexStatus.failed;
8276

83-
const onStartReindex = useCallback(() => {
84-
uiMetricService.trackUiMetric(METRIC_TYPE.CLICK, UIM_REINDEX_START_CLICK);
85-
startReindex();
86-
}, [startReindex]);
87-
88-
const onStopReindex = useCallback(() => {
89-
uiMetricService.trackUiMetric(METRIC_TYPE.CLICK, UIM_REINDEX_STOP_CLICK);
90-
cancelReindex();
91-
}, [cancelReindex]);
92-
9377
return (
9478
<Fragment>
9579
<EuiFlyoutBody>
@@ -168,7 +152,7 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
168152
/>
169153
</h3>
170154
</EuiTitle>
171-
<ReindexProgress reindexState={reindexState} cancelReindex={onStopReindex} />
155+
<ReindexProgress reindexState={reindexState} cancelReindex={cancelReindex} />
172156
</EuiFlyoutBody>
173157
<EuiFlyoutFooter>
174158
<EuiFlexGroup justifyContent="spaceBetween">
@@ -186,7 +170,7 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
186170
fill
187171
color={status === ReindexStatus.paused ? 'warning' : 'primary'}
188172
iconType={status === ReindexStatus.paused ? 'play' : undefined}
189-
onClick={onStartReindex}
173+
onClick={startReindex}
190174
isLoading={loading}
191175
disabled={loading || !hasRequiredPrivileges}
192176
data-test-subj="startReindexingButton"

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/table_row.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77

88
import React, { useState, useEffect, useCallback } from 'react';
99
import { EuiTableRowCell } from '@elastic/eui';
10-
import { METRIC_TYPE } from '@kbn/analytics';
1110
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
1211
import { GlobalFlyout } from '../../../../../shared_imports';
1312
import { useAppContext } from '../../../../app_context';
14-
import {
15-
uiMetricService,
16-
UIM_REINDEX_CLOSE_FLYOUT_CLICK,
17-
UIM_REINDEX_OPEN_FLYOUT_CLICK,
18-
} from '../../../../lib/ui_metric';
1913
import { DeprecationTableColumns } from '../../../types';
2014
import { EsDeprecationsTableCells } from '../../es_deprecations_table_cells';
2115
import { ReindexResolutionCell } from './resolution_table_cell';
@@ -35,15 +29,18 @@ const ReindexTableRowCells: React.FunctionComponent<TableRowProps> = ({
3529
}) => {
3630
const [showFlyout, setShowFlyout] = useState(false);
3731
const reindexState = useReindexContext();
32+
const {
33+
services: { api },
34+
} = useAppContext();
3835

3936
const { addContent: addContentToGlobalFlyout, removeContent: removeContentFromGlobalFlyout } =
4037
useGlobalFlyout();
4138

4239
const closeFlyout = useCallback(async () => {
4340
removeContentFromGlobalFlyout('reindexFlyout');
4441
setShowFlyout(false);
45-
uiMetricService.trackUiMetric(METRIC_TYPE.CLICK, UIM_REINDEX_CLOSE_FLYOUT_CLICK);
46-
}, [removeContentFromGlobalFlyout]);
42+
await api.sendReindexTelemetryData({ close: true });
43+
}, [api, removeContentFromGlobalFlyout]);
4744

4845
useEffect(() => {
4946
if (showFlyout) {
@@ -67,9 +64,13 @@ const ReindexTableRowCells: React.FunctionComponent<TableRowProps> = ({
6764

6865
useEffect(() => {
6966
if (showFlyout) {
70-
uiMetricService.trackUiMetric(METRIC_TYPE.CLICK, UIM_REINDEX_OPEN_FLYOUT_CLICK);
67+
async function sendTelemetry() {
68+
await api.sendReindexTelemetryData({ open: true });
69+
}
70+
71+
sendTelemetry();
7172
}
72-
}, [showFlyout]);
73+
}, [showFlyout, api]);
7374

7475
return (
7576
<>

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/use_reindex_state.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ export const useReindexStatus = ({ indexName, api }: { indexName: string; api: A
132132
cancelLoadingState: undefined,
133133
});
134134

135+
api.sendReindexTelemetryData({ start: true });
136+
135137
const { data, error } = await api.startReindexTask(indexName);
136138

137139
if (error) {
@@ -149,6 +151,8 @@ export const useReindexStatus = ({ indexName, api }: { indexName: string; api: A
149151
}, [api, indexName, reindexState, updateStatus]);
150152

151153
const cancelReindex = useCallback(async () => {
154+
api.sendReindexTelemetryData({ stop: true });
155+
152156
const { error } = await api.cancelReindexTask(indexName);
153157

154158
setReindexState({

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import { EuiPageHeader, EuiSpacer, EuiPageContent, EuiLink } from '@elastic/eui'
1212
import { i18n } from '@kbn/i18n';
1313
import { FormattedMessage } from '@kbn/i18n/react';
1414
import { DocLinksStart } from 'kibana/public';
15-
import { METRIC_TYPE } from '@kbn/analytics';
1615

1716
import { EnrichedDeprecationInfo } from '../../../../common/types';
1817
import { SectionLoading } from '../../../shared_imports';
1918
import { useAppContext } from '../../app_context';
20-
import { uiMetricService, UIM_ES_DEPRECATIONS_PAGE_LOAD } from '../../lib/ui_metric';
2119
import { getEsDeprecationError } from '../../lib/get_es_deprecation_error';
2220
import { DeprecationsPageLoadingError, NoDeprecationsPrompt, DeprecationCount } from '../shared';
2321
import { EsDeprecationsTable } from './es_deprecations_table';
@@ -84,7 +82,13 @@ export const EsDeprecations = withRouter(({ history }: RouteComponentProps) => {
8482
},
8583
} = useAppContext();
8684

87-
const { data: esDeprecations, isLoading, error, resendRequest } = api.useLoadEsDeprecations();
85+
const {
86+
data: esDeprecations,
87+
isLoading,
88+
error,
89+
resendRequest,
90+
isInitialRequest,
91+
} = api.useLoadEsDeprecations();
8892

8993
const deprecationsCountByLevel: {
9094
warningDeprecations: number;
@@ -99,8 +103,16 @@ export const EsDeprecations = withRouter(({ history }: RouteComponentProps) => {
99103
}, [breadcrumbs]);
100104

101105
useEffect(() => {
102-
uiMetricService.trackUiMetric(METRIC_TYPE.LOADED, UIM_ES_DEPRECATIONS_PAGE_LOAD);
103-
}, []);
106+
if (isLoading === false && isInitialRequest) {
107+
async function sendTelemetryData() {
108+
await api.sendPageTelemetryData({
109+
elasticsearch: true,
110+
});
111+
}
112+
113+
sendTelemetryData();
114+
}
115+
}, [api, isLoading, isInitialRequest]);
104116

105117
if (error) {
106118
return (

0 commit comments

Comments
 (0)