Send a track event when analytics settings are saved.

This commit is contained in:
Jeff Stieler 2019-07-11 12:16:20 -06:00
parent 1da8aba8e8
commit 280542255f
1 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { Component, Fragment } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { remove } from 'lodash';
import { remove, transform } from 'lodash';
import { withDispatch } from '@wordpress/data';
/**
@ -22,6 +22,7 @@ import { analyticsSettings } from './config';
import Setting from './setting';
import HistoricalData from './historical-data';
import withSelect from 'wc-api/with-select';
import { recordEvent } from 'lib/tracks';
const SETTINGS_FILTER = 'woocommerce_admin_analytics_settings';
@ -126,8 +127,18 @@ class Settings extends Component {
}
saveChanges = () => {
const { settings } = 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.
this.setState( { saving: true, isDirty: false } );