The use of the stones can clearly be tracked, even after the fact. In Endgame, Rocket is able to compare residual energy signatures from the Snap to the use of the stones on a very distant planet:
When Thanos snapped his fingers, Earth became ground zero for a power surge of ridiculously cosmic proportions. No one's ever seen anything like it... Until two days ago. On this planet.
Consider that in the events of Avengers, the Tesseract was used to open the portal, it was then used to transport Thor and Loki to Asgard, and then later on Loki then stole it and presumably used it to get back to the ship after awakening Surtur in Thor:Ragnarok; that means the last trace of the Tesseract's energy signature is OFF Asgard. Even if Thanos couldn't track the energy signature of its presence on the ship, all he'd really have to logically do is put himself in a direct route between Asgard and Earth - the only 2 places the Tesseract has been used in recent history. I'd argue the fact that he just shows up at the ship and opens fire is meant to clearly indicate he can keep tabs on it at all times.
Prior to the events of Avengers, SHIELD had been making constant use of the Tesseract for Phase 2, allowing plenty of time for anyone to detect and get used to the Tesseract's particular energy signature. Vision was the Mind Stone, meaning that by simply existing, he was making use of it - and arguably, since Wanda's power came from the Mind Stone, it's possible her use of magic was also giving off similar energy signatures. The Time Stone was used in recent history specifically at the Sanctums.
In between the fact that Thanos has been orchestrating his moves so that he can get his hands on as many stones as possible (to the point of knowing that the Reality stone was with the Collector), and that all of the stones had been active in a relatively short time span (the early 2000s), he certainly would have had the technology available. Moreover than that, he previously had the Mind Stone in his possession, and we don't necessary know what he did with it prior to giving the Scepter to Loki. He does specifically tells Tony Stark in Infinity War:
You're not the only one cursed with knowledge
Let's also not forget that Thanos used Eitri and the dwarves to create the Infinity Gauntlet.
I thought if I did what he asked, they'd be safe. I made what he wanted. A device capable of harnessing the power of the Stones.
Something like that is pretty impossible without some pretty specific knowledge on what the power/energy of the Stones is.