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 #3757

Merged
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 @@ -17,12 +17,13 @@
import { normalizeEventString } from '../../utils';
import { getBasicClickEventParameters } from '../common/ga4Utils';

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

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

const getBasicEventTypeConfig = (type) => ({
Expand All @@ -37,6 +38,14 @@ export const WIDGETS_EVENTS = {
modal: modalNames[modalId],
element_name: RATIO_BASED_ON,
}),

createClickExcludeSkippedTestsOnHealthCheck: (modalId) => (type, status) => ({
...getBasicEventTypeConfig(type),
type,
status,
modal: modalNames[modalId],
element_name: EXCLUDE_SKIPPED_TESTS_FROM_STATISTICS,
}),
};

export const DASHBOARD_EVENTS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export class DashboardItemPage extends Component {
ratioBasedOnChange: WIDGETS_EVENTS.createClickOnRatioBasedOptionInPassingRateCharts(
modalId,
),
excludeSkippedTests: WIDGETS_EVENTS.createClickExcludeSkippedTestsOnHealthCheck(modalId),
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import track from 'react-tracking';
import classNames from 'classnames/bind';
import { injectIntl, defineMessages } from 'react-intl';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -90,6 +91,7 @@ const attributeKeyValidator = (formatMessage) => (attributes) =>
@connect((state) => ({
activeProject: activeProjectSelector(state),
}))
@track()
@injectIntl
export class ComponentHealthCheckControls extends Component {
static propTypes = {
Expand All @@ -100,6 +102,9 @@ export class ComponentHealthCheckControls extends Component {
onFormAppearanceChange: PropTypes.func.isRequired,
activeProject: PropTypes.string.isRequired,
eventsInfo: PropTypes.object,
tracking: PropTypes.shape({
trackEvent: PropTypes.func,
}).isRequired,
};

static defaultProps = {
Expand Down Expand Up @@ -154,6 +159,16 @@ 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 @@ -184,7 +199,11 @@ export class ComponentHealthCheckControls extends Component {
)}
/>
</FieldProvider>
<FieldProvider name="contentParameters.widgetOptions.excludeSkipped" format={Boolean}>
<FieldProvider
onChange={this.handleExcludeSkipped}
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 @@ -16,6 +16,7 @@

import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import track from 'react-tracking';
import classNames from 'classnames/bind';
import { injectIntl, defineMessages } from 'react-intl';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -105,6 +106,7 @@ const attributeKeyValidator = (formatMessage) => (attributes) =>
@connect((state) => ({
activeProject: activeProjectSelector(state),
}))
@track()
@injectIntl
export class ComponentHealthCheckTableViewControls extends Component {
static propTypes = {
Expand All @@ -115,6 +117,9 @@ export class ComponentHealthCheckTableViewControls extends Component {
onFormAppearanceChange: PropTypes.func.isRequired,
activeProject: PropTypes.string.isRequired,
eventsInfo: PropTypes.object,
tracking: PropTypes.shape({
trackEvent: PropTypes.func,
}).isRequired,
};

static defaultProps = {
Expand Down Expand Up @@ -197,6 +202,16 @@ 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 @@ -230,7 +245,11 @@ export class ComponentHealthCheckTableViewControls extends Component {
)}
/>
</FieldProvider>
<FieldProvider name="contentParameters.widgetOptions.excludeSkipped" format={Boolean}>
<FieldProvider
onChange={this.handleExcludeSkipped}
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 @@ -329,6 +329,7 @@ export class SimpleWidget extends Component {
ratioBasedOnChange: WIDGETS_EVENTS.createClickOnRatioBasedOptionInPassingRateCharts(
modalId,
),
excludeSkippedTests: WIDGETS_EVENTS.createClickExcludeSkippedTestsOnHealthCheck(modalId),
},
},
});
Expand Down
Loading