Skip to content

Commit

Permalink
EPMRPP-82207 || Code review fixes - 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzmitry Kosarau authored and Dzmitry Kosarau committed Nov 10, 2023
1 parent 4f2b4dc commit 7ea965e
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 209 deletions.
14 changes: 0 additions & 14 deletions app/src/components/main/analytics/events/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

import { ENTER_KEY_CODE } from 'common/constants/keyCodes';

// conditions should look like 'statistics$defects$product_bug$pb001'
export const getDefectTypeLabel = (condition) => {
try {
Expand Down Expand Up @@ -44,15 +42,3 @@ export const getIncludedData = ({ includeData, includeComments, includeLogs }) =
.filter((key) => analyticsDataMap[key])
.join('#');
};

export const handleExternalLinkClick = (trackEvent, event) => ({ target: { tagName } }) => {
if (tagName === 'A') {
trackEvent(event);
}
};

export const handleExternalLinkKeyDown = (trackEvent, event) => ({ keyCode }) => {
if (keyCode === ENTER_KEY_CODE) {
trackEvent(event);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const DEFECT_TYPES = 'defect_types';
const INTEGRATIONS = 'integrations';
const PATTERN_ANALYSIS = 'pattern_analysis';
const GENERAL = 'general';
const BASIC_EVENT_PARAMETERS = {
...getBasicClickEventParameters(PROJECT_SETTINGS),
element_name: 'button_submit',
};
const BASIC_EVENT_PARAMETERS_ANALYZER_TAB = getBasicClickEventParameters(PROJECT_SETTINGS);
const BASIC_EVENT_PARAMETERS_NOTIFICATIONS = {
...getBasicClickEventParameters(PROJECT_SETTINGS),
place: NOTIFICATIONS,
Expand Down Expand Up @@ -64,44 +61,48 @@ const getStatus = (status) => (status ? 'active' : 'disabled');
const getSwitcher = (switcher) => (switcher ? 'on' : 'off');

export const PROJECT_SETTINGS_ANALYZER_EVENTS = {
CLICK_SUBMIT_IN_INDEX_TAB: (number, status) => ({
...BASIC_EVENT_PARAMETERS,
clickSubmitInIndexTab: (number, status) => ({
...BASIC_EVENT_PARAMETERS_ANALYZER_TAB,
element_name: 'button_submit',
place: `${ANALYZER}_index_settings`,
number,
status: getStatus(status),
}),

CLICK_SUBMIT_IN_AUTO_ANALYZER_TAB: (number, status, condition) => ({
...BASIC_EVENT_PARAMETERS,
clickSubmitInAutoAnalyzerTab: (number, status, condition) => ({
...BASIC_EVENT_PARAMETERS_ANALYZER_TAB,
place: `${ANALYZER}_auto_analyzer`,
element_name: 'button_submit',
number,
status: getStatus(status),
condition: LAUNCH_ANALYZE_TYPES_TO_ANALYTICS_TITLES_MAP[condition],
}),

CLICK_SUBMIT_IN_SIMILAR_ITEMS_TAB: (number) => ({
...BASIC_EVENT_PARAMETERS,
clickSubmitInSimilarItemsTab: (number) => ({
...BASIC_EVENT_PARAMETERS_ANALYZER_TAB,
place: `${ANALYZER}_similar_items`,
element_name: 'button_submit',
number,
}),

CLICK_SUBMIT_IN_UNIQUE_ERRORS_TAB: (status, type) => ({
...BASIC_EVENT_PARAMETERS,
clickSubmitInUniqueErrorsTab: (status, type) => ({
...BASIC_EVENT_PARAMETERS_ANALYZER_TAB,
place: `${ANALYZER}_unique_errors`,
status: getStatus(status),
element_name: 'button_submit',
type: type ? 'exclude' : 'include',
}),

CLICK_LINK_DOCUMENTATION: (place) => ({
...BASIC_EVENT_PARAMETERS,
clickDocumentationLink: (place) => ({
...BASIC_EVENT_PARAMETERS_ANALYZER_TAB,
place: `${ANALYZER}_${place}`,
link_name: 'documentation',
}),
};

export const PROJECT_SETTINGS_DEMO_DATA_EVENTS = {
CLICK_GENERATE_DATA_IN_DEMO_DATA_TAB: {
...BASIC_EVENT_PARAMETERS,
...getBasicClickEventParameters(PROJECT_SETTINGS),
element_name: 'button_generate_demo_data',
place: 'demo_data',
},
Expand Down Expand Up @@ -129,7 +130,7 @@ export const PROJECT_SETTINGS_NOTIFICATIONS_EVENTS = {
switcher: getSwitcher(switcher),
}),

CLICK_LINK_DOCUMENTATION: (place) => ({
clickDocumentationLink: (place) => ({
...BASIC_EVENT_PARAMETERS_NOTIFICATIONS,
...(place && { place }),
link_name: 'documentation',
Expand Down Expand Up @@ -242,7 +243,7 @@ export const PROJECT_SETTINGS_PATTERN_ANALYSIS_EVENTS = {
element_name: 'pattern_name',
status: 'open',
},
CLICK_LINK_DOCUMENTATION: (place) => ({
clickDocumentationLink: (place) => ({
...BASIC_EVENT_PARAMETERS_PATTERN_ANALYSIS,
...(place && { place }),
link_name: 'documentation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { daysFromNow, createExternalLink } from 'common/utils';
import { GhostButton } from 'components/buttons/ghostButton';
import { docsReferences } from 'common/utils/referenceDictionary';
import { PROFILE_EVENTS } from 'analyticsEvents/profilePageEvent';
import { ENTER_KEY_CODE } from 'common/constants/keyCodes';
import styles from './apiKeysBlock.scss';

const cx = classNames.bind(styles);
Expand Down Expand Up @@ -79,22 +78,9 @@ export const ApiKeysBlock = ({ apiKeys }) => {
}
};

const onDocumentationKeyDown = (event) => {
const { keyCode } = event;
const { tagName } = event.target;

if (tagName === 'A' && keyCode === ENTER_KEY_CODE) {
trackEvent(PROFILE_EVENTS.CLICK_DOCUMENTATION_LINK_WITH_API_KEY);
}
};

return (
<>
<div
className={cx('description')}
onClick={onDocumentationClick}
onKeyDown={onDocumentationKeyDown}
>
<div className={cx('description')} onClick={onDocumentationClick}>
{Parser(
formatMessage(messages.description, {
a: (data) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@ import { bindMessageToValidator, validate } from 'common/utils/validation';
import { Dropdown } from 'componentLibrary/dropdown';
import { Checkbox } from 'componentLibrary/checkbox';
import { useTracking } from 'react-tracking';
import Parser from 'html-react-parser';
import { PROJECT_SETTINGS_ANALYZER_EVENTS } from 'analyticsEvents/projectSettingsPageEvents';
import { docsReferences, createExternalLink } from 'common/utils';
import {
handleExternalLinkClick,
handleExternalLinkKeyDown,
} from 'components/main/analytics/events/common/utils';
import { Layout } from '../../layout';
import { FieldElement, LabeledPreloader } from '../../elements';
import { FieldElement, LabeledPreloader, FormattedDescription } from '../../elements';
import { messages } from './messages';
import {
ALL_MESSAGES_SHOULD_MATCH,
Expand Down Expand Up @@ -104,7 +99,7 @@ const AutoAnalysis = ({
setPending(false);

trackEvent(
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_SUBMIT_IN_AUTO_ANALYZER_TAB(
PROJECT_SETTINGS_ANALYZER_EVENTS.clickSubmitInAutoAnalyzerTab(
data[MIN_SHOULD_MATCH],
data[ANALYZER_ENABLED],
data[ANALYZER_MODE],
Expand All @@ -114,7 +109,7 @@ const AutoAnalysis = ({
const numberOfLogLines = data[NUMBER_OF_LOG_LINES] === '-1' ? 'all' : data[NUMBER_OF_LOG_LINES];

trackEvent(
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_SUBMIT_IN_INDEX_TAB(
PROJECT_SETTINGS_ANALYZER_EVENTS.clickSubmitInIndexTab(
numberOfLogLines,
data[ALL_MESSAGES_SHOULD_MATCH],
),
Expand All @@ -125,19 +120,14 @@ const AutoAnalysis = ({

return (
<Layout
handleDescriptionClick={handleExternalLinkClick(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('auto_analyzer'),
)}
handleDescriptionKeyDown={handleExternalLinkKeyDown(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('auto_analyzer'),
)}
description={Parser(
formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.autoAnalysisDocs),
}),
)}
description={
<FormattedDescription
content={formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.autoAnalysisDocs),
})}
event={PROJECT_SETTINGS_ANALYZER_EVENTS.clickDocumentationLink('auto_analyzer')}
/>
}
>
<form onSubmit={handleSubmit(submitHandler)}>
<FieldElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,15 @@ import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import classNames from 'classnames/bind';
import { reduxForm } from 'redux-form';
import Parser from 'html-react-parser';
import { Button } from 'componentLibrary/button';
import { SETTINGS_PAGE_EVENTS } from 'components/main/analytics/events';
import { useTracking } from 'react-tracking';
import { showModalAction } from 'controllers/modal';
import { useDispatch } from 'react-redux';
import { docsReferences, createExternalLink } from 'common/utils';
import {
handleExternalLinkClick,
handleExternalLinkKeyDown,
} from 'components/main/analytics/events/common/utils';
import { PROJECT_SETTINGS_ANALYZER_EVENTS } from 'components/main/analytics/events/ga4Events/projectSettingsPageEvents';
import { PROJECT_SETTINGS_ANALYZER_EVENTS } from 'analyticsEvents/projectSettingsPageEvents';
import { Layout } from '../../layout';
import { LabeledPreloader } from '../../elements';
import { LabeledPreloader, FormattedDescription } from '../../elements';
import { messages } from './messages';
import styles from './indexSettings.scss';

Expand All @@ -57,19 +52,14 @@ const IndexSettings = ({ indexingRunning, analyzerUnavailableTitle, hasPermissio

return (
<Layout
handleDescriptionClick={handleExternalLinkClick(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('index_settings'),
)}
handleDescriptionKeyDown={handleExternalLinkKeyDown(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('index_settings'),
)}
description={Parser(
formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.indexSettingsDocs),
}),
)}
description={
<FormattedDescription
content={formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.indexSettingsDocs),
})}
event={PROJECT_SETTINGS_ANALYZER_EVENTS.clickDocumentationLink('index_settings')}
/>
}
>
<div className={cx('index-block')}>
<span className={cx('index-block-title')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { reduxForm } from 'redux-form';
import Parser from 'html-react-parser';
import { COMMON_LOCALE_KEYS } from 'common/constants/localization';
import { Button } from 'componentLibrary/button';
import { FieldNumber } from 'componentLibrary/fieldNumber';
Expand All @@ -27,12 +26,8 @@ import { bindMessageToValidator, validate } from 'common/utils/validation';
import { useTracking } from 'react-tracking';
import { PROJECT_SETTINGS_ANALYZER_EVENTS } from 'analyticsEvents/projectSettingsPageEvents';
import { docsReferences, createExternalLink } from 'common/utils';
import {
handleExternalLinkClick,
handleExternalLinkKeyDown,
} from 'components/main/analytics/events/common/utils';
import { Layout } from '../../layout';
import { LabeledPreloader, FieldElement } from '../../elements';
import { LabeledPreloader, FieldElement, FormattedDescription } from '../../elements';
import { messages } from './messages';
import { SEARCH_LOGS_MIN_SHOULD_MATCH } from '../constants';

Expand All @@ -59,7 +54,7 @@ const SimilarItems = ({
setPending(false);

trackEvent(
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_SUBMIT_IN_SIMILAR_ITEMS_TAB(
PROJECT_SETTINGS_ANALYZER_EVENTS.clickSubmitInSimilarItemsTab(
data[SEARCH_LOGS_MIN_SHOULD_MATCH],
),
);
Expand All @@ -69,19 +64,14 @@ const SimilarItems = ({

return (
<Layout
handleDescriptionClick={handleExternalLinkClick(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('similar_items'),
)}
handleDescriptionKeyDown={handleExternalLinkKeyDown(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('similar_items'),
)}
description={Parser(
formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.similarItemsDocs),
}),
)}
description={
<FormattedDescription
content={formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.similarItemsDocs),
})}
event={PROJECT_SETTINGS_ANALYZER_EVENTS.clickDocumentationLink('similar_items')}
/>
}
>
<form onSubmit={handleSubmit(submitHandler)}>
<FieldElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { reduxForm } from 'redux-form';
import Parser from 'html-react-parser';
import { COMMON_LOCALE_KEYS } from 'common/constants/localization';
import { Button } from 'componentLibrary/button';
import { Dropdown } from 'componentLibrary/dropdown';
import { Checkbox } from 'componentLibrary/checkbox';
import { useTracking } from 'react-tracking';
import { PROJECT_SETTINGS_ANALYZER_EVENTS } from 'analyticsEvents/projectSettingsPageEvents';
import { docsReferences, createExternalLink } from 'common/utils';
import {
handleExternalLinkClick,
handleExternalLinkKeyDown,
} from 'components/main/analytics/events/common/utils';
import { FieldElement, LabeledPreloader } from '../../elements';
import { FieldElement, LabeledPreloader, FormattedDescription } from '../../elements';
import { messages } from './messages';
import { UNIQUE_ERROR_ENABLED, UNIQUE_ERROR_REMOVE_NUMBERS } from '../constants';
import { formatFieldName } from '../utils';
Expand Down Expand Up @@ -77,7 +72,7 @@ const UniqueErrors = ({
const type = JSON.parse(preparedData[UNIQUE_ERROR_REMOVE_NUMBERS]);

trackEvent(
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_SUBMIT_IN_UNIQUE_ERRORS_TAB(
PROJECT_SETTINGS_ANALYZER_EVENTS.clickSubmitInUniqueErrorsTab(
preparedData[UNIQUE_ERROR_ENABLED],
type,
),
Expand All @@ -88,19 +83,14 @@ const UniqueErrors = ({

return (
<Layout
handleDescriptionClick={handleExternalLinkClick(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('unique_errors'),
)}
handleDescriptionKeyDown={handleExternalLinkKeyDown(
trackEvent,
PROJECT_SETTINGS_ANALYZER_EVENTS.CLICK_LINK_DOCUMENTATION('unique_errors'),
)}
description={Parser(
formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.uniqueErrorsDocs),
}),
)}
description={
<FormattedDescription
content={formatMessage(messages.tabDescription, {
a: (data) => createExternalLink(data, docsReferences.uniqueErrorsDocs),
})}
event={PROJECT_SETTINGS_ANALYZER_EVENTS.clickDocumentationLink('unique_errors')}
/>
}
>
<form onSubmit={handleSubmit(submitHandler)}>
<FieldElement
Expand Down
Loading

0 comments on commit 7ea965e

Please sign in to comment.