Uncovering and explaining how our digital world is changing — and changing us.

Apple, Amazon, Facebook and Google cumulatively racked up a roughly $50 million tab fighting off President Donald Trump and an onslaught of new federal regulations last year — a reflection that the tech industry is increasingly under political siege in the nation’s capital.

Over the course of 2017, the biggest brands in tech warred with the White House over immigration, tried and failed to save net neutrality and weathered a congressional investigation into the ways in which Russian trolls spread propaganda on their sites during the last election.

The heightened scrutiny and withering criticism — targeting tech on everything from sex trafficking to fake news — prompted many companies to spend more money than ever to lobby the government, according to official ethics forms filed at midnight. And yet the industry’s political activities in 2017 may only presage a tougher and costlier clash with Washington, D.C., in the year to come.

Tech’s most prolific political spender last year was Google, which dedicated more than $18 million to lobby the U.S. government. That’s more than its tech peers, not to mention much of corporate America.

Like other tech giants, Google sought to stave off new regulations targeting the content and ads that appeared on sites and services like search and YouTube. Meanwhile, the company pitched its own wares, like self-driving cars, as lawmakers and other federal officials debated the new technology.

Amazon, meanwhile, spent more than $12.8 million in lobbying last year — nearly four times what it spent four years earlier — as it continued to advocate for friendlier federal rules around everything from online sales taxes and cloud computing to package-delivering drones. The company also had to contend in 2017 with fresh questions about the size of its corporate footprint, particularly after acquiring Whole Foods.

Facebook spent a record amount last year — roughly $11.5 million — as lawmakers railed on the social giant for the “fake news” and other content that appeared in users’ feeds.

And Apple shelled out $7 million — again, more than ever — to lobby the U.S. government over the same period. The iPhone giant continued to press forward on issues like encryption and immigration. And the company — like the rest of the industry — advocated for the tax reform law recently signed by Trump.

Apple and Facebook declined to comment for this story; Amazon and Google did not immediately respond to emails seeking comment.

For much of tech, the industry’s tough 2017 began as soon as Trump entered the White House and signed an executive order restricting immigrants and refugees from majority-Muslim countries. While federal courts later tossed that initial directive, Trump’s early, aggressive stance on immigration only foreshadowed further restrictions, including those targeting high-skilled foreign workers and their spouses.

More recently, tech giants like Amazon, Apple, Facebook, Google and Microsoft have tapped their vast lobbying armies to revive a program known as DACA. Scrapped by Trump in 2017, it had protected young immigrants who had been brought illegally to the U.S. as children from being deported. The future of DACA fed a stalemate in Congress this January that briefly caused the U.S. government to shut down.

Web companies, meanwhile, faced unfamiliar calls for fresh regulation in the nation’s capital last year. For Facebook, Google and Twitter, it primarily came in the form of an investigation that found that hundreds of millions of their U.S. users had fallen victim to Russian disinformation during the 2016 election.

In response, some lawmakers sought new federal rules governing the way tech companies display political ads. But Facebook, Google and Twitter each devoted their seemingly limitless lobbying resources toward fighting the measure, called the Honest Ads Act, as their federal disclosures show.

So, too, did that trio fight a proposal to hold social media companies, ad networks and others accountable for enabling — or even failing to spot — sex trafficking on their platforms. And these and other tech players lobbied extensively last year to save the U.S. government’s net neutrality rules, which the Federal Communications Commission ultimately scrapped in December anyway.

Those three fights — political ads, sex trafficking and net neutrality — remain unresolved at the beginning of 2018. Meanwhile, lawmakers and federal regulators are beginning to question the social costs of the digital age. FCC Chairman Ajit Pai, for one, has emerged as one of the more vocal critics of the “downsides” of social media.

Of course, the tech industry didn’t totally lose in Trump’s Washington last year. A major tax reform bill signed into law seems guaranteed to lessen tech giants’ annual bills to the feds. To that end, Apple — a longtime advocate for tax reform — announced this month that it would reinvest billions of dollars in the United States.

Meanwhile, Uber also spent slightly more to lobby lawmakers and federal regulators last year. The ride-hailing giant in 2017 had to contend with a major executive shakeup, a series of allegations about sexism, multiple investigations into its business practices and a major data security breach that it initially withheld from federal investigators.

Less known, however, is that the company began to lobby in Washington, D.C., for the first time on issues related to the Health Insurance Portability and Accountability Act, or HIPAA. The 1996 law governs the privacy and security of medical information, and Uber declined to explain to Recode why it hired a lobbyist last year specifically to focus on the issue.

So too did Uber begin to share with federal regulators its “advancements in vertical take-off and landing technology,” or VTOL. Remember, Uber has been exploring for years whether it’s possible to fly its users around cities.

Sign up for the newsletter Recode Daily Email (required) By signing up, you agree to our Privacy Notice and European users agree to the data transfer policy. Subscribe