A Better Way to Track Exceptions

I use Bugsnag as my go-to solution for tracking exceptions across my application portfolio. It's reliable, intuitive, and gives me peace of mind knowing I'll catch those pesky bugs before they cause real trouble.

The Ad-Blocker Challenge

Here's the thing - ad-blockers have become increasingly aggressive, and they often block Bugsnag's tracking code when it's loaded directly on websites. To be honest, this creates a blind spot in your QA process, especially when testing with privacy-conscious users who tend to use ad-blockers.

The Solution: A Simple Proxy

The fix is surprisingly straightforward. By running a proxy on Vercel, we can forward events to Bugsnag without triggering ad-blockers. It's like having your own private messenger that ensures your error reports always reach their destination.

Getting Started

Setting up your proxy is a breeze. Just deploy the code to Vercel, and you're almost there. When initializing Bugsnag in your application, instead of using their default endpoint, point it to your new proxy's URL. Think of it as giving your bug reports a VIP entrance that bypasses the usual restrictions.

const BUGSNAG_AGENT_URL = 'https://bugs.yourdomain.com';

Bugsnag.start({
  apiKey: <BUGSNAG API KEY>,
  autoTrackSessions: false,
  logger: null,
  endpoints: {
    notify: BUGSNAG_AGENT_URL,
    sessions: BUGSNAG_AGENT_URL
  }
});

Bugsnag.startSession();

Customization Options

We all know that privacy regulations, especially in the EU, can be tricky to navigate. The good news is that you can easily modify the proxy code to handle sensitive data according to your needs. Want to strip IP addresses or remove geolocation data? Just tweak the code to match your requirements.

Ready to Roll

You can grab the complete code from my GitHub repository. The readme file contains everything you need to know about deployment and configuration. I've kept the implementation clean and simple, making it easy to understand and modify.

GitHub - azeitler/bugsnag-agent-vercel at planetfall.co
Bugsnag agent running on vercel cloud functions. Contribute to azeitler/bugsnag-agent-vercel development by creating an account on GitHub.

This solution has saved me countless headaches in my development process, ensuring that I never miss critical error reports due to ad-blockers. Give it a try - your future self will thank you for it.