Merged in chore/upgrade-sentry (pull request #3191)
feat: upgrade sentry and use metrics * feat: upgrade sentry and use metrics * remove ununsed deps * rename span * . Approved-by: Linus Flood
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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 })
|
||||
}
|
||||
Reference in New Issue
Block a user