So, when you power on the drone, the drone determines the direction it is facing using the compass. Once that is established, and the drone takes off, it uses gyros and accelerometers to determine yaw. So, if you have magentic interference when you first power on the drone, once you get clear of that interference the drone is going to act crazy as yours did, because it can't make sense of what it is seeing. If you look at the image, the yaw and magyaw should have nearly identical values (the green and blue lines) but as you can see, they are off from the start and continue to be off throughout the flight most times. (red line is altitude)
By the way,
@BudWalker is to thank for this program (datcon and csvview) and I'm using info I saw in another similar post where he talked about this to determine what happened.