Gather browser info for every session not just users

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.

Last Updated: 2024-11-23

For debugging and other purposes, it can be helpful to store browser/device info for EVERY session (not just users who that have accounts with a website.)

I received two emails this week about a PDF preview feature on my site being broken.

Unfortunately, I had no way to knowing their browser. Ideally, my customer service email would grab that data and show it to me. But I only grab this information upon creation of a user object.

As an alternative, I could create an anonymous user object based on a permanent cookie and then use this for debugging purposes (perhaps keeping around and stitching to user account when later created).

Lesson

It can be worthwhile to track browser information and usage patterns of anonymous sessions on your website. This leads to better debugging and also richer user data (e.g. when stitching together previous data with eventual user account creation, you know what content they liked already)