This is also useful as a level detector for colored liquids like oil. This has some immunity to ambient sunlight as it detects ac pulses.
This is a Hand Crafted PCB Artwork done by a PCB Vendor years back, this method may be used even today.
PCB Design -
This PCB would go into a 30mm Nickel Plated Brass threaded tube, with Epoxy or Teflon ends. These were turned components as quantities made were small. An Optical Proximity Sensor that would fit the same place as the eddy current or Inductive sensors, in existing machines. It could work a longer distance and could detect Non-Metals and even translucent fluids.