Send a track event when analytics settings are saved.
This commit is contained in:
parent
1da8aba8e8
commit
280542255f
|
@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
|
||||||
import { Button } from '@wordpress/components';
|
import { Button } from '@wordpress/components';
|
||||||
import { Component, Fragment } from '@wordpress/element';
|
import { Component, Fragment } from '@wordpress/element';
|
||||||
import { compose } from '@wordpress/compose';
|
import { compose } from '@wordpress/compose';
|
||||||
import { remove } from 'lodash';
|
import { remove, transform } from 'lodash';
|
||||||
import { withDispatch } from '@wordpress/data';
|
import { withDispatch } from '@wordpress/data';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ import { analyticsSettings } from './config';
|
||||||
import Setting from './setting';
|
import Setting from './setting';
|
||||||
import HistoricalData from './historical-data';
|
import HistoricalData from './historical-data';
|
||||||
import withSelect from 'wc-api/with-select';
|
import withSelect from 'wc-api/with-select';
|
||||||
|
import { recordEvent } from 'lib/tracks';
|
||||||
|
|
||||||
const SETTINGS_FILTER = 'woocommerce_admin_analytics_settings';
|
const SETTINGS_FILTER = 'woocommerce_admin_analytics_settings';
|
||||||
|
|
||||||
|
@ -126,8 +127,18 @@ class Settings extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveChanges = () => {
|
saveChanges = () => {
|
||||||
|
const { settings } = this.state;
|
||||||
this.persistChanges( this.state );
|
this.persistChanges( this.state );
|
||||||
this.props.updateSettings( { wc_admin: this.state.settings } );
|
this.props.updateSettings( { wc_admin: settings } );
|
||||||
|
|
||||||
|
const eventProps = transform(
|
||||||
|
analyticsSettings,
|
||||||
|
( props, setting ) => {
|
||||||
|
props[ setting.name ] = settings[ setting.name ];
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
recordEvent( 'analytics_settings_save', eventProps );
|
||||||
|
|
||||||
// TODO: remove this optimistic set of isDirty to false once #2541 is resolved.
|
// TODO: remove this optimistic set of isDirty to false once #2541 is resolved.
|
||||||
this.setState( { saving: true, isDirty: false } );
|
this.setState( { saving: true, isDirty: false } );
|
||||||
|
|
Loading…
Reference in New Issue