Hypnogram reads how you slept and lets you log your nightly habits — then surfaces which of those habits track with your best and worst nights.
Free on iPhone, with an optional subscription.