fix: harden analytics writes and hide internal server errors from client

This commit is contained in:
Francis Cao committed 2026-06-22 22:07:07 -07:00
1 parent 770b4d59d2
commit 129681ebd7
15 files changed
+217 -128

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import { describe, expect, test } from 'vitest';
import { DATA_TYPE, FIELD_LENGTH } from './constants';
import { getStoredStringValue } from './data';
describe('getStoredStringValue', () => {
test('truncates oversized string values to the storage limit', () => {
expect(getStoredStringValue('x'.repeat(FIELD_LENGTH.stringValue + 25), DATA_TYPE.string)).toHaveLength(
FIELD_LENGTH.stringValue,
);
});
test('drops oversized array payloads instead of storing invalid truncated JSON', () => {
const oversizedArray = JSON.stringify([`x${'y'.repeat(FIELD_LENGTH.stringValue)}`]);
expect(getStoredStringValue(oversizedArray, DATA_TYPE.array)).toBeNull();
});
});