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
Don't remove www from hostname.
Mike Cao16a2abaf2114
diff --git a/src/app/api/send/route.ts b/src/app/api/send/route.tsindex 2892eefde..21e8790eb 100644--- a/src/app/api/send/route.ts+++ b/src/app/api/send/route.ts@@ -10,30 +10,30 @@ import { secret, uuid, visitSalt } from '@/lib/crypto';import { COLLECTION_TYPE } from '@/lib/constants';import { createSession, saveEvent, saveSessionData } from '@/queries';+const schema = z.object({+ type: z.enum(['event', 'identify']),+ payload: z.object({+ website: z.string().uuid(),+ data: z.object({}).passthrough().optional(),+ hostname: z.string().max(100).optional(),+ language: z.string().max(35).optional(),+ referrer: z.string().optional(),+ screen: z.string().max(11).optional(),+ title: z.string().optional(),+ url: z.string().optional(),+ name: z.string().max(50).optional(),+ tag: z.string().max(50).optional(),+ ip: z.string().ip().optional(),+ userAgent: z.string().optional(),+ }),+});+export async function POST(request: Request) {// Bot checkif (!process.env.DISABLE_BOT_CHECK && isbot(request.headers.get('user-agent'))) {return json({ beep: 'boop' });}- const schema = z.object({- type: z.enum(['event', 'identify']),- payload: z.object({- website: z.string().uuid(),- data: z.object({}).passthrough().optional(),- hostname: z.string().max(100).optional(),- language: z.string().max(35).optional(),- referrer: z.string().optional(),- screen: z.string().max(11).optional(),- title: z.string().optional(),- url: z.string().optional(),- name: z.string().max(50).optional(),- tag: z.string().max(50).optional(),- ip: z.string().ip().optional(),- userAgent: z.string().optional(),- }),- });-const { body, error } = await parseRequest(request, schema, { skipAuth: true });if (error) {@@ -133,7 +133,7 @@ export async function POST(request: Request) {let urlPath = currentUrl.pathname;const urlQuery = currentUrl.search.substring(1);- const urlDomain = currentUrl.hostname.replace(/^www\./, '');+ const urlDomain = currentUrl.hostname;if (process.env.REMOVE_TRAILING_SLASH) {urlPath = urlPath.replace(/(.+)\/$/, '$1');@@ -150,7 +150,7 @@ export async function POST(request: Request) {referrerQuery = referrerUrl.search.substring(1);if (referrerUrl.hostname !== 'localhost') {- referrerDomain = referrerUrl.hostname.replace(/^www\./, '');+ referrerDomain = referrerUrl.hostname;}}