Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

feature(lib): add event type filter

Alexander Klein2cab8bb15d4f
diff --git a/lib/filters.js b/lib/filters.js
index d48536185..8adeb13e2 100644
--- a/lib/filters.js
+++ b/lib/filters.js
@@ -113,6 +113,17 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
return Object.keys(map).map(key => ({ x: key, y: map[key], w: links[key] }));
};
+export const eventTypeFilter = (data, types) => {
+ if (!types || types.length === 0) {
+ return data;
+ }
+
+ return data.filter(({ x }) => {
+ const [event] = x.split('\t');
+ return types.some(type => type === event);
+ });
+};
+
export const browserFilter = data =>
data.map(({ x, y }) => ({ x: BROWSERS[x] || x, y })).filter(({ x }) => x);