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

+12 -1
View File
@@ -1,4 +1,5 @@
import { DATA_TYPE, DATETIME_REGEX } from './constants';
import { DATA_TYPE, DATETIME_REGEX, FIELD_LENGTH } from './constants';
import { truncateString } from './format';
import type { DynamicDataType } from './types';
export interface KeyValueData {
@@ -49,6 +50,16 @@ export function getStringValue(value: string, dataType: number) {
return value;
}
export function getStoredStringValue(value: string, dataType: number) {
const stringValue = getStringValue(value, dataType);
if (dataType === DATA_TYPE.array && stringValue.length > FIELD_LENGTH.stringValue) {
return null;
}
return truncateString(stringValue, FIELD_LENGTH.stringValue);
}
export function createKeyValue(key: string, value: any): KeyValueData {
const type = getDataType(value);
let dataType: DynamicDataType;