In January, a person infected with the dangerous new Wuhan coronavirus used public transportation to crisscross the eastern Chinese city of Nanjing, potentially exposing those along the way to the highly contagious pathogen.

Using the country’s pervasive digital-surveillance apparatus, authorities were able to track—down to the minute—the sick person’s exact journey through the city’s subway system.

Officials...