Skip to content

Commit

Permalink
Update telemetry events custom name (#16922)
Browse files Browse the repository at this point in the history
* add events

* add report, licence and filter events

* Update existing telemetry (#16868)

* updated NOTIFICATIONS telemetry

* add events

* add report, licence and filter events

* fix build errors

* updated configurations telemetry

---------

Co-authored-by: Ousmane Samba <[email protected]>

* updated inputs telemetry

* updated outputs telemetry

* updated indices telemetry

* updated logging telemetry

* add LUT events

* updated users telemetry

* add grok_patterns events

* updated roles telemetry

* updated authentication telemetry

* add sidecars events

* fix elint issues

* fix linter

* update configuration events

* main content packs telemetry events

* team telemetry events

* fix test

* fix eslint issues

* updated all remaining previous telemetry pattern events

* Finalized TelemetryEventType

* made sure tracking is fired before the promise is resolved

* fix review comments

* updated telemetry events

* add missing Security events

* fix build error

---------

Co-authored-by: Mohamed OULD HOCINE <[email protected]>
Co-authored-by: Mohamed Ould Hocine <[email protected]>
Co-authored-by: Laura <[email protected]>
  • Loading branch information
4 people authored Oct 25, 2023
1 parent ddcf519 commit 5df35ef
Show file tree
Hide file tree
Showing 57 changed files with 906 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ import { FormikFormGroup, ErrorAlert, Spinner } from 'components/common';
import SectionComponent from 'components/common/Section/SectionComponent';
import useHistory from 'routing/useHistory';
import type { HTTPHeaderAuthConfigJSON } from 'logic/authentication/HTTPHeaderAuthConfig';
import { getPathnameWithoutId } from 'util/URLUtils';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

const HTTPHeaderAuthConfigSection = () => {
const [submitError, setSubmitError] = useState<string | undefined>();
const [loadedConfig, setLoadedConfig] = useState<HTTPHeaderAuthConfig | undefined | void>();
const sectionTitle = 'Trusted Header Authentication';
const history = useHistory();

const { pathname } = useLocation();
const sendTelemetry = useSendTelemetry();

const _onSubmit = (data: HTTPHeaderAuthConfigJSON) => {
sendTelemetry('form_submit', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.CONFIG_UPDATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'authenticator-trustedheader',
app_action_value: 'config-update',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import { Select, InputDescription } from 'components/common';
import { Button } from 'components/bootstrap';
import type { HistoryFunction } from 'routing/useHistory';
import useHistory from 'routing/useHistory';
import { getPathnameWithoutId } from 'util/URLUtils';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

const ElementsContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -56,17 +59,18 @@ const BackendCreateSelect = () => {
const sortedAuthServices = authServices.sort((s1, s2) => defaultCompare(s1.displayName, s2.displayName));
const authServicesOptions = sortedAuthServices.map((service) => ({ label: service.displayName, value: service.name }));
const history = useHistory();
const { pathname } = useLocation();
const sendTelemetry = useSendTelemetry();

const onSubmit = useCallback((formState: FormState) => {
sendTelemetry('form_submit', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.SERVICE_CREATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'services',
app_action_value: 'create-service-form',
});

_onSubmit(history, formState);
}, [history, sendTelemetry]);
}, [history, pathname, sendTelemetry]);

return (
<Formik onSubmit={onSubmit} initialValues={{ authServiceType: undefined }}>
Expand All @@ -80,8 +84,8 @@ const BackendCreateSelect = () => {
<Select clearable={false}
inputProps={{ 'aria-label': 'Select a service' }}
onChange={(authService) => {
sendTelemetry('input_value_change', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.SERVICE_SELECTED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'services',
app_action_value: 'selectservice',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import { EnterprisePluginNotFound } from 'components/common';
import type Role from 'logic/roles/Role';
import { getEnterpriseGroupSyncPlugin } from 'util/AuthenticationService';
import type { WizardSubmitPayload } from 'logic/authentication/directoryServices/types';
import { getPathnameWithoutId } from 'util/URLUtils';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

import type { WizardFormValues } from './BackendWizardContext';

Expand All @@ -50,6 +53,7 @@ const GroupSyncStep = ({
help,
excludedFields,
}: Props) => {
const { pathname } = useLocation();
const sendTelemetry = useSendTelemetry();

const enterpriseGroupSyncPlugin = getEnterpriseGroupSyncPlugin();
Expand All @@ -66,8 +70,8 @@ const GroupSyncStep = ({
<ButtonToolbar className="pull-right">
<Button bsStyle="primary"
onClick={() => {
sendTelemetry('click', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.DIRECTORY_GROUP_SYNC_SAVE_CLICKED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'directory-service',
app_action_value: 'groupsync-save',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import { Formik, Form, Field } from 'formik';
import { validateField, formHasErrors } from 'util/FormsUtils';
import { FormikFormGroup, FormikInput, InputOptionalInfo as Opt } from 'components/common';
import { Input, Button, ButtonToolbar } from 'components/bootstrap';
import { getPathnameWithoutId } from 'util/URLUtils';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

import type { WizardFormValues } from './BackendWizardContext';
import BackendWizardContext from './BackendWizardContext';
Expand Down Expand Up @@ -93,7 +96,7 @@ const ServerConfigStep = ({ formRef, help = {}, onSubmit, onSubmitAll, submitAll
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { setStepsState, ...stepsState } = useContext(BackendWizardContext);
const { backendValidationErrors, authBackendMeta: { backendHasPassword } } = stepsState;

const { pathname } = useLocation();
const sendTelemetry = useSendTelemetry();

const _onTransportSecurityChange = (event, values, setFieldValue, onChange) => {
Expand All @@ -114,8 +117,8 @@ const ServerConfigStep = ({ formRef, help = {}, onSubmit, onSubmitAll, submitAll
};

const _onSubmitAll = (validateForm) => {
sendTelemetry('click', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.DIRECTORY_SERVER_CONFIG_SAVE_CLICKED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'directory-service',
app_action_value: 'server-configuration-save',
});
Expand Down Expand Up @@ -254,8 +257,8 @@ const ServerConfigStep = ({ formRef, help = {}, onSubmit, onSubmitAll, submitAll
<Button bsStyle="primary"
disabled={isSubmitting}
onClick={() => {
sendTelemetry('click', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.DIRECTORY_NEXT_USER_SYNC_CLICKED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'directory-service',
app_action_value: 'usersync-button',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import type Role from 'logic/roles/Role';
import { validateField, formHasErrors } from 'util/FormsUtils';
import { FormikFormGroup, Select, InputList } from 'components/common';
import { Alert, Button, ButtonToolbar, Row, Col, Panel, Input } from 'components/bootstrap';
import { getPathnameWithoutId } from 'util/URLUtils';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

import type { WizardFormValues } from './BackendWizardContext';
import BackendWizardContext from './BackendWizardContext';
Expand Down Expand Up @@ -71,12 +74,12 @@ const UserSyncStep = ({
const { setStepsState, ...stepsState } = useContext(BackendWizardContext);
const { backendValidationErrors } = stepsState;
const rolesOptions = roles.map((role) => ({ label: role.name, value: role.id })).toArray();

const { pathname } = useLocation();
const sendTelemetry = useSendTelemetry();

const _onSubmitAll = (validateForm) => {
sendTelemetry('click', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.DIRECTORY_USER_SYNC_SAVE_CLICKED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'directory-service',
app_action_value: 'usersync-save',
});
Expand Down Expand Up @@ -206,8 +209,8 @@ const UserSyncStep = ({
<Button bsStyle="success"
disabled={isSubmitting}
onClick={() => {
sendTelemetry('click', {
app_pathname: 'authentication',
sendTelemetry(TELEMETRY_EVENT_TYPE.AUTHENTICATION.DIRECTORY_NEXT_GROUP_SYNC_CLICKED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'directory-service',
app_action_value: 'groupsync-button',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { formatTrafficData } from 'util/TrafficUtils';
import { isPermitted } from 'util/PermissionsMixin';
import useCurrentUser from 'hooks/useCurrentUser';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

import TrafficGraph from './TrafficGraph';

Expand Down Expand Up @@ -108,7 +109,7 @@ const GraylogClusterTrafficGraph = () => {

setGraphDays(newDays);

sendTelemetry('input_value_change', {
sendTelemetry(TELEMETRY_EVENT_TYPE.SYSTEM_OVERVIEW_OUTGOING_TRAFFIC_DAYS_CHANGED, {
app_pathname: 'system-overview',
app_section: 'outgoing-traffic',
app_action_value: 'trafficgraph-days-button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import IfPermitted from 'components/common/IfPermitted';
import { isPermitted } from 'util/PermissionsMixin';
import generateId from 'logic/generateId';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

const URL_WHITELIST_CONFIG = 'org.graylog2.system.urlwhitelist.UrlWhitelist';

Expand Down Expand Up @@ -104,7 +105,7 @@ const URLWhiteListFormModal = ({ newUrlEntry, urlType, onUpdate }: Props) => {
event.stopPropagation();
}

sendTelemetry('form_submit', {
sendTelemetry(TELEMETRY_EVENT_TYPE.URLWHITELIST_CONFIGURATION_UPDATED, {
app_section: 'urlwhitelist',
app_action_value: 'configuration-update',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import styled from 'styled-components';
import { useState } from 'react';
import moment from 'moment';

import { qualifyUrl } from 'util/URLUtils';
import { qualifyUrl, getPathnameWithoutId } from 'util/URLUtils';
import fetch, { fetchPeriodically } from 'logic/rest/FetchProvider';
import type { DataNode } from 'preflight/types';
import UserNotification from 'util/UserNotification';
Expand All @@ -30,6 +30,8 @@ import { defaultCompare } from 'logic/DefaultCompare';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import DataNodeBadge from 'components/datanode/DataNodeBadge';
import { Badge } from 'preflight/components/common';
import useLocation from 'routing/useLocation';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

const StyledList = styled(ListGroup)`
max-width: fit-content;
Expand Down Expand Up @@ -98,6 +100,7 @@ const provisioningWording = {

const CertRenewalButton = ({ nodeId, status }: { nodeId: string, status: DataNode['status'] }) => {
const sendTelemetry = useSendTelemetry();
const { pathname } = useLocation();
const [isRenewing, setIsRenewing] = useState(false);
const {
buttonTitle,
Expand All @@ -111,8 +114,8 @@ const CertRenewalButton = ({ nodeId, status }: { nodeId: string, status: DataNod
const onCertificateRenewal = () => {
setIsRenewing(true);

sendTelemetry('form_submit', {
app_pathname: 'configurations',
sendTelemetry(TELEMETRY_EVENT_TYPE.CONFIGURATIONS.CERTIFICATE_RENEWAL_UPDATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'data-node',
app_action_value: telemetryAppSection,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import { ConfigurationType } from 'components/configurations/ConfigurationTypes'
import { IfPermitted, TimeUnitInput, Spinner } from 'components/common';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import Select from 'components/common/Select';
import useLocation from 'routing/useLocation';
import { getPathnameWithoutId } from 'util/URLUtils';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

type RenewalPolicy = {
mode: 'AUTOMATIC' | 'MANUAL',
Expand Down Expand Up @@ -115,6 +118,7 @@ const CertificateRenewalPolicyConfig = ({ className }: Props) => {
const { data: currentConfig, isLoading } = useQuery(queryKey, fetchCurrentConfig);

const sendTelemetry = useSendTelemetry();
const { pathname } = useLocation();
const queryClient = useQueryClient();

const { mutateAsync: updateConfig } = useMutation(handleSaveConfig, {
Expand Down Expand Up @@ -158,8 +162,8 @@ const CertificateRenewalPolicyConfig = ({ className }: Props) => {
};

const saveConfig = (values: FormConfig) => {
sendTelemetry('form_submit', {
app_pathname: 'configurations',
sendTelemetry(TELEMETRY_EVENT_TYPE.CONFIGURATIONS.CERTIFICATE_RENEWAL_POLICY_UPDATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'certificate-renewal-policy',
app_action_value: 'configuration-save',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import IndexMaintenanceStrategiesSummary from 'components/indices/IndexMaintenan
import IndexRetentionProvider from 'components/indices/contexts/IndexRetentionProvider';
import { TIME_BASED_SIZE_OPTIMIZING_ROTATION_STRATEGY } from 'stores/indices/IndicesStore';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { getPathnameWithoutId } from 'util/URLUtils';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

import FormikInput from '../common/FormikInput';

Expand Down Expand Up @@ -78,6 +81,7 @@ const IndexSetsDefaultsConfig = () => {
);

const sendTelemetry = useSendTelemetry();
const { pathname } = useLocation();

useEffect(() => {
ConfigurationsActions.list(ConfigurationType.INDEX_SETS_DEFAULTS_CONFIG).then(() => {
Expand Down Expand Up @@ -106,8 +110,8 @@ const IndexSetsDefaultsConfig = () => {
delete defaultIndexValues?.rotation_strategy;
delete defaultIndexValues?.retention_strategy;

sendTelemetry('form_submit', {
app_pathname: 'configurations',
sendTelemetry(TELEMETRY_EVENT_TYPE.CONFIGURATIONS.INDEX_SETS_UPDATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'index-default',
app_action_value: 'configuration-save',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import FormikInput from 'components/common/FormikInput';
import Spinner from 'components/common/Spinner';
import { InputDescription, ModalSubmit, IfPermitted } from 'components/common';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { getPathnameWithoutId } from 'util/URLUtils';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

const StyledDefList = styled.dl.attrs({ className: 'deflist' })(({ theme }) => css`
&&.deflist {
Expand All @@ -51,6 +54,7 @@ const PermissionsConfig = () => {
const configuration = useStore(ConfigurationsStore as Store<Record<string, any>>, (state) => state?.configuration);

const sendTelemetry = useSendTelemetry();
const { pathname } = useLocation();

useEffect(() => {
ConfigurationsActions.listPermissionsConfig(ConfigurationType.PERMISSIONS_CONFIG).then(() => {
Expand All @@ -59,8 +63,8 @@ const PermissionsConfig = () => {
}, [configuration]);

const saveConfig = (values: PermissionsConfigType) => {
sendTelemetry('form_submit', {
app_pathname: 'configurations',
sendTelemetry(TELEMETRY_EVENT_TYPE.CONFIGURATIONS.PERMISSIONS_UPDATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'permissions',
app_action_value: 'configuration-save',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import { onInitializingTimerange } from 'views/components/TimerangeForForm';
import useUserDateTime from 'hooks/useUserDateTime';
import type { DateTime, DateTimeFormats } from 'util/DateTime';
import { normalizeFromSearchBarForBackend } from 'views/logic/queries/NormalizeTimeRange';
import useLocation from 'routing/useLocation';
import { getPathnameWithoutId } from 'util/URLUtils';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

import TimeRangeOptionsForm from './TimeRangeOptionsForm';
import TimeRangeOptionsSummary from './TimeRangeOptionsSummary';
Expand Down Expand Up @@ -78,6 +81,7 @@ const SearchesConfig = () => {
const [defaultAutoRefreshOptionUpdate, setDefaultAutoRefreshOptionUpdate] = useState<string | undefined>(undefined);
const [timeRangePresetsUpdated, setTimeRangePresetsUpdated] = useState<Immutable.List<TimeRangePreset>>(undefined);
const sendTelemetry = useSendTelemetry();
const { pathname } = useLocation();

useEffect(() => {
ConfigurationsActions.list(ConfigurationType.SEARCHES_CLUSTER_CONFIG).then(() => {
Expand Down Expand Up @@ -152,8 +156,8 @@ const SearchesConfig = () => {
const saveConfig = () => {
const update = { ...formConfig };

sendTelemetry('form_submit', {
app_pathname: 'configurations',
sendTelemetry(TELEMETRY_EVENT_TYPE.CONFIGURATIONS.SEARCHES_UPDATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'search',
app_action_value: 'configuration-save',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import BootstrapModalForm from 'components/bootstrap/BootstrapModalForm';
import UrlWhiteListForm from 'components/configurations/UrlWhiteListForm';
import type { WhiteListConfig } from 'stores/configurations/ConfigurationsStore';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { getPathnameWithoutId } from 'util/URLUtils';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

const UrlWhiteListConfig = () => {
const [showConfigModal, setShowConfigModal] = useState(false);
Expand All @@ -38,6 +41,7 @@ const UrlWhiteListConfig = () => {
const [isValid, setIsValid] = useState(false);

const sendTelemetry = useSendTelemetry();
const { pathname } = useLocation();

useEffect(() => {
ConfigurationsActions.list(ConfigurationType.URL_WHITELIST_CONFIG).then(() => {
Expand Down Expand Up @@ -72,8 +76,8 @@ const UrlWhiteListConfig = () => {
};

const saveConfig = () => {
sendTelemetry('form_submit', {
app_pathname: 'configurations',
sendTelemetry(TELEMETRY_EVENT_TYPE.CONFIGURATIONS.URL_WHITE_LIST_UPDATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: 'urlwhitelist',
app_action_value: 'configuration-save',
});
Expand Down
Loading

0 comments on commit 5df35ef

Please sign in to comment.