Yes, it's happened to me twice, both times crossing from Canada to the US on a land border entry. There was a short period of time where the CBP was doing this in droves on Canada land border entries. The way it's generally structured is they ask permission, and if you refuse, they can't really do anything without a court order and can only hold you at most 72 hours. The time I was held up for 2 days was because they wanted to further inspect my vehicle, which I can't prevent. The only thing you really have any possible way to control is your digital devices, anything physically on your person / in your possession is open to physical inspection at a border entry point and there's no legal means to prevent it, so there's no point in even arguing. Your phone you /must/ relinquish to them, but you can refuse to unlock it if it's locked with a password. The only way to get around it is a court order, which they're not going to bother with if you're not actually suspected of anything.
Of course, YMMV, which is why I say the most important thing is realizing you could absolutely be arrested and charged for something stupid if you refuse, and should have 6-8 months of financial coverage. And of course, any non-citizen can be refused entry arbitrarily with no recourse.
FTA "(CBP) leaders have admitted to lawmakers in a briefing that its officials are adding information to a database from as many as 10,000 devices every year" this is not a rare occurrence, it's rare in the grand scheme of things because there's so many travelers in/out of the US, but it's not really that rare. If you travel internationally often enough, especially at land borders (I don't know why, but these get hassled more in my experience than airports), you will likely eventually get asked.