Skip to content

Commit bd3a7e1

Browse files
authored
Merge pull request #3465 from Vizzuality/feature/new-analytics-events-for-widget-settings
Feature: GA events for widget settings menu
2 parents 48ac3fb + f207d05 commit bd3a7e1

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

app/javascript/components/widgets/actions.js

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as WIDGETS from './manifest';
99
export const setWidgetSettings = createAction('setWidgetSettings');
1010
export const setWidgetLoading = createAction('setWidgetLoading');
1111
export const setWidgetData = createAction('setWidgetData');
12+
export const settingsItemSelected = createAction('settingsItemSelected');
1213

1314
export const getWidgetData = createThunkAction(
1415
'getWidgetData',
@@ -23,6 +24,12 @@ export const getWidgetData = createThunkAction(
2324
export const setWidgetSettingsUrl = createThunkAction(
2425
'setWidgetSettingsUrl',
2526
({ value, widget }) => (dispatch, state) => {
27+
dispatch(
28+
settingsItemSelected({
29+
value,
30+
widget
31+
})
32+
);
2633
const { location } = state();
2734
let params = value;
2835
if (location.query && location.query[widget]) {
@@ -68,6 +75,7 @@ export const setWidgetSettingsStore = createThunkAction(
6875
export default {
6976
setWidgetSettingsUrl,
7077
setWidgetSettingsStore,
78+
settingsItemSelected,
7179
setWidgetData,
7280
getWidgetData,
7381
setWidgetLoading,

app/javascript/pages/dashboards/analytics.js

+12-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import shareActions from 'components/modals/share/share-actions';
22
import modalActions from 'components/modals/meta/meta-actions';
33
import buttonActions from 'components/ui/button/button-actions';
4+
import widgetActions from 'components/widgets/actions';
45
import { COUNTRY } from 'pages/dashboards/router';
5-
import isEqual from 'lodash/isEqual';
6-
import omit from 'lodash/omit';
76

8-
const allActions = { ...shareActions, ...buttonActions, ...modalActions };
7+
const allActions = {
8+
...shareActions,
9+
...buttonActions,
10+
...modalActions,
11+
...widgetActions
12+
};
913
const actions = Object.keys(allActions).reduce(
1014
(state, action) => ({
1115
...state,
@@ -76,24 +80,11 @@ export const ANALYTICS_EVENTS = [
7680
label: payload => payload.subtitle
7781
},
7882
{
79-
name: COUNTRY,
80-
category: 'Country Page',
81-
action: 'User changes widget settings',
82-
label: 'User changed settings',
83-
condition: payload => {
84-
const location = payload && payload.location;
85-
const current =
86-
location &&
87-
location.current &&
88-
location.current.query &&
89-
omit(location.current.query, ['widget', 'category']);
90-
const prev =
91-
location &&
92-
location.prev &&
93-
location.prev.query &&
94-
omit(location.prev.query, ['widget', 'category']);
95-
return current && prev && !isEqual(current, prev);
96-
}
83+
name: actions.settingsItemSelected,
84+
category: 'Country Widget Settings',
85+
action: payload => `Change ${Object.keys(payload.value)[0]}`,
86+
label: payload =>
87+
`${payload.value[Object.keys(payload.value)[0]]} | ${payload.widget}`
9788
},
9889
{
9990
name: actions.buttonClicked,

0 commit comments

Comments
 (0)