fix: harden analytics writes and hide internal server errors from client
This commit is contained in:
1 parent
770b4d59d2
commit
129681ebd7
15 files changed
+217
-128
No files matched your search
+12
-1
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user