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: rate limit per user per env sync user identification endpoint #2090

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

ShubhamPalriwala
Copy link
Member

What does this PR do?

Rate Limit Per User Per Environment to 5 per minute avoid spam sync calls from an end user~

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

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 Feb 16, 2024

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

Name Status Preview Comments Updated (UTC)
formbricks-cloud ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 16, 2024 11:23am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
formbricks-com ⬜️ Ignored (Inspect) Visit Preview Feb 16, 2024 11:23am

Copy link
Contributor

github-actions bot commented Feb 16, 2024

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

Copy link
Contributor

apps/web/middleware.ts

Consider using destructuring assignment when accessing properties of the request.nextUrl object. This will make the code more readable and easier to maintain.
Create Issue
See the diff
Checkout the fix

    const { pathname } = request.nextUrl;
    if (isWebAppRoute(pathname) && !token) {
      ...
    }
    if (loginRoute(pathname)) {
      ...
    }
    // and so on for the rest of the code
git fetch origin && git checkout -b ReviewBot/Impro-otmnd9u origin/ReviewBot/Impro-otmnd9u

Consider using template literals instead of the plus operator for string concatenation. This will make the code more readable and easier to understand.
Create Issue
See the diff
Checkout the fix

    await syncUserIdentificationLimiter.check(`${environmentId}-${userId}`);
git fetch origin && git checkout -b ReviewBot/Impro-bfwkiub origin/ReviewBot/Impro-bfwkiub

Co-authored-by: review-agent-prime[bot] <147289438+review-agent-prime[bot]@users.noreply.github.com>
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 thank you for adding this additional rate limiter 💪 I hope this makes it less likely that the user identification get's used in the wrong way 😊

@mattinannt mattinannt added this pull request to the merge queue Feb 19, 2024
Merged via the queue into main with commit 2425dc5 Feb 19, 2024
13 checks passed
@mattinannt mattinannt deleted the shubham/fix-debugging-random-issue branch February 19, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants