File size: 867 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import { set } from 'lodash';
import { ANALYTICS_EVENT_RECORD } from 'calypso/state/action-types';
import { getCurrentOAuth2ClientId } from 'calypso/state/oauth2-clients/ui/selectors';
import { withEnhancers } from 'calypso/state/utils';
import { recordTracksEvent, recordPageView } from './record';
const enhanceWithClientId = ( action, getState ) => {
const clientId = getCurrentOAuth2ClientId( getState() );
if ( clientId ) {
if ( action.type === ANALYTICS_EVENT_RECORD ) {
set( action, 'meta.analytics[0].payload.properties.client_id', clientId );
} else {
set( action, 'meta.analytics[0].payload.client_id', clientId );
}
}
return action;
};
export const recordTracksEventWithClientId = withEnhancers(
recordTracksEvent,
enhanceWithClientId
);
export const recordPageViewWithClientId = withEnhancers( recordPageView, enhanceWithClientId );
|