PokerTracker 4 complies with PokerStars terms of service and where necessary some functionality is limited when playing there such as the importing of observed hands and PokerStars rules on the coloring of HUD statistics.
Yes. Poker HUDs are legal and the majority of poker platforms allow HUDs on their side. HUDs track/record player information and process it to present in the form of numbers and percentages. Players use these numbers and percentages to know about their opponents' playing style.