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.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Added option to remove trailing slash from urls.
Mike Cao6a8de2aeec05
diff --git a/pages/api/collect.js b/pages/api/collect.jsindex 41c9cabb7..2f0017585 100644--- a/pages/api/collect.js+++ b/pages/api/collect.js@@ -5,6 +5,7 @@ import { useCors, useSession } from 'lib/middleware';import { getIpAddress } from 'lib/request';import { ok, badRequest } from 'lib/response';import { createToken } from 'lib/crypto';+import { removeTrailingSlash } from 'lib/url';export default async (req, res) => {await useCors(req, res);@@ -37,18 +38,20 @@ export default async (req, res) => {await useSession(req, res);- const { type, payload } = req.body;const {+ body: { type, payload },session: { website_id, session_id },} = req;- if (type === 'pageview') {- const { url, referrer } = payload;+ let { url, referrer, event_type, event_value } = payload;++ if (process.env.REMOVE_TRAILING_SLASH) {+ url = removeTrailingSlash(url);+ }+ if (type === 'pageview') {await savePageView(website_id, session_id, url, referrer);} else if (type === 'event') {- const { url, event_type, event_value } = payload;-await saveEvent(website_id, session_id, url, event_type, event_value);} else {return badRequest(res);diff --git a/tracker/index.js b/tracker/index.jsindex 97976ec0a..38475a56f 100644--- a/tracker/index.js+++ b/tracker/index.js@@ -1,5 +1,5 @@-import { doNotTrack, hook } from '../lib/web';-import { removeTrailingSlash } from '../lib/url';+import { doNotTrack, hook } from 'lib/web';+import { removeTrailingSlash } from 'lib/url';(window => {const {