If getting shined on by a gamma ray is an extinction level event how do we detect them? Cosmic gamma ray bursts are seriously powerful and do a lot of damage. So how did we measure gamma ray frequencies without getting fried?

I have two possible explanations:


We never detected them directly but calculated their frequency from secondary radiation from the surrounding gas that was ionized.
We get a direct hit but the source is so far that beam divergence will be large enough for only a few photons per square meter to hit us, so there's not enough energy to be destructive.
The danger from gamma-ray bursts (GRBs) is the potential to reduce atmospheric ozone drastically, allowing harmful ultraviolet radiation to pass through the atmosphere and make life on Earth much more difficult. However, you have to be fairly close for this to happen. Gehrels et al. (2003) calculated that a typical GRB from a supernova would have to occur less than 8 parsecs from Earth to cause serious damage to the ozone layer - or, as they put it, to cause levels to drop low enough that they would


  double the “biologically active” UV ﬂux received at the surface


Obviously, though, we can detect gamma-rays from distances farther than 8 parsecs! The closest GRB detected so far, GRB 980425, is likely the result of SN 1998bw, and thus originated 140 million light-years away - over 42 million parsecs away. The radiation from it was nowhere near high enough to harm life on Earth.

Your second explanation, therefore, is the correct one. The intensity of the signal decreases according to the inverse-square law - that is, $I(r)\propto r^{-2}$ - so at large distances, the flux is small enough that there is negligible impact on Earth's atmosphere.

Phiteros also raised a good point: To cause severe problems from Earth, the gamma-ray emission from a GRB - which is often along an axis from both poles of the progenitor - would have to be pointed nearly directly at Earth. For example, there was once a scare that a supernova by either of two stars in the WR 104 system could cause problems for Earth, but the odds that the beam would hit Earth full-on are slim.