Somewhere on this forum is a solution proposed by @rickkas7 to do what you are looking for. I just haven't got time to search for it now.
Since Vin is not that different from USB you may search for either of the two.
But since most GPIOs on the Electron are 5V tolerant you could just use an input pin to read the voltage on Vin as this won't be showing any voltage when the device is running off LiPo only.