Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: helpful JS providing non string types #21130

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IconFeatures } from '@posthog/icons'
import { LemonButton, LemonTable, LemonTabs } from '@posthog/lemon-ui'
import { captureException } from '@sentry/react'
import { useActions, useValues } from 'kea'
import { JSONViewer } from 'lib/components/JSONViewer'
import { Sparkline } from 'lib/lemon-ui/Sparkline'
Expand Down Expand Up @@ -162,5 +163,20 @@ function parseTitle(error: string): string {
input = error
}

return input?.split('\n')[0].trim().substring(0, MAX_TITLE_LENGTH) || error
if (!input) {
return error
}

try {
// TRICKY - after json parsing we might not have a string,
// since the JSON parser will helpfully convert to other types too e.g. have seen objects here
if (typeof input !== 'string') {
input = JSON.stringify(input)
}

return input.split('\n')[0].trim().substring(0, MAX_TITLE_LENGTH) || error
} catch (e) {
captureException(e, { extra: { error }, tags: { feature: 'replay/error-clustering' } })
return error
}
}
Loading