Rename user_action telemetry app to ui_metric (#33904)
* Rename internal references to user actions to UI metrics in Index Management, ILM, and Rollups.
This commit is contained in:
parent
971533a29d
commit
8d262bded5
|
@ -17,11 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { registerUserActionRoute } from './server/routes/api/user_action';
|
||||
import { registerUserActionRoute } from './server/routes/api/ui_metric';
|
||||
|
||||
export default function (kibana) {
|
||||
return new kibana.Plugin({
|
||||
id: 'user_action',
|
||||
id: 'ui_metric',
|
||||
require: ['kibana', 'elasticsearch'],
|
||||
|
||||
uiExports: {
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"user-action": {
|
||||
"ui-metric": {
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "user_action",
|
||||
"name": "ui_metric",
|
||||
"version": "kibana"
|
||||
}
|
|
@ -22,23 +22,23 @@ import { Server } from 'hapi';
|
|||
|
||||
export const registerUserActionRoute = (server: Server) => {
|
||||
/*
|
||||
* Increment a count on an object representing a specific user action.
|
||||
* Increment a count on an object representing a specific interaction with the UI.
|
||||
*/
|
||||
server.route({
|
||||
path: '/api/user_action/{appName}/{actionTypes}',
|
||||
path: '/api/ui_metric/{appName}/{metricTypes}',
|
||||
method: 'POST',
|
||||
handler: async (request: any) => {
|
||||
const { appName, actionTypes } = request.params;
|
||||
const { appName, metricTypes } = request.params;
|
||||
|
||||
try {
|
||||
const { getSavedObjectsRepository } = server.savedObjects;
|
||||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');
|
||||
const internalRepository = getSavedObjectsRepository(callWithInternalUser);
|
||||
|
||||
const incrementRequests = actionTypes.split(',').map((actionType: string) => {
|
||||
const savedObjectId = `${appName}:${actionType}`;
|
||||
const incrementRequests = metricTypes.split(',').map((metricType: string) => {
|
||||
const savedObjectId = `${appName}:${metricType}`;
|
||||
// This object is created if it doesn't already exist.
|
||||
return internalRepository.incrementCounter('user-action', savedObjectId, 'count');
|
||||
return internalRepository.incrementCounter('ui-metric', savedObjectId, 'count');
|
||||
});
|
||||
|
||||
await Promise.all(incrementRequests);
|
|
@ -32,6 +32,6 @@ export default function ({ loadTestFile }) {
|
|||
loadTestFile(require.resolve('./suggestions'));
|
||||
loadTestFile(require.resolve('./status'));
|
||||
loadTestFile(require.resolve('./stats'));
|
||||
loadTestFile(require.resolve('./user_action'));
|
||||
loadTestFile(require.resolve('./ui_metric'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
export default function ({ loadTestFile }) {
|
||||
describe('User Action', () => {
|
||||
loadTestFile(require.resolve('./user_action'));
|
||||
describe('UI Metric', () => {
|
||||
loadTestFile(require.resolve('./ui_metric'));
|
||||
});
|
||||
}
|
|
@ -23,10 +23,10 @@ export default function ({ getService }) {
|
|||
const supertest = getService('supertest');
|
||||
const es = getService('es');
|
||||
|
||||
describe('user_action API', () => {
|
||||
describe('ui_metric API', () => {
|
||||
it('increments the count field in the document defined by the {app}/{action_type} path', async () => {
|
||||
await supertest
|
||||
.post('/api/user_action/myApp/myAction')
|
||||
.post('/api/ui_metric/myApp/myAction')
|
||||
.set('kbn-xsrf', 'kibana')
|
||||
.expect(200);
|
||||
|
||||
|
@ -41,7 +41,7 @@ export default function ({ getService }) {
|
|||
|
||||
it('supports comma-delimited action types', async () => {
|
||||
await supertest
|
||||
.post('/api/user_action/myApp/myAction1,myAction2')
|
||||
.post('/api/ui_metric/myApp/myAction1,myAction2')
|
||||
.set('kbn-xsrf', 'kibana')
|
||||
.expect(200);
|
||||
|
|
@ -4,4 +4,4 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { createUserActionUri } from './user_action';
|
||||
export { createUiMetricUri } from './ui_metric';
|
|
@ -6,6 +6,6 @@
|
|||
|
||||
import chrome from 'ui/chrome';
|
||||
|
||||
export function createUserActionUri(appName: string, actionType: string): string {
|
||||
return chrome.addBasePath(`/api/user_action/${appName}/${actionType}`);
|
||||
export function createUiMetricUri(appName: string, actionType: string): string {
|
||||
return chrome.addBasePath(`/api/ui_metric/${appName}/${actionType}`);
|
||||
}
|
|
@ -7,19 +7,19 @@
|
|||
export const BASE_PATH = '/management/elasticsearch/index_lifecycle_management/';
|
||||
export const PLUGIN_ID = 'index_lifecycle_management';
|
||||
export {
|
||||
UA_APP_NAME,
|
||||
UIM_APP_NAME,
|
||||
USER_ACTIONS,
|
||||
UA_APP_LOAD,
|
||||
UA_POLICY_CREATE,
|
||||
UA_POLICY_UPDATE,
|
||||
UA_POLICY_DELETE,
|
||||
UA_POLICY_ATTACH_INDEX,
|
||||
UA_POLICY_ATTACH_INDEX_TEMPLATE,
|
||||
UA_POLICY_DETACH_INDEX,
|
||||
UA_CONFIG_COLD_PHASE,
|
||||
UA_CONFIG_WARM_PHASE,
|
||||
UA_CONFIG_SET_PRIORITY,
|
||||
UA_CONFIG_FREEZE_INDEX,
|
||||
UA_INDEX_RETRY_STEP,
|
||||
UA_EDIT_CLICK,
|
||||
} from './user_action';
|
||||
UIM_APP_LOAD,
|
||||
UIM_POLICY_CREATE,
|
||||
UIM_POLICY_UPDATE,
|
||||
UIM_POLICY_DELETE,
|
||||
UIM_POLICY_ATTACH_INDEX,
|
||||
UIM_POLICY_ATTACH_INDEX_TEMPLATE,
|
||||
UIM_POLICY_DETACH_INDEX,
|
||||
UIM_CONFIG_COLD_PHASE,
|
||||
UIM_CONFIG_WARM_PHASE,
|
||||
UIM_CONFIG_SET_PRIORITY,
|
||||
UIM_CONFIG_FREEZE_INDEX,
|
||||
UIM_INDEX_RETRY_STEP,
|
||||
UIM_EDIT_CLICK,
|
||||
} from './ui_metric';
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const UIM_APP_NAME = 'index_lifecycle_management';
|
||||
|
||||
export const UIM_APP_LOAD = 'app_load';
|
||||
export const UIM_POLICY_CREATE = 'policy_create';
|
||||
export const UIM_POLICY_UPDATE = 'policy_update';
|
||||
export const UIM_POLICY_DELETE = 'policy_delete';
|
||||
export const UIM_POLICY_ATTACH_INDEX = 'policy_attach_index';
|
||||
export const UIM_POLICY_ATTACH_INDEX_TEMPLATE = 'policy_attach_index_template';
|
||||
export const UIM_POLICY_DETACH_INDEX = 'policy_detach_index';
|
||||
export const UIM_CONFIG_COLD_PHASE = 'config_cold_phase';
|
||||
export const UIM_CONFIG_WARM_PHASE = 'config_warm_phase';
|
||||
export const UIM_CONFIG_SET_PRIORITY = 'config_set_priority';
|
||||
export const UIM_CONFIG_FREEZE_INDEX = 'config_freeze_index';
|
||||
export const UIM_INDEX_RETRY_STEP = 'index_retry_step';
|
||||
export const UIM_EDIT_CLICK = 'edit_click';
|
||||
|
||||
export const USER_ACTIONS = [
|
||||
UIM_APP_LOAD,
|
||||
UIM_POLICY_CREATE,
|
||||
UIM_POLICY_UPDATE,
|
||||
UIM_POLICY_DELETE,
|
||||
UIM_POLICY_ATTACH_INDEX,
|
||||
UIM_POLICY_ATTACH_INDEX_TEMPLATE,
|
||||
UIM_POLICY_DETACH_INDEX,
|
||||
UIM_CONFIG_COLD_PHASE,
|
||||
UIM_CONFIG_WARM_PHASE,
|
||||
UIM_CONFIG_SET_PRIORITY,
|
||||
UIM_CONFIG_FREEZE_INDEX,
|
||||
UIM_INDEX_RETRY_STEP,
|
||||
UIM_EDIT_CLICK,
|
||||
];
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const UA_APP_NAME = 'index_lifecycle_management';
|
||||
|
||||
export const UA_APP_LOAD = 'app_load';
|
||||
export const UA_POLICY_CREATE = 'policy_create';
|
||||
export const UA_POLICY_UPDATE = 'policy_update';
|
||||
export const UA_POLICY_DELETE = 'policy_delete';
|
||||
export const UA_POLICY_ATTACH_INDEX = 'policy_attach_index';
|
||||
export const UA_POLICY_ATTACH_INDEX_TEMPLATE = 'policy_attach_index_template';
|
||||
export const UA_POLICY_DETACH_INDEX = 'policy_detach_index';
|
||||
export const UA_CONFIG_COLD_PHASE = 'config_cold_phase';
|
||||
export const UA_CONFIG_WARM_PHASE = 'config_warm_phase';
|
||||
export const UA_CONFIG_SET_PRIORITY = 'config_set_priority';
|
||||
export const UA_CONFIG_FREEZE_INDEX = 'config_freeze_index';
|
||||
export const UA_INDEX_RETRY_STEP = 'index_retry_step';
|
||||
export const UA_EDIT_CLICK = 'edit_click';
|
||||
|
||||
export const USER_ACTIONS = [
|
||||
UA_APP_LOAD,
|
||||
UA_POLICY_CREATE,
|
||||
UA_POLICY_UPDATE,
|
||||
UA_POLICY_DELETE,
|
||||
UA_POLICY_ATTACH_INDEX,
|
||||
UA_POLICY_ATTACH_INDEX_TEMPLATE,
|
||||
UA_POLICY_DETACH_INDEX,
|
||||
UA_CONFIG_COLD_PHASE,
|
||||
UA_CONFIG_WARM_PHASE,
|
||||
UA_CONFIG_SET_PRIORITY,
|
||||
UA_CONFIG_FREEZE_INDEX,
|
||||
UA_INDEX_RETRY_STEP,
|
||||
UA_EDIT_CLICK,
|
||||
];
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
import React, { useEffect } from 'react';
|
||||
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
|
||||
import { BASE_PATH, UA_APP_LOAD } from '../common/constants';
|
||||
import { BASE_PATH, UIM_APP_LOAD } from '../common/constants';
|
||||
import { EditPolicy } from './sections/edit_policy';
|
||||
import { PolicyTable } from './sections/policy_table';
|
||||
import { trackUserAction } from './services';
|
||||
import { trackUiMetric } from './services';
|
||||
|
||||
export const App = () => {
|
||||
useEffect(() => trackUserAction(UA_APP_LOAD), []);
|
||||
useEffect(() => trackUiMetric(UIM_APP_LOAD), []);
|
||||
|
||||
return (
|
||||
<HashRouter>
|
||||
|
|
|
@ -37,10 +37,10 @@ import {
|
|||
import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services';
|
||||
|
||||
import { getIndexListUri } from '../../../../../../index_management/public/services/navigation';
|
||||
import { BASE_PATH, UA_EDIT_CLICK } from '../../../../../common/constants';
|
||||
import { BASE_PATH, UIM_EDIT_CLICK } from '../../../../../common/constants';
|
||||
import { getPolicyPath } from '../../../../services/navigation';
|
||||
import { flattenPanelTree } from '../../../../services/flatten_panel_tree';
|
||||
import { trackUserAction } from '../../../../services';
|
||||
import { trackUiMetric } from '../../../../services';
|
||||
import { NoMatch } from '../no_match';
|
||||
import { ConfirmDelete } from './confirm_delete';
|
||||
import { AddPolicyToTemplateConfirmModal } from './add_policy_to_template_confirm_modal';
|
||||
|
@ -179,7 +179,7 @@ export class PolicyTableUi extends Component {
|
|||
className="policyTable__link"
|
||||
data-test-subj="policyTablePolicyNameLink"
|
||||
href={getPolicyPath(value)}
|
||||
onClick={() => trackUserAction(UA_EDIT_CLICK)}
|
||||
onClick={() => trackUiMetric(UIM_EDIT_CLICK)}
|
||||
>
|
||||
{value}
|
||||
</EuiLink>
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
*/
|
||||
import chrome from 'ui/chrome';
|
||||
import {
|
||||
UA_POLICY_DELETE,
|
||||
UA_POLICY_ATTACH_INDEX,
|
||||
UA_POLICY_ATTACH_INDEX_TEMPLATE,
|
||||
UA_POLICY_DETACH_INDEX,
|
||||
UA_INDEX_RETRY_STEP,
|
||||
UIM_POLICY_DELETE,
|
||||
UIM_POLICY_ATTACH_INDEX,
|
||||
UIM_POLICY_ATTACH_INDEX_TEMPLATE,
|
||||
UIM_POLICY_DETACH_INDEX,
|
||||
UIM_INDEX_RETRY_STEP,
|
||||
} from '../../common/constants';
|
||||
import { trackUserAction } from './user_action';
|
||||
import { trackUiMetric } from './ui_metric';
|
||||
|
||||
let httpClient;
|
||||
export const setHttpClient = (client) => {
|
||||
|
@ -53,7 +53,7 @@ export async function loadPolicies(withIndices, httpClient = getHttpClient()) {
|
|||
export async function deletePolicy(policyName, httpClient = getHttpClient()) {
|
||||
const response = await httpClient.delete(`${apiPrefix}/policies/${encodeURIComponent(policyName)}`);
|
||||
// Only track successful actions.
|
||||
trackUserAction(UA_POLICY_DELETE, httpClient);
|
||||
trackUiMetric(UIM_POLICY_DELETE, httpClient);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -73,27 +73,27 @@ export async function getAffectedIndices(indexTemplateName, policyName, httpClie
|
|||
export const retryLifecycleForIndex = async (indexNames, httpClient = getHttpClient()) => {
|
||||
const response = await httpClient.post(`${apiPrefix}/index/retry`, { indexNames });
|
||||
// Only track successful actions.
|
||||
trackUserAction(UA_INDEX_RETRY_STEP, httpClient);
|
||||
trackUiMetric(UIM_INDEX_RETRY_STEP, httpClient);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const removeLifecycleForIndex = async (indexNames, httpClient = getHttpClient()) => {
|
||||
const response = await httpClient.post(`${apiPrefix}/index/remove`, { indexNames });
|
||||
// Only track successful actions.
|
||||
trackUserAction(UA_POLICY_DETACH_INDEX, httpClient);
|
||||
trackUiMetric(UIM_POLICY_DETACH_INDEX, httpClient);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const addLifecyclePolicyToIndex = async (body, httpClient = getHttpClient()) => {
|
||||
const response = await httpClient.post(`${apiPrefix}/index/add`, body);
|
||||
// Only track successful actions.
|
||||
trackUserAction(UA_POLICY_ATTACH_INDEX, httpClient);
|
||||
trackUiMetric(UIM_POLICY_ATTACH_INDEX, httpClient);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const addLifecyclePolicyToTemplate = async (body, httpClient = getHttpClient()) => {
|
||||
const response = await httpClient.post(`${apiPrefix}/template`, body);
|
||||
// Only track successful actions.
|
||||
trackUserAction(UA_POLICY_ATTACH_INDEX_TEMPLATE, httpClient);
|
||||
trackUiMetric(UIM_POLICY_ATTACH_INDEX_TEMPLATE, httpClient);
|
||||
return response.data;
|
||||
};
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
|
||||
export { filterItems } from './filter_items';
|
||||
export { sortTable } from './sort_table';
|
||||
export { trackUserAction, getUserActionsForPhases } from './user_action';
|
||||
export { trackUiMetric, getUiMetricsForPhases } from './ui_metric';
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
|
||||
import { createUserActionUri } from '../../../../common/user_action';
|
||||
import { createUiMetricUri } from '../../../../common/ui_metric';
|
||||
|
||||
import {
|
||||
UA_APP_NAME,
|
||||
UA_CONFIG_COLD_PHASE,
|
||||
UA_CONFIG_WARM_PHASE,
|
||||
UA_CONFIG_SET_PRIORITY,
|
||||
UA_CONFIG_FREEZE_INDEX,
|
||||
UIM_APP_NAME,
|
||||
UIM_CONFIG_COLD_PHASE,
|
||||
UIM_CONFIG_WARM_PHASE,
|
||||
UIM_CONFIG_SET_PRIORITY,
|
||||
UIM_CONFIG_FREEZE_INDEX,
|
||||
} from '../../common/constants';
|
||||
|
||||
import {
|
||||
|
@ -31,21 +31,21 @@ import {
|
|||
|
||||
import { getHttpClient } from './api';
|
||||
|
||||
export function trackUserAction(actionType, httpClient = getHttpClient()) {
|
||||
const userActionUri = createUserActionUri(UA_APP_NAME, actionType);
|
||||
httpClient.post(userActionUri);
|
||||
export function trackUiMetric(metricType, httpClient = getHttpClient()) {
|
||||
const uiMetricUri = createUiMetricUri(UIM_APP_NAME, metricType);
|
||||
httpClient.post(uiMetricUri);
|
||||
}
|
||||
|
||||
export function getUserActionsForPhases(phases) {
|
||||
const possibleUserActions = [{
|
||||
action: UA_CONFIG_COLD_PHASE,
|
||||
isExecuted: () => Boolean(phases[PHASE_COLD]),
|
||||
export function getUiMetricsForPhases(phases) {
|
||||
const phaseUiMetrics = [{
|
||||
metric: UIM_CONFIG_COLD_PHASE,
|
||||
isTracked: () => Boolean(phases[PHASE_COLD]),
|
||||
}, {
|
||||
action: UA_CONFIG_WARM_PHASE,
|
||||
isExecuted: () => Boolean(phases[PHASE_WARM]),
|
||||
metric: UIM_CONFIG_WARM_PHASE,
|
||||
isTracked: () => Boolean(phases[PHASE_WARM]),
|
||||
}, {
|
||||
action: UA_CONFIG_SET_PRIORITY,
|
||||
isExecuted: () => {
|
||||
metric: UIM_CONFIG_SET_PRIORITY,
|
||||
isTracked: () => {
|
||||
const phaseToDefaultIndexPriorityMap = {
|
||||
[PHASE_HOT]: defaultHotPhase[PHASE_INDEX_PRIORITY],
|
||||
[PHASE_WARM]: defaultWarmPhase[PHASE_INDEX_PRIORITY],
|
||||
|
@ -60,16 +60,16 @@ export function getUserActionsForPhases(phases) {
|
|||
});
|
||||
},
|
||||
}, {
|
||||
action: UA_CONFIG_FREEZE_INDEX,
|
||||
isExecuted: () => phases[PHASE_COLD] && get(phases[PHASE_COLD], 'actions.freeze'),
|
||||
metric: UIM_CONFIG_FREEZE_INDEX,
|
||||
isTracked: () => phases[PHASE_COLD] && get(phases[PHASE_COLD], 'actions.freeze'),
|
||||
}];
|
||||
|
||||
const executedUserActions = possibleUserActions.reduce((executed, { action, isExecuted }) => {
|
||||
if (isExecuted()) {
|
||||
executed.push(action);
|
||||
const trackedUiMetrics = phaseUiMetrics.reduce((tracked, { metric, isTracked }) => {
|
||||
if (isTracked()) {
|
||||
tracked.push(metric);
|
||||
}
|
||||
return executed;
|
||||
return tracked;
|
||||
}, []);
|
||||
|
||||
return executedUserActions;
|
||||
return trackedUiMetrics;
|
||||
}
|
|
@ -5,10 +5,10 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
UA_CONFIG_COLD_PHASE,
|
||||
UA_CONFIG_WARM_PHASE,
|
||||
UA_CONFIG_SET_PRIORITY,
|
||||
UA_CONFIG_FREEZE_INDEX,
|
||||
UIM_CONFIG_COLD_PHASE,
|
||||
UIM_CONFIG_WARM_PHASE,
|
||||
UIM_CONFIG_SET_PRIORITY,
|
||||
UIM_CONFIG_FREEZE_INDEX,
|
||||
} from '../../common/constants';
|
||||
|
||||
import {
|
||||
|
@ -20,11 +20,11 @@ import {
|
|||
PHASE_INDEX_PRIORITY,
|
||||
} from '../constants';
|
||||
|
||||
import { getUserActionsForPhases } from './user_action';
|
||||
import { getUiMetricsForPhases } from './ui_metric';
|
||||
|
||||
describe('getUserActionsForPhases', () => {
|
||||
describe('getUiMetricsForPhases', () => {
|
||||
test('gets cold phase', () => {
|
||||
expect(getUserActionsForPhases({
|
||||
expect(getUiMetricsForPhases({
|
||||
cold: {
|
||||
actions: {
|
||||
set_priority: {
|
||||
|
@ -32,11 +32,11 @@ describe('getUserActionsForPhases', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
})).toEqual([UA_CONFIG_COLD_PHASE]);
|
||||
})).toEqual([UIM_CONFIG_COLD_PHASE]);
|
||||
});
|
||||
|
||||
test('gets warm phase', () => {
|
||||
expect(getUserActionsForPhases({
|
||||
expect(getUiMetricsForPhases({
|
||||
warm: {
|
||||
actions: {
|
||||
set_priority: {
|
||||
|
@ -44,11 +44,11 @@ describe('getUserActionsForPhases', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
})).toEqual([UA_CONFIG_WARM_PHASE]);
|
||||
})).toEqual([UIM_CONFIG_WARM_PHASE]);
|
||||
});
|
||||
|
||||
test(`gets index priority if it's different than the default value`, () => {
|
||||
expect(getUserActionsForPhases({
|
||||
expect(getUiMetricsForPhases({
|
||||
warm: {
|
||||
actions: {
|
||||
set_priority: {
|
||||
|
@ -56,11 +56,11 @@ describe('getUserActionsForPhases', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
})).toEqual([UA_CONFIG_WARM_PHASE, UA_CONFIG_SET_PRIORITY]);
|
||||
})).toEqual([UIM_CONFIG_WARM_PHASE, UIM_CONFIG_SET_PRIORITY]);
|
||||
});
|
||||
|
||||
test('gets freeze index', () => {
|
||||
expect(getUserActionsForPhases({
|
||||
expect(getUiMetricsForPhases({
|
||||
cold: {
|
||||
actions: {
|
||||
freeze: {},
|
||||
|
@ -69,6 +69,6 @@ describe('getUserActionsForPhases', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
})).toEqual([UA_CONFIG_COLD_PHASE, UA_CONFIG_FREEZE_INDEX]);
|
||||
})).toEqual([UIM_CONFIG_COLD_PHASE, UIM_CONFIG_FREEZE_INDEX]);
|
||||
});
|
||||
});
|
|
@ -7,13 +7,13 @@ import { i18n } from '@kbn/i18n';
|
|||
import { toastNotifications } from 'ui/notify';
|
||||
|
||||
import {
|
||||
UA_POLICY_CREATE,
|
||||
UA_POLICY_UPDATE,
|
||||
UIM_POLICY_CREATE,
|
||||
UIM_POLICY_UPDATE,
|
||||
} from '../../../common/constants';
|
||||
|
||||
import { showApiError } from '../../services/api_errors';
|
||||
import { saveLifecycle as saveLifecycleApi } from '../../services/api';
|
||||
import { trackUserAction, getUserActionsForPhases } from '../../services';
|
||||
import { trackUiMetric, getUiMetricsForPhases } from '../../services';
|
||||
|
||||
export const saveLifecyclePolicy = (lifecycle, isNew) => async () => {
|
||||
try {
|
||||
|
@ -30,9 +30,9 @@ export const saveLifecyclePolicy = (lifecycle, isNew) => async () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
const userActions = getUserActionsForPhases(lifecycle.phases);
|
||||
userActions.push(isNew ? UA_POLICY_CREATE : UA_POLICY_UPDATE);
|
||||
trackUserAction(userActions.join(','));
|
||||
const uiMetrics = getUiMetricsForPhases(lifecycle.phases);
|
||||
uiMetrics.push(isNew ? UIM_POLICY_CREATE : UIM_POLICY_UPDATE);
|
||||
trackUiMetric(uiMetrics.join(','));
|
||||
|
||||
const message = i18n.translate('xpack.indexLifecycleMgmt.editPolicy.successfulSaveMessage',
|
||||
{
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { fetchUserActions } from '../../../../server/lib/user_action';
|
||||
import { UA_APP_NAME, USER_ACTIONS } from '../../common/constants';
|
||||
import { fetchUiMetrics } from '../../../../server/lib/ui_metric';
|
||||
import { UIM_APP_NAME, USER_ACTIONS } from '../../common/constants';
|
||||
|
||||
const INDEX_LIFECYCLE_MANAGEMENT_USAGE_TYPE = 'index_lifecycle_management';
|
||||
|
||||
|
@ -13,10 +13,10 @@ export function registerIndexLifecycleManagementUsageCollector(server) {
|
|||
const collector = server.usage.collectorSet.makeUsageCollector({
|
||||
type: INDEX_LIFECYCLE_MANAGEMENT_USAGE_TYPE,
|
||||
fetch: async () => {
|
||||
const userActions = await fetchUserActions(server, UA_APP_NAME, USER_ACTIONS);
|
||||
const uiMetrics = await fetchUiMetrics(server, UIM_APP_NAME, USER_ACTIONS);
|
||||
|
||||
return {
|
||||
user_actions: userActions,
|
||||
ui_metrics: uiMetrics,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -9,33 +9,33 @@ export { BASE_PATH } from './base_path';
|
|||
export * from './index_statuses';
|
||||
|
||||
export {
|
||||
UA_APP_NAME,
|
||||
UA_APP_LOAD,
|
||||
UIM_APP_NAME,
|
||||
UIM_APP_LOAD,
|
||||
USER_ACTIONS,
|
||||
UA_UPDATE_SETTINGS,
|
||||
UA_INDEX_CLEAR_CACHE,
|
||||
UA_INDEX_CLEAR_CACHE_MANY,
|
||||
UA_INDEX_CLOSE,
|
||||
UA_INDEX_CLOSE_MANY,
|
||||
UA_INDEX_DELETE,
|
||||
UA_INDEX_DELETE_MANY,
|
||||
UA_INDEX_FLUSH,
|
||||
UA_INDEX_FLUSH_MANY,
|
||||
UA_INDEX_FORCE_MERGE,
|
||||
UA_INDEX_FORCE_MERGE_MANY,
|
||||
UA_INDEX_FREEZE,
|
||||
UA_INDEX_FREEZE_MANY,
|
||||
UA_INDEX_OPEN,
|
||||
UA_INDEX_OPEN_MANY,
|
||||
UA_INDEX_REFRESH,
|
||||
UA_INDEX_REFRESH_MANY,
|
||||
UA_INDEX_UNFREEZE,
|
||||
UA_INDEX_UNFREEZE_MANY,
|
||||
UA_INDEX_SETTINGS_EDIT,
|
||||
UA_SHOW_DETAILS_CLICK,
|
||||
UA_DETAIL_PANEL_SUMMARY_TAB,
|
||||
UA_DETAIL_PANEL_SETTINGS_TAB,
|
||||
UA_DETAIL_PANEL_MAPPING_TAB,
|
||||
UA_DETAIL_PANEL_STATS_TAB,
|
||||
UA_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
} from './user_action';
|
||||
UIM_UPDATE_SETTINGS,
|
||||
UIM_INDEX_CLEAR_CACHE,
|
||||
UIM_INDEX_CLEAR_CACHE_MANY,
|
||||
UIM_INDEX_CLOSE,
|
||||
UIM_INDEX_CLOSE_MANY,
|
||||
UIM_INDEX_DELETE,
|
||||
UIM_INDEX_DELETE_MANY,
|
||||
UIM_INDEX_FLUSH,
|
||||
UIM_INDEX_FLUSH_MANY,
|
||||
UIM_INDEX_FORCE_MERGE,
|
||||
UIM_INDEX_FORCE_MERGE_MANY,
|
||||
UIM_INDEX_FREEZE,
|
||||
UIM_INDEX_FREEZE_MANY,
|
||||
UIM_INDEX_OPEN,
|
||||
UIM_INDEX_OPEN_MANY,
|
||||
UIM_INDEX_REFRESH,
|
||||
UIM_INDEX_REFRESH_MANY,
|
||||
UIM_INDEX_UNFREEZE,
|
||||
UIM_INDEX_UNFREEZE_MANY,
|
||||
UIM_INDEX_SETTINGS_EDIT,
|
||||
UIM_SHOW_DETAILS_CLICK,
|
||||
UIM_DETAIL_PANEL_SUMMARY_TAB,
|
||||
UIM_DETAIL_PANEL_SETTINGS_TAB,
|
||||
UIM_DETAIL_PANEL_MAPPING_TAB,
|
||||
UIM_DETAIL_PANEL_STATS_TAB,
|
||||
UIM_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
} from './ui_metric';
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const UIM_APP_NAME = 'index_management';
|
||||
|
||||
export const UIM_APP_LOAD = 'app_load';
|
||||
export const UIM_UPDATE_SETTINGS = 'update_settings';
|
||||
export const UIM_INDEX_CLEAR_CACHE = 'index_clear_cache';
|
||||
export const UIM_INDEX_CLEAR_CACHE_MANY = 'index_clear_cache_many';
|
||||
export const UIM_INDEX_CLOSE = 'index_close';
|
||||
export const UIM_INDEX_CLOSE_MANY = 'index_close_many';
|
||||
export const UIM_INDEX_DELETE = 'index_delete';
|
||||
export const UIM_INDEX_DELETE_MANY = 'index_delete_many';
|
||||
export const UIM_INDEX_FLUSH = 'index_flush';
|
||||
export const UIM_INDEX_FLUSH_MANY = 'index_flush_many';
|
||||
export const UIM_INDEX_FORCE_MERGE = 'index_force_merge';
|
||||
export const UIM_INDEX_FORCE_MERGE_MANY = 'index_force_merge_many';
|
||||
export const UIM_INDEX_FREEZE = 'index_freeze';
|
||||
export const UIM_INDEX_FREEZE_MANY = 'index_freeze_many';
|
||||
export const UIM_INDEX_OPEN = 'index_open';
|
||||
export const UIM_INDEX_OPEN_MANY = 'index_open_many';
|
||||
export const UIM_INDEX_REFRESH = 'index_refresh';
|
||||
export const UIM_INDEX_REFRESH_MANY = 'index_refresh_many';
|
||||
export const UIM_INDEX_SETTINGS_EDIT = 'index_settings_edit';
|
||||
export const UIM_INDEX_UNFREEZE = 'index_unfreeze';
|
||||
export const UIM_INDEX_UNFREEZE_MANY = 'index_unfreeze_many';
|
||||
export const UIM_SHOW_DETAILS_CLICK = 'show_details_click';
|
||||
export const UIM_DETAIL_PANEL_EDIT_SETTINGS_TAB = 'detail_panel_edit_settings_tab';
|
||||
export const UIM_DETAIL_PANEL_MAPPING_TAB = 'detail_panel_mapping_tab';
|
||||
export const UIM_DETAIL_PANEL_SETTINGS_TAB = 'detail_panel_settings_tab';
|
||||
export const UIM_DETAIL_PANEL_STATS_TAB = 'detail_panel_stats_tab';
|
||||
export const UIM_DETAIL_PANEL_SUMMARY_TAB = 'detail_panel_summary_tab';
|
||||
|
||||
export const USER_ACTIONS = [
|
||||
UIM_APP_LOAD,
|
||||
UIM_UPDATE_SETTINGS,
|
||||
UIM_INDEX_CLEAR_CACHE,
|
||||
UIM_INDEX_CLEAR_CACHE_MANY,
|
||||
UIM_INDEX_CLOSE,
|
||||
UIM_INDEX_CLOSE_MANY,
|
||||
UIM_INDEX_DELETE,
|
||||
UIM_INDEX_DELETE_MANY,
|
||||
UIM_INDEX_FLUSH,
|
||||
UIM_INDEX_FLUSH_MANY,
|
||||
UIM_INDEX_FORCE_MERGE,
|
||||
UIM_INDEX_FORCE_MERGE_MANY,
|
||||
UIM_INDEX_FREEZE,
|
||||
UIM_INDEX_FREEZE_MANY,
|
||||
UIM_INDEX_OPEN,
|
||||
UIM_INDEX_OPEN_MANY,
|
||||
UIM_INDEX_REFRESH,
|
||||
UIM_INDEX_REFRESH_MANY,
|
||||
UIM_INDEX_SETTINGS_EDIT,
|
||||
UIM_INDEX_UNFREEZE,
|
||||
UIM_INDEX_UNFREEZE_MANY,
|
||||
UIM_SHOW_DETAILS_CLICK,
|
||||
UIM_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
UIM_DETAIL_PANEL_MAPPING_TAB,
|
||||
UIM_DETAIL_PANEL_SETTINGS_TAB,
|
||||
UIM_DETAIL_PANEL_STATS_TAB,
|
||||
UIM_DETAIL_PANEL_SUMMARY_TAB,
|
||||
];
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const UA_APP_NAME = 'index_management';
|
||||
|
||||
export const UA_APP_LOAD = 'app_load';
|
||||
export const UA_UPDATE_SETTINGS = 'update_settings';
|
||||
export const UA_INDEX_CLEAR_CACHE = 'index_clear_cache';
|
||||
export const UA_INDEX_CLEAR_CACHE_MANY = 'index_clear_cache_many';
|
||||
export const UA_INDEX_CLOSE = 'index_close';
|
||||
export const UA_INDEX_CLOSE_MANY = 'index_close_many';
|
||||
export const UA_INDEX_DELETE = 'index_delete';
|
||||
export const UA_INDEX_DELETE_MANY = 'index_delete_many';
|
||||
export const UA_INDEX_FLUSH = 'index_flush';
|
||||
export const UA_INDEX_FLUSH_MANY = 'index_flush_many';
|
||||
export const UA_INDEX_FORCE_MERGE = 'index_force_merge';
|
||||
export const UA_INDEX_FORCE_MERGE_MANY = 'index_force_merge_many';
|
||||
export const UA_INDEX_FREEZE = 'index_freeze';
|
||||
export const UA_INDEX_FREEZE_MANY = 'index_freeze_many';
|
||||
export const UA_INDEX_OPEN = 'index_open';
|
||||
export const UA_INDEX_OPEN_MANY = 'index_open_many';
|
||||
export const UA_INDEX_REFRESH = 'index_refresh';
|
||||
export const UA_INDEX_REFRESH_MANY = 'index_refresh_many';
|
||||
export const UA_INDEX_SETTINGS_EDIT = 'index_settings_edit';
|
||||
export const UA_INDEX_UNFREEZE = 'index_unfreeze';
|
||||
export const UA_INDEX_UNFREEZE_MANY = 'index_unfreeze_many';
|
||||
export const UA_SHOW_DETAILS_CLICK = 'show_details_click';
|
||||
export const UA_DETAIL_PANEL_EDIT_SETTINGS_TAB = 'detail_panel_edit_settings_tab';
|
||||
export const UA_DETAIL_PANEL_MAPPING_TAB = 'detail_panel_mapping_tab';
|
||||
export const UA_DETAIL_PANEL_SETTINGS_TAB = 'detail_panel_settings_tab';
|
||||
export const UA_DETAIL_PANEL_STATS_TAB = 'detail_panel_stats_tab';
|
||||
export const UA_DETAIL_PANEL_SUMMARY_TAB = 'detail_panel_summary_tab';
|
||||
|
||||
export const USER_ACTIONS = [
|
||||
UA_APP_LOAD,
|
||||
UA_UPDATE_SETTINGS,
|
||||
UA_INDEX_CLEAR_CACHE,
|
||||
UA_INDEX_CLEAR_CACHE_MANY,
|
||||
UA_INDEX_CLOSE,
|
||||
UA_INDEX_CLOSE_MANY,
|
||||
UA_INDEX_DELETE,
|
||||
UA_INDEX_DELETE_MANY,
|
||||
UA_INDEX_FLUSH,
|
||||
UA_INDEX_FLUSH_MANY,
|
||||
UA_INDEX_FORCE_MERGE,
|
||||
UA_INDEX_FORCE_MERGE_MANY,
|
||||
UA_INDEX_FREEZE,
|
||||
UA_INDEX_FREEZE_MANY,
|
||||
UA_INDEX_OPEN,
|
||||
UA_INDEX_OPEN_MANY,
|
||||
UA_INDEX_REFRESH,
|
||||
UA_INDEX_REFRESH_MANY,
|
||||
UA_INDEX_SETTINGS_EDIT,
|
||||
UA_INDEX_UNFREEZE,
|
||||
UA_INDEX_UNFREEZE_MANY,
|
||||
UA_SHOW_DETAILS_CLICK,
|
||||
UA_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
UA_DETAIL_PANEL_MAPPING_TAB,
|
||||
UA_DETAIL_PANEL_SETTINGS_TAB,
|
||||
UA_DETAIL_PANEL_STATS_TAB,
|
||||
UA_DETAIL_PANEL_SUMMARY_TAB,
|
||||
];
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
import React, { useEffect } from 'react';
|
||||
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
|
||||
import { BASE_PATH, UA_APP_LOAD } from '../common/constants';
|
||||
import { BASE_PATH, UIM_APP_LOAD } from '../common/constants';
|
||||
import { IndexList } from './sections/index_list';
|
||||
import { trackUserAction } from './services';
|
||||
import { trackUiMetric } from './services';
|
||||
|
||||
export const App = () => {
|
||||
useEffect(() => trackUserAction(UA_APP_LOAD), []);
|
||||
useEffect(() => trackUiMetric(UIM_APP_LOAD), []);
|
||||
|
||||
return (
|
||||
<HashRouter>
|
||||
|
|
|
@ -35,9 +35,9 @@ import {
|
|||
EuiPageContent,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { UA_SHOW_DETAILS_CLICK } from '../../../../../common/constants';
|
||||
import { UIM_SHOW_DETAILS_CLICK } from '../../../../../common/constants';
|
||||
import { REFRESH_RATE_INDEX_LIST } from '../../../../constants';
|
||||
import { healthToColor, trackUserAction } from '../../../../services';
|
||||
import { healthToColor, trackUiMetric } from '../../../../services';
|
||||
import {
|
||||
getBannerExtensions,
|
||||
getFilterExtensions,
|
||||
|
@ -224,7 +224,7 @@ export class IndexTableUi extends Component {
|
|||
className="indTable__link"
|
||||
data-test-subj="indexTableIndexNameLink"
|
||||
onClick={() => {
|
||||
trackUserAction(UA_SHOW_DETAILS_CLICK);
|
||||
trackUiMetric(UIM_SHOW_DETAILS_CLICK);
|
||||
openDetailPanel(value);
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
import chrome from 'ui/chrome';
|
||||
|
||||
import {
|
||||
UA_UPDATE_SETTINGS,
|
||||
UA_INDEX_CLEAR_CACHE,
|
||||
UA_INDEX_CLEAR_CACHE_MANY,
|
||||
UA_INDEX_CLOSE,
|
||||
UA_INDEX_CLOSE_MANY,
|
||||
UA_INDEX_DELETE,
|
||||
UA_INDEX_DELETE_MANY,
|
||||
UA_INDEX_FLUSH,
|
||||
UA_INDEX_FLUSH_MANY,
|
||||
UA_INDEX_FORCE_MERGE,
|
||||
UA_INDEX_FORCE_MERGE_MANY,
|
||||
UA_INDEX_FREEZE,
|
||||
UA_INDEX_FREEZE_MANY,
|
||||
UA_INDEX_OPEN,
|
||||
UA_INDEX_OPEN_MANY,
|
||||
UA_INDEX_REFRESH,
|
||||
UA_INDEX_REFRESH_MANY,
|
||||
UA_INDEX_UNFREEZE,
|
||||
UA_INDEX_UNFREEZE_MANY,
|
||||
UIM_UPDATE_SETTINGS,
|
||||
UIM_INDEX_CLEAR_CACHE,
|
||||
UIM_INDEX_CLEAR_CACHE_MANY,
|
||||
UIM_INDEX_CLOSE,
|
||||
UIM_INDEX_CLOSE_MANY,
|
||||
UIM_INDEX_DELETE,
|
||||
UIM_INDEX_DELETE_MANY,
|
||||
UIM_INDEX_FLUSH,
|
||||
UIM_INDEX_FLUSH_MANY,
|
||||
UIM_INDEX_FORCE_MERGE,
|
||||
UIM_INDEX_FORCE_MERGE_MANY,
|
||||
UIM_INDEX_FREEZE,
|
||||
UIM_INDEX_FREEZE_MANY,
|
||||
UIM_INDEX_OPEN,
|
||||
UIM_INDEX_OPEN_MANY,
|
||||
UIM_INDEX_REFRESH,
|
||||
UIM_INDEX_REFRESH_MANY,
|
||||
UIM_INDEX_UNFREEZE,
|
||||
UIM_INDEX_UNFREEZE_MANY,
|
||||
} from '../../common/constants';
|
||||
|
||||
import {
|
||||
|
@ -34,7 +34,7 @@ import {
|
|||
TAB_STATS,
|
||||
} from '../constants';
|
||||
|
||||
import { trackUserAction } from './track_user_action';
|
||||
import { trackUiMetric } from './track_ui_metric';
|
||||
|
||||
let httpClient;
|
||||
|
||||
|
@ -67,8 +67,8 @@ export async function closeIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/close`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_CLOSE_MANY : UA_INDEX_CLOSE;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_CLOSE_MANY : UIM_INDEX_CLOSE;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,8 @@ export async function deleteIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/delete`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_DELETE_MANY : UA_INDEX_DELETE;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_DELETE_MANY : UIM_INDEX_DELETE;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,8 @@ export async function openIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/open`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_OPEN_MANY : UA_INDEX_OPEN;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_OPEN_MANY : UIM_INDEX_OPEN;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@ export async function refreshIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/refresh`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_REFRESH_MANY : UA_INDEX_REFRESH;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_REFRESH_MANY : UIM_INDEX_REFRESH;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -111,8 +111,8 @@ export async function flushIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/flush`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_FLUSH_MANY : UA_INDEX_FLUSH;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_FLUSH_MANY : UIM_INDEX_FLUSH;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -123,8 +123,8 @@ export async function forcemergeIndices(indices, maxNumSegments) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/forcemerge`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_FORCE_MERGE_MANY : UA_INDEX_FORCE_MERGE;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_FORCE_MERGE_MANY : UIM_INDEX_FORCE_MERGE;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -134,8 +134,8 @@ export async function clearCacheIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/clear_cache`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_CLEAR_CACHE_MANY : UA_INDEX_CLEAR_CACHE;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_CLEAR_CACHE_MANY : UIM_INDEX_CLEAR_CACHE;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
export async function freezeIndices(indices) {
|
||||
|
@ -144,8 +144,8 @@ export async function freezeIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/freeze`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_FREEZE_MANY : UA_INDEX_FREEZE;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_FREEZE_MANY : UIM_INDEX_FREEZE;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
export async function unfreezeIndices(indices) {
|
||||
|
@ -154,8 +154,8 @@ export async function unfreezeIndices(indices) {
|
|||
};
|
||||
const response = await httpClient.post(`${apiPrefix}/indices/unfreeze`, body);
|
||||
// Only track successful requests.
|
||||
const actionType = indices.length > 1 ? UA_INDEX_UNFREEZE_MANY : UA_INDEX_UNFREEZE;
|
||||
trackUserAction(actionType);
|
||||
const actionType = indices.length > 1 ? UIM_INDEX_UNFREEZE_MANY : UIM_INDEX_UNFREEZE;
|
||||
trackUiMetric(actionType);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ export async function loadIndexSettings(indexName) {
|
|||
export async function updateIndexSettings(indexName, settings) {
|
||||
const response = await httpClient.put(`${apiPrefix}/settings/${indexName}`, settings);
|
||||
// Only track successful requests.
|
||||
trackUserAction(UA_UPDATE_SETTINGS);
|
||||
trackUiMetric(UIM_UPDATE_SETTINGS);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@ export * from './api';
|
|||
export { sortTable } from './sort_table';
|
||||
export { filterItems } from './filter_items';
|
||||
export { healthToColor } from './health_to_color';
|
||||
export { trackUserAction } from './track_user_action';
|
||||
export { trackUiMetric } from './track_ui_metric';
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { createUserActionUri } from '../../../../common/user_action';
|
||||
import { UA_APP_NAME } from '../../common/constants';
|
||||
import { createUiMetricUri } from '../../../../common/ui_metric';
|
||||
import { UIM_APP_NAME } from '../../common/constants';
|
||||
import { getHttpClient } from './api';
|
||||
|
||||
export function trackUserAction(actionType) {
|
||||
const userActionUri = createUserActionUri(UA_APP_NAME, actionType);
|
||||
getHttpClient().post(userActionUri);
|
||||
export function trackUiMetric(metricType) {
|
||||
const uiMetricUri = createUiMetricUri(UIM_APP_NAME, metricType);
|
||||
getHttpClient().post(uiMetricUri);
|
||||
}
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
import { handleActions } from 'redux-actions';
|
||||
import {
|
||||
UA_DETAIL_PANEL_SUMMARY_TAB,
|
||||
UA_DETAIL_PANEL_SETTINGS_TAB,
|
||||
UA_DETAIL_PANEL_MAPPING_TAB,
|
||||
UA_DETAIL_PANEL_STATS_TAB,
|
||||
UA_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
UIM_DETAIL_PANEL_SUMMARY_TAB,
|
||||
UIM_DETAIL_PANEL_SETTINGS_TAB,
|
||||
UIM_DETAIL_PANEL_MAPPING_TAB,
|
||||
UIM_DETAIL_PANEL_STATS_TAB,
|
||||
UIM_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
} from '../../../common/constants';
|
||||
import {
|
||||
TAB_SUMMARY,
|
||||
|
@ -19,7 +19,7 @@ import {
|
|||
TAB_STATS,
|
||||
TAB_EDIT_SETTINGS,
|
||||
} from '../../constants';
|
||||
import { trackUserAction } from '../../services';
|
||||
import { trackUiMetric } from '../../services';
|
||||
import { openDetailPanel, closeDetailPanel } from '../actions/detail_panel';
|
||||
import { loadIndexDataSuccess } from '../actions/load_index_data';
|
||||
import { updateIndexSettingsSuccess, updateIndexSettingsError } from '../actions/update_index_settings';
|
||||
|
@ -45,16 +45,16 @@ export const detailPanel = handleActions(
|
|||
title
|
||||
} = action.payload;
|
||||
|
||||
const panelTypeToUserActionMap = {
|
||||
[TAB_SUMMARY]: UA_DETAIL_PANEL_SUMMARY_TAB,
|
||||
[TAB_SETTINGS]: UA_DETAIL_PANEL_SETTINGS_TAB,
|
||||
[TAB_MAPPING]: UA_DETAIL_PANEL_MAPPING_TAB,
|
||||
[TAB_STATS]: UA_DETAIL_PANEL_STATS_TAB,
|
||||
[TAB_EDIT_SETTINGS]: UA_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
const panelTypeToUiMetricMap = {
|
||||
[TAB_SUMMARY]: UIM_DETAIL_PANEL_SUMMARY_TAB,
|
||||
[TAB_SETTINGS]: UIM_DETAIL_PANEL_SETTINGS_TAB,
|
||||
[TAB_MAPPING]: UIM_DETAIL_PANEL_MAPPING_TAB,
|
||||
[TAB_STATS]: UIM_DETAIL_PANEL_STATS_TAB,
|
||||
[TAB_EDIT_SETTINGS]: UIM_DETAIL_PANEL_EDIT_SETTINGS_TAB,
|
||||
};
|
||||
|
||||
if (panelTypeToUserActionMap[panelType]) {
|
||||
trackUserAction(panelTypeToUserActionMap[panelType]);
|
||||
if (panelTypeToUiMetricMap[panelType]) {
|
||||
trackUiMetric(panelTypeToUiMetricMap[panelType]);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { fetchUserActions } from '../../../../server/lib/user_action';
|
||||
import { UA_APP_NAME, USER_ACTIONS } from '../../common/constants';
|
||||
import { fetchUiMetrics } from '../../../../server/lib/ui_metric';
|
||||
import { UIM_APP_NAME, USER_ACTIONS } from '../../common/constants';
|
||||
|
||||
const INDEX_MANAGEMENT_USAGE_TYPE = 'index_management';
|
||||
|
||||
|
@ -13,10 +13,10 @@ export function registerIndexManagementUsageCollector(server) {
|
|||
const collector = server.usage.collectorSet.makeUsageCollector({
|
||||
type: INDEX_MANAGEMENT_USAGE_TYPE,
|
||||
fetch: async () => {
|
||||
const userActions = await fetchUserActions(server, UA_APP_NAME, USER_ACTIONS);
|
||||
const uiMetrics = await fetchUiMetrics(server, UIM_APP_NAME, USER_ACTIONS);
|
||||
|
||||
return {
|
||||
user_actions: userActions,
|
||||
ui_metrics: uiMetrics,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -130,7 +130,7 @@ export const mockServerResponses = server => {
|
|||
};
|
||||
|
||||
const mockUserActions = () => {
|
||||
server.respondWith(/\/api\/user_action\/.*/, [
|
||||
server.respondWith(/\/api\/ui_metric\/.*/, [
|
||||
200,
|
||||
{ 'Content-Type': 'application/json' },
|
||||
JSON.stringify({}),
|
||||
|
|
|
@ -11,20 +11,20 @@ export const PLUGIN = {
|
|||
export const CONFIG_ROLLUPS = 'rollups:enableIndexPatterns';
|
||||
|
||||
export {
|
||||
UA_APP_NAME,
|
||||
UIM_APP_NAME,
|
||||
USER_ACTIONS,
|
||||
UA_APP_LOAD,
|
||||
UA_JOB_CREATE,
|
||||
UA_JOB_DELETE,
|
||||
UA_JOB_DELETE_MANY,
|
||||
UA_JOB_START,
|
||||
UA_JOB_START_MANY,
|
||||
UA_JOB_STOP,
|
||||
UA_JOB_STOP_MANY,
|
||||
UA_SHOW_DETAILS_CLICK,
|
||||
UA_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
} from './user_action';
|
||||
UIM_APP_LOAD,
|
||||
UIM_JOB_CREATE,
|
||||
UIM_JOB_DELETE,
|
||||
UIM_JOB_DELETE_MANY,
|
||||
UIM_JOB_START,
|
||||
UIM_JOB_START_MANY,
|
||||
UIM_JOB_STOP,
|
||||
UIM_JOB_STOP_MANY,
|
||||
UIM_SHOW_DETAILS_CLICK,
|
||||
UIM_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
} from './ui_metric';
|
||||
|
|
39
x-pack/plugins/rollup/common/ui_metric.js
Normal file
39
x-pack/plugins/rollup/common/ui_metric.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const UIM_APP_NAME = 'rollup_job_wizard';
|
||||
|
||||
export const UIM_APP_LOAD = 'app_load';
|
||||
export const UIM_JOB_CREATE = 'job_create';
|
||||
export const UIM_JOB_DELETE = 'job_delete';
|
||||
export const UIM_JOB_DELETE_MANY = 'job_delete_many';
|
||||
export const UIM_JOB_START = 'job_start';
|
||||
export const UIM_JOB_START_MANY = 'job_start_many';
|
||||
export const UIM_JOB_STOP = 'job_stop';
|
||||
export const UIM_JOB_STOP_MANY = 'job_stop_many';
|
||||
export const UIM_SHOW_DETAILS_CLICK = 'show_details_click';
|
||||
export const UIM_DETAIL_PANEL_SUMMARY_TAB_CLICK = 'detail_panel_summary_tab_click';
|
||||
export const UIM_DETAIL_PANEL_TERMS_TAB_CLICK = 'detail_panel_terms_tab_click';
|
||||
export const UIM_DETAIL_PANEL_HISTOGRAM_TAB_CLICK = 'detail_panel_histogram_tab_click';
|
||||
export const UIM_DETAIL_PANEL_METRICS_TAB_CLICK = 'detail_panel_metrics_tab_click';
|
||||
export const UIM_DETAIL_PANEL_JSON_TAB_CLICK = 'detail_panel_json_tab_click';
|
||||
|
||||
export const USER_ACTIONS = [
|
||||
UIM_APP_LOAD,
|
||||
UIM_JOB_CREATE,
|
||||
UIM_JOB_DELETE,
|
||||
UIM_JOB_DELETE_MANY,
|
||||
UIM_JOB_START,
|
||||
UIM_JOB_START_MANY,
|
||||
UIM_JOB_STOP,
|
||||
UIM_JOB_STOP_MANY,
|
||||
UIM_SHOW_DETAILS_CLICK,
|
||||
UIM_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
];
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const UA_APP_NAME = 'rollup-job-wizard';
|
||||
|
||||
export const UA_APP_LOAD = 'app_load';
|
||||
export const UA_JOB_CREATE = 'job_create';
|
||||
export const UA_JOB_DELETE = 'job_delete';
|
||||
export const UA_JOB_DELETE_MANY = 'job_delete_many';
|
||||
export const UA_JOB_START = 'job_start';
|
||||
export const UA_JOB_START_MANY = 'job_start_many';
|
||||
export const UA_JOB_STOP = 'job_stop';
|
||||
export const UA_JOB_STOP_MANY = 'job_stop_many';
|
||||
export const UA_SHOW_DETAILS_CLICK = 'show_details_click';
|
||||
export const UA_DETAIL_PANEL_SUMMARY_TAB_CLICK = 'detail_panel_summary_tab_click';
|
||||
export const UA_DETAIL_PANEL_TERMS_TAB_CLICK = 'detail_panel_terms_tab_click';
|
||||
export const UA_DETAIL_PANEL_HISTOGRAM_TAB_CLICK = 'detail_panel_histogram_tab_click';
|
||||
export const UA_DETAIL_PANEL_METRICS_TAB_CLICK = 'detail_panel_metrics_tab_click';
|
||||
export const UA_DETAIL_PANEL_JSON_TAB_CLICK = 'detail_panel_json_tab_click';
|
||||
|
||||
export const USER_ACTIONS = [
|
||||
UA_APP_LOAD,
|
||||
UA_JOB_CREATE,
|
||||
UA_JOB_DELETE,
|
||||
UA_JOB_DELETE_MANY,
|
||||
UA_JOB_START,
|
||||
UA_JOB_START_MANY,
|
||||
UA_JOB_STOP,
|
||||
UA_JOB_STOP_MANY,
|
||||
UA_SHOW_DETAILS_CLICK,
|
||||
UA_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
];
|
|
@ -8,9 +8,9 @@ import React, { Component } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
|
||||
|
||||
import { UA_APP_LOAD } from '../../common';
|
||||
import { UIM_APP_LOAD } from '../../common';
|
||||
import { CRUD_APP_BASE_PATH } from './constants';
|
||||
import { registerRouter, setUserHasLeftApp, trackUserAction } from './services';
|
||||
import { registerRouter, setUserHasLeftApp, trackUiMetric } from './services';
|
||||
import { JobList, JobCreate } from './sections';
|
||||
|
||||
class ShareRouter extends Component {
|
||||
|
@ -41,7 +41,7 @@ class ShareRouter extends Component {
|
|||
|
||||
export class App extends Component { // eslint-disable-line react/no-multi-comp
|
||||
componentDidMount() {
|
||||
trackUserAction(UA_APP_LOAD);
|
||||
trackUiMetric(UIM_APP_LOAD);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
|
|
@ -27,13 +27,13 @@ import {
|
|||
} from '@elastic/eui';
|
||||
|
||||
import {
|
||||
UA_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
UA_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
UIM_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
} from '../../../../../common';
|
||||
import { trackUserAction } from '../../../services';
|
||||
import { trackUiMetric } from '../../../services';
|
||||
|
||||
import {
|
||||
JobActionMenu,
|
||||
|
@ -54,12 +54,12 @@ export const JOB_DETAILS_TABS = [
|
|||
JOB_DETAILS_TAB_JSON,
|
||||
];
|
||||
|
||||
const tabToUserActionMap = {
|
||||
[JOB_DETAILS_TAB_SUMMARY]: UA_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_TERMS]: UA_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_HISTOGRAM]: UA_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_METRICS]: UA_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_JSON]: UA_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
const tabToUiMetricMap = {
|
||||
[JOB_DETAILS_TAB_SUMMARY]: UIM_DETAIL_PANEL_SUMMARY_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_TERMS]: UIM_DETAIL_PANEL_TERMS_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_HISTOGRAM]: UIM_DETAIL_PANEL_HISTOGRAM_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_METRICS]: UIM_DETAIL_PANEL_METRICS_TAB_CLICK,
|
||||
[JOB_DETAILS_TAB_JSON]: UIM_DETAIL_PANEL_JSON_TAB_CLICK,
|
||||
};
|
||||
|
||||
export class DetailPanelUi extends Component {
|
||||
|
@ -114,7 +114,7 @@ export class DetailPanelUi extends Component {
|
|||
renderedTabs.push(
|
||||
<EuiTab
|
||||
onClick={() => {
|
||||
trackUserAction(tabToUserActionMap[tab]);
|
||||
trackUiMetric(tabToUiMetricMap[tab]);
|
||||
openDetailPanel({ panelType: tab, jobId: id });
|
||||
}}
|
||||
isSelected={isSelected}
|
||||
|
|
|
@ -21,7 +21,7 @@ jest.mock('../../../services', () => {
|
|||
const services = require.requireActual('../../../services');
|
||||
return {
|
||||
...services,
|
||||
trackUserAction: jest.fn(),
|
||||
trackUiMetric: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ import {
|
|||
EuiToolTip,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { UA_SHOW_DETAILS_CLICK } from '../../../../../common';
|
||||
import { trackUserAction } from '../../../services';
|
||||
import { UIM_SHOW_DETAILS_CLICK } from '../../../../../common';
|
||||
import { trackUiMetric } from '../../../services';
|
||||
import { JobActionMenu, JobStatus } from '../../components';
|
||||
|
||||
const COLUMNS = [{
|
||||
|
@ -259,7 +259,7 @@ export class JobTableUi extends Component {
|
|||
content = (
|
||||
<EuiLink
|
||||
onClick={() => {
|
||||
trackUserAction(UA_SHOW_DETAILS_CLICK);
|
||||
trackUiMetric(UIM_SHOW_DETAILS_CLICK);
|
||||
openDetailPanel(job.id);
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -15,7 +15,7 @@ jest.mock('../../../services', () => {
|
|||
const services = require.requireActual('../../../services');
|
||||
return {
|
||||
...services,
|
||||
trackUserAction: jest.fn(),
|
||||
trackUiMetric: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
|
||||
import chrome from 'ui/chrome';
|
||||
import {
|
||||
UA_JOB_CREATE,
|
||||
UA_JOB_DELETE,
|
||||
UA_JOB_DELETE_MANY,
|
||||
UA_JOB_START,
|
||||
UA_JOB_START_MANY,
|
||||
UA_JOB_STOP,
|
||||
UA_JOB_STOP_MANY,
|
||||
UIM_JOB_CREATE,
|
||||
UIM_JOB_DELETE,
|
||||
UIM_JOB_DELETE_MANY,
|
||||
UIM_JOB_START,
|
||||
UIM_JOB_START_MANY,
|
||||
UIM_JOB_STOP,
|
||||
UIM_JOB_STOP_MANY,
|
||||
} from '../../../common';
|
||||
import { getHttp } from './http_provider';
|
||||
import { trackUserRequest } from './track_user_action';
|
||||
import { trackUserRequest } from './track_ui_metric';
|
||||
|
||||
const apiPrefix = chrome.addBasePath('/api/rollup');
|
||||
|
||||
|
@ -27,28 +27,28 @@ export async function loadJobs() {
|
|||
export async function startJobs(jobIds) {
|
||||
const body = { jobIds };
|
||||
const request = getHttp().post(`${apiPrefix}/start`, body);
|
||||
const actionType = jobIds.length > 1 ? UA_JOB_START_MANY : UA_JOB_START;
|
||||
const actionType = jobIds.length > 1 ? UIM_JOB_START_MANY : UIM_JOB_START;
|
||||
return await trackUserRequest(request, actionType);
|
||||
}
|
||||
|
||||
export async function stopJobs(jobIds) {
|
||||
const body = { jobIds };
|
||||
const request = getHttp().post(`${apiPrefix}/stop`, body);
|
||||
const actionType = jobIds.length > 1 ? UA_JOB_STOP_MANY : UA_JOB_STOP;
|
||||
const actionType = jobIds.length > 1 ? UIM_JOB_STOP_MANY : UIM_JOB_STOP;
|
||||
return await trackUserRequest(request, actionType);
|
||||
}
|
||||
|
||||
export async function deleteJobs(jobIds) {
|
||||
const body = { jobIds };
|
||||
const request = getHttp().post(`${apiPrefix}/delete`, body);
|
||||
const actionType = jobIds.length > 1 ? UA_JOB_DELETE_MANY : UA_JOB_DELETE;
|
||||
const actionType = jobIds.length > 1 ? UIM_JOB_DELETE_MANY : UIM_JOB_DELETE;
|
||||
return await trackUserRequest(request, actionType);
|
||||
}
|
||||
|
||||
export async function createJob(job) {
|
||||
const body = { job };
|
||||
const request = getHttp().put(`${apiPrefix}/create`, body);
|
||||
return await trackUserRequest(request, UA_JOB_CREATE);
|
||||
return await trackUserRequest(request, UIM_JOB_CREATE);
|
||||
}
|
||||
|
||||
export async function validateIndexPattern(indexPattern) {
|
||||
|
|
|
@ -94,5 +94,5 @@ export {
|
|||
} from './sort_table';
|
||||
|
||||
export {
|
||||
trackUserAction,
|
||||
} from './track_user_action';
|
||||
trackUiMetric,
|
||||
} from './track_ui_metric';
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { createUserActionUri } from '../../../../../common/user_action';
|
||||
import { UA_APP_NAME } from '../../../common';
|
||||
import { createUiMetricUri } from '../../../../../common/ui_metric';
|
||||
import { UIM_APP_NAME } from '../../../common';
|
||||
import { getHttp } from './http_provider';
|
||||
|
||||
export function trackUserAction(actionType) {
|
||||
const userActionUri = createUserActionUri(UA_APP_NAME, actionType);
|
||||
getHttp().post(userActionUri);
|
||||
export function trackUiMetric(actionType) {
|
||||
const uiMetricUri = createUiMetricUri(UIM_APP_NAME, actionType);
|
||||
getHttp().post(uiMetricUri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ export function trackUserAction(actionType) {
|
|||
export function trackUserRequest(request, actionType) {
|
||||
// Only track successful actions.
|
||||
return request.then(response => {
|
||||
trackUserAction(actionType);
|
||||
trackUiMetric(actionType);
|
||||
// We return the response immediately without waiting for the tracking request to resolve,
|
||||
// to avoid adding additional latency.
|
||||
return response;
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
import { get } from 'lodash';
|
||||
import { fetchUserActions } from '../../../../server/lib/user_action';
|
||||
import { UA_APP_NAME, USER_ACTIONS } from '../../common';
|
||||
import { fetchUiMetrics } from '../../../../server/lib/ui_metric';
|
||||
import { UIM_APP_NAME, USER_ACTIONS } from '../../common';
|
||||
|
||||
const ROLLUP_USAGE_TYPE = 'rollups';
|
||||
|
||||
|
@ -182,7 +182,7 @@ export function registerRollupUsageCollector(server) {
|
|||
rollupVisualizationsFromSavedSearches,
|
||||
} = await fetchRollupVisualizations(kibanaIndex, callCluster, rollupIndexPatternToFlagMap, rollupSavedSearchesToFlagMap);
|
||||
|
||||
const userActions = await fetchUserActions(server, UA_APP_NAME, USER_ACTIONS);
|
||||
const uiMetrics = await fetchUiMetrics(server, UIM_APP_NAME, USER_ACTIONS);
|
||||
|
||||
return {
|
||||
index_patterns: {
|
||||
|
@ -197,7 +197,7 @@ export function registerRollupUsageCollector(server) {
|
|||
total: rollupVisualizationsFromSavedSearches,
|
||||
},
|
||||
},
|
||||
user_actions: userActions,
|
||||
ui_metrics: uiMetrics,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
59
x-pack/server/lib/ui_metric/fetch_ui_metrics.ts
Normal file
59
x-pack/server/lib/ui_metric/fetch_ui_metrics.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { Server } from 'hapi';
|
||||
|
||||
export interface UiMetricRecord {
|
||||
metricType: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface UiMetricAndCountKeyValuePair {
|
||||
key: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
// This is a helper method for retrieving user interaction telemetry data stored via the OSS
|
||||
// ui_metric API.
|
||||
export function fetchUiMetrics(
|
||||
server: Server,
|
||||
appName: string,
|
||||
metricTypes: string[]
|
||||
): Promise<UiMetricAndCountKeyValuePair[]> {
|
||||
const { SavedObjectsClient, getSavedObjectsRepository } = server.savedObjects;
|
||||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');
|
||||
const internalRepository = getSavedObjectsRepository(callWithInternalUser);
|
||||
const savedObjectsClient = new SavedObjectsClient(internalRepository);
|
||||
|
||||
async function fetchUiMetric(metricType: string): Promise<UiMetricRecord | undefined> {
|
||||
try {
|
||||
const savedObjectId = `${appName}:${metricType}`;
|
||||
const savedObject = await savedObjectsClient.get('ui-metric', savedObjectId);
|
||||
return { metricType, count: savedObject.attributes.count };
|
||||
} catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all(metricTypes.map(fetchUiMetric)).then(
|
||||
(userActions): UiMetricAndCountKeyValuePair[] => {
|
||||
const userActionAndCountKeyValuePairs = userActions.reduce(
|
||||
(pairs: UiMetricAndCountKeyValuePair[], uiMetric: UiMetricRecord | undefined) => {
|
||||
// UI metric is undefined if nobody has performed this interaction on the client yet.
|
||||
if (uiMetric !== undefined) {
|
||||
const { metricType, count } = uiMetric;
|
||||
const pair: UiMetricAndCountKeyValuePair = { key: metricType, value: count };
|
||||
pairs.push(pair);
|
||||
}
|
||||
return pairs;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return userActionAndCountKeyValuePairs;
|
||||
}
|
||||
);
|
||||
}
|
|
@ -4,4 +4,4 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { fetchUserActions } from './fetch_user_actions';
|
||||
export { fetchUiMetrics } from './fetch_ui_metrics';
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { Server } from 'hapi';
|
||||
|
||||
export interface UserActionRecord {
|
||||
actionType: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface UserActionAndCountKeyValuePair {
|
||||
key: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
// This is a helper method for retrieving user action telemetry data stored via the OSS
|
||||
// user_action API.
|
||||
export function fetchUserActions(
|
||||
server: Server,
|
||||
appName: string,
|
||||
actionTypes: string[]
|
||||
): Promise<UserActionAndCountKeyValuePair[]> {
|
||||
const { SavedObjectsClient, getSavedObjectsRepository } = server.savedObjects;
|
||||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');
|
||||
const internalRepository = getSavedObjectsRepository(callWithInternalUser);
|
||||
const savedObjectsClient = new SavedObjectsClient(internalRepository);
|
||||
|
||||
async function fetchUserAction(actionType: string): Promise<UserActionRecord | undefined> {
|
||||
try {
|
||||
const savedObjectId = `${appName}:${actionType}`;
|
||||
const savedObject = await savedObjectsClient.get('user-action', savedObjectId);
|
||||
return { actionType, count: savedObject.attributes.count };
|
||||
} catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all(actionTypes.map(fetchUserAction)).then(
|
||||
(userActions): UserActionAndCountKeyValuePair[] => {
|
||||
const userActionAndCountKeyValuePairs = userActions.reduce(
|
||||
(pairs: UserActionAndCountKeyValuePair[], userAction: UserActionRecord | undefined) => {
|
||||
// User action is undefined if nobody has performed this action on the client yet.
|
||||
if (userAction !== undefined) {
|
||||
const { actionType, count } = userAction;
|
||||
const pair: UserActionAndCountKeyValuePair = { key: actionType, value: count };
|
||||
pairs.push(pair);
|
||||
}
|
||||
return pairs;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return userActionAndCountKeyValuePairs;
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue