If you are screwing up at work or feel like you may get in trouble; call a meeting with your boss before they can call a meeting with you.
Tell you boss you’ve been struggling; unfocused; whatever and ask for help. They will bend over backwards to help you get back on the right path and you will stay out of trouble.