Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix: default to unknown user-agent

Carl-Gerhard Lindesvärde129a53ce5a3
diff --git a/apps/api/src/controllers/track.controller.ts b/apps/api/src/controllers/track.controller.ts
index 61887395d..2f6fbe7c7 100644
--- a/apps/api/src/controllers/track.controller.ts
+++ b/apps/api/src/controllers/track.controller.ts
@@ -125,7 +125,8 @@ async function buildContext(
validatedBody.type === 'track' && validatedBody.payload.properties?.__ip
? (validatedBody.payload.properties.__ip as string)
: request.clientIp;
- const ua = request.headers['user-agent'];
+ const ua = request.headers['user-agent'] ?? 'unknown/1.0';
+
const headers = getStringHeaders(request.headers);
const identity = getIdentity(validatedBody);