Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-87425 || Add events for Component health check widgets #3760

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +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 { getBasicClickEventParameters } from '../common/ga4Utils';

const DASHBOARDS = 'dashboards';
Expand All @@ -24,10 +30,17 @@ const modalNames = {
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,
type: widgetType[type],
status,
modal: modalNames[modalId],
element_name: EXCLUDE_SKIPPED_TESTS_FROM_STATISTICS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ export class ComponentHealthCheckControls extends Component {
);
};

handleExcludeSkipped = ({ target: { checked } }) => {
const {
eventsInfo: { excludeSkippedTests },
tracking: { trackEvent },
} = this.props;
const type = 'component_health_check';

trackEvent(excludeSkippedTests(type, checked));
};

render() {
const {
intl: { formatMessage },
Expand Down Expand Up @@ -199,11 +189,7 @@ export class ComponentHealthCheckControls extends Component {
)}
/>
</FieldProvider>
<FieldProvider
onChange={this.handleExcludeSkipped}
name="contentParameters.widgetOptions.excludeSkipped"
format={Boolean}
>
<FieldProvider name="contentParameters.widgetOptions.excludeSkipped" format={Boolean}>
<CheckboxControl fieldLabel=" " text={formatMessage(messages.excludeSkipped)} />
</FieldProvider>
<FieldProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,6 @@ export class ComponentHealthCheckTableViewControls extends Component {
);
};

handleExcludeSkipped = ({ target: { checked } }) => {
const {
eventsInfo: { excludeSkippedTests },
tracking: { trackEvent },
} = this.props;
const type = 'component_health_check_table_view';

trackEvent(excludeSkippedTests(type, checked));
};

render() {
const {
intl: { formatMessage },
Expand Down Expand Up @@ -245,11 +235,7 @@ export class ComponentHealthCheckTableViewControls extends Component {
)}
/>
</FieldProvider>
<FieldProvider
onChange={this.handleExcludeSkipped}
name="contentParameters.widgetOptions.excludeSkipped"
format={Boolean}
>
<FieldProvider name="contentParameters.widgetOptions.excludeSkipped" format={Boolean}>
<CheckboxControl fieldLabel=" " text={formatMessage(messages.excludeSkipped)} />
</FieldProvider>
<FieldProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ export class PassingRatePerLaunchControls extends Component {
});
}

handleExcludeSkippedChange = ({ target: { checked } }) => {
const {
eventsInfo: { excludeSkippedTests },
tracking: { trackEvent },
} = this.props;
const type = 'passing_rate_per_launch';

trackEvent(excludeSkippedTests(type, checked));
};

render() {
const {
intl: { formatMessage },
Expand Down Expand Up @@ -131,11 +121,7 @@ export class PassingRatePerLaunchControls extends Component {
)}
/>
</FieldProvider>
<FieldProvider
onChange={this.handleExcludeSkippedChange}
name="contentParameters.widgetOptions.excludeSkipped"
format={Boolean}
>
<FieldProvider name="contentParameters.widgetOptions.excludeSkipped" format={Boolean}>
<CheckboxControl fieldLabel=" " text={formatMessage(messages.excludeSkipped)} />
</FieldProvider>
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ export class PassingRateSummaryControls extends Component {
formatFilterValue = (value) => value?.[0];
parseFilterValue = (value) => value && [value];

handleExcludeSkippedChange = ({ target: { checked } }) => {
const {
eventsInfo: { excludeSkippedTests },
tracking: { trackEvent },
} = this.props;
const type = 'passing_rate_summary';

trackEvent(excludeSkippedTests(type, checked));
};

render() {
const {
intl: { formatMessage },
Expand Down Expand Up @@ -137,11 +127,7 @@ export class PassingRateSummaryControls extends Component {
)}
/>
</FieldProvider>
<FieldProvider
onChange={this.handleExcludeSkippedChange}
name="contentParameters.widgetOptions.excludeSkipped"
format={Boolean}
>
<FieldProvider name="contentParameters.widgetOptions.excludeSkipped" format={Boolean}>
<CheckboxControl fieldLabel=" " text={formatMessage(messages.excludeSkipped)} />
</FieldProvider>
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class EditWidgetModal extends Component {
eventsInfo: PropTypes.object,
}),
projectId: PropTypes.string,
eventsInfo: PropTypes.object,
tracking: PropTypes.shape({
trackEvent: PropTypes.func,
getTrackingData: PropTypes.func,
Expand All @@ -97,6 +98,7 @@ export class EditWidgetModal extends Component {
},
widgetSettings: {},
projectId: '',
eventsInfo: {},
};

constructor(props) {
Expand Down Expand Up @@ -133,18 +135,27 @@ export class EditWidgetModal extends Component {

onSave = (closeModal) => {
const {
data: { onConfirm, widget },
tracking: { trackEvent },
data: {
onConfirm,
widget,
eventsInfo: { excludeSkippedTests },
},
intl: { formatMessage },
widgetSettings,
projectId,
} = this.props;

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

const isForceUpdateNeeded =
!isEqual(widget.contentParameters, data.contentParameters) ||
!isEqual(widget.contentParameters, contentParameters) ||
!isEqual(
widget.appliedFilters.map((filter) => filter.id.toString()),
data.filterIds,
filterIds,
);

this.props.showScreenLockAction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,24 @@ export class WidgetWizardContent extends Component {
onAddWidget = (formData) => {
const {
tracking: { trackEvent },
eventsInfo: { addWidget },
eventsInfo: { excludeSkippedTests },
projectId,
onConfirm,
isAnalyticsEnabled,
baseEventParameters,
} = this.props;

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

trackEvent(addWidget);
this.props.showScreenLockAction();
fetch(URLS.widget(projectId), {
method: 'post',
Expand All @@ -178,9 +186,9 @@ export class WidgetWizardContent extends Component {
.then(({ id }) => {
const newWidget = {
widgetId: id,
widgetName: data.name,
widgetType: data.widgetType,
...getDefaultWidgetConfig(data.widgetType),
widgetName: name,
widgetType,
...getDefaultWidgetConfig(widgetType),
};
onConfirm(newWidget, this.props.closeModal, selectedDashboard);
if (isAnalyticsEnabled) {
Expand All @@ -192,7 +200,7 @@ export class WidgetWizardContent extends Component {
items: [
getEcWidget({
itemId: id,
itemName: widgetTypesMessages[data.widgetType].defaultMessage,
itemName: widgetTypesMessages[widgetType].defaultMessage,
itemVariant: this.props.currentPage,
itemListName: selectedDashboard.id,
}),
Expand Down
Loading