OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
Testing self-hosting
Carl-Gerhard Lindesvärd7572d27f77a8
diff --git a/apps/api/src/controllers/event.controller.ts b/apps/api/src/controllers/event.controller.tsindex 749dee7a3..13e0b519e 100644--- a/apps/api/src/controllers/event.controller.ts+++ b/apps/api/src/controllers/event.controller.ts@@ -1,3 +1,4 @@+import { logger } from '@/utils/logger';import { getClientIp, parseIp } from '@/utils/parseIp';import type { FastifyReply, FastifyRequest } from 'fastify';@@ -12,6 +13,56 @@ export async function postEvent(}>,reply: FastifyReply) {+ if (process.env.TEST_SELF_HOSTING) {+ try {+ logger.info(+ {+ ['X-Forwarded-For']: request.headers['X-Forwarded-For'] as string,+ ['x-real-ip']: request.headers['x-real-ip'] as string,+ origin: request.headers.origin!,+ 'user-agent': request.headers['user-agent']!,+ 'Content-Type': 'application/json',+ 'openpanel-client-id': request.headers[+ 'openpanel-client-id'+ ] as string,+ 'openpanel-client-secret': request.headers[+ 'openpanel-client-secret'+ ] as string,+ 'mixan-client-id': request.headers['mixan-client-id'] as string,+ 'mixan-client-secret': request.headers[+ 'mixan-client-secret'+ ] as string,+ },+ 'Sending event to op.coderax.se'+ );+ // Test batching on a different service+ await fetch('https://op.coderax.se/api/event', {+ headers: {+ ['X-Forwarded-For']: request.headers['X-Forwarded-For'] as string,+ ['x-real-ip']: request.headers['x-real-ip'] as string,+ origin: request.headers.origin!,+ 'user-agent': request.headers['user-agent']!,+ 'Content-Type': 'application/json',+ 'openpanel-client-id': request.headers[+ 'openpanel-client-id'+ ] as string,+ 'openpanel-client-secret': request.headers[+ 'openpanel-client-secret'+ ] as string,+ 'mixan-client-id': request.headers['mixan-client-id'] as string,+ 'mixan-client-secret': request.headers[+ 'mixan-client-secret'+ ] as string,+ },+ method: 'POST',+ body: JSON.stringify(request.body),+ })+ .then((res) => res.json())+ .catch((res) => res);+ } catch (e) {+ logger.error(e);+ }+ }const ip = getClientIp(request)!;const ua = request.headers['user-agent']!;const origin = request.headers.origin!;