OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
better logging for sdk auth
Carl-Gerhard Lindesvärd848561872630
diff --git a/apps/api/src/routes/event.router.ts b/apps/api/src/routes/event.router.tsindex c821eddfb..54343f65c 100644--- a/apps/api/src/routes/event.router.ts+++ b/apps/api/src/routes/event.router.ts@@ -17,7 +17,7 @@ const eventRouter: FastifyPluginCallback = (fastify, opts, done) => {) => {try {const projectId = await validateSdkRequest(req.headers).catch(- () => null+ req.log.error);if (!projectId) {return reply.status(401).send();diff --git a/apps/api/src/routes/profile.router.ts b/apps/api/src/routes/profile.router.tsindex d1951e67d..2ad932f19 100644--- a/apps/api/src/routes/profile.router.ts+++ b/apps/api/src/routes/profile.router.ts@@ -6,7 +6,9 @@ import type { FastifyPluginCallback } from 'fastify';const eventRouter: FastifyPluginCallback = (fastify, opts, done) => {fastify.addHook('preHandler', async (req, reply) => {try {- const projectId = await validateSdkRequest(req.headers).catch(() => null);+ const projectId = await validateSdkRequest(req.headers).catch(+ req.log.error+ );if (!projectId) {return reply.status(401).send();}diff --git a/apps/api/src/utils/auth.ts b/apps/api/src/utils/auth.tsindex 58f135b08..0f99786d0 100644--- a/apps/api/src/utils/auth.ts+++ b/apps/api/src/utils/auth.ts@@ -23,11 +23,6 @@ export async function validateSdkRequest(const clientSecret = clientSecretNew || clientSecretOld;const origin = headers.origin;- // Temp log- logger.info(- { clientId, origin: origin ? origin : 'empty' },- 'validateSdkRequest'- );if (!clientId) {throw new Error('Ingestion: Missing client id');@@ -69,7 +64,12 @@ export async function validateSdkRequest(}}- throw new Error('Ingestion: Invalid client secret');+ logger.error({+ client,+ headers,+ origin,+ });+ throw new Error('Ingestion: Invalid cors or secret');}export async function validateExportRequest(