Javascript event + do not track = error?

Hello,

I would like to send event with javascript.
Is there a specific beaviour for “do not track” visitor to avoid Uncaught ReferenceError: trackEvent is not defined for example or a good practice?

Thank you in advance for your advice.

jB