There could be some inflammation going on in her digestive tract, especially throat, oesophagus, or stomach. Mucus usually forms as a protection on inflamed mucus membranes. And if it gets too much she will heave it up to try to clear it away. That's probably what the swallowing hard is all about too.
I can't help thinking that the best plan is to try and find out what this is and get it treated. Not all illnesses or body problems are terminal!
It's also possible it's caused by allergic reaction to something.
When she brings up the phlegm, is it just mucus? No blood....not any food as well? And what colour is it? Clear? Or yellowish/greenish?
the phlem is clear no blood or food its more so liquid but sometimes there will be a small mucus glob in with it the mucus is very light yellow almost clear and the rest is clear.
Agree with ginger. This could be any number of things. Do you know ud the dog ingested anything it shouldn't have? Have you changed foods? Any other symptoms like pain? How are the stools? This could even be from parasites. If you can, take a sample of the phlegm and a stool sample to the Vet. You can put them in separate plastic containers or baggies.
Another idea....It's possible she may have something stuck way down in her throat or oesophagus. When she plays with toys, does she ever bite little bits off them? Or does she play with sticks?....or anything else that you can think of she may have swallowed. It might only be a very tiny piece of something -it wouldn't have to be huge, but if it's stuck somewhere...