Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix crash when non string metadata is sent

Blue Mouse8ac7b939e205
diff --git a/backend/apps/cloud/src/analytics/dto/events.dto.ts b/backend/apps/cloud/src/analytics/dto/events.dto.ts
index 02316253a..c8e837888 100644
--- a/backend/apps/cloud/src/analytics/dto/events.dto.ts
+++ b/backend/apps/cloud/src/analytics/dto/events.dto.ts
@@ -24,7 +24,9 @@ export class MetadataSizeLimit implements ValidatorConstraintInterface {
let totalSize = 0
for (let i = 0; i < keys.length; i++) {
- totalSize += keys[i].length + values[i].length
+ totalSize +=
+ keys[i].length +
+ (values[i] && typeof values[i] === 'string' ? values[i].length : 0)
if (totalSize > MAX_METADATA_VALUE_LENGTH) {
return false
}
diff --git a/backend/apps/community/src/analytics/dto/events.dto.ts b/backend/apps/community/src/analytics/dto/events.dto.ts
index 02316253a..c8e837888 100644
--- a/backend/apps/community/src/analytics/dto/events.dto.ts
+++ b/backend/apps/community/src/analytics/dto/events.dto.ts
@@ -24,7 +24,9 @@ export class MetadataSizeLimit implements ValidatorConstraintInterface {
let totalSize = 0
for (let i = 0; i < keys.length; i++) {
- totalSize += keys[i].length + values[i].length
+ totalSize +=
+ keys[i].length +
+ (values[i] && typeof values[i] === 'string' ? values[i].length : 0)
if (totalSize > MAX_METADATA_VALUE_LENGTH) {
return false
}