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.

Added connection logging.

Mike Caob355522569c8
diff --git a/src/pages/api/send.ts b/src/pages/api/send.ts
index 8e73463c3..e452a3e34 100644
--- a/src/pages/api/send.ts
+++ b/src/pages/api/send.ts
@@ -1,3 +1,4 @@
+/* eslint-disable no-console */
import { isbot } from 'isbot';
import { NextApiRequest, NextApiResponse } from 'next';
import {
@@ -85,6 +86,16 @@ const schema = {
export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
await useCors(req, res);
+ req.socket.on('close', () => {
+ console.log('Client closed connection');
+ });
+
+ const abortController = new AbortController();
+ req.on('close', () => {
+ console.log('Request closed');
+ abortController.abort();
+ });
+
if (req.method === 'POST') {
if (!process.env.DISABLE_BOT_CHECK && isbot(req.headers['user-agent'])) {
return ok(res, { beep: 'boop' });