I’ve added this feature to quite a few of my vehicles over the years and it’s saved me quite a few times.  There are two variations of the circuit - this one for vehicles that apply power to the interior courtesy lights when the door is opened and another (not shown here) for vehicles that apply ground to the courtesy lights when the door is opened.  The circuit board is here.