The easiest would be to wrap the function’s implementation in try-catch - incognito mode can be variously cursed, from localStorage
existing but doing nothing (write something, read it back, and get nothing) to exceptions being thrown when trying to access it