You aren’t likely to end up in a situation as dramatic as this. If you find yourself making a stand for ethical tech work, it would probably look more like arguing about what restrictions to put on a name field (e.g., minimum length), prioritizing accessibility, or arguing that a small piece of data about users is not really needed and shouldn’t be tracked. But regardless, if you end up in a position to have an influence in tech, we want you to be able to think through the ethical implications of what you are asked to do and how you choose to respond.
Although in this case the engineer was able to successfully stand up against the unethical aspects of what they were doing, I think in other circumstances it may not be so easy. Engineers who don't comply could simply be fired, or they could find other workarounds if everyone isn't on the same page as they were with this case.