This code unlocks your FitBit sleep stage data, making it so much funner to own a FitBit! It allows you to access your daily FitBit sleep stages data, download that data into a Google Sheet, and save a timestamped copy of that Google Sheet.
It's basically an adaptation of the heartrate.gs codebase I posted earlier, found here: https://github.com/JoelDoerfel/google-fitbit-autosave.
For installation, follow the instructions here: https://github.com/JoelDoerfel/google-fitbit-autosave. Just remember to swap out sleepstage.gs for heartrate.gs.
The only line of code in sleepstage.gs you'll need to change is line 430, where you can insert your destination folder of choice if you want it to autosave correctly.
Enjoy!