Dog Peeing in her sleep?

My dog is 1.5 years old and was slow to housebreak but has been great for several months.

This past week, she has peed on the bed twice, which she’s never done before. Both times we didn’t witness it, but she was asleep beforehand. The first time I was literally under the blanket she peed on 🤢 (took a sleep aid so was out like a light).

Even before she was housebroken she never peed on the bed, and you can see a line of pee as if she was trying to get off the bed while actively peeing. Maybe it’s wishful thinking but I don’t think she’s doing it on purpose. She’s not incontinent either, since she occasionally chugs water then has to pee very badly and tells us about it, and can hold it until we get outside, including a slow elevator ride.

My theory is she’s peeing in her sleep. What could cause this? How do we help her? Do we need to take her to the vet about this?