Skip to content

Commit

Permalink
Track filters/search
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Oct 12, 2021
1 parent e989a57 commit 94c1e71
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 78 deletions.
2 changes: 1 addition & 1 deletion locales/de.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locales/it.json

Large diffs are not rendered by default.

27 changes: 11 additions & 16 deletions src/components/manage/Blocks/FiltersBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
deleteQueryParam,
} from '@eeacms/volto-datablocks/actions';
import config from '@plone/volto/registry';
import { getEncodedQueryString, createEvent } from '~/utils';
import { getEncodedQueryString } from '~/utils';
import { trackSiteSearch } from '@eeacms/volto-matomo/utils';

import menuSVG from '@plone/volto/icons/menu-alt.svg';
import circlePlus from '@plone/volto/icons/circle-plus.svg';
Expand Down Expand Up @@ -152,11 +153,9 @@ const View = ({ content, ...props }) => {
'riverBasin',
'siteCountry',
];
createEvent('matomoTrackEvent', {
category: 'Filters',
action: 'Filters changed',
name: 'Map/Table filters',
value: JSON.stringify({
trackSiteSearch({
category: 'Map/Table filters',
keyword: JSON.stringify({
...Object.keys(props.discodata_query.search)
.filter(
(key) =>
Expand All @@ -178,18 +177,14 @@ const View = ({ content, ...props }) => {
) {
const { siteTerm, locationTerm } = props.discodata_query.search;
if (siteTerm) {
createEvent('matomoTrackEvent', {
category: 'Search',
action: 'Search by site term',
name: 'Map/Table search',
value: siteTerm,
trackSiteSearch({
category: 'Map/Table search by site term',
keyword: siteTerm,
});
} else if (locationTerm?.text) {
createEvent('matomoTrackEvent', {
category: 'Search',
action: 'Search by location',
name: 'Map/Table search',
value: locationTerm.text,
trackSiteSearch({
category: 'Map/Table search by location',
keyword: locationTerm.text,
});
}
}
Expand Down
12 changes: 0 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,3 @@ export const getEncodedString = (str) => {
}
return '';
};

export const createEvent = (type, detail) => {
let newEvent;
if (window.document.documentMode) {
// IE support event
newEvent = document.createEvent('CustomEvent');
newEvent.initCustomEvent(type, false, false, { detail });
} else {
newEvent = new CustomEvent(type, { detail });
}
document.dispatchEvent(newEvent);
};
48 changes: 0 additions & 48 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5928,13 +5928,6 @@ cubic-hermite@^1.0.0:
resolved "https://registry.yarnpkg.com/cubic-hermite/-/cubic-hermite-1.0.0.tgz#84e3b2f272b31454e8393b99bb6aed45168c14e5"
integrity sha1-hOOy8nKzFFToOTuZu2rtRRaMFOU=

cwise-compiler@^1.0.0, cwise-compiler@^1.1.2:
version "1.1.3"
resolved "https://registry.yarnpkg.com/cwise-compiler/-/cwise-compiler-1.1.3.tgz#f4d667410e850d3a313a7d2db7b1e505bb034cc5"
integrity sha1-9NZnQQ6FDToxOn0tt7HlBbsDTMU=
dependencies:
uniq "^1.0.0"

cyclist@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
Expand Down Expand Up @@ -8564,11 +8557,6 @@ functions-have-names@^1.2.2:
resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.2.tgz#98d93991c39da9361f8e50b337c4f6e41f120e21"
integrity sha512-bLgc3asbWdwPbx2mNk2S49kmJCuQeu0nfmaOgbs8WIyzzkw3r4htszdIi9Q9EMezDPTYuJx2wvjZ/EwgAthpnA==

gamma@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/gamma/-/gamma-0.1.0.tgz#3315643403bf27906ca80ab37c36ece9440ef330"
integrity sha1-MxVkNAO/J5BsqAqzfDbs6UQO8zA=

gauge@~2.7.3:
version "2.7.4"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
Expand Down Expand Up @@ -10321,11 +10309,6 @@ invert-kv@^2.0.0:
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02"
integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==

invert-permutation@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/invert-permutation/-/invert-permutation-1.0.0.tgz#a0a78042eadb36bc17551e787efd1439add54933"
integrity sha1-oKeAQurbNrwXVR54fv0UOa3VSTM=

iota-array@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/iota-array/-/iota-array-1.0.0.tgz#81ef57fe5d05814cd58c2483632a99c30a0e8087"
Expand Down Expand Up @@ -12520,13 +12503,6 @@ mapbox-to-css-font@^2.4.0:
resolved "https://registry.yarnpkg.com/mapbox-to-css-font/-/mapbox-to-css-font-2.4.0.tgz#a23b51664a1ee839beaefade013f2655bee9a390"
integrity sha512-v674D0WtpxCXlA6E+sBlG1QJWdUkz/s9qAD91bJSXBGuBL5lL4tJXpoJEftecphCh2SVQCjWMS2vhylc3AIQTg==

marching-simplex-table@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/marching-simplex-table/-/marching-simplex-table-1.0.0.tgz#bc16256e0f8f9b558aa9b2872f8832d9433f52ea"
integrity sha1-vBYlbg+Pm1WKqbKHL4gy2UM/Uuo=
dependencies:
convex-hull "^1.0.3"

mat4-decompose@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/mat4-decompose/-/mat4-decompose-1.0.4.tgz#65eb4fe39d70878f7a444eb4624d52f7e7eb2faf"
Expand Down Expand Up @@ -14243,21 +14219,6 @@ performant-array-to-tree@^1.7.1:
resolved "https://registry.yarnpkg.com/performant-array-to-tree/-/performant-array-to-tree-1.9.1.tgz#24897a56dedaa00c1f9c1a7e7ba92103008d1059"
integrity sha512-t+Hiy1HbKTVXg+mdcDUwPwAGgrLMtNUOhs2vV0M9MG2aAfnXQT9czAadksufMnf75h4xYU014HqlQ91JZ4XdlA==

permutation-parity@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/permutation-parity/-/permutation-parity-1.0.0.tgz#0174d51fca704b11b9a4b152b23d537fdc6b5ef4"
integrity sha1-AXTVH8pwSxG5pLFSsj1Tf9xrXvQ=
dependencies:
typedarray-pool "^1.0.0"

permutation-rank@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/permutation-rank/-/permutation-rank-1.0.0.tgz#9fd98bbcecf08fbf5994b5eadc94a62e679483b5"
integrity sha1-n9mLvOzwj79ZlLXq3JSmLmeUg7U=
dependencies:
invert-permutation "^1.0.0"
typedarray-pool "^1.0.0"

pick-by-alias@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/pick-by-alias/-/pick-by-alias-1.2.0.tgz#5f7cb2b1f21a6e1e884a0c87855aa4a37361107b"
Expand Down Expand Up @@ -19196,15 +19157,6 @@ traverse@0.6.6:
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137"
integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=

triangulate-hypercube@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/triangulate-hypercube/-/triangulate-hypercube-1.0.1.tgz#d8071db2ebfcfd51f308d0bcf2a5c48a5b36d137"
integrity sha1-2Acdsuv8/VHzCNC88qXEils20Tc=
dependencies:
gamma "^0.1.0"
permutation-parity "^1.0.0"
permutation-rank "^1.0.0"

triangulate-polyline@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/triangulate-polyline/-/triangulate-polyline-1.0.3.tgz#bf8ba877a85054103feb9fa5a61b4e8d7017814d"
Expand Down

0 comments on commit 94c1e71

Please sign in to comment.