If you sample the AC voltage and AC current at a sufficient rate (say 100 times per cycle), then you just multiply each instantaneous voltage sample with the current sample taken at the same instant. Then sum all these calculated results over one cycle. That will automatically include the affect of any power factor phase shift and will give you the true RMS power. No need to separately determine the phase shift or power factor.
Edit: Commercial energy meters use ICs built by Analog Devices and others to perform all the relevant calculations for determined power, energy, PF, etc. from the voltage and current measurements.
Edit 2: You do know that there are devices available for about $25, such as the Kill a Watt that do all these measurements and display the results on a digital readout. I have one and it works quite well. You just plug the meter into the wall and the appliance into the meter.