What is the purpose of proximity sensors on hydraulic systems?
A proximity sensor is any sensor that detects whether there is something in its proximity (within specified distance).

There are many kinds of proximity sensors (optical, magnetic, capacitive etc.) that detect different kinds of target objects and to various distances.

In this case, proximity sensor is used to detect position of the spoiler. Proximity sensors are preferred over micro-switches because they are more reliable, since they have no moving parts and thus don't wear out.

For parts actuated with hydraulics they are the only way to detect the position, since hydraulic actuators don't provide any direct way for detecting their position (compared to electric actuators, where in some cases the response of the actuator can be used to detect the position; the principle is similar to a magnetic proximity sensor anyway though).