From what I can tell this was a capability the USPS has had for a while, probably going back to the days of anthrax spores being sent to politicians. The USPS was probably directed to track where every piece of mail came from and image the outside of it.
Informed Delivery was just a monetization of that system. Note that some pieces of mail trigger ads from third party companies.