If we put an extra sensor next to the slits, measuring which slit is the electron going through, we are limiting the number of possible transitions that the electron can do, avoiding interference.
How is it? The sensor collapses the wavefunction in on measure, which is either slit A or slit B, but can’t be a superposition of both. Then, in the screen we will have the same pattern as if we were doing the experiment in a classic system, with two lines of intensity, each one corresponding to slit A and slit B transitions.
But when we add the sensor, A1A2 and A2A1 contributions to the intensity become 0, because it is not possible for the electron to go thorough the two slits if an observable is there. Then, the intensity, as I’ve said, present the same pattern as the one of a classic system, with two different lines corresponding to each slit, and without an interference pattern.