feat: upgrade sentry and use metrics * feat: upgrade sentry and use metrics * remove ununsed deps * rename span * . Approved-by: Linus Flood
30 lines
649 B
TypeScript
30 lines
649 B
TypeScript
import { flatten } from "flat"
|
|
|
|
export function flattenInput(
|
|
input: unknown
|
|
): Record<string, unknown> | undefined {
|
|
if (typeof input !== "object" || input === null) {
|
|
return undefined
|
|
}
|
|
|
|
const onlyPrimitives = Object.entries(input).reduce(
|
|
(acc, [key, value]) => {
|
|
if (
|
|
typeof value === "string" ||
|
|
typeof value === "number" ||
|
|
typeof value === "boolean"
|
|
) {
|
|
acc[key] = value
|
|
}
|
|
return acc
|
|
},
|
|
{} as Record<string, unknown>
|
|
)
|
|
|
|
if (onlyPrimitives && Object.keys(onlyPrimitives).length === 0) {
|
|
return undefined
|
|
}
|
|
|
|
return flatten({ input: onlyPrimitives })
|
|
}
|