TidyLinker.com
TypeScript
Pull Request Merged
PR #144 merged: fix: throttle Resend API + consent-gated Meta Pixel
Summary
Two unrelated weekend issues bundled (both small, both client-facing):
- Resend rate limit fixed. All bulk-sendable Mailables now share a Redis-backed
resend-apirate limiter (4/sec, leaving headroom under Resend's 5/sec cap). Cluster-wide enforcement across the 10 production Horizon workers, soemail:send-launch-announcement, admin bulk nudges, and concurrent transactional sends no longer tripToo many requests. Rate-limited jobs are released back to the queue with delay — no mail lost. - Meta (Facebook) Pixel installed, consent-gated. Loads only after the visitor accepts
marketingcookies via the existing consent banner. Pixel ID is wired throughVITE_FACEBOOK_PIXEL_ID; if unset the component is a no-op (so dev/local builds never load it). FiresPageViewon initial load and on every Inertia navigation.
To get visitors the updated marketing description (which now names Meta and the data flow) the consent storage key was bumped to cookie-consent-v2 — existing visitors will see the banner once more.
Required prod env change
Set in Coolify and redeploy (Vite injects at build time):
VITE_FACEBOOK_PIXEL_ID=1008517204941231
Until that's set + a fresh build ships, the Pixel is a no-op even for visitors who consent.
Test plan
-
php artisan test --compact tests/Feature/Mail— the new throttle test covers all 5 mailables and asserts the limiter is registered. - Existing
tests/Feature/SendLaunchAnnouncementTest.phpandtests/Feature/Admin/NudgeControllerTest.phpstill pass. - Manually: visit prod after deploy, confirm consent banner re-appears, refuse marketing → Pixel does not load (no
fbevents.jsrequest, no_fbpcookie). Accept marketing → Pixel loads and firesPageView. - Manually: trigger a bulk launch announcement / bulk nudge from admin and confirm Resend no longer logs
Too many requestsin Sentry.
Files
app/Providers/AppServiceProvider.php— registerresend-apirate limiter (4/sec)app/Mail/Concerns/ThrottlesResendApi.php— trait returning[new RateLimitedWithRedis('resend-api')]frommiddleware()app/Mail/{LaunchAnnouncement,OnboardingNudge,ProfileCompletionNudge,StripeSetupReminder,VerificationReminder}Mail.php— apply traittests/Feature/Mail/ThrottlesResendApiTest.php— wiring testsresources/js/components/meta-pixel.tsx— new client component, consent-gatedresources/js/components/cookie-consent-banner.tsx— bump storage key to v2, dispatchcookie-consent-changedevent on saveresources/js/components/cookie-preferences-modal.tsx— plain-English marketing description naming Meta and the data flowresources/js/app.tsx— render<MetaPixel />inside the consent provider.env.example— documentVITE_FACEBOOK_PIXEL_ID
+187
additions
-9
deletions
13
files changed