Skip to content

Commit

Permalink
EPMRPP-92625 & EPMRPP-92629 || Remove extra GA events (#3912)
Browse files Browse the repository at this point in the history
* EPMRPP-92625 || Extra event is sent to GA when resizing a widget

* EPMRPP-92629 || Extra event is sent to GA when adding or editing widget

* EPMRPP-92629 || removed unused staff

* EPMRPP-92629 || removed commented part
  • Loading branch information
maria-hambardzumian authored Jul 11, 2024
1 parent ec5f4e6 commit aaf49fc
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ export const WIDGET_FIELD_EVENT_NAME_BY_TYPE = {
},
};

export const getJoinedFieldEventNamesByType = (type, keys) => {
if (!keys.length) {
return 'not_set';
}
export const getJoinedFieldEventNamesByType = (type, keys = []) => {
const uniqueValues = new Set();

const changedFields = WIDGET_FIELD_EVENT_NAME_BY_TYPE[type];
Expand All @@ -230,5 +227,5 @@ export const getJoinedFieldEventNamesByType = (type, keys) => {
}
});

return Array.from(uniqueValues).join('#');
return Array.from(uniqueValues).join('#') || 'not_set';
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,12 @@
* limitations under the License.
*/

import {
PASSING_RATE_PER_LAUNCH,
PASSING_RATE_SUMMARY,
COMPONENT_HEALTH_CHECK,
COMPONENT_HEALTH_CHECK_TABLE,
} from 'common/constants/widgetTypes';
import { getJoinedFieldEventNamesByType } from 'components/main/analytics/events/common/widgetPages/utils';
import { getBasicClickEventParameters } from '../common/ga4Utils';

const DASHBOARDS = 'dashboards';
const EXCLUDE_SKIPPED_TESTS_FROM_STATISTICS = 'exclude_skipped_tests_from_statistics';

const modalNames = {
editWidgetModal: 'edit_widget',
widgetWizardModal: 'add_widget',
};

const widgetType = {
[PASSING_RATE_PER_LAUNCH]: 'passing_rate_per_launch',
[PASSING_RATE_SUMMARY]: 'passing_rate_summary',
[COMPONENT_HEALTH_CHECK]: 'component_health_check',
[COMPONENT_HEALTH_CHECK_TABLE]: 'component_health_check_table_view',
};

export const WIDGETS_EVENTS = {
createClickExcludeSkippedTestsOnHealthCheck: (modalId) => (type, status) => ({
...getBasicClickEventParameters(DASHBOARDS),
type: widgetType[type],
status,
modal: modalNames[modalId],
element_name: EXCLUDE_SKIPPED_TESTS_FROM_STATISTICS,
}),
clickOnDeleteWidgetButton: (type, dashboardId) => ({
...getBasicClickEventParameters(DASHBOARDS),
element_name: 'delete',
Expand All @@ -66,6 +40,7 @@ export const WIDGETS_EVENTS = {
levelsCount,
modifiedFields,
isEditModal = false,
isExcludeSkippedTests = null,
}) => {
const actionType = isEditModal
? {
Expand All @@ -84,6 +59,7 @@ export const WIDGETS_EVENTS = {
link_name: isWidgetDescriptionChanged,
status: isWidgetNameChanged,
type,
...(isExcludeSkippedTests !== null && { place: isExcludeSkippedTests }),
...(levelsCount && { switcher: levelsCount }),
...actionType,
};
Expand Down
3 changes: 1 addition & 2 deletions app/src/pages/inside/dashboardItemPage/dashboardItemPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { DASHBOARD_PAGE_EVENTS } from 'components/main/analytics/events';
import { DashboardPageHeader } from 'pages/inside/common/dashboardPageHeader';
import AddWidgetIcon from 'common/img/add-widget-inline.svg';
import ExportIcon from 'common/img/export-inline.svg';
import { WIDGETS_EVENTS, DASHBOARD_EVENTS } from 'analyticsEvents/dashboardsPageEvents';
import { DASHBOARD_EVENTS } from 'analyticsEvents/dashboardsPageEvents';
import { getUpdatedWidgetsList } from './modals/common/utils';
import EditIcon from './img/edit-inline.svg';
import CancelIcon from './img/cancel-inline.svg';
Expand Down Expand Up @@ -300,7 +300,6 @@ export class DashboardItemPage extends Component {
clickOnZoomWidgetArea: DASHBOARD_PAGE_EVENTS.CLICK_ZOOM_ADD_WIDGET_AREA,
selectCriteria: DASHBOARD_PAGE_EVENTS.SELECT_CRITERIA_ADD_NEW_WIDGET_MODAL,
selectToggleButtons: DASHBOARD_PAGE_EVENTS.SELECT_TOGGLE_BUTTONS_ADD_NEW_WIDGET_MODAL,
excludeSkippedTests: WIDGETS_EVENTS.createClickExcludeSkippedTestsOnHealthCheck(modalId),
},
},
});
Expand Down
8 changes: 8 additions & 0 deletions app/src/pages/inside/dashboardItemPage/modals/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ export const getCreatedWidgetLevelsCount = (widgetType, data) => {
} = data;
return widgetOptions.attributes?.length || widgetOptions.attributeKeys?.length || 1;
};

export const getIsExcludeSkipped = (widgetType, data) => {
if (![COMPONENT_HEALTH_CHECK, COMPONENT_HEALTH_CHECK_TABLE].includes(widgetType)) return null;
const {
contentParameters: { widgetOptions },
} = data;
return widgetOptions.excludeSkipped.toString();
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { EditWidgetInfoSection } from './editWidgetInfoSection';
import { WIDGET_WIZARD_FORM } from '../common/constants';
import {
getCreatedWidgetLevelsCount,
getIsExcludeSkipped,
getModifiedFieldsLabels,
prepareWidgetDataForSubmit,
} from '../common/utils';
Expand Down Expand Up @@ -146,11 +147,7 @@ export class EditWidgetModal extends Component {
onSave = (closeModal) => {
const {
tracking: { trackEvent },
data: {
onConfirm,
widget,
eventsInfo: { excludeSkippedTests },
},
data: { onConfirm, widget },
intl: { formatMessage },
widgetSettings,
projectId,
Expand All @@ -160,8 +157,6 @@ export class EditWidgetModal extends Component {

const data = prepareWidgetDataForSubmit(this.preprocessOutputData(widgetSettings));
const { widgetType, contentParameters, filterIds } = data;
const { excludeSkipped } = contentParameters.widgetOptions;
trackEvent(excludeSkippedTests(widgetType, excludeSkipped));

const isForceUpdateNeeded =
!isEqual(widget.contentParameters, contentParameters) ||
Expand Down Expand Up @@ -189,6 +184,7 @@ export class EditWidgetModal extends Component {
isWidgetDescriptionChanged:
data?.description !== initiallyFilledWidgetSettings?.description,
levelsCount: getCreatedWidgetLevelsCount(widgetType, data),
isExcludeSkippedTests: getIsExcludeSkipped(widgetType, data),
isEditModal: true,
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
getModifiedFieldsLabels,
prepareWidgetDataForSubmit,
getDefaultWidgetConfig,
getIsExcludeSkipped,
} from '../../common/utils';
import { WizardInfoSection } from './wizardInfoSection';
import { WizardControlsSection } from './wizardControlsSection';
Expand Down Expand Up @@ -168,7 +169,6 @@ export class WidgetWizardContent extends Component {
onAddWidget = (formData) => {
const {
tracking: { trackEvent },
eventsInfo: { excludeSkippedTests },
projectId,
onConfirm,
initialFormValues,
Expand All @@ -179,14 +179,7 @@ export class WidgetWizardContent extends Component {

const { selectedDashboard, ...rest } = formData;
const data = prepareWidgetDataForSubmit(this.preprocessOutputData(rest));
const {
widgetType,
name,
contentParameters: {
widgetOptions: { excludeSkipped },
},
} = data;
trackEvent(excludeSkippedTests(widgetType, excludeSkipped));
const { widgetType, name } = data;

this.props.showScreenLockAction();
fetch(URLS.widget(projectId), {
Expand All @@ -213,6 +206,7 @@ export class WidgetWizardContent extends Component {
isWidgetNameChanged: name !== initialFormValues?.name,
isWidgetDescriptionChanged: data?.description !== initialFormValues?.description,
levelsCount: getCreatedWidgetLevelsCount(widgetType, data),
isExcludeSkippedTests: getIsExcludeSkipped(widgetType, data),
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ export class SimpleWidget extends Component {
clickOnZoomWidgetArea: DASHBOARD_PAGE_EVENTS.CLICK_ZOOM_EDIT_WIDGET_AREA,
selectCriteria: DASHBOARD_PAGE_EVENTS.SELECT_CRITERIA_EDIT_WIDGET_MODAL,
selectToggleButtons: DASHBOARD_PAGE_EVENTS.SELECT_TOGGLE_BUTTONS_EDIT_WIDGET_MODAL,
excludeSkippedTests: WIDGETS_EVENTS.createClickExcludeSkippedTestsOnHealthCheck(modalId),
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export class WidgetsGrid extends Component {
};

onGridItemChange = (newLayout, oldWidgetPosition, newWidgetPosition) => {
this.props.tracking.trackEvent(WIDGETS_EVENTS.ON_DRAG_WIDGET);
let newWidgets;
const itemChanged = Object.keys(oldWidgetPosition).some(
(prop) => oldWidgetPosition[prop] !== newWidgetPosition[prop],
Expand Down Expand Up @@ -127,6 +126,11 @@ export class WidgetsGrid extends Component {
}
};

onDragStop = (newLayout, oldWidgetPosition, newWidgetPosition) => {
this.props.tracking.trackEvent(WIDGETS_EVENTS.ON_DRAG_WIDGET);
this.onGridItemChange(newLayout, oldWidgetPosition, newWidgetPosition);
};

onResizeStart = (layout, oldItem) => {
const widgets = this.props.dashboard.widgets;
const targetWidget = widgets.find((widget) => +widget.widgetId === +oldItem.i);
Expand Down Expand Up @@ -234,7 +238,7 @@ export class WidgetsGrid extends Component {
rowHeight={rowHeight}
breakpoints={breakpoints}
onBreakpointChange={this.onBreakpointChange}
onDragStop={this.onGridItemChange}
onDragStop={this.onDragStop}
onResizeStart={this.onResizeStart}
onResizeStop={this.onResizeStop}
cols={cols}
Expand Down

0 comments on commit aaf49fc

Please sign in to comment.