I dry hop at the last 3rd of fermentation. This may or may not be accurate, but in my mind it drives off vegetal/grassy flavors from the hops, and any oxygen they might have. If you use enough hops (no less than 2oz for a 1.065ish IPA), it will still retain plenty of the volatile aromas you want.
Further, I feel that especially for hoppy beers, an extra transfer to a conditioning/brite vessel/carboy (I don’t call them secondaries because there isn’t a secondary fermentation happening), means more possibility of introducing oxygen, which sucks for all beers, but especially hop-forward beers.
Of all the conflicting information out there on dry hopping, there seems to be one constant: the only way to tell if the beer has had enough dry hopping (contact time with the dry hops) is by taste. Not days, hours, or temperature (though I’ve heard 70 is better than 40 for dry hopping).
Doing it in the keg is a great way to go, but you want to have a way to easily remove the hop mass/bag when the flavor is right. Most do this with an unflavored piece of dental floss tied to a muslin bag full of hops, with the other end tied to the inside of the pressure release valve on the lid. This method also works great for dry hopping in another vessel. Also, it doesn’t matter much to me, but clarity is tough to achieve when adequately dry hopping (for my taste!) I wouldn’t leave dry hops in a keg for a month as you slowly consume the keg though. Muslin bag is a must for keg-hopping.