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

feat: /health endpoint #1898

Merged
merged 8 commits into from
Jan 22, 2024
Merged

Conversation

ShubhamPalriwala
Copy link
Contributor

What does this PR do?

/health endpoint checks if the system is running as expected or not! Throws UI + status code (200 or not) accordingly.

Fixes #1840

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Copy link

vercel bot commented Jan 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Visit Preview Jan 22, 2024 7:35am
formbricks-com ⬜️ Ignored (Inspect) Visit Preview Jan 22, 2024 7:35am

@github-actions github-actions bot added the enhancement New feature or request label Jan 12, 2024
Copy link
Contributor

github-actions bot commented Jan 12, 2024

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

apps/web/app/health/error.tsx

React components re-render by default whenever their parent component re-renders, even if their props haven't changed. This can lead to unnecessary re-rendering and a performance hit. To avoid this, you can use React.memo to memoize your component. This will make it so your component only re-renders when its props change.
Create Issue
See the diff
Checkout the fix

    export default React.memo(Error);
git fetch origin && git checkout -b ReviewBot/Impro-yg7guhk origin/ReviewBot/Impro-yg7guhk

Comment on lines +5 to +13
export default function Error({ error }: { error: Error & { digest?: string } }) {
return (
<div className="mx-auto flex h-full max-w-xl flex-col items-center justify-center text-center">
<XCircleIcon height={40} color="red" />
<p className="text-md mt-4 font-bold text-zinc-900">Your Formbricks health is degraded</p>
<p className="text-sm text-zinc-900">{error.message}</p>
</div>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapped the Error component with React.memo to prevent unnecessary re-rendering when the props haven't changed, improving performance.

Suggested change
export default function Error({ error }: { error: Error & { digest?: string } }) {
return (
<div className="mx-auto flex h-full max-w-xl flex-col items-center justify-center text-center">
<XCircleIcon height={40} color="red" />
<p className="text-md mt-4 font-bold text-zinc-900">Your Formbricks health is degraded</p>
<p className="text-sm text-zinc-900">{error.message}</p>
</div>
);
}
export default React.memo(Error);

Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShubhamPalriwala thanks a lot for the quick turnaround. Looks great! 😊

@mattinannt mattinannt added this pull request to the merge queue Jan 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 12, 2024
@mattinannt mattinannt added this pull request to the merge queue Jan 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 12, 2024
@mattinannt
Copy link
Member

@ShubhamPalriwala unfortunately we are getting build errors in the pipeline. Can you please take a look :-)

@mattinannt mattinannt marked this pull request as draft January 15, 2024 13:50
@ShubhamPalriwala ShubhamPalriwala marked this pull request as ready for review January 22, 2024 07:48
@ShubhamPalriwala ShubhamPalriwala added this pull request to the merge queue Jan 22, 2024
Merged via the queue into main with commit bd256b9 Jan 22, 2024
12 checks passed
@ShubhamPalriwala ShubhamPalriwala deleted the shubham/for-1683-add-health-check-page branch January 22, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Status or Healthcheck Endpoint
2 participants