Skip to content

Commit

Permalink
Revert "fix(sidepanel): parse the stringified JSON from the `getFeatu…
Browse files Browse the repository at this point in the history
…reFlagPayload` response" (#25184)
  • Loading branch information
dmarticus authored Sep 24, 2024
1 parent 42cad37 commit d4c86a9
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,11 @@ export const sidePanelActivityLogic = kea<sidePanelActivityLogicType>([

let changelogNotification: ChangelogFlagPayload | null = null
const flagPayload = posthog.getFeatureFlagPayload('changelog-notification')
// `getFeatureFlagPayload` ostensibly returns a JsonType, but in practice it's a stringified JSON object,
// so we need to parse it before checking for the presence of the required fields.
if (typeof flagPayload === 'string') {
try {
const parsedPayload = JSON.parse(flagPayload)
if (parsedPayload.markdown && parsedPayload.notificationDate) {
changelogNotification = {
markdown: parsedPayload.markdown,
notificationDate: dayjs(parsedPayload.notificationDate),
} as ChangelogFlagPayload
}
} catch (e) {
console.error('Failed to parse changelog notification payload', e)
}
if (flagPayload) {
changelogNotification = {
markdown: flagPayload['markdown'],
notificationDate: dayjs(flagPayload['notificationDate']),
} as ChangelogFlagPayload
}

if (changelogNotification) {
Expand All @@ -237,8 +228,9 @@ export const sidePanelActivityLogic = kea<sidePanelActivityLogicType>([
return 1
} else if (a.created_at.isAfter(b.created_at)) {
return -1
} else {
return 0
}
return 0
})
return notifications
}
Expand Down

0 comments on commit d4c86a9

Please sign in to comment.